/** * Sandbox control protocol. * * Transport: * - JSON control messages typed in this module. * - Binary output frames stream stdout/stderr chunks. * * Client → Server: * - exec { type: "exec", id, cmd, argv?, env?, cwd?, stdin?, pty? } * - stdin { type: "stdin", id, data?: base64 string, eof? } * - pty_resize { type: "pty_resize", id, rows, cols } * - lifecycle { type: "lifecycle", action: "restart" | "shutdown" } * - snapshot { type: "snapshot", id, path } * - boot { type: "boot", fuseMount?, fuseBinds? } * * Server → Client: * - status { type: "status", state: "starting" | "running" | "stopped" } * - exec_response { type: "exec_response", id, exit_code, signal? } * - snapshot_response { type: "snapshot_response", id, path, name } * - error { type: "error", id?, code, message } * * Binary output frame: * +---------+-----------+-------------------+ * | u8 tag | u32 id | data bytes | * +---------+-----------+-------------------+ * tag = 1 stdout, tag = 2 stderr, id big-endian. */ export type ExecCommandMessage = { type: "exec"; /** request id */ id: number; /** executable */ cmd: string; /** argv entries (excluding cmd) */ argv?: string[]; /** environment variables as `KEY=VALUE` */ env?: string[]; /** working directory */ cwd?: string; /** whether stdin messages will be sent */ stdin?: boolean; /** whether to allocate a pty */ pty?: boolean; /** initial stdout credit window in `bytes` (0 = default) */ stdout_window?: number; /** initial stderr credit window in `bytes` (0 = default) */ stderr_window?: number; }; export type StdinCommandMessage = { type: "stdin"; /** request id */ id: number; /** stdin chunk as base64 */ data?: string; /** whether this chunk closes stdin */ eof?: boolean; }; export type PtyResizeCommandMessage = { type: "pty_resize"; /** request id */ id: number; /** pty row count */ rows: number; /** pty column count */ cols: number; }; export type LifecycleCommandMessage = { type: "lifecycle"; /** lifecycle action */ action: "restart" | "shutdown"; }; export type SnapshotCommandMessage = { type: "snapshot"; /** request id */ id: number; /** absolute output path for the checkpoint `.qcow2` file */ path: string; }; export type BootCommandMessage = { type: "boot"; /** guest mountpoint for fuse (defaults to server config) */ fuseMount?: string; /** guest paths to bind into the fuse mount */ fuseBinds?: string[]; }; export type ExecWindowCommandMessage = { type: "exec_window"; /** request id */ id: number; /** additional stdout credits in `bytes` */ stdout?: number; /** additional stderr credits in `bytes` */ stderr?: number; }; export type ClientMessage = BootCommandMessage | ExecCommandMessage | StdinCommandMessage | PtyResizeCommandMessage | ExecWindowCommandMessage | LifecycleCommandMessage | SnapshotCommandMessage; export type ExecResponseMessage = { type: "exec_response"; /** request id */ id: number; /** process exit code */ exit_code: number; /** termination signal (if any) */ signal?: number; }; export type ErrorMessage = { type: "error"; /** request id (when the error is correlated to a request) */ id?: number; /** stable error code */ code: string; /** human-readable error message */ message: string; }; export type SnapshotResponseMessage = { type: "snapshot_response"; /** request id */ id: number; /** absolute path to the checkpoint `.qcow2` file */ path: string; /** snapshot name */ name: string; }; export type StatusMessage = { type: "status"; /** sandbox state */ state: "starting" | "running" | "stopped"; }; export type ServerMessage = ExecResponseMessage | ErrorMessage | SnapshotResponseMessage | StatusMessage; export type OutputStream = "stdout" | "stderr"; export declare function encodeOutputFrame(id: number, stream: OutputStream, data: Buffer): Buffer; export declare function decodeOutputFrame(frame: Buffer): { id: number; stream: OutputStream; data: Buffer; }; //# sourceMappingURL=control-protocol.d.ts.map