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.

1.5 KB
Raw Blame
/**
 * Down-frames the backend mints for an adapter, which a client must never be able to forge.
 *
 * The `__` prefix already marks most of these; these predate that convention and are not prefixed, so
 * each client socket that relays frames down (`webWs`, its legacy apiKey path, `deviceWs`) has to refuse
 * them by name. The adapter refuses them too unless they arrive on the backend's own `connId: ''`.
 *
 * Senders, all backend-side: `lib/adapterWs.ts` (on connect), `services/MachineService.ts`
 * (rename, revoke) and `lib/adapterAccountPushes.ts` (desk_changed, zoo_changed, machines_changed —
 * forged, each one makes every window on that computer re-read from this backend, device_keys_changed),
 * and `lib/adapterWs.ts` again for `devlog_append_result`, the answer to a machine's own log append; and the Swarm pushes
 * (`lib/swarmHostPushes.ts` swarm_host_changed, `lib/swarmClientPushes.ts` swarm_changed — forged, a host or a window reads
 * early, or believes the server pushes and waits for its safety net).
 */
export const BACKEND_ONLY_DOWN_TYPES = new Set(['machine_meta', 'machine_revoked', 'desk_changed', 'zoo_changed', 'machines_changed', 'device_keys_changed', 'connectors_changed', 'devlog_append_result', 'swarm_host_changed', 'swarm_changed'])

/** A type no client may send down: the backend's own `__` control frames and the named ones above. */
export function isBackendOnlyDownType(type: unknown): boolean {
  return typeof type === 'string' && (type.startsWith('__') || BACKEND_ONLY_DOWN_TYPES.has(type))
}