# Everyday running

## Everyday checks

| Check | Where |
|---|---|
| The server is up | `curl -s https://lumate.yourcompany.com/health` → `{"status":"ok"}` |
| The runner is online | Settings → Runners (green); the sidebar shows a banner when no runner checked in for a minute |
| WhatsApp is connected | Settings → WhatsApp |
| The agents' browser is online (the server's, or the office PC's) | Settings → Browser |
| Failed runs | Inbox → Problems; Dashboard → failures |
| What happened | Activity (everything people and agents did) |

## Logs

- **The server edition:** `sudo lumate logs server` (or `runner`, `whatsapp`, `caddy`, `browser`, `updater`). `sudo lumate
  support-bundle` gathers versions, settings without secrets and log lines for OXS support, never data.
- **Lumate Local:** the logs folder, see [Lumate Local](/docs/install-windows#logs).

| Service | What its log holds |
|---|---|
| `server` | API, scheduler, phone webhooks, browser relay |
| `runner` | Claimed runs, Claude Code output summaries |
| `whatsapp` | Connection state; never message texts or full numbers |
| `browser` | Displays started and stopped, refusals (memory, no sandbox), and the memory limit it sized itself to; never the pages visited or what was typed |


An agent's full run, with every tool call and result, is on the agent's **Runs** tab, or from the run pill in a thread.

Each service keeps at most 30 MB of log (three files of 10 MB; the oldest goes first), so logs never fill the disk.
The server logs what happens, not every request: the runner's and the open pages' frequent checks leave no lines.

**Memory.** The server edition bounds each service: the server 2 GB, the runner 2 GB, WhatsApp 512 MB, Caddy 256 MB and
the updater 512 MB, so one runaway process cannot take the machine. With more than two runs at once (`RUNNER_SLOTS`),
give the runner more (`RUNNER_MEMORY=4g`; `SERVER_MEMORY` for the server) in `/opt/lumate/.env`, then
`sudo docker compose --project-directory /opt/lumate -f /opt/lumate/compose.yml up -d runner`.

**The server browsers' memory.** All the server browsers (a screen and a Chromium each) live in one `browser` container, bound
to `BROWSER_MEMORY` (3 GB) with `BROWSER_SHM` (1 GB) of shared memory; set them in `/opt/lumate/.env` and run
`sudo docker compose --project-directory /opt/lumate -f /opt/lumate/compose.yml up -d browser`. A display is counted at about
250 MB after 600 MB for the agent and headroom, so the number of browsers at once is `(BROWSER_MEMORY - 600 MB) / 250 MB`, at
most 40: 9 at 3 GB, 22 at 6 GB (`BROWSER_MAX_DISPLAYS` sets it by hand). Before it starts one the agent also looks at what is
really left inside the container and refuses while less than `BROWSER_MIN_AVAILABLE_MB` (600) is free: Lumate then says the
browsers are all in use, instead of Linux killing a running one for lack of memory. `lumate logs browser` names the refusals.

## Backups

**The server edition** backs itself up: every day, before every update and when asked (Settings → Backups, or
`lumate backup`), with a copy to a bucket if you want one, and `lumate restore` puts a backup back. See
[The server edition](/docs/install-server#backups). A backup needs as much free disk space as the data, plus 512 MB: with
less, it is refused before anything is written (and an update waits, changing nothing), so a backup never fills the
disk. A backup holds the saved logins of the server browsers, sealed with `SECRETS_KEY`: without that key in `/opt/lumate/.env` they
cannot be read, so keep it. It holds no browser profile and not the WhatsApp browser's profile. **Lumate Local** keeps daily backups by itself, see [Lumate Local](/docs/install-windows#updates-and-backups).

## Updating

**The server edition** updates itself from its channel (Settings → Updates: automatic installs in the maintenance
window, or Update now), backs up first and goes back by itself when the new version does not start. From the shell:
`lumate update`, `lumate update --bundle <offline bundle>`, `lumate rollback`. See
[The server edition](/docs/install-server#updates). **Lumate Local** updates itself too, see
[Lumate Local](/docs/install-windows#updates-and-backups).

The update that brings the server browser may come after one that prepares the server. Install both, in order; the server does the rest.

## Troubleshooting

### Sign-in and setup

| Symptom | Cause and fix |
|---|---|
| "Too many attempts" | 5 tries a minute per address. Wait a minute. Behind a proxy, set `TRUSTED_PROXIES`, or everyone shares one limit. |
| Signed out right after login | `COOKIE_SECURE=true` over plain HTTP. Use HTTPS, or `false` only for local trials. |
| Lost the setup token | The server edition: `sudo grep SETUP_TOKEN /opt/lumate/.env` |
| Forgot a password | **Forgot password?** on the sign-in page, once [email](/docs/email) is set up; otherwise the [command line](/docs/operations#command-line) |

### Licence

| Symptom | Cause and fix |
|---|---|
| "Lumate is not activated yet" | A fresh install: the person who set it up activates it in Settings → Licence (or the setup's Activate step). See [Licensing](/docs/licensing). |
| "The 30 days to activate Lumate have ended" | An install from before licensing that was not activated in time: activate it; nothing was lost. |
| "Lumate's licence has ended" | The subscription stopped, or no check-in reached OXS Cloud for 14 days. Renew in the portal, then **Check again** on the lock page. Export all data works meanwhile. |
| "This computer's clock is behind" | Set the right date and time; the next check-in (within 5 minutes) unlocks Lumate. |
| "Lumate could not reach OXS Cloud for N days" | The server cannot reach OXS Cloud over HTTPS (firewall, proxy, TLS inspection). The licence keeps working until its last day; fix the connection, then Settings → Licence → Check now. |
| "This install's licence is in use on another machine" | A copy of this install (a restored database) runs elsewhere. Deactivate the one you do not want; activate this one with a free slot. |

### Agents

| Symptom | Cause and fix |
|---|---|
| Agents never answer; "No runner online" | Settings → Runners shows whether the runner is online and its Claude Code signed in. The server edition: `sudo lumate status` and `sudo lumate logs runner`. |
| A run failed with a Claude login error | The Claude sign-in expired or was revoked. Sign in again: `sudo lumate claude-login` on the server edition, a new key or token in Settings → Runners, or Settings → General → Claude on Lumate Local. |
| A run failed with a usage limit | The company's Claude plan hit its limit. Wait for the reset, or raise the plan. |
| An agent stays "Working…" | The run's lease expires within 2 minutes and the run is queued again. If it repeats, check the runner log. |
| An agent ignores a file | Files over 25 MB, or of an unsupported type, are refused at upload. Office files are read through their extracted text. |

### Voice and phone

| Symptom | Cause and fix |
|---|---|
| The microphone does nothing | The browser needs HTTPS and microphone permission. Check that `OPENAI_API_KEY` is saved. |
| Inbound calls are not answered | Check the webhook URL in OpenAI, `OPENAI_WEBHOOK_SECRET`, that the server's public address is reachable over HTTPS, and that the number is added with an agent. |
| "Outbound calling is off" | An admin enables it in Settings → Phone with the trunk. |
| A call is refused by the gate | The reason says which rule applies: calling hours, do-not-call, consent, attempt limits. |
| One-way or no audio through Asterisk | RTP ports and `external_media_address`, see [Phone and Asterisk](/docs/phone#checking-it) |

### WhatsApp

| Symptom | Cause and fix |
|---|---|
| "WhatsApp is not running on this server" | The server edition: `sudo lumate status` shows the `whatsapp` service; `sudo lumate logs whatsapp` says why it stopped. |
| Logged out | The phone removed the linked device, or it was offline for about two weeks. Link again. |
| Replaced | The number was linked from another place. Link again here, only once. |
| A message shows "waiting (limit)" | The pace limits hold it. It goes out by itself. |
| A WhatsApp Web call connects but nobody hears anything | Read the call's lines in `sudo lumate logs server` (`WhatsApp call N diag: …`), see [Office browser → Calls through WhatsApp Web](/docs/office-browser#calls-through-whatsapp-web). If the person sees a "silenced unknown caller", it is their WhatsApp's **Silence unknown callers** setting: they save the number or turn it off. |

### Office browser

| Symptom | Cause and fix |
|---|---|
| "This package was already used or is older than 30 minutes" | Download a new package |
| Offline | The PC sleeps, Chrome is closed, or the extension was removed. Keep Chrome open; the extension reconnects by itself. |
| Switches between Online and Offline while nobody uses the PC | Chrome puts an idle extension to sleep. The extension wakes every 30 seconds and reconnects; a command sent in that moment fails and the agent tries again. Turn off the PC's sleep. If it stays offline for about 30 seconds of every minute, it is an older extension that woke only once a minute: download it again from Settings → Browser. |
| "This site is read-only for agents" | The site is not on the allowed list. Add it in Settings → Browser if agents should work there. |
| "Slow down: this site's page limit was reached" | 12 page loads a minute per site. The agent waits and continues. |
| The agent cannot log in to a site | By design: a person signs in once in that Chrome profile. |

### Server browsers

| Symptom | Cause and fix |
|---|---|
| Settings → Browser says the server browser is offline or starting | The `browser` container takes up to a minute after a start, then pairs by itself. `sudo lumate status`; `sudo lumate logs browser`. |
| The live view says all the browsers are in use | The container's memory is spent or too little is free: give it more (`BROWSER_MEMORY`, above) or wait for a job to end. |
| No browser starts on Ubuntu 24.04, the log says `no_sandbox` | Lumate's AppArmor profile is not in use: `sudo lumate apparmor` (below). |
| The screen stays black or does not connect | Reload with **Reconnect**. Behind another proxy, it must pass websocket upgrades for `/browser-view/`. Port 8000 must stay on `127.0.0.1`, with Caddy the only way in. |
| A person cannot take control | Someone else holds it (the page says who; an admin can take over), or the person lost their role. Control ends by itself 10 minutes after the holder's page goes quiet. |
| The server log says "browser N runs build X, expected Y (a stale extension worker)" | The browser still runs an older extension than the server ships (an old background worker, or no build reported: "unknown"). It is reset on the browser's next start after an update; `sudo lumate logs server` shows `browser N connected: build …` for each. If the warning comes back after the next update, send `sudo lumate support-bundle` to OXS. |
| A saved login does nothing | It has expired (30 days) or was revoked; add it again in Settings → Saved logins. A personal login is used only for a task its owner made and alone wrote in. |
| A portal refuses the server's browser | Some portals refuse data-centre addresses. Use **Import from my own Chrome**, or the office PC for that portal. |

### Live view of the server browsers

The live view reaches a browser's screen only through Caddy (`/browser-view/<display>/t/<ticket>/…`), after Lumate checks a signed ticket on every request. Port 8000 (Lumate) must stay on `127.0.0.1`: Caddy's check at `/api/browser/view/authorize` trusts the address Caddy forwards to it and hands back the screen's VNC login, so it is answered 404 to everyone outside and must never be reachable from a network. A ticket lasts 10 minutes and ends sooner with a password change, a sign-out, or a change of the person's role. Caddy passes only the screen's page, its files and its websocket to the screen; the rest of the screen server's own web API (users, screenshots, downloads) answers 404.

**Several companies on one server.** Until every browser runs as a user of its own, the browsers of all the companies on one
server share one trust domain: they run in the same container as the same system user, so a page open in one company's
browser could in principle reach another company's browser through the machine. That is fine for one company (the people
who can watch or drive the browsers already work together), but it is not a wall between companies. **For now, run one company
per server** when the companies must not see each other's browsers; the live view's tickets and the agent's logins still
keep other people out, and nothing in this paragraph affects the database or the files, which stay apart per company.

**Meeting audio widens the same exposure (A7).** A meeting display's PulseAudio listens on a socket in `/tmp/lumate-pulse/<display number>/`
(a `0700` folder, anonymous access). Every browser in the container runs as the same user, so the folder's mode and the anonymous login stop nobody
*inside* the container, and the display number (1 to 40) is easy to guess. What is new is what sits behind that door: the meeting's sound
(`meeting_out.monitor`) and a way to speak into the meeting (`meeting_mic_in`). A compromised browser process of **another** display (another
company's shared or WhatsApp browser, a personal browser) could connect to that socket, record the meeting, or speak in it. Renderers are sandboxed,
so this takes a compromise of a browser process, the same bar as reaching another display's profile in `/dev/shm/profiles` (the paragraph above);
it is a bigger prize behind the same door, not a new door. What is in place: only a meeting display created with audio has a PulseAudio or any
`PULSE_SERVER`; every other Chromium resolves to a dead default server (`autospawn = no`) and cannot find one by accident; PulseAudio cannot load
modules, uses no shared memory, no capability and no new privileges. What is not possible inside one user: stopping a deliberate connection. A
separate user for PulseAudio would, at the price of a Dockerfile and entrypoint change. **For now: do not run meetings that matter to one company
on a server whose other browsers visit pages you do not trust**, and keep to one company per server as above. The meeting's Chromium also
grants the microphone to any page it opens without a question (`--use-fake-ui-for-media-stream`); the microphone carries only Lumate's own voice,
and the display has no camera.

**The browser's sandbox on Ubuntu 24.04.** Ubuntu 24.04 stops a container from making the user namespace Chromium's sandbox
needs, unless its AppArmor profile allows it. A new install loads Lumate's profile by itself. A server that was installed before this
version, or updated from Settings → Updates (the updater has no access to the host), says **"apparmor profile pending: run
'sudo lumate apparmor'"** in `lumate status` and in the update's result (also when the profile in use belongs to an older
version): run `sudo lumate apparmor` (it asks first: the server browsers restart and open sessions on them end; `--yes` skips
the question). `sudo lumate update` tries to load the new version's profile while the update runs and, when the update is over,
says whether the running browser really uses it; if the update started the browser before the profile was loaded it says so and
asks you to run `sudo lumate apparmor`. Until a profile is in use, the browser container answers `no_sandbox` and starts no
browser on Ubuntu 24.04 (its log says why).

### Meeting browsers and their audio (for the Meet work)

A server browser of kind `meeting` made with `audio` gets its own sound: PulseAudio runs inside the `browser` container for that display
only, with one virtual **speaker** (what Chromium plays: the other people in the meeting) and one virtual **microphone** (what Chromium
records: Lumate's voice). No other display has audio: a request for audio on a shared, personal or WhatsApp display is answered without
it, and their Chromium gets no PulseAudio to find. The container keeps its confinement (no added capability, the same seccomp and
AppArmor profiles); it needs no extra port, the sound travels over the agent's own port (7800) on the Docker network.

**From Lumate's server** (`server/app/services/server_browser.py`, `services/meeting_audio.py`):

```python
agent = agent_client(settings)                          # AgentClient; None when the install has no server browsers
display = await agent.open_display(login_id=7)          # kind="meeting", audio=True; key "m-<random>" unless key= is given
try:
    async for frame in display.audio:                   # the meeting's sound: bytes, always 960 long (20 ms)
        ...                                             # e.g. voice_session.append_audio(frame), as bridge_line does with its frames
    await display.audio.play(pcm)                       # Lumate's voice, paced at speech speed; False when a flush ended it
    await display.audio.flush()                         # stop talking now (drops what the agent still holds)
finally:
    await agent.close_display(display)                  # audio socket, Chromium, PulseAudio and the profile; safe to call twice
```

- `open_display` raises `ServerBrowserError` (`error == "busy"`, 409: three personal and meeting browsers at once, or no memory left;
  `"conflict"`: the key is a display of another kind) or `MeetingAudioError` (the audio socket failed; a display this call made is stopped
  again). A browser that was not paired or logged in is the caller's: `login_id` only rides on the returned handle, because loading a saved
  login goes through the display's paired extension (`browser_logins.load_into`) and needs the database.
- The stream ends (`async for` stops, `display.audio.closed` is true, `send`/`play` raise `MeetingAudioClosed`) when the display is
  deleted, the agent restarts, or PulseAudio dies (the agent starts it and the browser again; open a new socket).
- On the client side `MeetingAudio` reads the socket continuously into a backlog of at most 500 ms and drops the oldest when the consumer is
  slower (`dropped_frames`, `agent_dropped`): a consumer that lags hears the meeting a fraction of a second late, never seconds. `send` refuses
  an odd number of bytes (`ValueError`).
- Always close the display in a `finally`. If the code that opened it dies instead, the display still goes: `open_display(run_id=…)` ties it to
  a run (`server_browser.run_ended` closes it when the run ends), the reconcile sweep (`sweep_meetings`, every half minute) closes a meeting
  display of this process that has no open audio socket and was not used for 10 minutes, and **the agent itself stops a meeting display with no
  audio socket that nobody asked for in `BROWSER_MEETING_IDLE_MINUTES` (default 10; 0 = never)** — asked for means created again, restarted,
  kicked, or an audio socket opened or closed; an open socket keeps it for as long as it is open. Without this, a crashed server would hold one
  of the three personal/meeting places, and its PulseAudio and memory, until the container restarts. The sweep never forgets or closes a
  handle opened after the agent's list it works from was taken (`since`) or less than 2 minutes ago (`MEETING_GRACE`), and the agent's expiry
  stops a persistent meeting display without wiping its profile (only `delete` with `wipe=true` does).
- **What the lifetime means for the Meet work** (consequences of the rule above, not bugs): (a) a meeting display made with `audio=False` can
  never hold a socket, so the agent stops it 10 minutes after the last ask and the server sweep closes its handle 10 minutes after it was
  opened, whatever happens: keep asking (create again) for as long as it is needed. (b) An open socket counts as use for ever: a handle whose
  own process forgot it, with the socket still open and no `run_id`, is never swept: tie it to a run or close it in a `finally`. (c) A socket
  that opens and closes every few minutes keeps a display for ever (each open and close is an ask).

**The wire contract** (the agent's K1 addition; `GET /displays/{key}/audio`, a WebSocket, `Authorization: Bearer <agent token>`):

| | |
|---|---|
| Errors before the upgrade | 401 no/wrong token · 400 not a WebSocket request (`Upgrade` must be `websocket`, `Connection` must list `upgrade`, version 13, a 16-byte key) · 404 `no_audio` (the display has no audio) or unknown key · 409 `busy` (a socket is open already; one at a time) |
| First message (agent → server) | text, JSON: `{"type":"hello","version":1,"key":…,"format":"s16le","rate":24000,"channels":1,"frame_ms":20,"frame_bytes":960}` |
| Agent → server | binary messages of exactly 960 bytes: 16-bit little-endian signed PCM, mono, 24 000 Hz, 20 ms each, one every 20 ms **including silence** (zeros) while the socket is open |
| Freshness (agent → server) | the agent never lets the sound pile up: frames wait in a queue of about 0.2 s plus a small socket buffer (on Linux the buffer counts memory, not payload: under a second in all); when the server reads slower, **the oldest frames are dropped** and counted. The agent says so in a text message `{"type":"dropped","frames":N}` (the running total, at most once a second). A server that stops reading for 3 s is disconnected |
| Server → agent | binary messages of **an even number of bytes** (whole samples; an odd one ends the socket with close code 1003), at most 65 536 bytes, in order. Send at speech speed (a frame per 20 ms): the agent keeps the last 2 s and drops the oldest beyond that. `play()` does the pacing |
| Server → agent, text | `{"type":"flush"}` drops everything not yet played (a speaker that must stop at once); other text is ignored |
| Ends | either side closes; the agent also closes when the display is deleted or its audio fails, and drops a peer that stops reading for 3 s (the socket never waits on it, so the display's one audio place is free again at once) |

The microphone is silent until sound is sent. The agent starts the meeting's Chromium with `--use-fake-ui-for-media-stream` (the microphone
is granted without a question: nobody sits at that screen) and `--autoplay-policy=no-user-gesture-required`; the display's `URLBlocklist`
and the container's egress rules are the same as for every browser. Camera: there is none. A meeting display costs about 30 MB more than
a plain one for PulseAudio and counts against the same memory limit.

**What this adds to the browser agent's API (K1, all additive).** `POST /displays` and `GET /displays` answer with `"audio": true|false` (a meeting
display made with audio is true; `audio` asked for on any other kind is silently false); `POST /displays` also answers `"created": true|false`
(false: the key already ran, so a caller whose audio then fails does not stop a display that is not its own); asking again for a key with a
different `audio` is a 409 `conflict` (it was idempotent before; every non-meeting kind is normalised to false, so existing callers are not
affected); new `GET /displays/{key}/audio` (above) with the 404 `no_audio` answer; new setting `BROWSER_MEETING_IDLE_MINUTES` (read by the agent; the compose file does not pass it on yet, so the 10-minute default applies unless it is added to the `browser` service's environment by hand).

**Checking it.** `deploy/browser/smoke.sh` creates a meeting display, plays a 440 Hz `<audio>` tone in its Chromium and reads it as
non-silent frames on the socket (after reading silence), then sends a tone over the socket and has `getUserMedia` + an `AnalyserNode` in
the same Chromium report it (after measuring silence), and checks that deleting the display ends PulseAudio and its helpers.

## Command line

On the server edition, run these in `/opt/lumate` with `sudo`:

```bash
docker compose exec server python -m app.cli create-user <username> [--admin]
docker compose exec server python -m app.cli reset-password <username>
docker compose exec server python -m app.cli create-runner-key <company-slug> <name>
```

`reset-password` sets a new password and prints it once: sign in with it, then choose your own in Settings → Your
account. Every other session of that person ends. It is also how an address gets back to its owner when an account
was made for it by someone else: reset it, give the password to the real person, and they choose their own.
