import type { JobManager } from "./job-manager.js"; import type { ScreenShareProvider } from "./agent-controller.js"; import type { RemoteOperator } from "@aicommander/protocol"; interface ConnectionOpts { serverUrl: string; sessionCode: string; agentToken: string; signal?: AbortSignal; /** Desktop-only screen-share provider; absent on the headless Linux agent. */ screenShare?: ScreenShareProvider; /** * Job manager answering the `do:job_*` RPCs. The controller supplies one built * with its own configDir (and already recovered) at startup; when absent we * fall back to the process-wide instance, which is the headless CLI path. */ jobManager?: JobManager; listAdmins?: () => Promise; /** Signed native Windows launcher; desktop supplies its extraResources copy. */ windowsExecLauncherPath?: string; onStatus?: (s: 'connecting' | 'connected' | 'disconnected') => void; onActivity?: (active: boolean) => void; /** * Fired with the driving operator on each operator-initiated command (exec / * screenshot) that carries an identity. The controller rate-limits these into a * desktop "someone connected" notice; absent on the headless agent. */ onRemoteActivity?: (operator: RemoteOperator) => void; /** * Fired whenever the link proves alive (on open and on every server ping). * Lets a supervisor watch link liveness independently of command workload — * pings flow every 20s even during a long command, so a stalled heartbeat * means a genuinely dead link, not a busy one. */ onHeartbeat?: () => void; silent?: boolean; /** * If set, the agent rotates its agentToken roughly this often: while idle it * cleanly drops the connection, calls `reauth()` for a fresh token, and * reconnects — bounding the lifetime of any single (potentially leaked) token. */ reauthIntervalMs?: number; /** Re-register and return a fresh agentToken (caller persists it). */ reauth?: () => Promise; } /** Default agent-token rotation cadence (6h). */ export declare const AGENT_TOKEN_ROTATE_MS: number; export declare function sleepAbortable(ms: number, signal: AbortSignal): Promise; export declare function runConnectionLoop(opts: ConnectionOpts): Promise; export {};