mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:10:43 +00:00
fix: keep model list synthetic auth refs exact
This commit is contained in:
@@ -144,6 +144,18 @@ describe("createModelListAuthIndex", () => {
|
||||
expect(index.hasProviderAuth("codex")).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps synthetic auth refs exact instead of applying auth-choice aliases", () => {
|
||||
const index = createModelListAuthIndex({
|
||||
cfg: {},
|
||||
authStore: emptyStore,
|
||||
env: {},
|
||||
syntheticAuthProviderRefs: ["claude-cli"],
|
||||
});
|
||||
|
||||
expect(index.hasProviderAuth("claude-cli")).toBe(true);
|
||||
expect(index.hasProviderAuth("anthropic")).toBe(false);
|
||||
});
|
||||
|
||||
it("ignores derived synthetic auth snapshots", () => {
|
||||
pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata.mockReturnValueOnce({
|
||||
source: "derived",
|
||||
|
||||
@@ -57,12 +57,20 @@ export function createModelListAuthIndex(
|
||||
const aliasMap = resolveProviderAuthAliasMap({ config: params.cfg, env });
|
||||
const envCandidateMap = resolveProviderEnvApiKeyCandidates({ config: params.cfg, env });
|
||||
const authenticatedProviders = new Set<string>();
|
||||
const syntheticAuthProviders = new Set<string>();
|
||||
const addProvider = (provider: string | undefined) => {
|
||||
if (!provider?.trim()) {
|
||||
return;
|
||||
}
|
||||
authenticatedProviders.add(normalizeAuthProvider(provider, aliasMap));
|
||||
};
|
||||
const addSyntheticProvider = (provider: string | undefined) => {
|
||||
const normalized = provider?.trim() ? normalizeProviderIdForAuth(provider) : "";
|
||||
if (!normalized) {
|
||||
return;
|
||||
}
|
||||
syntheticAuthProviders.add(normalized);
|
||||
};
|
||||
|
||||
for (const credential of Object.values(params.authStore.profiles ?? {})) {
|
||||
addProvider(credential.provider);
|
||||
@@ -94,12 +102,15 @@ export function createModelListAuthIndex(
|
||||
|
||||
for (const provider of params.syntheticAuthProviderRefs ??
|
||||
listValidatedSyntheticAuthProviderRefs({ cfg: params.cfg, env })) {
|
||||
addProvider(provider);
|
||||
addSyntheticProvider(provider);
|
||||
}
|
||||
|
||||
return {
|
||||
hasProviderAuth(provider: string): boolean {
|
||||
return authenticatedProviders.has(normalizeAuthProvider(provider, aliasMap));
|
||||
return (
|
||||
authenticatedProviders.has(normalizeAuthProvider(provider, aliasMap)) ||
|
||||
syntheticAuthProviders.has(normalizeProviderIdForAuth(provider))
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user