faProviderPreconfig function
The explicit FA_PROVIDER_* env preconfig (Docker/headless):
FA_PROVIDER_TYPE + FA_PROVIDER_NAME + FA_PROVIDER_CONFIG (a JSON
object with required baseUrl/model and an optional apiKeyEnvVar)
plus the key env var the config references. Every text input has a
_BASE64 twin (FA_PROVIDER_CONFIG_BASE64, <apiKeyEnvVar>_BASE64)
for platforms that mangle special characters; when both carry the same
value the plain one is used. This is an explicit declaration, so it
wins over the saved config restore too — a container that declares its
provider in env vars runs on it, store or config notwithstanding. An
explicit --provider flag means full manual control and disables the
preconfig entirely (mixing the flag's provider with the env endpoint
would be a silent misconfiguration).
Throws ConfigException on a malformed declaration: a container that
names its provider wrong must fail loud at boot, not 401 mid-run (the
executable maps that to its fa: usage failure).
Implementation
EnvProviderPreconfig? faProviderPreconfig(
CliArgs parsed,
CliConfig saved, {
required Map<String, String> env,
}) {
if (parsed.providerExplicit) return null;
return parseEnvProviderPreconfig(
providerType: env['FA_PROVIDER_TYPE'],
providerName: env['FA_PROVIDER_NAME'],
providerConfig: env['FA_PROVIDER_CONFIG'],
providerConfigBase64: env['FA_PROVIDER_CONFIG_BASE64'],
envVarValue: (name) => env[name],
takenNames: [for (final entry in saved.customProviders) entry.name],
);
}