Configuration
config.json structure, environment variables, and deployment mode differences.
AgentDesk separates non-secret settings (host, port, paths, timings) from secrets (encryption keys, auth tokens). Non-secret config lives in a JSON file; secrets live in .env.
Deployment Modes
AgentDesk operates in one of two modes, determined by the AGDESK_HOME environment variable:
| Mode | When | Config file | Data paths |
|---|---|---|---|
| Installed | AGDESK_HOME is set (the agdesk CLI sets it before forking the daemon) | $AGDESK_HOME/config.json | Subdirectories of $AGDESK_HOME |
| Dev | AGDESK_HOME is unset (running from repo via npm run dev) | ./agent-desk.json (project root) | ./data, ./projects, etc. |
The CLI never auto-falls-back to ~/.agent-desk. Installed mode activates only when AGDESK_HOME is explicitly set.
Value Resolution Order
Every setting follows the same priority chain:
- Config file (
config.json/agent-desk.json) — user-editable - Environment variable — for CI/container overrides
- Code default — depends on deployment mode
config.json Structure
{
"server": {
"host": "0.0.0.0",
"port": 3737,
"allowedHosts": ["myhost.example.com", "https://agentdesk.tailnet.ts.net"]
},
"paths": {
"projectsDir": "/data/agentdesk/projects"
},
"dispatcher": {
"tickActiveMs": 15000,
"tickCoolingMs": 45000,
"tickIdleMs": 90000,
"perTurnHardTimeoutMs": 600000,
"postRunCooldownMs": 60000
},
"websocket": {
"keepAlivePingMs": 30000
}
}
All keys are optional. Unknown top-level keys emit a warning but never crash the server. Numeric fields are validated at load time — non-finite or non-number values are discarded with a warning.
server
| Key | Type | Default | Description |
|---|---|---|---|
host | string | "0.0.0.0" | Bind address. 0.0.0.0 listens on all interfaces. |
port | number | 3737 | HTTP/WebSocket port. |
allowedHosts | string[] | [] | Extra hostnames/URLs accepted by the request-origin validator (reverse proxies, custom domains). Merged with AGDESK_ALLOWED_HOSTS env. |
paths
| Key | Type | Default | Description |
|---|---|---|---|
projectsDir | string | $AGDESK_HOME/projects (installed) or ./projects (dev) | Root directory for project files, watched by the file watcher for real-time UI updates. |
dispatcher
Controls the proactive dispatcher’s adaptive tick loop. See the Dispatcher page for behavioral details.
| Key | Type | Default | Description |
|---|---|---|---|
tickActiveMs | number | 15000 | Tick interval when work was dispatched on the last tick. |
tickCoolingMs | number | 45000 | Tick interval when work was found recently but not this tick. |
tickIdleMs | number | 90000 | Tick interval when no work has been found for multiple ticks. |
perTurnHardTimeoutMs | number | 600000 | Maximum wall-clock time for a single agent turn (10 minutes). |
postRunCooldownMs | number | 60000 | Cooldown before an agent becomes eligible again after a turn. |
websocket
| Key | Type | Default | Description |
|---|---|---|---|
keepAlivePingMs | number | 30000 | Interval between server-side WebSocket keepalive pings. Terminates dead connections behind proxies/NATs. |
platforms
An optional array of platform adapter overrides. Each entry has an id (e.g. "claude-code", "openclaw") and an optional enabled boolean. This key is consumed by the platform adapter layer (src/lib/adapters/index.ts) to control which agent-platform modules are loaded at boot time. Most single-platform installs can omit this entirely.
Environment Variables
Secrets (.env only — never in config.json)
| Variable | Description |
|---|---|
AGDESK_SECRET_KEY | 32-byte hex string used for AES-256-GCM encryption of credentials at rest. Auto-generated by agdesk setup and by the boot-time safety net in load-env.ts. See Security. |
AGDESK_INTERNAL_TOKEN | Shared secret for agent CLI auth. Used by ad-* skill scripts to authenticate API calls from localhost. Also signs HMAC provider routing headers. Auto-generated by agdesk setup. |
Server / networking
| Variable | Default | Description |
|---|---|---|
AGDESK_HOST | 0.0.0.0 | Bind address. Overridden by server.host in config.json. |
AGDESK_PORT | 3737 | Listen port. Overridden by server.port in config.json. |
AGDESK_URL | Computed from host+port | Full public URL. Set explicitly for reverse-proxy setups (e.g. https://desk.example.com). |
AGDESK_ALLOWED_HOSTS | (empty) | Comma-separated list of additional allowed hostnames. Merged with server.allowedHosts in config.json. Used to validate Origin and X-Forwarded-* headers. |
AGDESK_COOKIE_SECURE | false | Set to true when behind an HTTPS reverse proxy to mark session cookies as Secure. |
AGDESK_GATEWAY_FALLBACK_IP | 127.0.0.1 | Fallback IP for the OpenClaw gateway when Tailscale is unavailable. |
Paths
| Variable | Default | Description |
|---|---|---|
AGDESK_HOME | (unset) | Root data directory. When set, activates installed mode. The agdesk CLI sets this before launching the daemon. |
AGDESK_PROJECTS_DIR | $AGDESK_HOME/projects or ./projects | Override the project files root. |
AGDESK_DATA_DIR | $AGDESK_HOME or ./data | Override the data directory (avatars, runtime blobs). |
DATABASE_PATH | $AGDESK_HOME/data.db or ./data/agent-desk.db | Override the SQLite database file path. |
Platform
| Variable | Default | Description |
|---|---|---|
AGDESK_PLATFORM | claude-code | Which agent platform to activate. Set to openclaw for OpenClaw installs. Determines which boot modules load (dispatcher, scheduler, transcript watcher). |
NODE_ENV | (unset) | Standard Node.js env. npm run dev sets development; agdesk start sets production. Controls HMR, debug logging, and Next.js build mode. |
Bootstrap (first-boot only)
These variables are written by agdesk setup and consumed on the server’s first boot to seed the initial provider row. After seeding, they are automatically wiped from .env — the encrypted DB row is the source of truth from that point forward.
| Variable | Description |
|---|---|
AGDESK_BOOTSTRAP_PRESET_KEY | Provider preset: anthropic-subscription, anthropic-api-key, z-ai, openrouter, minimax, openai, custom. |
AGDESK_BOOTSTRAP_CREDENTIAL | The API key or OAuth token for the bootstrap provider. |
AGDESK_BOOTSTRAP_BASE_URL | Required only for the custom preset. |
AGDESK_BOOTSTRAP_DEFAULT_MODEL | Optional model slug override for the bootstrap provider. |
.env File Loading
AgentDesk uses @next/env (bundled with Next.js) to load .env files so precedence matches what API routes and the app router see at runtime. The load directory is:
$AGDESK_HOMEif set (installed mode)process.cwd()otherwise (dev mode)
The .env loader runs as the very first import in server.ts via a side-effect module (load-env.ts). This guarantees environment variables are available before any other module evaluates.
Auto-generation of AGDESK_SECRET_KEY
On boot, if AGDESK_SECRET_KEY is missing, blank, or not a valid 64-character hex string, the load-env.ts module generates a fresh 32-byte random key and persists it to .env with file mode 0600. This safety net ensures encryption always uses a strong key, even on installs that predate the key or have a corrupted value.
Example .env
# Shared secret for agent CLI auth (auto-generated by agdesk setup)
AGDESK_INTERNAL_TOKEN=your-generated-token-here
# Encryption key for credentials at rest (auto-generated)
AGDESK_SECRET_KEY=64-hex-characters-here
# Optional: set when behind HTTPS reverse proxy
# AGDESK_COOKIE_SECURE=true
# Optional: override the public URL for reverse-proxy setups
# AGDESK_URL=https://desk.example.com
Editing Configuration
To change non-secret settings, edit the config file directly and restart:
$ vim ~/.agent-desk/config.json
$ agdesk restart
For secrets, edit .env:
$ vim ~/.agent-desk/.env
$ agdesk restart
Changes to config.json and .env require a server restart to take effect. There is no hot-reload for configuration.