Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

665 B
Raw Blame
/**
 * A request body as `application/gzip` bytes of its JSON.
 *
 * Publications carry what people made (HTML, JavaScript, any text a session wrote), and Cloudflare's
 * managed rules in front of the Hub and its API refuse a body with raw `<script>` in it as an attack.
 * Gzipped, it reaches the backend, which unpacks and validates it as it would a raw one.
 */
export const gzipType = 'application/gzip';

export async function gzipJson(value: unknown): Promise<Uint8Array<ArrayBuffer>> {
  const stream = new Response(JSON.stringify(value)).body!.pipeThrough(new CompressionStream('gzip'));
  return new Uint8Array(await new Response(stream).arrayBuffer());
}