@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
33 lines • 1.63 kB
TypeScript
/**
* Checks an API key against its provider without storing it (desktop #2510): one cheap authenticated
* read (the model list) with the key in memory only. The answer is `ok`, `rejected` (the provider
* said 401/403), `unreachable` (no answer, 5xx, timeout) or `unsupported` (no probe for this API, or
* the endpoint has no model list), so a client can say "we could not check" instead of guessing.
* Neither the key nor the request headers ever reach a log, an error message or the result.
*/
import type { Api, Model } from "@earendil-works/pi-ai/compat";
import type { AuthProviderInfo } from "./auth-providers.ts";
import type { ModelRegistry } from "./model-registry.ts";
export type ApiKeyVerification = {
readonly ok: true;
} | {
readonly ok: false;
readonly reason: "rejected" | "unreachable" | "unsupported" | "unknown-provider";
readonly status?: number;
};
export declare function verifyApiKey(input: {
readonly models: readonly Model<Api>[];
readonly provider: string;
readonly key: string;
readonly signal: AbortSignal;
readonly fetch?: typeof globalThis.fetch;
}): Promise<ApiKeyVerification>;
/**
* `{ keyHint }` for the api_key row of a provider whose key the app stored as a literal, long enough
* that four characters reveal nothing useful. A command (`!...`) or `$ENV` reference is never hinted:
* any slice of it would describe where the secret lives, not which key it is.
*/
export declare function storedKeyHint(modelRegistry: ModelRegistry, info: Pick<AuthProviderInfo, "id" | "authType">): {
keyHint?: string;
};
//# sourceMappingURL=verify-api-key.d.ts.map