/** * WorkTreeDashboard — Browser-based live WorkTree visualization * * Serves a single-page HTML dashboard over HTTP and streams WorkTree * state changes over WebSocket. Zero external dependencies — uses only * Node.js built-in modules. * * Follows the same architecture as {@link DashboardServer} for the * TopologyTracker but renders a hierarchical task tree instead of a * force-directed graph. * * @module WorkTreeDashboard * @version 1.0.0 */ import { EventEmitter } from 'events'; import type { WorkTree } from './work-tree'; /** Options for WorkTreeDashboard */ export interface WorkTreeDashboardOptions { /** TCP port to listen on (default: 4821) */ port?: number; /** Hostname to bind to (default: '127.0.0.1') */ host?: string; } /** A single agent log entry */ export interface AgentLogEntry { time: string; message: string; level: 'info' | 'warn' | 'error'; } /** Agent state as sent to the dashboard */ export interface DashboardAgentInfo { name: string; role: 'orchestrator' | 'worker'; status: 'idle' | 'busy' | 'error'; tasks: Array<{ id: string; label: string; status: string; }>; currentTask: string | null; logs: AgentLogEntry[]; tokens: number; } /** A detected system-wide diagnostic entry */ export interface SystemDiagnostic { level: 'info' | 'warn' | 'error'; category: string; message: string; agent?: string; taskId?: string; } /** System health summary sent to the dashboard */ export interface SystemHealth { status: 'healthy' | 'warning' | 'critical'; summary: string; diagnostics: SystemDiagnostic[]; } /** * HTTP + WebSocket server for live WorkTree visualization. * * ```typescript * const tree = new WorkTree('root', 'My Project'); * const dashboard = new WorkTreeDashboard(tree, { port: 4821 }); * await dashboard.start(); * // Open http://127.0.0.1:4821 in your browser * ``` */ export declare class WorkTreeDashboard extends EventEmitter { private readonly tree; private readonly port; private readonly host; private server; private clients; private pingInterval; private eventHandlers; private clientCounter; private deltaPending; private agentLogs; private orchestratorLogs; private orchestratorAgent; constructor(tree: WorkTree, options?: WorkTreeDashboardOptions); /** * Start the dashboard server. */ start(): Promise; /** * Stop the dashboard server. */ stop(): Promise; /** Number of connected WebSocket clients. */ clientCount(): number; /** The URL the dashboard is serving on. */ get url(): string; /** * Designate an agent as the orchestrator (shown at the top of the Agents tab). */ setOrchestrator(agentName: string): void; /** * Push a log entry for an agent. Triggers a broadcast to connected clients. * * @param agent - The agent name (must match `node.agent` in the tree) * @param message - Log message text * @param level - Severity: 'info' | 'warn' | 'error' (default: 'info') */ pushLog(agent: string, message: string, level?: 'info' | 'warn' | 'error'): void; /** * Push a narrative message to the orchestrator log (not tied to a specific agent). */ pushNarrative(message: string): void; private subscribeToTree; private unsubscribeFromTree; private handleHTTP; private handleUpgrade; private sendSnapshot; /** * Broadcast a delta (changed nodes + stats) to all clients. * Debounced via queueMicrotask to batch rapid events per tick. */ private broadcastUpdate; /** * Build agent map from tree snapshot + stored logs. */ private buildAgentMap; /** * Analyze system state and detect issues, stalls, and failures. */ private computeDiagnostics; private pingClients; } //# sourceMappingURL=work-tree-dashboard.d.ts.map