import type { RuntimeStore } from '../runtime/store/index.js';
import type { RuntimeEventBus, RuntimeEventDomain } from '../runtime/events/index.js';
import type { ControlPlaneClientDescriptor, ControlPlaneServerConfig, ControlPlaneSurfaceMessage } from './types.js';
import type { FeatureFlagReader } from '../runtime/feature-flags/index.js';
import { DEFAULT_DOMAINS, type ControlPlaneRecentEvent } from './gateway-utils.js';
export type { ControlPlaneRecentEvent } from './gateway-utils.js';
export interface ControlPlaneGatewayConfig {
    readonly runtimeBus?: RuntimeEventBus | null | undefined;
    readonly runtimeStore?: RuntimeStore | null | undefined;
    readonly server?: Partial<ControlPlaneServerConfig> | undefined;
    readonly featureFlags?: FeatureFlagReader | undefined;
}
export interface ControlPlaneEventStreamOptions {
    readonly clientId?: string | undefined;
    readonly clientKind?: 'tui' | 'web' | 'slack' | 'discord' | 'ntfy' | 'webhook' | 'homeassistant' | 'telegram' | 'google-chat' | 'signal' | 'whatsapp' | 'imessage' | 'msteams' | 'bluebubbles' | 'mattermost' | 'matrix' | 'daemon';
    readonly transport?: 'local' | 'http' | 'sse' | 'ws' | 'webhook' | undefined;
    readonly label?: string | undefined;
    readonly domains?: readonly RuntimeEventDomain[] | undefined;
    readonly principalId?: string | undefined;
    readonly principalKind?: 'user' | 'bot' | 'service' | 'token' | undefined;
    readonly scopes?: readonly string[] | undefined;
    readonly sessionId?: string | undefined;
    readonly routeId?: string | undefined;
    readonly surfaceId?: string | undefined;
    readonly remoteAddress?: string | undefined;
    readonly capabilities?: readonly string[] | undefined;
}
interface LiveControlPlaneClient {
    readonly clientId: string;
    readonly kind: 'tui' | 'web' | 'slack' | 'discord' | 'ntfy' | 'webhook' | 'homeassistant' | 'telegram' | 'google-chat' | 'signal' | 'whatsapp' | 'imessage' | 'msteams' | 'bluebubbles' | 'mattermost' | 'matrix' | 'daemon';
    readonly surfaceId?: string | undefined;
    readonly routeId?: string | undefined;
    readonly send: (event: string, payload: unknown, id?: string) => void;
}
export declare class ControlPlaneGateway {
    private runtimeBus;
    private dispatch;
    private readonly serverConfig;
    private readonly featureFlags;
    private readonly clients;
    private readonly liveClients;
    private readonly websocketClients;
    private readonly recentMessages;
    private readonly _recentEventsRing;
    private _recentEventsHead;
    private _recentEventsCount;
    private readonly _recentEventsCapacity;
    /** Materialized newest-first view of the recent event ring buffer. */
    private get recentEvents();
    private requestCount;
    private errorCount;
    private lastRequestAt;
    private _syncScheduled;
    private _lastEventAt;
    constructor(config?: ControlPlaneGatewayConfig);
    private isEnabled;
    private requireEnabled;
    attachRuntime(config: {
        readonly runtimeBus?: RuntimeEventBus | null | undefined;
        readonly runtimeStore?: RuntimeStore | null | undefined;
    }): void;
    listClients(): ControlPlaneClientDescriptor[];
    getSnapshot(): Record<string, unknown>;
    listSurfaceMessages(limit?: number): ControlPlaneSurfaceMessage[];
    listRecentEvents(limit?: number): ControlPlaneRecentEvent[];
    publishSurfaceMessage(input: Omit<ControlPlaneSurfaceMessage, 'id' | 'createdAt'>): ControlPlaneSurfaceMessage;
    publishEvent(event: string, payload: unknown, filter?: {
        readonly clientKind?: LiveControlPlaneClient['kind'] | undefined;
        readonly clientId?: string | undefined;
        readonly routeId?: string | undefined;
        readonly surfaceId?: string | undefined;
    }): void;
    recordApiRequest(input: {
        readonly method: string;
        readonly path: string;
        readonly status: number;
        readonly clientKind?: ControlPlaneEventStreamOptions['clientKind'] | undefined;
        readonly error?: string | undefined;
    }): void;
    setServerState(patch: Partial<ControlPlaneServerConfig>): void;
    openWebSocketClient(options: ControlPlaneEventStreamOptions, send: (event: string, payload: unknown, id?: string) => void): {
        clientId: string;
        domains: readonly RuntimeEventDomain[];
    };
    touchWebSocketClient(clientId: string, metadata?: Record<string, unknown>): void;
    authenticateClient(clientId: string, input: {
        readonly principalId: string;
        readonly principalKind?: 'user' | 'bot' | 'service' | 'token' | undefined;
        readonly scopes?: readonly string[] | undefined;
        readonly label?: string | undefined;
        readonly capabilities?: readonly string[] | undefined;
    }): void;
    subscribeWebSocketClient(clientId: string, domains: readonly RuntimeEventDomain[]): void;
    unsubscribeWebSocketClient(clientId: string, domains?: readonly RuntimeEventDomain[]): void;
    closeWebSocketClient(clientId: string, reason?: string): void;
    private replayRecentTraffic;
    createEventStream(request: Request, options?: ControlPlaneEventStreamOptions): Response;
    renderWebUi(authTokenHint?: string): Response;
    private _scheduleControlPlaneSync;
    private rememberEvent;
}
export { DEFAULT_DOMAINS as DEFAULT_DOMAINS_TEST_EXPORT };
//# sourceMappingURL=gateway.d.ts.map