fix: keep model list synthetic auth refs exact · openclaw/openclaw@1df1ee4
shakkernerd
·
2026-04-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -144,6 +144,18 @@ describe("createModelListAuthIndex", () => {
|
144 | 144 | expect(index.hasProviderAuth("codex")).toBe(true); |
145 | 145 | }); |
146 | 146 | |
| 147 | +it("keeps synthetic auth refs exact instead of applying auth-choice aliases", () => { |
| 148 | +const index = createModelListAuthIndex({ |
| 149 | +cfg: {}, |
| 150 | +authStore: emptyStore, |
| 151 | +env: {}, |
| 152 | +syntheticAuthProviderRefs: ["claude-cli"], |
| 153 | +}); |
| 154 | + |
| 155 | +expect(index.hasProviderAuth("claude-cli")).toBe(true); |
| 156 | +expect(index.hasProviderAuth("anthropic")).toBe(false); |
| 157 | +}); |
| 158 | + |
147 | 159 | it("ignores derived synthetic auth snapshots", () => { |
148 | 160 | pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata.mockReturnValueOnce({ |
149 | 161 | source: "derived", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -57,12 +57,20 @@ export function createModelListAuthIndex(
|
57 | 57 | const aliasMap = resolveProviderAuthAliasMap({ config: params.cfg, env }); |
58 | 58 | const envCandidateMap = resolveProviderEnvApiKeyCandidates({ config: params.cfg, env }); |
59 | 59 | const authenticatedProviders = new Set<string>(); |
| 60 | +const syntheticAuthProviders = new Set<string>(); |
60 | 61 | const addProvider = (provider: string | undefined) => { |
61 | 62 | if (!provider?.trim()) { |
62 | 63 | return; |
63 | 64 | } |
64 | 65 | authenticatedProviders.add(normalizeAuthProvider(provider, aliasMap)); |
65 | 66 | }; |
| 67 | +const addSyntheticProvider = (provider: string | undefined) => { |
| 68 | +const normalized = provider?.trim() ? normalizeProviderIdForAuth(provider) : ""; |
| 69 | +if (!normalized) { |
| 70 | +return; |
| 71 | +} |
| 72 | +syntheticAuthProviders.add(normalized); |
| 73 | +}; |
66 | 74 | |
67 | 75 | for (const credential of Object.values(params.authStore.profiles ?? {})) { |
68 | 76 | addProvider(credential.provider); |
@@ -94,12 +102,15 @@ export function createModelListAuthIndex(
|
94 | 102 | |
95 | 103 | for (const provider of params.syntheticAuthProviderRefs ?? |
96 | 104 | listValidatedSyntheticAuthProviderRefs({ cfg: params.cfg, env })) { |
97 | | -addProvider(provider); |
| 105 | +addSyntheticProvider(provider); |
98 | 106 | } |
99 | 107 | |
100 | 108 | return { |
101 | 109 | hasProviderAuth(provider: string): boolean { |
102 | | -return authenticatedProviders.has(normalizeAuthProvider(provider, aliasMap)); |
| 110 | +return ( |
| 111 | +authenticatedProviders.has(normalizeAuthProvider(provider, aliasMap)) || |
| 112 | +syntheticAuthProviders.has(normalizeProviderIdForAuth(provider)) |
| 113 | +); |
103 | 114 | }, |
104 | 115 | }; |
105 | 116 | } |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。