@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
44 lines (43 loc) • 2.17 kB
TypeScript
import { type ClaudeHome } from "./claude-accounts.js";
import type { UsageWindow } from "./usage.js";
export interface ClaudeCredit {
/** Short id derived from the entry, for `--remove`. */
id: string;
amountUSD: number;
/** Spend counts from this day (UTC midnight). */
since: string;
expiresAt?: string;
label?: string;
}
/** One session's cost as Claude Code reported it, and when the session began. */
export interface SessionCost {
costUSD: number;
startedAt: string;
}
/** The credits entered for one Claude home, in `<bridge>/accounts.yaml` under `credits`. */
export declare function claudeCredits(home: string): ClaudeCredit[];
/** `phren bridge accounts credit <id> --amount <usd> [--expires <date>] [--since <date>] [--label <name>]`. */
export declare function addClaudeCredit(home: string, entry: {
amount: string;
expires?: string;
since?: string;
label?: string;
}, now?: Date): Promise<ClaudeCredit>;
export declare function removeClaudeCredit(home: string, id: string): Promise<boolean>;
/** Per-session costs from the status line, kept only for homes with a credit. */
export declare const costLedgerFile: (home: ClaudeHome) => string;
/** Record one status-line render: the session's running total only grows, so the largest seen stands. */
export declare function recordSessionCost(home: ClaudeHome, payload: unknown, now?: Date): Promise<void>;
/**
* Every session cost known for a home: the status-line ledger, plus the
* `lastCost` Claude Code keeps per project in the home's `.claude.json`
* (which also covers sessions with no status line), dated by the session's
* transcript. The larger figure for one session stands.
*/
export declare function homeSessionCosts(home: ClaudeHome): Record<string, SessionCost>;
/**
* One window per live credit: spend is drawn from the credit that expires
* first among those active when the session began, overflowing to the next.
* Expired credits are left out. The window's `resetsAt` is the expiry.
*/
export declare function creditWindows(credits: readonly ClaudeCredit[], sessions: Record<string, SessionCost>, now?: Date): UsageWindow[];