/**
 * `ToolLedger` — a stateful record of tool activity across a build session.
 *
 * While Smithy designs an agent it leans on the underlying runtime tools (read a
 * file, run a command, search the tree, and so on). Something has to keep a
 * running account of which tools fired, with what, and whether each call landed.
 * The old shape of this was a pure reducer: a single function folded a list of
 * executions into a fresh summary on every call, recomputing the whole picture
 * from the start each time it was asked.
 *
 * This module replaces that fold with a long-lived object. A `ToolLedger` owns
 * its history and is mutated as the session runs. It keeps two things in step:
 *
 *   - an *append-only log* — every {@link record} call pushes one
 *     {@link LedgerEntry} onto the end and nothing is ever rewritten or removed;
 *   - a set of *derived aggregates* — per-tool counts and a failure tally that are
 *     advanced incrementally on each append, never rebuilt by re-walking the log.
 *
 * Because the aggregates ride along with the log, {@link summary} is a cheap read
 * of already-settled numbers rather than a fold. {@link reset} returns the ledger
 * to its just-constructed state so one instance can serve a fresh session.
 *
 * The class holds no I/O and no clock of its own beyond an optional caller-stamped
 * time on each record; it only accounts for what it is told.
 */
/** A single tool invocation as the ledger was asked to remember it. */
export interface ToolEvent {
    /** The tool's name, e.g. `read-file` or `run-command`. */
    readonly tool: string;
    /** The arguments the tool was called with, as the caller saw them. */
    readonly input?: unknown;
    /** Whatever the tool produced (a result, an error payload, anything). */
    readonly output?: unknown;
    /** Whether the call is considered to have succeeded. */
    readonly ok: boolean;
}
/**
 * One settled row of the ledger: the event the caller recorded, plus the
 * bookkeeping the ledger stamped onto it as it filed the row.
 */
export interface LedgerEntry extends ToolEvent {
    /** 1-based position in the append order; also the count after this row. */
    readonly seq: number;
    /** When the row was filed (epoch ms), defaulting to filing time. */
    readonly at: number;
}
/** The per-tool slice of a {@link LedgerSummary}. */
export interface ToolTally {
    /** Total calls recorded for this tool. */
    readonly calls: number;
    /** How many of those calls succeeded (`ok: true`). */
    readonly ok: number;
    /** How many failed (`ok: false`); always `calls - ok`. */
    readonly failed: number;
}
/**
 * A point-in-time digest of everything the ledger has seen.
 *
 * `byTool` carries one {@link ToolTally} per distinct tool name. The top-level
 * fields are session-wide rollups so a caller never has to sum the map by hand.
 */
export interface LedgerSummary {
    /** Total calls recorded across every tool. */
    readonly total: number;
    /** Total successful calls across every tool. */
    readonly ok: number;
    /** Total failed calls across every tool. */
    readonly failed: number;
    /** Number of distinct tool names that have fired at least once. */
    readonly tools: number;
    /** Per-tool breakdown, keyed by tool name. */
    readonly byTool: Record<string, ToolTally>;
}
/**
 * A stateful, append-style account of tool executions for one build session.
 *
 * Construct one per session, feed it each tool result through {@link record}, and
 * read {@link entries} or {@link summary} whenever a snapshot is wanted. The
 * derived counts are kept current as records arrive, so reads never re-fold the
 * log.
 */
export declare class ToolLedger {
    /** The append-only history; never spliced, only pushed. */
    private readonly log;
    /** Live per-tool counters, advanced one record at a time. */
    private readonly counters;
    /** Session-wide rollups, kept in step with {@link counters}. */
    private totalCalls;
    private totalOk;
    private totalFailed;
    /**
     * File one tool execution.
     *
     * Appends a stamped {@link LedgerEntry} to the log and advances the per-tool and
     * session-wide aggregates by exactly this one event. Returns the filed entry so
     * a caller can read its assigned `seq` / `at`.
     *
     * @param event  The execution to remember.
     * @param at     Optional epoch-ms timestamp; defaults to `Date.now()`.
     */
    record(event: ToolEvent, at?: number): LedgerEntry;
    /**
     * The append-only log, oldest first.
     *
     * Returns a shallow copy so a caller cannot mutate the ledger's history through
     * the returned array. The {@link LedgerEntry} rows are themselves read-only.
     */
    entries(): readonly LedgerEntry[];
    /**
     * A digest built from the live aggregates — counts per tool and the failure
     * tally — without re-walking the log.
     *
     * The returned object is a fresh, detached snapshot: the `byTool` map and each
     * tally are copied out so later records don't reach back into it.
     */
    summary(): LedgerSummary;
    /** True once at least one execution has been recorded. */
    get size(): number;
    /**
     * Clear the log and every derived aggregate, returning the ledger to its
     * freshly-constructed state so the same instance can serve a new session.
     */
    reset(): void;
    /**
     * Fold a single freshly-filed entry into the running aggregates. This is the
     * only place the counters move, which is what keeps {@link summary} a read
     * rather than a recomputation.
     */
    private advance;
}
