import { type FileRpcResult } from "@aicommander/protocol"; export interface PullRequest { serverUrl: string; path: string; token: string; /** Ceiling asked for by the relay. Clamped to FILE_MAX_BYTES; see `sizeCeiling`. */ maxBytes?: number; /** Aborts the transfer when the connection that ordered it goes away. */ signal?: AbortSignal; } /** * Read a local file and upload it to the relay. * * Order matters: stat first, refuse on shape or size, and only then open a socket. * A 4 GB checkpoint must cost a stat call and a clear refusal, not a transfer that * runs for minutes before the relay cuts it off at the cap. */ export declare function pullFileToRelay(req: PullRequest): Promise; export interface PushRequest { serverUrl: string; destPath: string; token: string; expectedBytes: number; /** The agent's own ceiling. Defaults to FILE_MAX_BYTES; overridable for tests. */ maxBytes?: number; /** Aborts the transfer when the connection that ordered it goes away. */ signal?: AbortSignal; } /** * Delete abandoned `.aic-transfer-*.part` files in one directory. * * The handled error paths already unlink their own temp file; this exists for the * ones that cannot — a crash, a self-update, a power loss mid-push — after which up * to FILE_MAX_BYTES stays on the user's disk with nothing left to clean it up. Run * from the push path against the directory a push is about to write to, because that * is both the only directory we ever leave these in and the one whose filling up the * user would notice. Entirely best-effort: a sweep that cannot read the directory * must never stop the transfer that triggered it. */ export declare function sweepStaleTransferTemps(dir: string, now?: number): Promise; /** * Download a stored blob from the relay and write it to a local path, atomically. * * The temp file lives in the DESTINATION'S directory, not in /tmp: a rename is only * atomic within one filesystem, and a NAS or a container routinely has /tmp on a * different mount than the data directory. Writing to /tmp first would silently * downgrade the guarantee to a copy — a reader could then observe a partial file. */ export declare function pushFileFromRelay(req: PushRequest): Promise;