import {
ensureAuthProfileStore,
resolveApiKeyForProfile,
resolveAuthProfileOrder,
} from "../../agents/auth-profiles.js"; import { resolveEnvApiKey } from "../../agents/model-auth.js"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; import type { RuntimeEnv } from "../../runtime.js"; import { normalizeOptionalSecretInput } from "../../utils/normalize-secret-input.js"; import type { SecretInputMode } from "../onboard-types.js";
export type NonInteractiveApiKeySource = "flag" | "env" | "profile";
function parseEnvVarNameFromSourceLabel(source: string | undefined): string | undefined { if (!source) { return undefined;
} const match = /^(?:shell env: |env: )([A-Z][A-Z0-9_]*)$/.exec(source.trim()); return match?.[1];
}
async function resolveApiKeyFromProfiles(params: {
provider: string;
cfg: OpenClawConfig;
agentDir?: string;
}): Promise<string | null> { const store = ensureAuthProfileStore(params.agentDir); const order = resolveAuthProfileOrder({
cfg: params.cfg,
store,
provider: params.provider,
}); for (const profileId of order) { const cred = store.profiles[profileId]; if (cred?.type !== "api_key") { continue;
} const resolved = await resolveApiKeyForProfile({
cfg: params.cfg,
store,
profileId,
agentDir: params.agentDir,
}); if (resolved?.apiKey) { return resolved.apiKey;
}
} returnnull;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.