# Wivexx online relay — one-time setup (v1.18)

This lets you control Wivexx from **wivexx.com/ai** on any device, anywhere, while
you're logged in to **your own wivexx.com account** — exactly like the phone page, but over
the internet. Your PC stays the brain; **nothing on it is exposed to the web**. The
website drops your commands into a private Supabase table and Wivexx (on your PC)
reads them, runs them, and writes the reply back. Your PC must be on and online.

It's **off by default**. Three short steps switch it on.

---

## 1. Create the relay table in Supabase

Open your Supabase project → **SQL Editor** → paste the contents of
`Startup - Wivexx/site/supabase/setup.sql` and **Run**. (It's idempotent — re-running
the whole file is always safe; the new `ai_messages` table + admin-only security is
at the bottom.)

## 2. Put your Supabase keys in the PC `.env`

In the Assistant folder, open (or create) the file named `.env` and add:

```
SUPABASE_URL=https://YOUR-PROJECT-ref.supabase.co
SUPABASE_SERVICE_KEY=eyJ... your service_role key ...
```

- Find both in Supabase → **Project Settings → API**.
  - `SUPABASE_URL` = the **Project URL** (the bare `https://…supabase.co`).
  - `SUPABASE_SERVICE_KEY` = the **`service_role`** secret (NOT the `anon` key).
- The `service_role` key is powerful — it stays **only** in this `.env` (already
  git-ignored). Never put it on the website or share it.

## 3. Turn it on

In `wivexx_config.py` set:

```python
RELAY_ENABLED = True
```

Restart Wivexx. On boot the log/console will say
**"Wivexx online relay active — drive it from wivexx.com/ai."**

---

## Using it

Go to **wivexx.com**, log in to your account, open the account menu →
**wivexx ai →** (or visit `wivexx.com/ai` directly). Type a command or question —
it runs on your PC and the reply appears in the chat. The page is admin-only; no one
else can see or use it.

Examples: *"what's on my calendar today?"*, *"take a screenshot"*,
*"social media report"*, *"how much disk space is left?"*.

## Notes & safety

- **No inbound exposure**: the PC only makes outbound HTTPS calls to Supabase — no
  port is opened, no tunnel runs. The site never talks to your PC directly.
- **Owner-only**: the `ai_messages` table is locked by row-level security to admin
  (you). The PC uses the `service_role` key, which is why it stays on the PC only.
- **PC must be on**: if the PC is off/asleep, commands queue as "pending" and run
  when it's back online.
- **Tuning**: `RELAY_POLL_SECS` (default 2s) controls how often the PC checks for
  new commands.
- To turn it off, set `RELAY_ENABLED = False` and restart — everything else keeps
  working unchanged.
