/** * ControlPlane — Unified multi-workspace dashboard server * * Provides a single HTTP + WebSocket server that aggregates multiple * WorkTrees and LockedBlackboards into one live dashboard. Users register * named workspaces; the browser UI lets operators switch between them * and view Task Trees, Agent orchestration, and Blackboard state. * * ```typescript * const cp = new ControlPlane({ port: 4800 }); * cp.addWorkspace('feature-x', { tree: myTree, blackboard: myBB }); * cp.addWorkspace('feature-y', { tree: otherTree }); * await cp.start(); * // Open http://127.0.0.1:4800 * ``` * * @module ControlPlane * @version 1.0.0 */ import { EventEmitter } from 'events'; import type { WorkTree } from './work-tree'; import type { LockedBlackboard } from './locked-blackboard'; /** Configuration for a single workspace */ export interface WorkspaceConfig { /** Hierarchical task tree (enables Tree + Agents tabs) */ tree?: WorkTree; /** Shared blackboard (enables Blackboard tab) */ blackboard?: LockedBlackboard; } /** A log entry for an agent */ export interface AgentLogEntry { time: string; message: string; level: 'info' | 'warn' | 'error'; } /** Agent info for the dashboard */ export interface CPAgentInfo { name: string; role: 'orchestrator' | 'worker'; status: 'idle' | 'busy' | 'error'; tasks: Array<{ id: string; label: string; status: string; }>; currentTask: string | null; logs: AgentLogEntry[]; tokens: number; } /** Workspace summary for the workspace picker */ export interface WorkspaceSummary { name: string; hasTree: boolean; hasBlackboard: boolean; nodeCount: number; progress: number; bbKeyCount: number; } /** Options for the ControlPlane */ export interface ControlPlaneOptions { /** TCP port (default: 4800) */ port?: number; /** Hostname (default: '127.0.0.1') */ host?: string; } /** * Unified dashboard server for multiple WorkTrees and Blackboards. * * Register named workspaces, then open the browser to see them all. */ export declare class ControlPlane extends EventEmitter { private readonly port; private readonly host; private server; private clients; private workspaces; private pingInterval; private bbPollInterval; private clientCounter; private pendingBroadcasts; constructor(options?: ControlPlaneOptions); /** * Register a named workspace with an optional WorkTree and/or Blackboard. */ addWorkspace(name: string, config: WorkspaceConfig): void; /** * Remove a workspace. */ removeWorkspace(name: string): boolean; /** * Set the orchestrator agent for a workspace. */ setOrchestrator(workspaceName: string, agentName: string): void; /** * Push a log entry to an agent in a workspace. */ pushLog(workspaceName: string, agent: string, message: string, level?: 'info' | 'warn' | 'error'): void; /** * Push a narrative message to the orchestrator log for a workspace. */ pushNarrative(workspaceName: string, message: string): void; /** * List all registered workspace names. */ listWorkspaces(): string[]; /** Start the ControlPlane server. */ start(): Promise; /** Stop the ControlPlane server. */ stop(): Promise; /** Number of connected clients. */ clientCount(): number; /** Dashboard URL. */ get url(): string; private handleHTTP; private handleUpgrade; private handleClientMessage; private buildWorkspaceList; private buildWorkspaceData; private buildAgentMap; private sendWorkspaceSnapshot; private scheduleBroadcast; private broadcastWorkspaceList; /** Track last BB snapshot hashes for change detection */ private bbHashes; private pollBlackboards; private pingClients; } //# sourceMappingURL=control-plane.d.ts.map