Files
cc-switch/tests/config/hermesBuiltinProviderIds.test.ts
Jason f460410f5d feat(hermes): warn when a provider key is a Hermes built-in provider id
Hermes routes model.provider to its built-in provider whenever the name is a
canonical built-in id (runtime_provider_custom._shadowed_by_builtin), so a card
keyed "deepseek" or "openrouter" is ignored: Hermes asks for the built-in's own
API key env var and never uses the card's endpoint or key. #8538 only fixed the
two MiniMax presets by prefilling cc-switch-minimax.

The provider key field now shows a warning for any of the 52 canonical ids
(generated from hermes-agent rc.3-v0.22.0) and suggests cc-switch-<key>. A
locked key gets a variant that says to re-add the provider under another key.
Aliases such as kimi still reach the custom provider and are not flagged.
Saving is not blocked.
2026-10-20 21:59:20 +08:00

45 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
HERMES_BUILTIN_PROVIDER_IDS,
isHermesBuiltinProviderId,
} from "@/config/hermesBuiltinProviderIds";
import { hermesProviderPresets } from "@/config/hermesProviderPresets";
describe("Hermes built-in provider ids", () => {
it.each(["minimax", "minimax-cn", "minimax-oauth", "deepseek", "openrouter"])(
"flags canonical built-in id %s",
(key) => {
expect(isHermesBuiltinProviderId(key)).toBe(true);
},
);
it("normalizes like Hermes before matching", () => {
expect(isHermesBuiltinProviderId(" DeepSeek ")).toBe(true);
});
// Aliases resolve to a different canonical id, so Hermes still picks the
// same-named custom provider.
it.each(["kimi", "glm", "zhipu", "moonshot", "cc-switch-minimax", "custom"])(
"does not flag %s",
(key) => {
expect(isHermesBuiltinProviderId(key)).toBe(false);
},
);
it("only lists ids a provider key can hold", () => {
for (const id of HERMES_BUILTIN_PROVIDER_IDS) {
expect(id).toMatch(/^[a-z0-9]+(-[a-z0-9]+)*$/);
}
});
it("no preset prefills a provider key that Hermes shadows", () => {
for (const preset of hermesProviderPresets) {
if (!preset.providerKey) continue;
expect({
preset: preset.name,
shadowed: isHermesBuiltinProviderId(preset.providerKey),
}).toEqual({ preset: preset.name, shadowed: false });
}
});
});