@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
31 lines • 1.64 kB
TypeScript
/**
* The subscription accounts a usage poll can speak for, named exactly as turns name them in the store
* (senpi#3684): a Claude account by its slot name, a ChatGPT account by its pool slot name (`default` for a
* single login). The token is read only when a poll is actually due. A Claude account polls with its
* `CLAUDE_CODE_OAUTH_TOKEN` env token, or, for a claude CLI account, with the access token the CLI keeps in its
* own store, read as it stands: senpi never refreshes a Claude token (senpi#4436), so an expired one waits for
* the CLI's next turn. Tokens never leave this module's callers: they go into one request header and nowhere else.
*/
import type { CredentialStore } from "@earendil-works/pi-ai";
import type { UsageProvider } from "./usage-endpoints.ts";
/** `undefined`: nothing usable to ask with right now (an expired ChatGPT token a turn will renew). */
export type AccessResult = {
readonly access: string;
} | {
readonly error: string;
} | undefined;
export interface PollAccount {
readonly provider: UsageProvider;
readonly account: string;
access(signal: AbortSignal): Promise<AccessResult>;
}
export interface AccountSources {
readonly store: CredentialStore;
readonly env: (name: string) => string | undefined;
readonly now: () => number;
/** Where the claude CLI account dirs live; without it, only env token accounts are polled. */
readonly agentDir?: string;
}
export declare const SIGN_IN_NEEDED = "auth stale - run /login";
export declare function listPollAccounts(sources: AccountSources): Promise<PollAccount[]>;
//# sourceMappingURL=usage-accounts.d.ts.map