import type { Server as HTTPServer } from "http";
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 { DaemonConfigStore } from "./daemon-config-store.js";
import { type ServerCapabilities, type WSOutboundMessage } from "./messages.js";
import type { HostnamesConfig } from "./hostnames.js";
import { Session, type SessionLifecycleIntent } from "./session.js";
import { ProviderSnapshotManager } from "./agent/provider-snapshot-manager.js";
import type { WorkspaceGitService } from "./workspace-git-service.js";
import { type PushNotificationSender } from "./push/notifications.js";
import type { ScriptHealthState } from "./script-health-monitor.js";
import type { ServiceProxySubsystem } from "./service-proxy.js";
import type { WorkspaceScriptRuntimeStore } from "./workspace-script-runtime-store.js";
import type { SpeechReadinessSnapshot, SpeechService } from "./speech/speech-runtime.js";
import type { VoiceCallerContext, VoiceSpeakHandler } from "./voice-types.js";
import { type GitHubService } from "../services/github-service.js";
import { type DaemonAuthConfig } from "./auth.js";
export interface ExternalSocketMetadata {
    transport: "relay";
    externalSessionKey?: string;
}
interface WebSocketServerConfig {
    allowedOrigins: Set<string>;
    hostnames?: HostnamesConfig;
}
interface WebSocketLike {
    readyState: number;
    bufferedAmount?: number;
    send: (data: string | Uint8Array | ArrayBuffer) => void;
    close: (code?: number, reason?: string) => void;
    on: (event: "message" | "close" | "error", listener: (...args: unknown[]) => void) => void;
    once: (event: "close" | "error", listener: (...args: unknown[]) => 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 daemonRuntimeConfig;
    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 github;
    private readonly workspaceGitService;
    private readonly downloadTokenStore;
    private readonly paseoHome;
    private readonly worktreesRoot;
    private readonly daemonConfigStore;
    private readonly pushTokenStore;
    private readonly pushNotificationSender;
    private readonly mcpBaseUrl;
    private speech;
    private terminalManager;
    private serviceProxy;
    private scriptRuntimeStore;
    private getDaemonTcpPort;
    private getDaemonTcpHost;
    private serviceProxyPublicBaseUrl;
    private resolveScriptHealth;
    private dictation;
    private readonly voiceSpeakHandlers;
    private readonly voiceCallerContexts;
    private readonly workspaceSetupSnapshots;
    private readonly providerSnapshotManager;
    private onLifecycleIntent;
    private onBranchChanged;
    private serverCapabilities;
    private readonly runtimeMetrics;
    private runtimeMetricsInterval;
    private unsubscribeSpeechReadiness;
    private unsubscribeDaemonConfigChange;
    constructor(server: HTTPServer, logger: pino.Logger, serverId: string, agentManager: AgentManager, agentStorage: AgentStorage, downloadTokenStore: DownloadTokenStore, paseoHome: string, daemonConfigStore: DaemonConfigStore, mcpBaseUrl: string | null, wsConfig: WebSocketServerConfig, auth?: DaemonAuthConfig, speech?: SpeechService | null, terminalManager?: TerminalManager | null, dictation?: {
        finalTimeoutMs?: number;
    }, daemonVersion?: string, onLifecycleIntent?: (intent: SessionLifecycleIntent) => void, projectRegistry?: ProjectRegistry, workspaceRegistry?: WorkspaceRegistry, chatService?: FileBackedChatService, loopService?: LoopService, scheduleService?: ScheduleService, checkoutDiffManager?: CheckoutDiffManager, serviceProxy?: ServiceProxySubsystem | null, scriptRuntimeStore?: WorkspaceScriptRuntimeStore | null, onBranchChanged?: (workspaceId: string, oldBranch: string | null, newBranch: string | null) => void, getDaemonTcpPort?: () => number | null, getDaemonTcpHost?: () => string | null, resolveScriptHealth?: (hostname: string) => ScriptHealthState | null, workspaceGitService?: WorkspaceGitService, github?: GitHubService, pushNotificationSender?: PushNotificationSender, providerSnapshotManager?: ProviderSnapshotManager, daemonRuntimeConfig?: {
        listen: string | null;
        worktreesRoot?: string;
        relay: {
            enabled: boolean;
            endpoint: string;
            publicEndpoint: string;
            useTls: boolean;
            publicUseTls: boolean;
        };
    }, serviceProxyPublicBaseUrl?: string | null);
    private assignOptionalServices;
    private createWebSocketServer;
    private startRuntimeMetricsInterval;
    private verifyWsUpgrade;
    private attachAuthenticatedSocket;
    broadcast(message: WSOutboundMessage): void;
    listActiveSessions(): Session[];
    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 createDaemonConfigChangedMessage;
    private broadcastCapabilitiesUpdate;
    private broadcastDaemonConfigChanged;
    private bindSocketHandlers;
    resolveVoiceSpeakHandler(callerAgentId: string): VoiceSpeakHandler | null;
    resolveVoiceCallerContext(callerAgentId: string): VoiceCallerContext | null;
    private detachSocket;
    private cleanupConnection;
    private handleInvalidInboundMessage;
    private maybeHandleBinaryFrame;
    private handlePendingConnectionMessage;
    private handleRawMessage;
    private dispatchSessionMessage;
    private handleRawMessageError;
    private decodeRawMessagePayloadForError;
    private incrementRuntimeCounter;
    private recordInboundMessageType;
    private recordInboundSessionRequestType;
    private recordRequestLatency;
    private collectSessionRuntimeMetrics;
    private flushRuntimeMetrics;
    private getClientActivityState;
    private broadcastAgentAttention;
}
export {};
//# sourceMappingURL=websocket-server.d.ts.map