UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

57 lines • 2.97 kB
/** * Provider-list builders for the /login and /logout selectors. * * Shared by the classic interactive mode and the RPC connection handler. Both * attribute a credential to a row through `authMethodStatus`, so a row either * surface lists gets the same status. RPC lists rows from * `buildLoginProviderInfos`; the TUI lists the methods each provider declares. */ import type { AuthCheck } from "@earendil-works/pi-ai"; import type { ModelRegistry } from "./model-registry.ts"; import type { AuthStatus } from "./provider-composer.ts"; /** One provider entry for a login/logout selector. */ export interface AuthProviderInfo { id: string; name: string; authType: "oauth" | "api_key"; } /** * Whether a provider should be offered for API-key login. * * - A provider with a built-in display name is always API-key eligible. * - A built-in model provider without a display name is not (it authenticates * via oauth or is otherwise not an API-key login target). * - Any other provider is API-key eligible unless it is an oauth provider. */ export declare function isApiKeyLoginProvider(providerId: string, oauthProviderIds: ReadonlySet<string>, builtInProviderIds?: ReadonlySet<string>): boolean; /** * Build the /login provider options: every oauth provider plus every API-key * eligible model provider, sorted by display name. When `authType` is given the * list is narrowed to that kind. */ export declare function buildLoginProviderInfos(modelRegistry: ModelRegistry, authType?: "oauth" | "api_key"): AuthProviderInfo[]; /** * Build the /logout provider options: every provider with a stored credential, * sorted by display name. Environment variables and models.json config are not * listed — /logout only removes credentials saved by /login. */ export declare function buildLogoutProviderInfos(modelRegistry: ModelRegistry): AuthProviderInfo[]; /** * The status of ONE login method row, by one rule for every surface (#3537). A stored credential * belongs to the row of its own type. A non-stored sign-in (the provider's own check resolved * `type: "oauth"`, e.g. `CLAUDE_CODE_OAUTH_TOKEN` or an ambient Claude Code login) belongs to the * oauth row. Every other source (runtime `--api-key`, environment key, models.json, fallback) is a * key and belongs to the api_key row only: a key never lights a sign-in row, even on a provider * that lists no api_key row. */ export declare function authMethodStatus(modelRegistry: ModelRegistry, info: AuthProviderInfo): AuthStatus; /** * The TUI picker's single status for one row: the row's own `authMethodStatus` when it is * configured, otherwise the other method's, so the picker can say "API key configured" beside an * unconfigured sign-in row (#3537). */ export declare function loginRowStatus(modelRegistry: ModelRegistry, provider: { id: string; name: string; }, authType: "oauth" | "api_key"): AuthCheck | undefined; //# sourceMappingURL=auth-providers.d.ts.map