/** * Resolve `--profiles a,b` to benchmark connections (T12495, T12735). * * Names resolve through the System One profile store (T12733, * `decide-credentials.json`), in this order: * * 1. An exact profile id, `/` (e.g. `layahost/work`). * 2. A bare provider kind (`layahost`, `jev`): that provider's ACTIVE * profile when the active profile belongs to it, else `/default`. * 3. The environment override layer, for a name the store does not hold: * `CLEO_DECIDE_PROFILE__KEY` (plus `_URL`, `_MODEL`, `_PROVIDER`), * `` upper-cased with non-alphanumerics as `_` * (`layahost/lab` → `CLEO_DECIDE_PROFILE_LAYAHOST_LAB_KEY`). Useful for a * throwaway key that should never be written to disk. * * A stored profile's `default` URL, and an environment profile without * `_URL`, both resolve through {@link presetBaseUrl} — the same preset table * everyday decisions use. An unknown name fails with {@link BenchProfileError}, * which lists the stored profile ids with masked keys. * * @task T12735 * @epic T12486 */ import { listDecideProfiles, resolveDecideProfile } from '../credentials.js'; import type { BenchConnection } from './types.js'; /** Resolves one profile name to a connection. */ export interface BenchProfileResolver { /** * @param name - Profile name. * @returns The connection, or `null` when no profile has that name. * @throws BenchProfileInvalidError when the profile exists but is misconfigured. */ resolve(name: string): BenchConnection | null; /** * The profiles that could be named, for the unknown-profile error. * * @returns Secret-free labels, e.g. `layahost/work (key …1111)`. */ available?(): readonly string[]; } /** A profile name that resolved to nothing. */ export declare class BenchProfileError extends Error { /** The names that did not resolve. */ readonly missing: readonly string[]; /** Secret-free labels of the stored profiles (id and masked key). */ readonly available: readonly string[]; /** * @param missing - Unresolved names. * @param available - Secret-free labels of the profiles that do exist. */ constructor(missing: readonly string[], available?: readonly string[]); } /** A profile that exists but is misconfigured (bad URL, key or model). */ export declare class BenchProfileInvalidError extends Error { /** The profile name. */ readonly profile: string; /** * @param profile - Profile name. * @param problem - What is wrong, e.g. `invalid URL "…"`. */ constructor(profile: string, problem: string); } /** * Environment variable prefix for one profile. * * @param name - Profile name. * @returns `CLEO_DECIDE_PROFILE_` (upper-cased, non-alphanumerics as `_`). */ export declare function benchProfileEnvPrefix(name: string): string; /** Profile-store access, injectable for tests. Defaults to the real store. */ export interface BenchProfileStore { /** List the stored profiles (secret-free). */ readonly list: typeof listDecideProfiles; /** Resolve one stored profile (contains the key). */ readonly resolve: typeof resolveDecideProfile; } /** Options for {@link createProfileResolver}. */ export interface BenchProfileResolverOptions { /** Environment for the override layer. Default `process.env`. */ readonly env?: NodeJS.ProcessEnv; /** Profile store. Default: `decide-credentials.json` in the CLEO home. */ readonly store?: BenchProfileStore; } /** * The benchmark's profile resolver: the T12733 profile store (exact id, then * bare provider), then the environment override layer. See the module doc. * * @param opts - Environment and store. Defaults: `process.env` and the real store. * @returns A resolver. */ export declare function createProfileResolver(opts?: BenchProfileResolverOptions): BenchProfileResolver; /** * Resolve every name, or throw naming all that did not resolve. * * @param names - Profile names (duplicates removed, order kept). * @param resolver - Resolver. Default: {@link createProfileResolver}. * @returns One connection per name. * @throws BenchProfileError when any name is unknown (lists the stored profiles, keys masked). * @throws BenchProfileInvalidError when a profile has a bad URL, key or model. */ export declare function resolveBenchProfiles(names: readonly string[], resolver?: BenchProfileResolver): BenchConnection[]; //# sourceMappingURL=profiles.d.ts.map