
























@@ -1,8 +1,8 @@
11import type { AuthProfileStore } from "../../agents/auth-profiles/types.js";
22import {
3+listProviderEnvAuthLookupKeys,
34resolveProviderEnvAuthEvidence,
45resolveProviderEnvApiKeyCandidates,
5-resolveProviderEnvAuthLookupKeys,
66} from "../../agents/model-auth-env-vars.js";
77import { resolveEnvApiKey } from "../../agents/model-auth-env.js";
88import { resolveAwsSdkEnvVarName } from "../../agents/model-auth-runtime-shared.js";
@@ -27,10 +27,6 @@ export type CreateModelListAuthIndexParams = {
2727syntheticAuthProviderRefs?: readonly string[];
2828};
292930-export const EMPTY_MODEL_LIST_AUTH_INDEX: ModelListAuthIndex = {
31-hasProviderAuth: () => false,
32-};
33-3430function normalizeAuthProvider(
3531provider: string,
3632aliasMap: Readonly<Record<string, string>>,
@@ -90,12 +86,13 @@ export function createModelListAuthIndex(
9086addProvider(credential.provider);
9187}
928893-for (const provider of resolveProviderEnvAuthLookupKeys(lookupParams)) {
89+for (const provider of listProviderEnvAuthLookupKeys({ envCandidateMap, authEvidenceMap })) {
9490if (
9591resolveEnvApiKey(provider, env, {
9692 aliasMap,
9793candidateMap: envCandidateMap,
9894 authEvidenceMap,
95+config: params.cfg,
9996workspaceDir: params.workspaceDir,
10097})
10198) {
@@ -131,8 +128,16 @@ export function createModelListAuthIndex(
131128if (cached !== undefined) {
132129return cached;
133130}
131+const hasPrecomputedCandidates = Object.hasOwn(envCandidateMap, normalized);
132+const hasPrecomputedEvidence = Object.hasOwn(authEvidenceMap, normalized);
134133const hasAuth = Boolean(
135-resolveEnvApiKey(provider, env, { aliasMap, candidateMap: envCandidateMap }),
134+resolveEnvApiKey(provider, env, {
135+ aliasMap,
136+candidateMap: hasPrecomputedCandidates ? envCandidateMap : undefined,
137+authEvidenceMap: hasPrecomputedEvidence ? authEvidenceMap : undefined,
138+config: params.cfg,
139+workspaceDir: params.workspaceDir,
140+}),
136141);
137142envProviderAuthCache.set(normalized, hasAuth);
138143if (hasAuth) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。