import type { SessionMeta } from '../session/types.js';
/** Max chars of a `run --task` description persisted to the ledger — see the
 *  module docblock's retention/privacy note. */
export declare const TASK_PREVIEW_MAX_CHARS = 200;
/** One `computer.action` ledger entry, narrowed to the fields this module
 *  renders or groups by. */
export interface ComputerAction {
    /** CLI verb: `click`, `type`, `screenshot`, … or `run` for the task marker
     *  `registerRunCommand` emits before entering the model loop. */
    verb: string;
    ts: string;
    tsMs: number;
    /** The emitting CLI process's own pid — the run/task grouping key. */
    pid: number;
    /** Unique for the emitting CLI process; absent only on legacy ledger rows. */
    invocationId?: string;
    /** The driven app's pid, when resolved. */
    targetPid?: number;
    bundle?: string;
    /** `--device <device>` target when this action drove a remote daemon. */
    host?: string;
    /** Truncated `--task` text; only ever present on a `verb: 'run'` marker. */
    task?: string;
    sessionId?: string;
    launchId?: string;
    agent?: string;
    machineId?: string;
    hostname?: string;
}
/** Read `computer.action` events straight from the durable event ledger,
 *  newest first, bounded by `limit`. Malformed/legacy records (missing
 *  `command` or `pid`, or an unparseable `ts`) are skipped, never thrown —
 *  the ledger is a plain rotated JSONL file another process can be mid-write
 *  or mid-rotate against. */
export declare function listComputerActions(opts?: {
    limit?: number;
}): ComputerAction[];
/** Why a row carries no session digest: `linked` resolved one, `unresolved`
 *  has a sessionId/launchId but no matching indexed session, `unlinked` has
 *  neither (a bare terminal invocation with no agent session env at all). */
export type ComputerRunLinkStatus = 'linked' | 'unresolved' | 'unlinked';
/** One task-first row: every `computer.action` emitted by one CLI process
 *  (see the module docblock's "Grouping key" note), plus the agent session
 *  it links to when resolvable. */
export interface ComputerRunRow {
    /** Invoking CLI process's pid. Absent on a run recovered from the DB after
     *  the ledger pruned — that process is long gone and its pid unknowable. */
    pid?: number;
    invocationId?: string;
    /**
     * Total actions for a run recovered from the DB after the event ledger
     * pruned its individual actions. Set ONLY on such rows: when it is present,
     * `actions`/`counts` are empty because the per-verb detail is genuinely gone,
     * and this total is all that survived. Live ledger rows leave it undefined
     * and report real per-verb `counts` instead.
     */
    recoveredActionCount?: number;
    /** Truncated task description — present only for a `computer run --task`
     *  invocation; a bare verb call has none. */
    task?: string;
    /** Invoking machine's hostname — the CLI's own machine, not necessarily
     *  the driven one (see `remoteHost`). */
    machine: string;
    machineId?: string;
    /** `--device <device>` target when the run drove a remote (Windows) daemon. */
    remoteHost?: string;
    /** Best-known target app bundle across the run's actions. */
    bundle?: string;
    agent?: string;
    sessionId?: string;
    launchId?: string;
    linkStatus: ComputerRunLinkStatus;
    linkedSession?: SessionMeta;
    /** Newest first; excludes the `run` task marker itself. */
    actions: ComputerAction[];
    /** Per-verb counts over `actions` (never includes the `run` marker). */
    counts: Record<string, number>;
    /** Oldest action's mtime — the row's start. */
    startMs: number;
    /** Newest action's mtime — the row's sort/age key. */
    endMs: number;
}
/**
 * Group flat ledger actions into task-first rows, newest first. Pure:
 * session resolvers are passed in, so this has no filesystem/session-index
 * dependency and is unit-testable with synthetic data (see
 * {@link buildComputerSessionRows} for the impure disk/index-reading caller).
 */
export declare function groupIntoComputerRuns(actions: ComputerAction[], resolveSession?: (sessionId: string) => SessionMeta | null, resolveLaunch?: (launchId: string) => SessionMeta | null): ComputerRunRow[];
/** Build task-first rows from the real ledger, resolving each row's owning
 *  session against the live indexes. The interactive picker's (and the
 *  flat/`--json` printer's) data source. `machine` narrows to rows whose
 *  invoking hostname, machineId, or `--device` target contains the substring. */
export declare function buildComputerSessionRows(opts?: {
    limit?: number;
    machine?: string;
}): ComputerRunRow[];
/**
 * Search predicate for the interactive picker: task text, machine/remote
 * host, target bundle, the linked session's agent/topic/label, or any
 * driven verb in the row.
 */
export declare function matchesComputerSessionRow(row: ComputerRunRow, queryText: string): boolean;
/** Human one-line summary of a row's per-verb action counts, most frequent
 *  first — shared by the flat table and the interactive picker's label. */
/**
 * One row's action summary — the single renderer every surface should use.
 *
 * A run recovered from the DB after the ledger pruned has no per-verb detail,
 * only a total. Rendering it through the per-verb formatter printed
 * "(no actions)", which is indistinguishable from a run that did nothing — so a
 * 40-action run read as empty. Report the surviving total, and say plainly that
 * the breakdown is gone rather than implying we still have it.
 */
export declare function formatRowActions(row: ComputerRunRow): string;
export declare function formatActionCounts(counts: Record<string, number>): string;
/** Human table for the CLI. Returns lines (no trailing newline). */
export declare function renderComputerSessionRows(rows: ComputerRunRow[]): string;
/** Default row cap for the flat/non-interactive table. A computer row is
 *  much finer-grained than a browser task — real usage is mostly one
 *  standalone verb per CLI invocation, not a `run --task` loop, so an
 *  unbounded flat dump against real history reads as hundreds of one-action
 *  rows (confirmed against a real machine's history while building this).
 *  The interactive picker has no such cap (it's searchable); only the
 *  static table needs one. `--limit` overrides. */
export declare const DEFAULT_ROW_DISPLAY_LIMIT = 50;
/** Slice `rows` to at most `limit` (newest first, rows are already sorted),
 *  and report how many were dropped — pure, so the cap arithmetic and the
 *  trailer condition are unit-testable without a console spy. */
export declare function applyRowDisplayLimit(rows: ComputerRunRow[], limit?: number): {
    shown: ComputerRunRow[];
    more: number;
};
/**
 * Shared CLI action for `agents computer sessions` and `agents sessions
 * --computer`. Non-interactive by design (the interactive routing decision
 * lives in `commands/computer-sessions-picker.ts`, mirroring
 * `runBrowserSessions`/`runBrowserSessionsCommand`'s split).
 */
export declare function runComputerSessions(opts: {
    machine?: string;
    json?: boolean;
    limit?: number;
}): void;
/** Print already-collected rows. Fleet callers use this after merging local and
 * remote JSON so text, limits, and JSON keep exactly one renderer. */
export declare function printComputerSessionRows(rows: ComputerRunRow[], opts: {
    json?: boolean;
    limit?: number;
}): void;
