import type { Server as HTTPServer } from "http";
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
import type { AgentManager } from "./agent/agent-manager.js";
import type { AgentStorage } from "./agent/agent-storage.js";
import type { DownloadTokenStore } from "./file-download/token-store.js";
import type { TerminalManager } from "../terminal/terminal-manager.js";
import type pino from "pino";
import type { ProjectRegistry, WorkspaceRegistry } from "./workspace-registry.js";
import type { FileBackedChatService } from "./chat/chat-service.js";
import type { LoopService } from "./loop-service.js";
import type { ScheduleService } from "./schedule/service.js";
import type { CheckoutDiffManager } from "./checkout-diff-manager.js";
import { type ServerCapabilities, type WSOutboundMessage } from "./messages.js";
import type { AllowedHostsConfig } from "./allowed-hosts.js";
import { type SessionLifecycleIntent } from "./session.js";
import type { AgentProviderRuntimeSettingsMap } from "./agent/provider-launch-config.js";
import type { SpeechReadinessSnapshot, SpeechService } from "./speech/speech-runtime.js";
import type { VoiceCallerContext, VoiceMcpStdioConfig, VoiceSpeakHandler } from "./voice-types.js";
export type AgentMcpTransportFactory = () => Promise<Transport>;
export type ExternalSocketMetadata = {
    transport: "relay";
    externalSessionKey?: string;
};
type WebSocketServerConfig = {
    allowedOrigins: Set<string>;
    allowedHosts?: AllowedHostsConfig;
};
type WebSocketLike = {
    readyState: number;
    bufferedAmount?: number;
    send: (data: string | Uint8Array | ArrayBuffer) => void;
    close: (code?: number, reason?: string) => void;
    on: (event: "message" | "close" | "error", listener: (...args: any[]) => void) => void;
    once: (event: "close" | "error", listener: (...args: any[]) => void) => void;
};
export declare class MissingDaemonVersionError extends Error {
    constructor();
}
/**
 * WebSocket server that only accepts sockets + parses/forwards messages to the session layer.
 */
export declare class VoiceAssistantWebSocketServer {
    private readonly logger;
    private readonly wss;
    private readonly pendingConnections;
    private readonly sessions;
    private readonly externalSessionsByKey;
    private readonly serverId;
    private readonly daemonVersion;
    private readonly agentManager;
    private readonly agentStorage;
    private readonly projectRegistry;
    private readonly workspaceRegistry;
    private readonly chatService;
    private readonly loopService;
    private readonly scheduleService;
    private readonly checkoutDiffManager;
    private readonly downloadTokenStore;
    private readonly paseoHome;
    private readonly pushTokenStore;
    private readonly pushService;
    private readonly createAgentMcpTransport;
    private readonly speech;
    private readonly terminalManager;
    private readonly dictation;
    private readonly voice;
    private readonly voiceSpeakHandlers;
    private readonly voiceCallerContexts;
    private readonly agentProviderRuntimeSettings;
    private readonly onLifecycleIntent;
    private serverCapabilities;
    private runtimeWindowStartedAt;
    private readonly runtimeCounters;
    private readonly inboundMessageCounts;
    private readonly inboundSessionRequestCounts;
    private readonly requestLatencies;
    private runtimeMetricsInterval;
    private unsubscribeSpeechReadiness;
    constructor(server: HTTPServer, logger: pino.Logger, serverId: string, agentManager: AgentManager, agentStorage: AgentStorage, downloadTokenStore: DownloadTokenStore, paseoHome: string, createAgentMcpTransport: AgentMcpTransportFactory, wsConfig: WebSocketServerConfig, speech?: SpeechService | null, terminalManager?: TerminalManager | null, voice?: {
        voiceAgentMcpStdio?: VoiceMcpStdioConfig | null;
        ensureVoiceMcpSocketForAgent?: (agentId: string) => Promise<string>;
        removeVoiceMcpSocketForAgent?: (agentId: string) => Promise<void>;
    }, dictation?: {
        finalTimeoutMs?: number;
    }, agentProviderRuntimeSettings?: AgentProviderRuntimeSettingsMap, daemonVersion?: string, onLifecycleIntent?: (intent: SessionLifecycleIntent) => void, projectRegistry?: ProjectRegistry, workspaceRegistry?: WorkspaceRegistry, chatService?: FileBackedChatService, loopService?: LoopService, scheduleService?: ScheduleService, checkoutDiffManager?: CheckoutDiffManager);
    broadcast(message: WSOutboundMessage): void;
    publishSpeechReadiness(readiness: SpeechReadinessSnapshot | null): void;
    updateServerCapabilities(capabilities: ServerCapabilities | null | undefined): void;
    attachExternalSocket(ws: WebSocketLike, metadata?: ExternalSocketMetadata): Promise<void>;
    close(): Promise<void>;
    private sendToClient;
    private sendBinaryToClient;
    private sendToConnection;
    private sendBinaryToConnection;
    private attachSocket;
    private createSessionConnection;
    private clearPendingConnection;
    private handleHello;
    private buildServerInfoStatusPayload;
    private createServerInfoMessage;
    private broadcastCapabilitiesUpdate;
    private bindSocketHandlers;
    resolveVoiceSpeakHandler(callerAgentId: string): VoiceSpeakHandler | null;
    resolveVoiceCallerContext(callerAgentId: string): VoiceCallerContext | null;
    private detachSocket;
    private cleanupConnection;
    private handleRawMessage;
    private readonly ACTIVITY_THRESHOLD_MS;
    private incrementRuntimeCounter;
    private incrementCount;
    private recordInboundMessageType;
    private recordInboundSessionRequestType;
    private recordRequestLatency;
    private getTopCounts;
    private computeLatencyStats;
    private collectSessionRuntimeMetrics;
    private flushRuntimeMetrics;
    private getClientActivityState;
    private broadcastAgentAttention;
}
export {};
//# sourceMappingURL=websocket-server.d.ts.map