/**
 * Limits-CLI persistence helpers (CLI.8) — split out of limits.ts for the
 * file-size budget.
 *
 * Two concerns:
 *
 *   1. `enumeratePackRateLimits` — walk a packs directory (default
 *      `~/.opensquid/packs/`), load each pack's `manifest.yaml` via the
 *      Manifest schema, and surface the `rate_limits:` block per pack.
 *      Unconfigured packs (no `rate_limits:`) contribute zero rows — the
 *      limits CLI surface mirrors the runtime: only declared (pack,
 *      trigger) pairs have caps, everything else is unlimited.
 *
 *   2. `readBuckets` / `resetPackBuckets` — direct libsql access to the
 *      AUTO.2 `rate_limit_buckets` table (the runtime state owned by
 *      `RateLimiter`). The CLI deliberately reads rows directly rather
 *      than instantiating a `RateLimiter` because the limiter API exposes
 *      `check` / `release` (single-key mutations) — not enumerate. Reset
 *      uses a single `DELETE FROM ... WHERE pack_id = ?` so post-reset
 *      `check()` on any (trigger, key) pair starts from a fresh bucket
 *      (no row → defaults to `max` tokens per the limiter's read path).
 *
 * Pack-side data: only the schema-validated `rate_limits` block; the
 * runtime Pack type strips it (see `src/runtime/types.ts`), so we re-parse
 * manifest.yaml here rather than hooking the loader. Same precedent as
 * `triggers_state.enumeratePacks` re-loading via `loadPack`.
 *
 * Imports from: node:fs/promises, node:path, @libsql/client,
 *   ../../packs/schemas/manifest, ../../packs/yaml, ../../runtime/paths.
 * Imported by: src/setup/cli/limits.ts + src/setup/cli/limits.test.ts.
 */
import type { Client } from '@libsql/client';
import type { RateLimits as RateLimitsType } from '../../packs/schemas/manifest.js';
import type { TriggerKind } from '../../packs/schemas/skill.js';
export declare const defaultPacksDir: () => string;
/** One pack's declared rate-limit block. `rateLimits` is the
 *  manifest-parsed map (trigger kind → config); empty when the pack
 *  omits the block (i.e. unlimited across triggers). */
export interface PackRateLimitDecl {
    packId: string;
    rateLimits: RateLimitsType;
}
/** Walk packs/ and pull each pack's `rate_limits:` block. Packs without
 *  a manifest.yaml are skipped (matches `triggers_state` posture). */
export declare function enumeratePackRateLimits(packsDir: string): Promise<PackRateLimitDecl[]>;
/** One row from `rate_limit_buckets`. `tokens` is the current refilled
 *  count; `lastRefillMs` is the last-touch timestamp used for continuous
 *  refill math. */
export interface BucketRow {
    packId: string;
    triggerKind: TriggerKind;
    key: string;
    tokens: number;
    lastRefillMs: number;
    concurrentCount: number;
}
/** Read ALL buckets across packs. Used by the default `limits` verb to
 *  enumerate runtime state when joined against pack-declared caps. */
export declare function readAllBuckets(db: Client): Promise<BucketRow[]>;
/** Atomic delete of all buckets for one pack. Returns the deleted row
 *  count so the CLI can confirm action. */
export declare function resetPackBuckets(db: Client, packId: string): Promise<number>;
/** Joined per-pack per-trigger row surfaced by the default `limits` verb. */
export interface LimitRow {
    pack: string;
    trigger: TriggerKind;
    max: number;
    used: number;
    remaining: number;
}
/** Aggregate buckets by (pack, trigger) — worst-case (lowest tokens) wins
 *  so the CLI surfaces "what's about to throttle". Trigger-keys other
 *  than the default `<pack>::<trigger>` (per-skill, per-event) collapse
 *  into one row per (pack, trigger). */
export declare function buildLimitRows(decls: readonly PackRateLimitDecl[], buckets: readonly BucketRow[]): LimitRow[];
export declare function renderLimitsTable(rows: readonly LimitRow[]): string;
//# sourceMappingURL=limits_state.d.ts.map