cleanup(environment): keep one lookup order

This commit is contained in:
Tianyi Cui
2026-08-07 23:33:11 +08:00
parent 2c532f3b2c
commit d0e052dd83
10 changed files with 25 additions and 29 deletions

View File

@@ -182,7 +182,7 @@ export function resolveAdapterOptions(config: Config, environment?: EnvironmentS
return {
apiKeyEnv: credentialRef(config.apiKeyEnv ?? DEFAULT_API_KEY_ENV),
baseURL: config.baseURL
?? environment?.getFrom(BASE_URL_ENV, ['process', 'project-env', 'user-env'])?.value
?? environment?.get(BASE_URL_ENV)?.value
?? PUBLIC_BASE_URL,
defaults: {
thinking: config.thinking,
@@ -232,7 +232,7 @@ export function apply(ctx: Context, config: Config): void {
} else {
// Without the seam there is no managed store to rank against, so the
// environment is the whole credential plane.
const ambient = environmentOf(ctx).getFrom(ref, ['process', 'project-env', 'user-env'])
const ambient = environmentOf(ctx).get(ref)
if (ambient !== undefined && ambient.value.length > 0) {
return assertUsableApiKey(ambient.value, 'llm-deepseek', ref)
}

View File

@@ -143,7 +143,7 @@ export function apply(ctx: Context, config: Config): void {
const hit = credentials !== undefined
? (await credentials.resolve(ref))?.value
// Without the seam the environment is the whole credential plane.
: environmentOf(ctx).getFrom(ref, ['process', 'project-env', 'user-env'])?.value
: environmentOf(ctx).get(ref)?.value
if (hit !== undefined && hit.length > 0) return assertUsableApiKey(hit, 'llm-pi-ai', ref)
throw new LlmError(
`llm-pi-ai: no credential for provider route "${provider}"; its profile resolves ${ref}, which is not`