/**
 * Single fixed reverse-proxy port per daemon. Each session's xterm.js web
 * terminal runs on its own dynamically-assigned worker port, which makes SSH
 * port-forwarding painful on dev machines (one `ssh -L` per topic). This proxy
 * fronts all of a daemon's session terminals under one stable port, routing by
 * sub-path: `http://host:{proxyPort}/s/{sessionId}/...` → the worker's port.
 * Forward one port, reach every session.
 */
export interface TerminalProxyOptions {
    port: number;
    host?: string;
    /** Resolve a sessionId to its live worker HTTP port (undefined if not running). */
    resolvePort: (sessionId: string) => number | undefined;
    /**
     * Optional on-demand wake: when `resolvePort` finds no live worker, re-fork it
     * (re-attaching the surviving tmux/zellij pane) and resolve once its port is
     * up. Lets terminals open after a quiet restart without first messaging the
     * session. Returns undefined when there's nothing to wake. Slow path only.
     */
    ensureWorkerPort?: (sessionId: string) => Promise<number | undefined>;
    /** Max upward port probes when `port` is taken (EADDRINUSE). Default 20; 0 disables. */
    maxProbe?: number;
}
export interface TerminalProxyHandle {
    port: number;
    close: () => Promise<void>;
}
/**
 * Split a request URL of the form `/s/{sessionId}{rest}` into its sessionId and
 * the remainder that should be forwarded to the worker. The remainder always
 * starts with `/` so the worker sees a normal request (`/`, `/?token=x`, …).
 * Returns null when the URL is not a session route.
 */
export declare function parseTarget(rawUrl: string): {
    sessionId: string;
    rest: string;
} | null;
export declare function startTerminalProxy(opts: TerminalProxyOptions): Promise<TerminalProxyHandle>;
//# sourceMappingURL=terminal-proxy.d.ts.map