char-slop/berry

multipurpose self-modifiable agentic harness

git clone https://git.t4t.associates/char-slop/berry

Charlotte Somadd terminal extension6334b24

main
1.0 KiB28 linesraw
1// What crosses the terminal's channel. Bytes from the server lead with what they are; bytes to it are typed input.
2
3/** The first byte of the server's binary messages. */
4export const OUTPUT = 0;
5export const SNAPSHOT = 1;
6
7/** The server's other messages. */
8export type ServerMessage =
9  /** No shell has run in this conversation since the server started. */
10  | { t: "none" }
11  /** The shell exited, with its code, or `null` when a signal ended it; its last screen stays. */
12  | { t: "exit"; code: number | null }
13  /** The session's size, which whoever resized it last chose. */
14  | { t: "size"; cols: number; rows: number }
15  /** Starting a shell failed. */
16  | { t: "error"; message: string };
17
18export type ClientMessage =
19  /** Start a shell, unless one is running. */
20  | { t: "start"; cols: number; rows: number }
21  | { t: "resize"; cols: number; rows: number };
22
23export const tagged = (tag: number, data: Uint8Array) => {
24  const out = new Uint8Array(data.length + 1);
25  out[0] = tag;
26  out.set(data, 1);
27  return out;
28};