mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-19 13:42:09 +03:00
The /v1/models catalog mirrors `claude/<provider>/<model>` ids purely from the alias gate -- ccAliasPredicate.ts consults no provider registry. The request path additionally required the prefix to be an open-sse REGISTRY entry or an operator-defined custom node. Enterprise-cloud providers such as azure-ai / azure-openai live only in the provider catalog (src/shared/constants/providers/apikey/enterprise-cloud.ts). They route fine directly -- `azure-ai/Phi-4` returns 200 -- but have no open-sse registry entry, so the two sides disagreed: the catalog advertised `claude/azure-ai/<model>` while stripCcDiscoveryAlias refused to strip it. The unstripped id then fell through to normal resolution, which splits on the first / and parsed `claude` as the provider. Every Claude Code request for an Azure model was routed to the Claude provider instead: ROUTING: Provider: claude, Model: azure-ai/DeepSeek-V4-Flash Extract the predicate as `isRoutableProviderPrefix()` and widen it to the provider catalog (id + alias) alongside the open-sse registry, so the request path recognises exactly what the catalog can advertise. Regression guard: tests/unit/cc-discovery-alias-routable-prefix.test.ts pins azure-ai/azure-openai/azure as routable, keeps openai/anthropic routable, and keeps an unknown prefix non-routable. Verified failing before the widening. Co-authored-by: Mihaly Bodo <michael@proton-quantum.com>
44 lines
1.9 KiB
TypeScript
44 lines
1.9 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { isRoutableProviderPrefix } from "../../src/lib/ccDiscoveryAliasResolve.ts";
|
|
|
|
/**
|
|
* Regression guard for the "listed but rejected" cc-discovery alias mismatch.
|
|
*
|
|
* The /v1/models catalog mirrors `claude/<provider>/<model>` ids based purely on
|
|
* the alias gate (src/app/api/v1/models/ccAliasPredicate.ts — it does NOT consult
|
|
* any provider registry). The request path additionally required the prefix to be
|
|
* an `open-sse` REGISTRY entry or an operator-defined custom node.
|
|
*
|
|
* Enterprise-cloud providers such as `azure-ai` / `azure-openai` live in the
|
|
* provider CATALOG (src/shared/constants/providers/apikey/enterprise-cloud.ts)
|
|
* and route fine directly (`azure-ai/Phi-4` → 200), but have no `open-sse`
|
|
* registry entry. So the catalog advertised `claude/azure-ai/<model>` while the
|
|
* request path refused to strip it — the id fell through with `claude` parsed as
|
|
* the provider, and every request was routed to the Claude provider instead.
|
|
*
|
|
* These assertions pin the predicate to "can the router actually reach it",
|
|
* which is the property the catalog side already assumes.
|
|
*/
|
|
|
|
test("catalog-only enterprise-cloud providers are routable (azure-ai regression)", () => {
|
|
assert.equal(isRoutableProviderPrefix("azure-ai"), true);
|
|
assert.equal(isRoutableProviderPrefix("azure-openai"), true);
|
|
});
|
|
|
|
test("open-sse registry providers stay routable", () => {
|
|
assert.equal(isRoutableProviderPrefix("openai"), true);
|
|
assert.equal(isRoutableProviderPrefix("anthropic"), true);
|
|
});
|
|
|
|
test("provider aliases resolve too", () => {
|
|
// `azure` is the declared alias of the `azure-openai` catalog entry.
|
|
assert.equal(isRoutableProviderPrefix("azure"), true);
|
|
});
|
|
|
|
test("an unknown prefix is not routable", () => {
|
|
assert.equal(isRoutableProviderPrefix("definitely-not-a-provider-xyz"), false);
|
|
assert.equal(isRoutableProviderPrefix(""), false);
|
|
});
|