<!-- LOVABLE:BEGIN -->
> [!IMPORTANT]
> This project is connected to [Lovable](https://lovable.dev). Avoid rewriting
> published git history — force pushing, or rebasing/amending/squashing commits
> that are already pushed — as it rewrites history on Lovable's side and the
> user will likely lose their project history.
>
> Commits you push to the connected branch sync back to Lovable and show up in
> the editor, so keep the branch in a working state.
<!-- LOVABLE:END -->

- Echo's voice call is Gemini Live: a server function mints a single-use Google token locked to model/voice/instructions, and the browser streams audio directly to Google — the real key never reaches the browser and no Lovable AI credits are used.
- Echo requires sign-in; history and builds are private per user (row security by user_id), and Gemini may only read the caller's own history; its only actions are history lookup, build_website and deploy_website — no shell or file-write tools, because those need a separate authorized execution service.
- Preserve complete Gemini model parts, including thought signatures, during history-tool continuations so multi-step requests remain valid.
- Echo's website builds: live call calls build_website → server function generates one self-contained HTML file with Gemini, saves it to voice_builds keyed by a per-call session_id, and the page shows it in a sandboxed iframe; session pages live at /session/$id.
- Built apps run with zero install: React UMD + Babel standalone pinned to v7 (later Babel emits ES imports that break in-browser compiling); withEchoRuntime in src/lib/echo-runtime.ts pins CDN versions, injects window.EchoDB, an in-memory storage fallback for the sandboxed iframe, and the live-test reporter.
- Live testing: the preview iframe posts errors and a load health check to SitePreview; a voice build is auto-fixed at most once (fix results never auto-fix again) to avoid loops, and the result is told to Echo as a text note.
- Deploys go to Cloudflare Pages Direct Upload with the Cloudfare_Api_keys secret, one project per call session (echo-<session prefix>), so redeploys update the same address.
- Built-app data lives in app_records via the public route /api/public/apps/$appId/$collection (CORS *, size and count limits, app must exist); EchoDB posts as text/plain to avoid CORS preflight. It is public by design and must never hold private data.
- Routes: / is the public landing page, /profile the profile (sign-in when signed out), /echo the Echo call page, /autonomous the agent studio, /security the Aegis workspace and /cloud the private cloud project workspace; the global AppHeader in __root links them. AI and security operations require sign-in so strangers cannot spend saved keys.
- Aegis security scans use Mozilla Observatory through fixed server-side URLs with explicit public-report consent; never fetch caller-supplied URLs directly, to avoid SSRF.
- Cloudflare security reads use the connector server-side and return only caller-owned TXT-verified domains; never expose builder-wide zone inventory or incidents. TXT verification uses an admin update only after scoped ownership and DNS proof checks because clients cannot self-assert verification.
- Aegis is advice and monitoring, not edge enforcement; do not mutate DNS/WAF/TLS automatically or imply an HTTP grade proves safety. Poll read-only status every minute only while visible; non-security requests require consent before opening Echo.
- Aegis voice reuses the direct Gemini transport with a separate authenticated security-only token and tools; scans require domain-specific on-screen approval and Echo handoffs end the call only after approval. Never save Aegis calls as Echo history or give Aegis build/deploy tools, to preserve assistant and permission boundaries.
- Cloud voice uses a cloud-only authenticated token; its tools only read caller-owned saved projects or request on-screen publishing approval, to prevent spoken requests from publishing or replacing a site automatically. Cloud lists group the caller's latest 200 saved builds by session and preserve previous published versions; recorded URLs never imply uptime. Publishing reuses Echo's existing workflow, not new hosting infrastructure for Codesynux itself.
- Voice project commands (list_projects/open_project) live in the shared useGeminiLive hook so Echo and Nova both get them; matching rules are in src/lib/project-match.ts, scoped to the caller's own builds.
- Custom domains: connectCustomDomain (codehub.functions.ts) attaches a domain to the caller's own Pages project and auto-adds a CNAME only when the zone is in the same Cloudflare account; Echo voice uses the connect_domain tool for the current session.
