export { parseGitHubRequestId as getGitHubRequestId } from "../../github/common/client/headers.js"; export interface IConnectionDiagnosticState { readonly connectionState?: "connecting" | "connected" | "reconnecting" | "incompatible" | "closed"; readonly authenticationRestorePending?: boolean; readonly lastSuccessfulResponseAgeMs?: number; readonly reconnectAttempt?: number; readonly reconnectScheduled?: boolean; readonly reconnectDelayMs?: number; } export interface IConnectionDiagnosticEvent extends IConnectionDiagnosticState { readonly operationId: string; readonly attemptId?: string; readonly phase: string; readonly timestamp: number; readonly outcome: "started" | "succeeded" | "failed" | "info"; readonly durationMs?: number; readonly detail?: string; readonly error?: IConnectionDiagnosticError; readonly requestKind?: ConnectionDiagnosticRequestKind; readonly connectionOperation?: "connect" | "recover"; readonly sessionResource?: string; readonly chatResource?: string; readonly turnId?: string; readonly sessionState?: "creating" | "ready" | "failed"; } export type ConnectionDiagnosticRequestKind = "listSessions" | "createSession" | "subscribeRoot" | "subscribeSession" | "subscribeChat" | "subscribeOther"; export interface IConnectionDiagnosticError { readonly name: string; readonly message: string; readonly code?: string; readonly status?: number; readonly requestId?: string; readonly cause?: IConnectionDiagnosticError; } export type ConnectionDiagnosticObserver = (event: IConnectionDiagnosticEvent) => void; export declare function emitConnectionDiagnostic(observer: ((event: T) => void) | undefined, event: T): void; /** Best-effort redaction for connection errors, never protocol bodies or authentication objects. */ export declare function sanitizeConnectionDiagnosticText(value: string, limit?: number): string; /** Reads only known error metadata, not response bodies, stacks, or arbitrary object properties. */ export declare function getConnectionDiagnosticError(error: unknown, depth?: number): IConnectionDiagnosticError; export declare function formatConnectionDiagnosticError(error: IConnectionDiagnosticError): string; /** Records an operation without adding an asynchronous boundary to its caller. */ export declare class ConnectionDiagnosticOperation { private readonly observer; private readonly phase; private readonly operationId; private readonly started; constructor(observer: ConnectionDiagnosticObserver, phase: string, detail?: string); succeeded(detail?: string): void; failed(error: unknown): void; private complete; } /** A single operation ID ties its start to its completion without modifying errors or results. */ export declare function traceConnectionOperation(observer: ConnectionDiagnosticObserver | undefined, phase: string, operation: () => Promise): Promise; export interface IRemoteConnectionDiagnosticEvent extends IConnectionDiagnosticEvent { readonly address: string; } /** Bounded in-memory evidence; never persisted or sent as telemetry. */ export declare class ConnectionDiagnosticBuffer { private readonly events; record(address: string, event: IConnectionDiagnosticEvent): void; getEvents(): readonly IRemoteConnectionDiagnosticEvent[]; }