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:

ModeWhenConfig fileData paths
InstalledAGDESK_HOME is set (the agdesk CLI sets it before forking the daemon)$AGDESK_HOME/config.jsonSubdirectories of $AGDESK_HOME
DevAGDESK_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:

  1. Config file (config.json / agent-desk.json) — user-editable
  2. Environment variable — for CI/container overrides
  3. 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

KeyTypeDefaultDescription
hoststring"0.0.0.0"Bind address. 0.0.0.0 listens on all interfaces.
portnumber3737HTTP/WebSocket port.
allowedHostsstring[][]Extra hostnames/URLs accepted by the request-origin validator (reverse proxies, custom domains). Merged with AGDESK_ALLOWED_HOSTS env.

paths

KeyTypeDefaultDescription
projectsDirstring$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.

KeyTypeDefaultDescription
tickActiveMsnumber15000Tick interval when work was dispatched on the last tick.
tickCoolingMsnumber45000Tick interval when work was found recently but not this tick.
tickIdleMsnumber90000Tick interval when no work has been found for multiple ticks.
perTurnHardTimeoutMsnumber600000Maximum wall-clock time for a single agent turn (10 minutes).
postRunCooldownMsnumber60000Cooldown before an agent becomes eligible again after a turn.

websocket

KeyTypeDefaultDescription
keepAlivePingMsnumber30000Interval 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)

VariableDescription
AGDESK_SECRET_KEY32-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_TOKENShared 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

VariableDefaultDescription
AGDESK_HOST0.0.0.0Bind address. Overridden by server.host in config.json.
AGDESK_PORT3737Listen port. Overridden by server.port in config.json.
AGDESK_URLComputed from host+portFull 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_SECUREfalseSet to true when behind an HTTPS reverse proxy to mark session cookies as Secure.
AGDESK_GATEWAY_FALLBACK_IP127.0.0.1Fallback IP for the OpenClaw gateway when Tailscale is unavailable.

Paths

VariableDefaultDescription
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 ./projectsOverride the project files root.
AGDESK_DATA_DIR$AGDESK_HOME or ./dataOverride the data directory (avatars, runtime blobs).
DATABASE_PATH$AGDESK_HOME/data.db or ./data/agent-desk.dbOverride the SQLite database file path.

Platform

VariableDefaultDescription
AGDESK_PLATFORMclaude-codeWhich 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.

VariableDescription
AGDESK_BOOTSTRAP_PRESET_KEYProvider preset: anthropic-subscription, anthropic-api-key, z-ai, openrouter, minimax, openai, custom.
AGDESK_BOOTSTRAP_CREDENTIALThe API key or OAuth token for the bootstrap provider.
AGDESK_BOOTSTRAP_BASE_URLRequired only for the custom preset.
AGDESK_BOOTSTRAP_DEFAULT_MODELOptional 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:

  1. $AGDESK_HOME if set (installed mode)
  2. 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.