/** * agent-top-renderer.ts — Live top-like resource table for orchestrated agents. * * Layout contract: * - Every cell is padded/truncated with ANSI-aware helpers (`visibleWidth`, * `padAndTruncate`) so colored spinners never shift columns. * - Column set is responsive at 60 / 80 / 100 / 140 terminal columns. * - Row visible width equals the content budget (gutter + columns + separators). * - `mode: "widget"` is a compact strip for the persistent above-editor widget; * `"full"` is used by the interactive dashboard top view. */ import type { AgentRecord } from "../types.js"; import type { AgentActivity } from "./agent-ui-types.js"; import { type DashboardTheme } from "./theme.js"; export type SortKey = "tokens" | "turns" | "duration" | "toolUses" | "name" | "lastSeen"; export interface AgentTopEntry { id: string; /** Agent type id when known (from live records); optional in synthetic test fixtures. */ type?: string; name: string; status: string; tokens: number; turns: number; toolUses: number; durationMs: number; lastSeenMs: number | undefined; } export type TopRenderMode = "full" | "widget"; type ColumnKey = "name" | "status" | "tokens" | "turns" | "toolUses" | "duration" | "lastSeen" | "load"; type TopColumn = { key: ColumnKey; label: string; width: number; align: "left" | "right"; }; export declare function getAgentTopEntries(agents: AgentRecord[], activity: Map): AgentTopEntry[]; export declare function sortEntries(entries: AgentTopEntry[], key: SortKey, asc: boolean): AgentTopEntry[]; export declare function createTopThemeAdapter(th: DashboardTheme): { fg(color: string, text: string): string; bold(text: string): string; }; /** Compact token count for table cells (no "token" suffix — column label carries the unit). */ export declare function formatCellTokens(count: number): string; /** Human runtime: `12.3s` / `4m41s` / `1h05m`. */ export declare function formatCellRuntime(ms: number): string; /** * Build responsive columns. Drop order matches AGENTS.md / existing tests: * load <102, SEEN <92, TOOLS <78, TURNS <68. */ export declare function buildColumns(width: number): TopColumn[]; export interface RenderTopTableOptions { mode?: TopRenderMode; helpLine?: string; } export declare function renderTopTable(entries: AgentTopEntry[], sortKey: SortKey, sortAsc: boolean, page: number, pageSize: number, th: DashboardTheme, width: number, helpLineOrOptions?: string | RenderTopTableOptions): string[]; export {};