// What crosses the terminal's channel. Bytes from the server lead with what they are; bytes to it are typed input. /** The first byte of the server's binary messages. */ export const OUTPUT = 0; export const SNAPSHOT = 1; /** The server's other messages. */ export type ServerMessage = /** No shell has run in this conversation since the server started. */ | { t: "none" } /** The shell exited, with its code, or `null` when a signal ended it; its last screen stays. */ | { t: "exit"; code: number | null } /** The session's size, which whoever resized it last chose. */ | { t: "size"; cols: number; rows: number } /** Starting a shell failed. */ | { t: "error"; message: string }; export type ClientMessage = /** Start a shell, unless one is running. */ | { t: "start"; cols: number; rows: number } | { t: "resize"; cols: number; rows: number }; export const tagged = (tag: number, data: Uint8Array) => { const out = new Uint8Array(data.length + 1); out[0] = tag; out.set(data, 1); return out; };