@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
37 lines • 2.33 kB
TypeScript
import type { CredentialBlock, RateLimitResetSource } from "./classify.ts";
/**
* A local record of why the pool blocked a slot (senpi#3216): the classified reason, where the reset came from,
* and a redacted excerpt of the provider's answer, so a support question about a long block can be answered from
* the machine. One JSON line per block, next to the pool state file, never holding tokens or account ids.
*/
export type CredentialBlockLogEntry = {
readonly at: string;
readonly provider: string;
/** The slot's local name in the pool (`default`, `login-2`), not a provider account id. */
readonly slot: string;
readonly reason: CredentialBlock["reason"];
readonly blockedUntil?: string;
readonly resetSource?: RateLimitResetSource;
/** The model family a model-scoped limit binds; absent for a block on the whole account. */
readonly model?: string;
readonly excerpt?: string;
};
/** The log rolls over to one `.1` generation past this size, so it stays bounded on a busy machine. */
export declare const BLOCK_LOG_MAX_BYTES: number;
export declare function redactBlockExcerpt(text: string): string;
/**
* Appends one entry without blocking the caller (the block is recorded on the session path, which must not run
* synchronous fs work: senpi#3993). A log that cannot be written never fails the request that was blocked.
*/
export declare function appendCredentialBlockLog(path: string, entry: CredentialBlockLogEntry): void;
/** Resolves once every entry appended to `path` so far is on disk (or was dropped as unwritable). */
export declare function flushCredentialBlockLog(path: string): Promise<void>;
/**
* Resolves once every entry appended so far to a log inside `directory` is on disk. A caller that removes a tree
* holding a pool state file (a test teardown, senpi#6488) joins here first: an append still running would
* otherwise create the log while the removal walks the tree, and the removal fails with ENOTEMPTY.
*/
export declare function settledCredentialBlockLogsWithin(directory: string): Promise<void>;
/** The block logs inside `directory` with an append still pending, for a caller that cannot wait (a synchronous removal). */
export declare function pendingCredentialBlockLogsWithin(directory: string): string[];
//# sourceMappingURL=block-log.d.ts.map