Skip to main content

Self-Host Setup

Run the complete AgentHiFive stack on your own infrastructure. You get full control over data storage, encryption keys, and network topology.

Prerequisites

  • Node.js 24+ (via nvm)
  • pnpm 9.x (via corepack)
  • Docker 24+ (for PostgreSQL)
  • Git

Step 1: Clone the Repository

git clone https://github.com/AH5-AgentHiFive/AgentH5.git
cd AgentH5

Step 2: Install Prerequisites

The prereqs target installs nvm, Node.js 24, pnpm, and Docker if they are not already present:

make prereqs

After it completes, open a new terminal so nvm is loaded in your shell.

Step 3: Configure Environment Variables

cp .env.example .env

Open .env and set the values below. At minimum you need ENCRYPTION_KEY and BETTER_AUTH_SECRET — everything else has working defaults for local development.

Key Environment Variables

VariablePurposeDefault / How to Generate
DATABASE_URLPostgreSQL connection stringpostgresql://agenthifive:dev-password@localhost:5432/agenthifive
BETTER_AUTH_SECRETSession signing secretGenerate: openssl rand -hex 32
ENCRYPTION_KEYAES-256-GCM key (64 hex chars)Generate: openssl rand -hex 32
WEB_URLPublic-facing URL of the web apphttp://localhost:3000
WEB_JWKS_URLJWKS endpoint for JWT verification (keep internal)http://localhost:4000/.well-known/jwks.json
API_PORTFastify listen port4000
GOOGLE_CLIENT_IDGoogle OAuth app credentials (for vault connections)Optional — users can add their own via Settings
GOOGLE_CLIENT_SECRETGoogle OAuth app secretOptional
MICROSOFT_CLIENT_IDMicrosoft OAuth app credentials (for vault connections)Optional
MICROSOFT_CLIENT_SECRETMicrosoft OAuth app secretOptional
AUTH_GOOGLE_CLIENT_IDGoogle credentials for social login buttonOptional
AUTH_GOOGLE_CLIENT_SECRETGoogle secret for social login buttonOptional
AUTH_MICROSOFT_CLIENT_IDMicrosoft credentials for social login buttonOptional
AUTH_MICROSOFT_CLIENT_SECRETMicrosoft secret for social login buttonOptional
TELEGRAM_BOT_TOKENTelegram bot token (for Telegram connections)Optional
Production secrets

Never use the example values (dev-only-secret-change-in-production, 0000...) in production. Always generate cryptographically random secrets.

Step 4: Initialize

This installs dependencies, builds shared packages, starts PostgreSQL in Docker, and runs database migrations:

make init

Step 5: Start Development Servers

make dev

This starts:

Open your browser to http://localhost:3000 and create your first account.

Background mode

For headless servers or long-running sessions, use make dev-ul to run in the background. View logs with make dev-ul-logs and stop with make dev-ul-stop.

Makefile Command Reference

CommandDescription
make initFirst-time setup: install deps, build packages, start DB, migrate
make devStart web (:3000) + API (:4000) dev servers
make dev-ulStart dev servers in background (survives SSH disconnect)
make buildBuild all packages and apps
make testRun full test suite
make lintRun linter
make typecheckRun TypeScript type checks
make migratePush schema changes to the database
make migrate-generateGenerate a new migration file
make db-resetDrop and recreate the database, then re-migrate
make upStart Docker services (PostgreSQL)
make downStop Docker services
make down-hardStop Docker services and delete volumes
make dummydataSeed example agent and permission requests
make psqlOpen a PostgreSQL shell
make cleanRemove all build artifacts and node_modules

Connecting OpenClaw

Once your self-hosted instance is running, install the AgentHiFive plugin for OpenClaw:

openclaw plugins install @agenthifive/openclaw
npx @agenthifive/openclaw-setup

When prompted for the base URL, enter your self-hosted URL (e.g., https://ah5.yourcompany.com or http://localhost:8080 for local testing).

The setup will:

  1. Ask for an enrolment key (bootstrap secret) — generate one from the dashboard (Agents → your agent → Bootstrap Secret)
  2. Register an ES256 key pair with AgentHiFive
  3. Fetch your vault connections and configure the LLM provider
  4. Install the plugin and apply integration patches
  5. Verify the installation

See the Setup CLI Reference for the full list of options and advanced usage.

Verify the connection by starting the TUI:

openclaw tui

You should see:

[plugins] AgentHiFive: token refreshed (prefix: ah5t...)

Production Checklist

Before exposing your instance to the internet:

  • TLS enabled — terminate HTTPS at a reverse proxy (Nginx, Caddy, or a cloud load balancer). See the production Nginx template for a full TLS configuration with Let's Encrypt.
  • Strong secretsENCRYPTION_KEY and BETTER_AUTH_SECRET generated with openssl rand -hex 32, not dev defaults
  • Database TLSDATABASE_URL includes ?sslmode=require (or verify-full if your provider supports it)
  • Internal JWKSWEB_JWKS_URL points to an internal address (e.g., http://api:4000/.well-known/jwks.json), not exposed publicly
  • OAuth credentials configured — Google and/or Microsoft app credentials set for the providers you need
  • Firewall rules — only port 443 (HTTPS) exposed publicly; database port (5432) blocked from external access
  • Backups — PostgreSQL automated backups configured (pg_dump cron, cloud provider snapshots, or WAL archiving)
  • Monitoring — set SENTRY_DSN for error tracking, or connect your preferred observability stack

Next Steps

  • Quickstart — End-to-end walkthrough: create an agent, bind a policy, make a vault call
  • Architecture — System design, request flow, and execution models