/** * Transport diagnostics panel data provider. * * Stores the history of protocol version negotiations for remote substrate * connections. Populated by calling `record()` after each handshake attempt, * whether successful or not. * * The panel exposes: * - The latest negotiated version/mode per connection * - Downgrade events with explicit reason codes * - Unsupported failures so unsupported peers are surfaced to operators */ import type { TransportNegotiationEntry, ComponentConfig } from '../types.js'; import type { NegotiatedProtocol, VersionNegotiationResult } from '../../remote/types.js'; /** * Snapshot of the transport panel for a single connection. */ export interface TransportPanelSnapshot { /** Connection ID (local tracking ID). */ readonly connectionId: string; /** Remote endpoint. */ readonly endpoint: string; /** Most recent negotiation entry for this connection. */ readonly latest: TransportNegotiationEntry; /** Full negotiation history for this connection, most recent first. */ readonly history: readonly TransportNegotiationEntry[]; } /** * TransportPanel, diagnostics data provider for transport protocol negotiations. * * Usage: * ```ts * const panel = new TransportPanel(); * * // On handshake success: * panel.record(connectionId, endpoint, negotiationResult, offeredVersion, peerVersion); * * // In the diagnostics UI: * const snaps = panel.getAll(); * const latest = panel.getLatest(connectionId); * const downgrades = panel.getDowngrades(); * const failures = panel.getUnsupportedFailures(); * ``` */ export declare class TransportPanel { private readonly _config; /** Per-connection negotiation history (oldest-first within each list). */ private readonly _histories; /** Subscribers notified on any change. */ private readonly _subscribers; constructor(config?: ComponentConfig); /** * Record the result of a version negotiation. * * Call this from the ReconnectEngine's `onVersionNegotiated` callback * (success) or from the failure path when `unsupportedCode` is present. * * @param connectionId - Local connection tracking ID. * @param endpoint - Remote endpoint URL or address. * @param result - The VersionNegotiationResult from `negotiateProtocolVersion()`. * @param offeredVersionLabel - The version label this side offered. * @param peerVersionLabel - The version label the peer advertised. */ record(connectionId: string, endpoint: string, result: VersionNegotiationResult, offeredVersionLabel: string, peerVersionLabel: string): void; /** * Record a successful negotiation directly from a NegotiatedProtocol object. * * Convenience overload for callers that already have the NegotiatedProtocol * from a ConnectOutcome (skips re-running the matrix lookup). * * @param connectionId - Local connection tracking ID. * @param endpoint - Remote endpoint URL or address. * @param protocol - The NegotiatedProtocol from the successful ConnectOutcome. */ recordSuccess(connectionId: string, endpoint: string, protocol: NegotiatedProtocol): void; /** * Record an unsupported failure. * * Call this when a ConnectOutcome returns `unsupportedCode`. * * @param connectionId - Local connection tracking ID. * @param endpoint - Remote endpoint URL or address. * @param unsupportedCode - The structured code from the outcome. * @param unsupportedReason - Human-readable explanation. * @param offeredVersionLabel - The version label this side offered. * @param peerVersionLabel - The version label the peer advertised. */ recordUnsupported(connectionId: string, endpoint: string, unsupportedCode: 'major_version_mismatch' | 'peer_version_too_old' | 'peer_version_unsupported', unsupportedReason: string, offeredVersionLabel: string, peerVersionLabel: string): void; /** * Get the most recent negotiation entry for a connection. * * @param connectionId - The connection ID to look up. * @returns The latest entry, or undefined if no negotiation has been recorded. */ getLatest(connectionId: string): TransportNegotiationEntry | undefined; /** * Get the full negotiation history for a connection, most recent first. * * @param connectionId - The connection ID to look up. * @returns Array of entries, most recent first. Empty if unknown connection. */ getHistory(connectionId: string): readonly TransportNegotiationEntry[]; /** * Get a snapshot for every tracked connection, most recently updated first. */ getAll(): TransportPanelSnapshot[]; /** * Get all connections that experienced a protocol downgrade. * Includes only the latest negotiation per connection. */ getDowngrades(): TransportNegotiationEntry[]; /** * Get all connections with recorded unsupported failures. * These represent peers that could NOT proceed, surfaced explicitly * so operators know an inunsupported peer attempted connection. */ getUnsupportedFailures(): TransportNegotiationEntry[]; /** * Summary counts across all connections. */ getSummary(): { totalConnections: number; successfulNegotiations: number; downgradedConnections: number; unsupportedFailures: number; incompatibilityFailures: number; }; recordIncompatibility(connectionId: string, endpoint: string, incompatibilityCode: 'major_version_mismatch' | 'peer_version_too_old' | 'peer_version_unsupported', incompatibilityReason: string, offeredVersionLabel: string, peerVersionLabel: string): void; getIncompatibilityFailures(): TransportNegotiationEntry[]; /** * Register a callback invoked whenever the data changes. * @returns An unsubscribe function. */ subscribe(callback: () => void): () => void; /** * Remove all data for a specific connection. * * @param connectionId - The connection ID to remove. */ untrack(connectionId: string): void; /** * Release all subscriptions and clear internal state. */ dispose(): void; private _toEntry; private _append; private _notify; } //# sourceMappingURL=transport.d.ts.map