// Install the audio patches (getUserMedia → robot speaker) BEFORE the SDK // opens the session, via this import's side effect. import { installAudioPatches } from "./voice/audio"; import { connectToHost } from "@pollen-robotics/reachy-mini-sdk/host/embed"; import { safelyReturnToPose } from "@pollen-robotics/reachy-mini-sdk/animation"; import { RobotGestures } from "./robot/gestures"; import { App } from "./ui/app"; import "./ui/styles.css"; installAudioPatches(); async function main() { const handle = await connectToHost(); const { reachy } = handle; // Don't push our (idle, silent) outbound audio bus to the robot until the // user actually talks — that's what made the robot react while idle. Keep // the robot's OWN mic flowing (do NOT setAudioMuted) so robot-mic voice can // capture it. Turn OFF the daemon's audio-reactive head wobble: it's a // separate motion master that fought ours and buzzed an antenna; we keep // the talking motion calm. try { reachy.setMicMuted(true); reachy.sendRaw({ type: "set_wobbling", enabled: false }); } catch { /* older SDK / no audio path */ } document.documentElement.setAttribute("data-theme", handle.theme); handle.onThemeChange((theme) => document.documentElement.setAttribute("data-theme", theme)); const root = document.getElementById("root"); if (!root) throw new Error("missing #root element"); const gestures = new RobotGestures(reachy); const app = new App(root, gestures, () => reachy); app.start(); // Canonical safe teardown — the host owns the session lifecycle. handle.onLeave(() => { gestures.cancel(); safelyReturnToPose(reachy); }); } void main().catch((err) => { console.error("[cookaiware] boot failed", err); window.parent.postMessage( { source: "reachy-mini", type: "embed:error", version: 1, message: String(err), fatal: true }, window.location.origin, ); });