import { Command } from 'commander'; export type BridgeTarget = { kind: 'local'; url: string; } | { kind: 'remote'; url: string; token: string; computerId?: string; }; /** * Resolve the bridge target. Order: * 1. `--remote` flag or `SUPEN_CODEX_BRIDGE_REMOTE=1`: connect to the * gateway from the saved CLI auth (`supen login`), with bearer + computer * id headers, mirroring how iOS reaches the daemon-owned app-server. * 2. `SUPEN_CODEX_BRIDGE_URL` pointing at a remote URL (wss/ws): treat it as * a remote target using the saved auth. * 3. Otherwise: loopback to the daemon's local bridge (no auth headers). * * Remote CLI access fulfills AGENTS.md's "Devices that only consume a remote * runtime use Supen CLI/ProxyCommand" path; the gateway stays a byte relay and * never owns app-server state. */ export declare function resolveBridgeTarget(forceRemote: boolean): Promise; export declare function buildHeaders(target: BridgeTarget): Record | undefined; /** * Decide whether a failed relay attempt should be retried, and how long to * back off. Pure so the policy is table-testable without spinning sockets. * * - Local targets never retry: a loopback failure means the daemon is down and * retrying is just noise. * - Remote targets retry up to MAX_BRIDGE_ATTEMPTS, except when the failure is * an auth/session problem (expired token, login required) — those need user * action, not another attempt. */ export declare function computeBackoff(target: BridgeTarget, attempt: number, message: string): { retry: boolean; delayMs: number; }; /** * stdio surface used by relayOnce. Defaults to `process`; tests pass in fake * streams so they never touch the real process I/O. */ export type BridgeIO = { stdin: { setEncoding(encoding: BufferEncoding): void; on(event: 'data', listener: (chunk: string) => void): unknown; on(event: 'end', listener: () => void): unknown; }; stdout: { write(chunk: string): boolean; }; }; export declare function relayOnce(url: string, headers?: Record, io?: BridgeIO): Promise; export declare function registerCodexBridgeCommand(program: Command): void;