feat: add codex web terminal

This commit is contained in:
Felipe Coury
2026-05-02 17:16:20 -03:00
parent 35aaa5d9fc
commit 7be5328f34
25 changed files with 2147 additions and 51 deletions
+28
View File
@@ -0,0 +1,28 @@
export const INPUT_FRAME = 0x00;
export const RESIZE_FRAME = 0x01;
export function decodeClientFrame(frame) {
const data = Buffer.isBuffer(frame) ? frame : Buffer.from(frame);
if (data.length === 0) {
return { type: "invalid", reason: "empty frame" };
}
const kind = data.readUInt8(0);
if (kind === INPUT_FRAME) {
return { type: "input", data: data.subarray(1).toString("utf8") };
}
if (kind === RESIZE_FRAME) {
if (data.length !== 5) {
return { type: "invalid", reason: "malformed resize frame" };
}
const cols = data.readUInt16BE(1);
const rows = data.readUInt16BE(3);
if (cols === 0 || rows === 0) {
return { type: "invalid", reason: "resize dimensions must be positive" };
}
return { type: "resize", cols, rows };
}
return { type: "invalid", reason: `unknown frame type ${kind}` };
}