






















@@ -37,6 +37,24 @@ describe("resolveVisibleModelCatalog", () => {
3737expect(result).toEqual([{ provider: "openai", id: "gpt-test", name: "GPT Test" }]);
3838});
393940+it("does not runtime-normalize unrestricted default browse", async () => {
41+normalizeProviderModelIdWithRuntimeMock.mockImplementation(() => "custom-modern-model");
42+43+const result = await resolveVisibleModelCatalog({
44+cfg: {} as OpenClawConfig,
45+catalog: [{ provider: "custom-provider", id: "custom-legacy-model", name: "Custom Legacy" }],
46+defaultProvider: "custom-provider",
47+defaultModel: "custom-legacy-model",
48+runtimeAuthDiscovery: false,
49+providerAuthChecker: vi.fn(() => true),
50+});
51+52+expect(result).toEqual([
53+{ provider: "custom-provider", id: "custom-legacy-model", name: "Custom Legacy" },
54+]);
55+expect(normalizeProviderModelIdWithRuntimeMock).not.toHaveBeenCalled();
56+});
57+4058it("limits visible catalog to provider wildcard entries after default discovery", async () => {
4159const authChecker = vi.fn((provider: string) => provider !== "blocked");
4260const catalog: ModelCatalogEntry[] = [
@@ -78,6 +96,41 @@ describe("resolveVisibleModelCatalog", () => {
7896expect(normalizeProviderModelIdWithRuntimeMock).not.toHaveBeenCalled();
7997});
809899+it("uses runtime model normalization for exact allowlist entries", async () => {
100+normalizeProviderModelIdWithRuntimeMock.mockImplementation(({ provider, context }) => {
101+if (
102+provider === "custom-provider" &&
103+(context as { modelId?: string }).modelId === "custom-legacy-model"
104+) {
105+return "custom-modern-model";
106+}
107+return undefined;
108+});
109+110+const cfg = {
111+agents: {
112+defaults: {
113+models: {
114+"custom-provider/custom-legacy-model": {},
115+},
116+},
117+},
118+} as OpenClawConfig;
119+120+const result = await resolveVisibleModelCatalog({
121+ cfg,
122+catalog: [{ provider: "custom-provider", id: "custom-modern-model", name: "Custom Modern" }],
123+defaultProvider: "anthropic",
124+runtimeAuthDiscovery: false,
125+providerAuthChecker: vi.fn(() => true),
126+});
127+128+expect(result).toEqual([
129+{ provider: "custom-provider", id: "custom-modern-model", name: "Custom Modern" },
130+]);
131+expect(normalizeProviderModelIdWithRuntimeMock).toHaveBeenCalled();
132+});
133+81134it("does not broaden visibility when selected providers have no catalog rows", async () => {
82135const authChecker = vi.fn(() => true);
83136此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。