The computer's screen has no GPU and no window manager, so the tab in front is always on show and Chrome draws its animations in software at full rate whether or not anyone watches: one animated site kept a production computer at 200% CPU. - The agent parks the browser after COBBLE_BROWSER_PARK_AFTER_SECONDS (default 180, 0 turns it off) without a /mcp call or a screen view: a blank tab goes in front of every site on show, as a person switching tabs would, so pages keep their connections and see nothing unusual. The next /mcp call or screen view brings them back before it goes through. Done over the agent's own small CDP client (the image's Node has no WebSocket). - Chrome composites pages in software (--disable-gpu-compositing): about half the CPU while a bot works, WebGL unchanged. - The managed policy sets TabDiscardingExceptions so a parked tab is never discarded and reloaded. - The screen's websocket bridge now closes when a viewer goes away without a close frame; it used to stay half open for good. - Computer image bumped to 1.1.0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
type Params = {
|
|
opcode: number;
|
|
payload: Buffer;
|
|
/**
|
|
* Four bytes to mask the payload with, as a client must (the agent's
|
|
* own DevTools client); a server's frames go unmasked.
|
|
*/
|
|
mask?: Buffer;
|
|
};
|
|
|
|
/**
|
|
* One whole frame (RFC 6455) around a payload: unmasked, as a server
|
|
* sends it, unless a `mask` is given.
|
|
*/
|
|
export default function encodeWebsocketFrame({ opcode, payload, mask }: Params) {
|
|
const length = payload.length;
|
|
const mask_bit = mask ? 0x80 : 0;
|
|
let header: Buffer;
|
|
|
|
if (length < 126) {
|
|
header = Buffer.from([0x80 | opcode, mask_bit | length]);
|
|
} else if (length < 65536) {
|
|
header = Buffer.alloc(4);
|
|
header[0] = 0x80 | opcode;
|
|
header[1] = mask_bit | 126;
|
|
header.writeUInt16BE(length, 2);
|
|
} else {
|
|
header = Buffer.alloc(10);
|
|
header[0] = 0x80 | opcode;
|
|
header[1] = mask_bit | 127;
|
|
header.writeBigUInt64BE(BigInt(length), 2);
|
|
}
|
|
|
|
if (!mask) return Buffer.concat([header, payload]);
|
|
|
|
const masked = Buffer.from(payload);
|
|
|
|
for (let index = 0; index < masked.length; index++) masked[index]! ^= mask[index & 3]!;
|
|
|
|
return Buffer.concat([header, mask.subarray(0, 4), masked]);
|
|
}
|