import { type AccountInfo } from '../agents.js';
import type { AgentId } from '../types.js';
import { type UsageSnapshot } from '../accounting/usage.js';
/** An account's usage headroom rolled into one glanceable summary. */
export interface QuotaSummary {
    /**
     * `available` / `rate_limited` from the live usage windows, or `null` when
     * there is no snapshot at all (no data yet, or the agent has no usage source).
     */
    status: 'available' | 'rate_limited' | 'out_of_credits' | null;
    /** Canonical launch verdict. Kept separate from utilization for JSON clients. */
    verdict: 'available' | 'rate_limited' | 'out_of_credits' | 'unavailable';
    /** Max utilization across blocking windows (0-100, rounded), or null when unknown. */
    usedPercent: number | null;
    /** True when the snapshot is a cached `last_seen`, not a fresh `live` read. */
    stale: boolean;
    /** ISO-8601 timestamp for the underlying usage observation. */
    capturedAt: string | null;
    /** Earliest reset across blocking windows, ISO-8601. */
    resetsAt: string | null;
    /** Why quota could not be evaluated; null when a verdict is available. */
    unavailableReason: string | null;
}
/** One installed (agent, version) on a host, fully resolved. */
export interface HarnessRow {
    agent: AgentId;
    version: string;
    /** Account display label (email / id), or null when signed out or unidentifiable. */
    account: string | null;
    signedIn: boolean;
    quota: QuotaSummary;
    /** signed in AND not rate-limited — usable for a run right now. */
    ready: boolean;
    /** When `!ready`, a short reason ("signed out" / "rate-limited"). */
    reason?: string;
}
/** One host's rows, or the reason it produced none. */
export interface HostHarnessResult {
    host: string;
    rows: HarnessRow[];
    /** Set when the host failed to probe (offline / error). */
    error?: string;
    /** Set when the host was skipped (control / offline). */
    skipped?: string;
}
/** An account collapsed across the installs on one host that share it. */
export interface AccountGroup {
    /** Account display label, or null for the signed-out bucket. */
    account: string | null;
    /** Distinct agent ids using this account, sorted. */
    agents: AgentId[];
    /** How many (agent, version) installs share this account. */
    installs: number;
    /** True when at least one install under this account is signed in. */
    signedIn: boolean;
    /** Representative quota — an account maps to one provider identity, so its usage is shared. */
    quota: QuotaSummary;
    ready: boolean;
    reason?: string;
}
/**
 * Roll one usage snapshot into a {@link QuotaSummary}. Mirrors the blocking-window
 * selection of {@link deriveUsageStatusFromSnapshot} (the model-specific
 * `sonnet_week` sub-limit is excluded so hitting it doesn't read as a throttled
 * account) and takes the highest utilization across those windows. Pure.
 */
export declare function summarizeQuota(snapshot: UsageSnapshot | null | undefined, unavailableReason?: string | null, accountStatus?: AccountInfo['usageStatus']): QuotaSummary;
/**
 * "Ready" = signed in AND not rate-limited. A missing quota snapshot does NOT
 * block readiness: the account is signed in and usable, we just have no live
 * utilization to show. Pure.
 */
export declare function computeReady(signedIn: boolean, quota: QuotaSummary): {
    ready: boolean;
    reason?: string;
};
/**
 * Enumerate every installed (agent, version) on THIS host, resolve account +
 * sign-in + quota + ready, and return the rows. Signed-out installs are kept
 * (they are the actionable ones), unlike the auth-health probe which drops
 * `unconfigured`. Quota is cache-only unless `refresh` is set.
 */
export declare function collectLocalHarnessInventory(opts?: {
    agents?: readonly AgentId[];
    refresh?: boolean;
}): Promise<HarnessRow[]>;
/**
 * Collapse a host's rows into one {@link AccountGroup} per distinct account (the
 * signed-out installs fall into the `null` bucket). Because an account label maps
 * to a single provider identity, every install sharing it shares one quota, so
 * the group's quota is taken from the first row carrying real data (preferring a
 * `rate_limited` row so a throttle is never hidden). Pure.
 */
export declare function groupByAccount(rows: HarnessRow[]): AccountGroup[];
/** Short human quota cell: "12%", "limited", or "—" when no data. */
export declare function formatQuota(quota: QuotaSummary): string;
/**
 * Render the device × harness table: one block per device, one row per installed
 * (agent, version) with account / signed-in / quota / ready. Pure.
 */
export declare function renderHarnessMatrix(results: HostHarnessResult[]): string[];
/**
 * Render the device × account table: one block per device, one row per distinct
 * account (installs sharing it collapsed), showing which harnesses use it. Pure.
 */
export declare function renderAccountsMatrix(results: HostHarnessResult[]): string[];
