/** * SupervisedSession — a `ReplSession` that survives transient serial * disconnects. * * The state machine in `replStateMachine` binds to a single `ReplSession` * for its lifetime: it subscribes once to `messages$` and calls * `awaitReady$` once. To stay alive across USB re-enumerations (e.g. light * sleep on USJ-console chips), this wrapper owns the inner `ReplSession` * lifecycle, swaps the inner instance on disconnect, and re-drives the * handshake on the new instance — all transparent to the state machine. * * Events surfaced to the state machine (in addition to the inner * session's events): * - `{type: 'reconnecting'}` when the inner disconnects and we're * starting the reconnect poll. The state machine renders a subtle * "Reconnecting…" footer line. * - `{type: 'reconnected'}` after the new transport is open. The new * inner's MSG_READY (delivered via `messages$` shortly after) drives * the state machine back to `ready`. * - `{type: 'disconnect', error: '...'}` if the device doesn't return * within the timeout — the same shape as a hard transport error, so * the state machine's existing handler surfaces it as an error. */ import { SerialPort } from 'serialport'; import { type ConnectReplOptions, type ReplSession } from '../session.js'; export interface SupervisedSessionOptions { devicePath: string; baudRate: number; /** USB serial of the device we connected to. Reconnect re-finds the * device by this serial across port changes, so a board that comes back * on a different path is followed and a *different* board that grabs the * old path is ignored. Undefined for devices without a USB serial (some * UART bridges); reconnect then falls back to watching the original path. */ serialNumber?: string; /** Total ms to wait for the device to reappear before giving up. * Defaults to Infinity (see `RECONNECT_TIMEOUT_MS`). */ reconnectTimeoutMs?: number; /** Called when a reconnect cycle starts, before the `'reconnecting'` * event reaches the state machine. Useful for aborting in-flight * deploys. */ onReconnectStart?: () => void; /** Firmware-version policy forwarded to every inner `connectRepl` * (initial connect and reconnects). See {@link ConnectReplOptions.compat}. */ compat?: ConnectReplOptions['compat']; } /** * Wrap an already-open SerialPort into a self-supervising ReplSession. * The caller hands off ownership of `initialSerial`; closing the returned * session closes the underlying port. */ export declare function createSupervisedSession(initialSerial: SerialPort, opts: SupervisedSessionOptions): ReplSession; //# sourceMappingURL=supervisedSession.d.ts.map