/** * Remote Substrate, Observability Panel Data Provider * * Provides introspection data about remote connections for display in * diagnostic panels. Follows the same panel data provider pattern used * by the diagnostics subsystem (see src/runtime/diagnostics/). * * Unlike the diagnostics panels, RemoteObservabilityProvider is specialized * for remote transport state and does not subscribe to the general event bus. * It instead receives push updates from the RemoteSubstrate facade. */ import type { RemoteSession, RemoteTask, RemoteHealth, DurableIdentity } from './types.js'; /** * A point-in-time snapshot of a single remote connection for panel rendering. */ export interface RemoteConnectionSnapshot { /** Local connection tracking ID. */ readonly connectionId: string; /** Durable identity (stable IDs). */ readonly identity: DurableIdentity; /** Remote endpoint address. */ readonly endpoint: string; /** Current transport state string. */ readonly transportState: string; /** Number of reconnect attempts since last success. */ readonly reconnectAttempts: number; /** Epoch ms of last successful connection (undefined = never). */ readonly lastConnectedAt: number | undefined; /** Current remote health status. */ readonly health: RemoteHealth; /** Remote tasks currently tracked for this connection. */ readonly tasks: readonly RemoteTaskSnapshot[]; /** Number of messages sent. */ readonly messagesSent: number; /** Number of messages received. */ readonly messagesReceived: number; /** Last acknowledged message offset. */ readonly lastAckedOffset: number; /** Last error message (undefined if healthy). */ readonly lastError: string | undefined; } /** * Condensed view of a remote task for panel rendering. */ export interface RemoteTaskSnapshot { readonly taskId: string; readonly agentId: string; readonly title: string; readonly status: RemoteTask['status']; readonly updatedAt: number; readonly progress: number | undefined; readonly error: string | undefined; } /** * Aggregated observability snapshot across all remote connections. */ export interface RemoteObservabilitySnapshot { /** Epoch ms when this snapshot was taken. */ readonly capturedAt: number; /** All tracked remote connections. */ readonly connections: readonly RemoteConnectionSnapshot[]; /** Total number of active connections. */ readonly activeCount: number; /** Total messages sent across all connections. */ readonly totalMessagesSent: number; /** Total messages received across all connections. */ readonly totalMessagesReceived: number; /** Count of connections in terminal_failure state. */ readonly failedCount: number; } /** * RemoteObservabilityProvider, aggregates remote session state for panel rendering. * * Register active RemoteSessions via `trackSession()` and unregister via * `untrackSession()`. Subscribe to changes with `subscribe()`. Retrieve * point-in-time snapshots with `getSnapshot()`. * * @example * ```ts * const obs = new RemoteObservabilityProvider(); * obs.trackSession(session); * * const unsubscribe = obs.subscribe(() => { * const snap = obs.getSnapshot(); * renderRemotePanel(snap); * }); * * // When session ends: * obs.untrackSession(session.connectionId); * unsubscribe(); * ``` */ export declare class RemoteObservabilityProvider { /** Sessions keyed by connectionId. */ private readonly _sessions; /** Change subscribers. */ private readonly _subscribers; /** * Begin tracking a remote session. * * @param session - The remote session to track. */ trackSession(session: RemoteSession): void; /** * Update an existing session's state. * * Call this whenever the RemoteSubstrate mutates a session. * * @param session - Updated session snapshot. */ updateSession(session: RemoteSession): void; /** * Stop tracking a remote session. * * @param connectionId - The connectionId of the session to remove. */ untrackSession(connectionId: string): void; /** * Return a point-in-time snapshot of all tracked connections. * * @returns Frozen aggregated snapshot. */ getSnapshot(): RemoteObservabilitySnapshot; /** * Subscribe to observability data changes. * * @param callback - Invoked whenever the tracked session list or state changes. * @returns An unsubscribe function. */ subscribe(callback: () => void): () => void; /** * Dispose this provider, clearing all sessions and subscribers. */ dispose(): void; private _buildConnectionSnapshot; private _notify; } //# sourceMappingURL=observability.d.ts.map