Something went wrong. Try again.
Local build agent for Nodrix — compiles sketches with your own Arduino toolchain so the browser can flash them. Dials out over WebSocket; n…
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334// Frames on the agent socket. The agent dials out, so the instance never needs// to reach a machine behind NAT and the browser never talks to localhost.
export type BuildRequest = { type: 'build'; id: string; fqbn: string; sketch: string;};
export type CloudFrame = BuildRequest | { type: 'ping' };
export type AgentFrame = | { type: 'hello'; version: string; platform: string; arch: string; cli: string | null } | { type: 'log'; build: string; line: string } | { type: 'result'; build: string; ok: true; fqbn: string } | { type: 'result'; build: string; ok: false; error: string };
export function parseCloudFrame(raw: string): CloudFrame | null { let msg: unknown; try { msg = JSON.parse(raw); } catch { return null; } if (!msg || typeof msg !== 'object') return null; const m = msg as Record<string, unknown>; if (m['type'] === 'ping') return { type: 'ping' }; if (m['type'] !== 'build') return null; const { id, fqbn, sketch } = m; if (typeof id !== 'string' || typeof fqbn !== 'string' || typeof sketch !== 'string') return null; return { type: 'build', id, fqbn, sketch };}