# Server configuration

## State directory: `~/.openprogram/`

| Path | Contents |
| --- | --- |
| `config.json` | Ports, last model, providers, disabled tools. [Configuration reference](https://fzkuji.github.io/OpenProgram/docs/reference/config.html) |
| `projects/<id>/chats/`, `projects/<id>/memory/` | Conversations and memory. `projects/default/` is the home project |
| `agents/`, `agents.json` | Agent definitions (persona, model, skills) |
| `auth/` | Provider credential store |
| `skills/`, `plugins/`, `mcp_servers.json` | Installed skills and plugins, MCP servers |
| `channels/` | Chat channel state (Telegram, Discord, WeChat and others) |
| `browser-states/`, `chrome-profile/` | Left by earlier versions; nothing reads them now and they can be deleted |
| `worktrees/`, `shadow-git/` | Git worktree state |
| `logs/`, `worker.log`, `worker.pid`, `worker.port`, `worker.lock` | Logs and worker runtime files |
| `models/`, `cache/`, `tool_results/`, `usage.db` | Model catalog cache, general cache, tool results, usage database |

## `openprogram config`

| Command | Effect |
| --- | --- |
| `openprogram config list` | Every setting: value, group, when it applies |
| `openprogram config get <key>` | One setting |
| `openprogram config set <key> <value>` | Change one |
| `openprogram ports`, `openprogram ports --port 8101` | View or persist the port |

| Key | Meaning | Default | Applies |
| --- | --- | --- | --- |
| `ui.web_port` | The single worker port | Unset: 18100, or the next free port, chosen at the first start | next start |
| `ui.open_browser` | `openprogram web` opens a browser | true | next start |
| `search.default_provider` | Web search provider; `auto` picks the highest-priority configured | auto | live |
| `memory.backend` | `local`, or `none`: no prompt memory, recall, automatic writes, organizer or memory threads | local | next start |
| `memory.writer.model` | `provider/model` for background writing; empty follows the default chat agent | empty | live |
| `tools.disabled.<name>` | Per-tool switch | all enabled | live |
| `execution.prevent_idle_sleep` | Keep the system awake during agent execution; Linux needs `systemd-inhibit` | false | live |

`config list` also shows read-only `providers.<name>` rows; use `openprogram providers login` or the Providers page.

**How idle-sleep prevention behaves**

- Each execution reads the setting when its agent loop starts and holds a native power assertion until the loop finishes, fails or is cancelled, approval waits included. Running executions ignore a change.
- Display sleep and explicit sleep still work; no permanent power setting changes.
- Unsupported platforms or assertion failures log a warning and continue.
- Independent background services and commands after the loop are not covered.

## Who can reach the server

| Layer | Rule |
| --- | --- |
| Bind address `web.host` | Default `127.0.0.1`, this machine only. `0.0.0.0` exposes the authenticated UI to other interfaces and needs at least one `web.allowed_origins` entry. On an untrusted network prefer HTTPS through a same-host reverse proxy |
| Sign-in | Every API and WebSocket request needs the owner cookie, set by a sign-in link, a paired device's credential (`openprogram web pair`), or a bearer token. Otherwise 401. Public: `/healthz`, page shells, `/docs`, and Scheduler webhooks under `/hooks/`, guarded by the task's own key |
| Host | Must name an effective origin: loopback when bound to loopback, plus `web.allowed_origins`. Otherwise 403 |
| `Sec-Fetch-Site` | `cross-site` gets 403 |
| `Origin`, when present | Must match the request's own origin. Otherwise 403 |

The last three stop a page you visit from opening a WebSocket to `127.0.0.1` and driving the agent, or re-resolving its own name to loopback. Stored API keys cannot be read back: the old reveal route answers 410.

```
openprogram config set web.allowed_origins '["https://agent.example.com"]'   # your own reverse proxy; next start
```

## Network proxy

| Destination | Route |
| --- | --- |
| `web_fetch`, image and attachment downloads, built-in search (DuckDuckGo included), update checks and other fixed public services, providers in the audited inventory | Ordinary proxy |
| Custom origins: configured provider base URL, SearXNG, skills or plugin catalogs | Direct with address checks, or an explicit enforcing policy proxy |
| CLI providers | The external CLI's own routing; it inherits the worker environment |
| Loopback hosts | Never proxied |

| Precedence | Ordinary proxy source |
| --- | --- |
| 1 | `security.outbound_url.policy_proxy`, requires an owner assertion that it enforces target policy |
| 2 | `OPENPROGRAM_PROXY_URL`: `http://`, `https://`, `socks5://` |
| 3 | `http_proxy`, `https_proxy`, `all_proxy` and uppercase forms, by HTTPX's rules; macOS and Windows system proxy where applicable |

`NO_PROXY` bypasses still apply, with the full address check. `openprogram rescue` reports the resolved proxy and a missing SOCKS package.

**What the proxy path checks**

- The client validates the target first and checks the proxy socket address. TLS still verifies the service hostname. Proxy authentication stays on the proxy connection. A failed proxy request does not fall back to direct.
- Through a proxy, the proxy resolves the hostname. That is what makes fake-IP proxies such as Clash work: their local answers come from `198.18.0.0/15`, which a direct connection refuses as `NON_GLOBAL_ADDRESS`.
- Still refused: private, loopback and metadata IPs; local names (`localhost`, single-label hosts, `.local`, `.lan`, `.internal` and similar); hostnames whose local DNS answer is a real private address.
- For a guarantee that the final resolution is checked too, configure an enforcing policy proxy.

## What the agent's tools can reach

| Setting | Effect |
| --- | --- |
| `security.outbound_url.model_tools` | `open` (default): in your own turns `web_fetch` and image downloads reach any address, port and HTTP method. `strict`: applies the address checks. Other people's turns and the server's own calls are always strict |
| `computer_use.refused_apps` | JSON list of app names or bundle ids `computer_use` will not touch. Empty by default |
| `computer_use.refuse_password_fields` | Stops it typing into password fields. Off by default |
| `sandbox.mode` | Used by a scheduled task with no conversation; otherwise its conversation's Sandbox setting when it fires |
| `sandbox.deny_write` | With the startup, Git and state paths in [permissions](https://fzkuji.github.io/OpenProgram/docs/capabilities/permissions.html), the only paths the sandbox restricts |

## Multiple instances

`--profile <name>` or `OPENPROGRAM_PROFILE` moves config, sessions and logs to `~/.openprogram-<name>/`. Add a different `OPENPROGRAM_WEB_PORT` to run several at once.

```
openprogram --profile dev
OPENPROGRAM_PROFILE=dev openprogram status
```

[Profiles](https://fzkuji.github.io/OpenProgram/docs/install/profiles.html)
