refactor(open-sse): registry consolidation + DRY media/oauth/adhoc cleanup
- Single-source registry: oauth clientId/tokenUrl, usage URLs, image/embed configs, search defaultModel, codex fixedPort, google token url derive. - Remove 29 unused OmniRoute providers (registry 100→71); media intact. - De-adhoc: codex literals → registry format/oauth flags; reasoningInject, image/embed openrouter headers + xai bodyFields config-driven. - Add REGISTRY_TEMPLATE.js + expand PROVIDER_DEFAULTS/schema JSDoc. - Baselines updated; PROVIDERS 62 + alias 90 byte-for-byte, golden snapshots. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,143 +1,22 @@
|
||||
import { OAUTH_ALIASES } from "../config/providerModels.js";
|
||||
import REGISTRY from "../providers/registry/index.js";
|
||||
|
||||
// Reverse OAuth aliases (id→alias) into alias→id; "mmf" intentionally excluded to preserve behavior
|
||||
const OAUTH_ALIAS_TO_ID = Object.fromEntries(
|
||||
Object.entries(OAUTH_ALIASES)
|
||||
.filter(([id]) => id !== "mimo-free")
|
||||
.map(([id, alias]) => [alias, id])
|
||||
);
|
||||
|
||||
// Provider alias to ID mapping (OAuth short aliases derived above)
|
||||
const ALIAS_TO_PROVIDER_ID = {
|
||||
...OAUTH_ALIAS_TO_ID,
|
||||
ocg: "opencode-go",
|
||||
qoder: "qoder",
|
||||
// TTS providers
|
||||
// Alias→id derived from registry single-source: id→id, alias→id, aliases[]→id.
|
||||
// Media-only providers without a registry transport entry keep explicit aliases here.
|
||||
const MEDIA_ONLY_ALIASES = {
|
||||
el: "elevenlabs",
|
||||
// API Key providers
|
||||
openai: "openai",
|
||||
vercel: "vercel-ai-gateway",
|
||||
"vercel-ai-gateway": "vercel-ai-gateway",
|
||||
anthropic: "anthropic",
|
||||
gemini: "gemini",
|
||||
openrouter: "openrouter",
|
||||
glm: "glm",
|
||||
kimi: "kimi",
|
||||
minimax: "minimax",
|
||||
"minimax-cn": "minimax-cn",
|
||||
hf: "huggingface",
|
||||
huggingface: "huggingface",
|
||||
ds: "deepseek",
|
||||
deepseek: "deepseek",
|
||||
cmc: "commandcode",
|
||||
commandcode: "commandcode",
|
||||
groq: "groq",
|
||||
xai: "xai",
|
||||
mistral: "mistral",
|
||||
pplx: "perplexity",
|
||||
perplexity: "perplexity",
|
||||
together: "together",
|
||||
fireworks: "fireworks",
|
||||
cerebras: "cerebras",
|
||||
cohere: "cohere",
|
||||
nvidia: "nvidia",
|
||||
nebius: "nebius",
|
||||
siliconflow: "siliconflow",
|
||||
hyp: "hyperbolic",
|
||||
hyperbolic: "hyperbolic",
|
||||
dg: "deepgram",
|
||||
deepgram: "deepgram",
|
||||
aai: "assemblyai",
|
||||
assemblyai: "assemblyai",
|
||||
nb: "nanobanana",
|
||||
nanobanana: "nanobanana",
|
||||
ch: "chutes",
|
||||
chutes: "chutes",
|
||||
ark: "volcengine-ark",
|
||||
"volcengine-ark": "volcengine-ark",
|
||||
byteplus: "byteplus",
|
||||
bpm: "byteplus",
|
||||
cursor: "cursor",
|
||||
vx: "vertex",
|
||||
vertex: "vertex",
|
||||
vxp: "vertex-partner",
|
||||
"vertex-partner": "vertex-partner",
|
||||
// Web cookie providers
|
||||
gw: "grok-web",
|
||||
"grok-web": "grok-web",
|
||||
pw: "perplexity-web",
|
||||
"perplexity-web": "perplexity-web",
|
||||
mimo: "xiaomi-mimo",
|
||||
"xiaomi-mimo": "xiaomi-mimo",
|
||||
xmtp: "xiaomi-tokenplan",
|
||||
"xiaomi-tokenplan": "xiaomi-tokenplan",
|
||||
cf: "cloudflare-ai",
|
||||
"cloudflare-ai": "cloudflare-ai",
|
||||
// Image/video providers
|
||||
fal: "fal-ai",
|
||||
"fal-ai": "fal-ai",
|
||||
stability: "stability-ai",
|
||||
"stability-ai": "stability-ai",
|
||||
bfl: "black-forest-labs",
|
||||
"black-forest-labs": "black-forest-labs",
|
||||
recraft: "recraft",
|
||||
topaz: "topaz",
|
||||
runway: "runwayml",
|
||||
runwayml: "runwayml",
|
||||
// Embedding/rerank
|
||||
jina: "jina-ai",
|
||||
"jina-ai": "jina-ai",
|
||||
// TTS
|
||||
polly: "aws-polly",
|
||||
"aws-polly": "aws-polly",
|
||||
// Free-tier providers (synced from OmniRoute)
|
||||
agentrouter: "agentrouter",
|
||||
aimlapi: "aimlapi",
|
||||
aiml: "aimlapi",
|
||||
novita: "novita",
|
||||
modal: "modal",
|
||||
mdl: "modal",
|
||||
reka: "reka",
|
||||
nlpcloud: "nlpcloud",
|
||||
nlpc: "nlpcloud",
|
||||
bazaarlink: "bazaarlink",
|
||||
bzl: "bazaarlink",
|
||||
completions: "completions",
|
||||
cpl: "completions",
|
||||
enally: "enally",
|
||||
enly: "enally",
|
||||
freetheai: "freetheai",
|
||||
fta: "freetheai",
|
||||
llm7: "llm7",
|
||||
lepton: "lepton",
|
||||
kluster: "kluster",
|
||||
ai21: "ai21",
|
||||
"inference-net": "inference-net",
|
||||
inet: "inference-net",
|
||||
predibase: "predibase",
|
||||
bytez: "bytez",
|
||||
morph: "morph",
|
||||
longcat: "longcat",
|
||||
lc: "longcat",
|
||||
puter: "puter",
|
||||
pu: "puter",
|
||||
uncloseai: "uncloseai",
|
||||
unc: "uncloseai",
|
||||
scaleway: "scaleway",
|
||||
scw: "scaleway",
|
||||
deepinfra: "deepinfra",
|
||||
sambanova: "sambanova",
|
||||
samba: "sambanova",
|
||||
nscale: "nscale",
|
||||
baseten: "baseten",
|
||||
publicai: "publicai",
|
||||
"nous-research": "nous-research",
|
||||
nous: "nous-research",
|
||||
glhf: "glhf",
|
||||
bb: "blackbox",
|
||||
blackbox: "blackbox",
|
||||
};
|
||||
|
||||
const ALIAS_TO_PROVIDER_ID = { ...MEDIA_ONLY_ALIASES };
|
||||
for (const entry of REGISTRY) {
|
||||
ALIAS_TO_PROVIDER_ID[entry.id] = entry.id;
|
||||
if (entry.alias) ALIAS_TO_PROVIDER_ID[entry.alias] = entry.id;
|
||||
for (const a of entry.aliases || []) ALIAS_TO_PROVIDER_ID[a] = entry.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve provider alias to provider ID
|
||||
*/
|
||||
@@ -237,6 +116,15 @@ export async function getModelInfoCore(modelStr, aliasesOrGetter) {
|
||||
};
|
||||
}
|
||||
|
||||
// Config-driven prefix → provider inference (first match wins, fallback "openai").
|
||||
const MODEL_PREFIX_PROVIDERS = [
|
||||
[/^claude-/, "anthropic"],
|
||||
[/^gemini-/, "gemini"],
|
||||
[/^gpt-/, "openai"],
|
||||
[/^o[134]/, "openai"],
|
||||
[/^deepseek-/, "openrouter"],
|
||||
];
|
||||
|
||||
/**
|
||||
* Infer provider from model name prefix
|
||||
* Used as fallback when no provider prefix or alias is given
|
||||
@@ -244,12 +132,5 @@ export async function getModelInfoCore(modelStr, aliasesOrGetter) {
|
||||
function inferProviderFromModelName(modelName) {
|
||||
if (!modelName) return "openai";
|
||||
const m = modelName.toLowerCase();
|
||||
if (m.startsWith("claude-")) return "anthropic";
|
||||
if (m.startsWith("gemini-")) return "gemini";
|
||||
if (m.startsWith("gpt-")) return "openai";
|
||||
if (m.startsWith("o1") || m.startsWith("o3") || m.startsWith("o4"))
|
||||
return "openai";
|
||||
if (m.startsWith("deepseek-")) return "openrouter";
|
||||
// Default fallback
|
||||
return "openai";
|
||||
return MODEL_PREFIX_PROVIDERS.find(([re]) => re.test(m))?.[1] || "openai";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user