@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
40 lines • 1.9 kB
TypeScript
import { type SubscriptionLimitStore } from "./limit-store.ts";
import { type PollAccount } from "./usage-accounts.ts";
import { type UsageFetch, type UsageProvider } from "./usage-endpoints.ts";
/** Claude's numbers move in five-hour blocks and its endpoint is the stricter one, so it is read half as often. */
export declare const POLL_INTERVAL_MS: Readonly<Record<UsageProvider, number>>;
export interface UsagePollerDeps {
readonly store: SubscriptionLimitStore;
readonly cachePath: string;
readonly listAccounts: () => Promise<PollAccount[]>;
readonly fetch: UsageFetch;
readonly now: () => number;
}
export declare class UsagePoller {
#private;
constructor(deps: UsagePollerDeps);
/**
* One pass: adopt what siblings already read, fetch what is due and claimed by this process, publish. `refresh`
* also makes that provider's accounts due when their reading is at least REFRESH_MIN_AGE_MS old (senpi#6536).
*/
pollOnce(signal?: AbortSignal, refresh?: {
readonly provider: UsageProvider;
}): Promise<void>;
}
/**
* Re-reads `provider`'s account usage now instead of at the next interval, so a limit the provider lifted early
* shows on the next turn a person starts (senpi#6536). A no-op where nothing polls (print mode, `--offline`, a
* session isolate); a failure keeps the last reading and never fails the turn.
*/
export declare function refreshSubscriptionUsage(provider: string): Promise<void>;
/**
* Starts the process's poller once (interactive and RPC modes; never print mode or `--offline`). The timer
* is unref'd, so it never holds the process open; `report` receives a pass that failed as a whole.
*/
export declare function startSubscriptionUsagePolling(options: {
readonly agentDir: string;
readonly report: (message: string) => void;
}): {
stop(): void;
};
//# sourceMappingURL=usage-poller.d.ts.map