# itabot config-server

Serves itabot's remote-managed agent config (provider/model/API key/URL/context
tuning) to every install, backed by Postgres. Every install only ever reads
`GET /config` — nothing on a client machine ever touches Postgres directly.

## Setup

1. `createdb itabot_config` (or point `DATABASE_URL` at an existing database).
2. `psql $DATABASE_URL -f schema.sql`
3. `cp .env.example .env` and fill in `DATABASE_URL` / `CONFIG_API_TOKEN`.
4. `npm install`
5. `npm start`

## Changing the config clients receive

1. `cp config.example.json config.local.json` (first time only — this file is
   gitignored, it holds the real API key).
2. Edit `config.local.json` with the values you want live.
3. `npm run set-config` — bumps the version so every install picks it up
   within 30 minutes (or immediately if someone clicks "Actualizar" in the
   desktop Settings screen).

## itabot client configuration

Point installs at this server via env vars on the machine running the itabot
gateway (defaults are hardcoded in `itabot/config/remote.py` for production
use, these are for testing against a staging server):

```
ITABOT_CONFIG_URL=https://your-host/config
ITABOT_CONFIG_TOKEN=same value as CONFIG_API_TOKEN above
```
