import { type Server } from "node:http";
import type { PraxisApplicationCommand, PraxisApplicationCommandResult, PraxisApplicationEvent, PraxisApplicationRuntime, PraxisApplicationViewModel } from "./applicationContract.js";
export type PraxisApplicationTransportKind = "local" | "rest" | "websocket";
export type PraxisApplicationRestRoute = "GET /application/view" | "POST /application/commands" | "GET /application/events";
export type PraxisApplicationWebSocketMessage = {
    type: "application.command";
    commandId: string;
    command: PraxisApplicationCommand;
} | {
    type: "application.commandResult";
    commandId: string;
    result: PraxisApplicationCommandResult;
} | {
    type: "application.event";
    event: PraxisApplicationEvent;
} | {
    type: "application.view";
    view: PraxisApplicationViewModel;
};
export type PraxisApplicationProtocolMessage = {
    type: "application.ready";
    view: PraxisApplicationViewModel;
} | PraxisApplicationWebSocketMessage | {
    type: "application.error";
    commandId?: string;
    error: {
        code: string;
        message: string;
    };
    view?: PraxisApplicationViewModel;
};
export type PraxisApplicationTransportDescriptor = {
    kind: PraxisApplicationTransportKind;
    protocol: "in-process" | "rest-json" | "websocket-json";
    routes?: readonly PraxisApplicationRestRoute[];
    messageTypes?: readonly PraxisApplicationWebSocketMessage["type"][];
};
export type PraxisApplicationTransportClient = {
    readonly descriptor: PraxisApplicationTransportDescriptor;
    getView(): Promise<PraxisApplicationViewModel>;
    dispatch(command: PraxisApplicationCommand): Promise<PraxisApplicationCommandResult>;
    subscribe(listener: (event: PraxisApplicationEvent) => void): () => void;
};
export type PraxisApplicationRestServer = {
    readonly descriptor: PraxisApplicationTransportDescriptor;
    readonly server: Server;
    readonly url: string;
    close(): Promise<void>;
};
export type PraxisApplicationWebSocketServer = {
    readonly descriptor: PraxisApplicationTransportDescriptor;
    readonly server: Server;
    readonly url: string;
    close(): Promise<void>;
};
export declare function describeApplicationRestTransport(): PraxisApplicationTransportDescriptor;
export declare function describeApplicationWebSocketTransport(): PraxisApplicationTransportDescriptor;
export declare function createLocalApplicationTransport(runtime: PraxisApplicationRuntime): PraxisApplicationTransportClient;
export declare function createApplicationRestServer(runtime: PraxisApplicationRuntime, options?: {
    host?: string;
    port?: number;
}): Promise<PraxisApplicationRestServer>;
export declare function createApplicationWebSocketServer(runtime: PraxisApplicationRuntime, options?: {
    host?: string;
    port?: number;
    path?: string;
}): Promise<PraxisApplicationWebSocketServer>;
