mission-control
"Interact with Mission Control — AI agent orchestration dashboard. Use when registering agents, managing tasks, syncing skills, or querying agent/task status via MC APIs."
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Check it deeper on your machine
It has changed since its scan on 11 Nov 2026. Its scripts were only partly scanned.
As a Claude Code plugin, install it and then ask Claude Code:
/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/builderz-labs/mission-control with scanskillsafety
Or from a terminal, clone it and run it:
git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/builderz-labs/mission-control'
It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.
Badge for your README
Markdown
[](/listings/builderz-labs-mission-control)HTML
<a href="/listings/builderz-labs-mission-control"><img src="/api/listings/builderz-labs-mission-control/badge.svg" alt="findsafeskills safety rating" /></a>Install
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
SKILL.md · Manifest · 277 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- ---
- name: mission-control
- description: "Interact with Mission Control — AI agent orchestration dashboard. Use when registering agents, managing tasks, syncing skills, or querying agent/task status via MC APIs."
- ---
- # Mission Control Agent Skill
- Mission Control (MC) is an AI agent orchestration dashboard with real-time SSE/WebSocket, a skill registry, framework adapters, and RBAC. This skill teaches agents how to interact with MC APIs programmatically.
- ## Quick Start
- **Base URL:** `http://localhost:3000` (default Next.js dev) or your deployed host.
- **Auth header:** `x-api-key: <your-api-key>`
- **Register + heartbeat in two calls:**
- ```bash
- # 1. Register
- curl -X POST http://localhost:3000/api/adapters \
- -H "Content-Type: application/json" \
- -H "x-api-key: $MC_API_KEY" \
- -d '{
- "framework": "generic",
- "action": "register",
- "payload": { "agentId": "my-agent-01", "name": "My Agent" }
- }'
- # 2. Heartbeat (repeat every 5 minutes)
- curl -X POST http://localhost:3000/api/adapters \
- -H "Content-Type: application/json" \
- -H "x-api-key: $MC_API_KEY" \
- -d '{
- "framework": "generic",
- "action": "heartbeat",
- "payload": { "agentId": "my-agent-01", "status": "online" }
- }'
- ```
- ## Authentication
- MC supports two auth methods:
- | Method | Header | Use Case |
- |--------|--------|----------|
- | API Key | `x-api-key: <key>` or `Authorization: Bearer <key>` | Agents, scripts, CI/CD |
- | Session cookie | `Cookie: __Host-mc-session=<token>` (HTTPS) or `mc-session=<token>` (HTTP) | Browser UI |
- **Roles (hierarchical):** `viewer` < `operator` < `admin`
- - **viewer** — Read-only access (GET endpoints)
- - **operator** — Create/update agents, tasks, skills, use adapters
- - **admin** — Full access including user management
- API key auth grants `admin` role by default. The key is set via `API_KEY` env var or the `security.api_key` DB setting.
- Agents can identify themselves with the optional `X-Agent-Name` header for attribution in audit logs.
- ## Agent Lifecycle
- ```
- register → heartbeat (5m interval) → fetch assignments → report task status → disconnect
- ```
- All lifecycle actions go through the adapter protocol (`POST /api/adapters`).
- ### 1. Register
- ```json
- {
- "framework": "generic",
- "action": "register",
- "payload": {
- "agentId": "my-agent-01",
- "name": "My Agent",
- "metadata": { "version": "1.0", "capabilities": ["code", "review"] }
- }
- }
- ```
- ### 2. Heartbeat
- Send every ~5 minutes to stay marked as online.
- ```json
- {
- "framework": "generic",
- "action": "heartbeat",
- "payload": {
- "agentId": "my-agent-01",
- "status": "online",
- "metrics": { "tasks_completed": 5, "uptime_seconds": 3600 }
- }
- }
- ```
- ### 3. Fetch Assignments
- Returns up to 5 pending tasks sorted by priority (critical → low), then due date.
- ```json
- {
- "framework": "generic",
- "action": "assignments",
- "payload": { "agentId": "my-agent-01" }
- }
- ```
- **Response:**
- ```json
- {
- "assignments": [
- { "taskId": "42", "description": "Fix login bug\nUsers cannot log in with SSO", "priority": 1 }
- ],
- "framework": "generic"
- }
- ```
- ### 4. Report Task Progress
- ```json
- {
- "framework": "generic",
- "action": "report",
- "payload": {
- "taskId": "42",
- "agentId": "my-agent-01",
- "progress": 75,
- "status": "in_progress",
- "output": "Fixed SSO handler, running tests..."
- }
- }
- ```
- `status` values: `in_progress`, `done`, `failed`, `blocked`
- ### 5. Disconnect
- ```json
- {
- "framework": "generic",
- "action": "disconnect",
- "payload": { "agentId": "my-agent-01" }
- }
- ```
- ## Core API Reference
- ### Agents — `/api/agents`
- | Method | Min Role | Description |
- |--------|----------|-------------|
- | GET | viewer | List agents. Query: `?status=online&role=dev&limit=50&offset=0` |
- | POST | operator | Create agent. Body: `{ name, role, status?, config?, template?, session_key?, soul_content? }` |
- | PUT | operator | Update agent. Body: `{ name, status?, role?, config?, session_key?, soul_content?, last_activity? }` |
- **GET response shape:**
- ```json
- {
- "agents": [{
- "id": 1, "name": "scout", "role": "researcher", "status": "online",
- "config": {}, "taskStats": { "total": 10, "assigned": 2, "in_progress": 1, "completed": 7 }
- }],
- "total": 1, "page": 1, "limit": 50
- }
- ```
- ### Tasks — `/api/tasks`
- | Method | Min Role | Description |
- |--------|----------|-------------|
- | GET | viewer | List tasks. Query: `?status=in_progress&assigned_to=scout&priority=high&project_id=1&limit=50&offset=0` |
- | POST | operator | Create task. Body: `{ title, description?, status?, priority?, assigned_to?, project_id?, tags?, metadata?, due_date?, estimated_hours? }` |
- | PUT | operator | Bulk status update. Body: `{ tasks: [{ id, status }] }` |
- **Priority values:** `critical`, `high`, `medium`, `low`
- **Status values:** `inbox`, `assigned`, `in_progress`, `review`, `done`, `failed`, `blocked`, `cancelled`
- Note: Moving a task to `done` via PUT requires an Aegis quality review approval.
- **POST response:**
- ```json
- {
- "task": {
- "id": 42, "title": "Fix login bug", "status": "assigned",
- "priority": "high", "assigned_to": "scout", "ticket_ref": "GEN-001",
- "tags": ["bug"], "metadata": {}
- }
- }
- ```
- ### Skills — `/api/skills`
- | Method | Min Role | Description |
- |--------|----------|-------------|
- | GET | viewer | List all skills across roots |
- | GET `?mode=content&source=...&name=...` | viewer | Read a skill's SKILL.md content |
- | GET `?mode=check&source=...&name=...` | viewer | Run security check on a skill |
- | POST | operator | Create/upsert skill. Body: `{ source, name, content }` |
- | PUT | operator | Update skill content. Body: `{ source, name, content }` |
- | DELETE `?source=...&name=...` | operator | Delete a skill |
- **Skill sources:** `user-agents`, `user-codex`, `project-agents`, `project-codex`, `openclaw`
- ### Status — `/api/status`
- | Action | Min Role | Description |
- |--------|----------|-------------|
- | GET `?action=overview` | viewer | System status (uptime, memory, disk, sessions) |
- | GET `?action=dashboard` | viewer | Aggregated dashboard data with DB stats |
- | GET `?action=gateway` | viewer | Gateway process status and port check |
- | GET `?action=models` | viewer | Available AI models (catalog + local Ollama) |
- | GET `?action=health` | viewer | Health checks (gateway, disk, memory) |
- | GET `?action=capabilities` | viewer | Feature flags: gateway reachable, Claude home, subscriptions |
- ### Adapters — `/api/adapters`
- | Method | Min Role | Description |
- |--------|----------|-------------|
- | GET | viewer | List available framework adapter names |
- | POST | operator | Execute adapter action (see Agent Lifecycle above) |
- ## Framework Adapter Protocol
- All agent lifecycle operations use a single endpoint:
- ```
- POST /api/adapters
- Content-Type: application/json
- x-api-key: <key>
- {
- "framework": "<adapter-name>",
- "action": "<action>",
- "payload": { ... }
- }
- ```
- **Available frameworks:** `generic`, `openclaw`, `crewai`, `langgraph`, `autogen`, `claude-sdk`
- **Available actions:** `register`, `heartbeat`, `report`, `assignments`, `disconnect`
- All adapters implement the same `FrameworkAdapter` interface — choose the one matching your agent framework, or use `generic` as a universal fallback.
- **Payload shapes by action:**
- | Action | Required Fields | Optional Fields |
- |--------|----------------|-----------------|
- | `register` | `agentId`, `name` | `metadata` |
- | `heartbeat` | `agentId` | `status`, `metrics` |
- | `report` | `taskId`, `agentId` | `progress`, `status`, `output` |
- | `assignments` | `agentId` | — |
- | `disconnect` | `agentId` | — |
- ## Environment Variables
- | Variable | Default | Description |
- |----------|---------|-------------|
- | `API_KEY` | — | API key for agent/script authentication |
- | `OPENCLAW_GATEWAY_HOST` | `127.0.0.1` | Gateway host address |
- | `OPENCLAW_GATEWAY_PORT` | `18789` | Gateway port |
- | `OPENCLAW_STATE_DIR` | `~/.openclaw` | OpenClaw state directory |
- | `OPENCLAW_CONFIG_PATH` | `<state-dir>/openclaw.json` | Gateway config file path |
- | `MC_CLAUDE_HOME` | `~/.claude` | Claude home directory |
- ## Real-Time Events
- MC broadcasts events via SSE (`/api/events`) and WebSocket. Key event types:
- - `agent.created`, `agent.updated`, `agent.status_changed`
- - `task.created`, `task.updated`, `task.status_changed`
- Subscribe to SSE for live dashboard updates when building integrations.
README.md · README · 306 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- <div align="center">
- # Mission Control
- Self-hosted control plane for operating AI agents.
- Dispatch tasks, inspect runs, review failures, track spend, and coordinate agent runtimes
- from one local dashboard backed by SQLite.
- An open-source project by [Builderz Labs](https://builderz.dev), created and maintained by [nyk](https://nyk.dev).
- It works with OpenClaw, Claude Code, Codex, and other runtimes - it is not part of any one of them.
- [](https://github.com/builderz-labs/mission-control/actions/workflows/quality-gate.yml)
- [](https://github.com/builderz-labs/mission-control/releases)
- [](LICENSE)
- [](https://github.com/sponsors/builderz-labs)
- <img src="docs/mission-control-overview.png" alt="Mission Control overview dashboard with active sessions, live activity, fleet status per runtime, and the task pipeline" width="900">
- </div>
- > [!WARNING]
- > Mission Control is alpha software. APIs, schemas, and configuration may change between
- > releases. Read the [security guidance](#security-boundary) before exposing it to a network.
- ## Start locally
- Node.js 22 or newer and pnpm are required for a source install.
- ```bash
- git clone https://github.com/builderz-labs/mission-control.git
- cd mission-control
- bash install.sh --local
- ```
- Open `http://localhost:3000/setup`, create the first admin account, then copy the API key
- from Settings if an agent or script needs headless access.
- The manual path is useful when you already manage Node and pnpm:
- ```bash
- nvm use 22
- pnpm install
- pnpm dev
- ```
- Windows users can run `./install.ps1 -Mode local` in PowerShell.
- ### Start with Docker
- ```bash
- docker compose up
- ```
- Or run the published multi-architecture image:
- ```bash
- docker pull ghcr.io/builderz-labs/mission-control:latest
- docker run --rm -p 3000:3000 ghcr.io/builderz-labs/mission-control:latest
- ```
- Use the hardened Compose overlay for a network-accessible deployment:
- ```bash
- docker compose -f docker-compose.yml -f docker-compose.hardened.yml up -d
- ```
- The [deployment guide](docs/deployment.md) covers persistent data, TLS termination,
- gateway connectivity, and standalone builds.
- ## What Mission Control governs
- The control plane sits above agent runtimes. It does not replace their reasoning or tool
- loops. It gives operators one place to see and govern the work around those loops.
- | Area | Shipped surface |
- |---|---|
- | Tasks | Inbox, assignment, execution, review, Aegis quality gate, and completion receipts |
- | Agents | Registration, presence, sessions, runtime adapters, configuration, and workspace sync |
- | Operations | Activity stream, schedules, alerts, webhooks, logs, token use, and cost views |
- | Knowledge | Memory browser, relationship graph, skills registry, and local skill synchronization |
- | Governance | Roles, API keys, security events, trust signals, approvals, audits, and evals |
- | Interfaces | Web UI, CLI, MCP server, OpenAPI-described REST API, WebSocket, and SSE |
- The runtime is self-hosted and workspace-aware. SQLite stores local control-plane state.
- Shared workspaces can use deployment-level runtime integrations. Strict workspaces block
- those integrations until the underlying resources carry workspace ownership. A gateway is
- optional for task, project, agent, scheduler, webhook, alert, and cost work; live session
- messaging needs a connected runtime gateway.
- ## Operator field notes
- Dashboards compress a sequence into current state. When a run needs review, record the
- identity, task, tool call, approval, result, and verification evidence before changing it.
- Keep unresolved items distinct from accepted risk.
- 
- Logs show what ran. A completion receipt or inspected artifact shows what finished.
- ## Pick the right fit
- Use Mission Control when multiple agents or runtimes make it hard to answer who owns a
- task, what executed, which result passed review, or where spend and failures accumulated.
- It is probably the wrong tool when:
- - one agent on one machine already stays understandable from its native CLI;
- - you need a managed multi-tenant SaaS rather than a self-hosted control plane;
- - you want an agent framework to define planning and tool use;
- - your deployment cannot tolerate alpha schema or API changes.
- Adapters and observation surfaces cover OpenClaw, Claude Code, Codex,
- CrewAI, LangGraph, AutoGen, and Claude SDK workflows. Adapter depth varies by runtime; see
- [agent setup](docs/agent-setup.md) and [CLI integration](docs/cli-integration.md) before
- assuming feature parity.
- ## Connect an agent
- The shortest gateway-free loop uses the REST API. Export the URL and API key shown in
- Settings:
- ```bash
- export MC_URL=http://localhost:3000
- export MC_API_KEY=replace-with-your-api-key
- ```
- Register an agent and create work:
- ```bash
- curl -s -X POST "$MC_URL/api/agents/register" \
- -H "Authorization: Bearer $MC_API_KEY" \
- -H "Content-Type: application/json" \
- -d '{"name":"scout","role":"researcher"}'
- curl -s -X POST "$MC_URL/api/tasks" \
- -H "Authorization: Bearer $MC_API_KEY" \
- -H "Content-Type: application/json" \
- -d '{"title":"Review open incidents","assigned_to":"scout","priority":"medium"}'
- ```
- The agent can then claim its queue:
- ```bash
- curl -s "$MC_URL/api/tasks/queue?agent=scout" \
- -H "Authorization: Bearer $MC_API_KEY"
- ```
- Continue with the [first-agent quickstart](docs/quickstart.md) for heartbeats, task results,
- queue behavior, CLI equivalents, and MCP setup.
- ### CLI
- ```bash
- pnpm mc agents list --json
- pnpm mc tasks queue --agent scout --json
- pnpm mc events watch --types agent,task
- ```
- ### MCP server
- ```bash
- claude mcp add mission-control -- \
- env MC_URL=http://127.0.0.1:3000 MC_API_KEY=replace-with-your-api-key \
- node /absolute/path/to/mission-control/scripts/mc-mcp-server.cjs
- ```
- Use the [CLI and MCP reference](docs/cli-agent-control.md) for the current command and tool
- surface. The REST contract lives in [`openapi.json`](openapi.json). A running instance serves
- the interactive reference at `/docs` and the OpenAPI JSON at `/api/docs`.
- ## Product surfaces
- ### Tasks and quality review
- The task board tracks work through inbox, assignment, execution, review, quality review,
- and completion. Aegis review requires an approval record before a task reaches done.
- 
- ### Agents and runtimes
- Agent views combine registration state, heartbeats, sessions, configuration, local runtime
- discovery, and workspace files.
- 
- ### Memory and skills
- The memory browser and relationship graph inspect filesystem-backed memory and linked
- session knowledge. The Skills Hub discovers local skill roots and scans registry content
- before installation.
- 
- ### Schedules and activity
- Recurring task templates create dated work on a cron schedule. The activity stream combines
- agent, task, and system events for operator review.
- 
- 
- ## Documentation
- | Guide | Use it for |
- |---|---|
- | [Quickstart](docs/quickstart.md) | Register an agent and run the first task loop |
- | [Agent setup](docs/agent-setup.md) | Sources, identities, SOUL files, and heartbeats |
- | [Orchestration](docs/orchestration.md) | Dispatch, handoffs, workflows, and review gates |
- | [CLI and MCP](docs/cli-agent-control.md) | Headless commands and agent tools |
- | [CLI integration](docs/cli-integration.md) | Claude Code, Codex, and gateway-free connections |
- | [Deployment](docs/deployment.md) | Local, Docker, standalone, reverse proxy, and VPS setup |
- | [Security hardening](docs/SECURITY-HARDENING.md) | Network, container, CSP, and secret controls |
- | [Support](SUPPORT.md) | Questions, bugs, feature proposals, and security-report routing |
- | [OpenClaw compatibility](docs/openclaw-config-compatibility.md) | Config and state-directory behavior |
- | [Release process](RELEASE.md) | Versioning, tags, images, and release checks |
- ## Architecture
- ```text
- Web UI ─┐
- CLI ────┼── auth ─ dispatch ─ events ─ policy ─ receipts
- MCP ────┤ │
- REST ───┘ SQLite + agent runtimes
- ```
- | Layer | Technology |
- |---|---|
- | Application | Next.js 16 App Router, React 19, TypeScript 5 |
- | Interface | Tailwind CSS 4, Zustand, Recharts, xterm.js |
- | State | SQLite through better-sqlite3, with WAL mode |
- | Boundaries | REST/OpenAPI, MCP, CLI, WebSocket, and SSE |
- | Access | Session cookies, API keys, Google sign-in, and role checks |
- | Validation | Zod at input boundaries |
- | Verification | Vitest, Playwright, ESLint, TypeScript, build, and API parity checks |
- Runtime data defaults to `.data/`. Set `MISSION_CONTROL_DATA_DIR` to an absolute persistent
- path for standalone deployments. The complete environment contract is in
- [`.env.example`](.env.example).
- ## Security boundary
- - Keep Mission Control on a trusted network unless a TLS reverse proxy and
- `MC_ALLOWED_HOSTS` are configured.
- - Replace or securely store generated credentials before broader access.
- - Use the hardened Compose overlay for production-like container deployments.
- - Treat agent messages, skill packages, webhooks, and MCP content as untrusted input.
- - Report vulnerabilities through [SECURITY.md](SECURITY.md), not a public issue.
- Access controls and security inspection surfaces are included, but alpha status
- still applies. Read [SECURITY-HARDENING.md](docs/SECURITY-HARDENING.md) before relying on a
- network-accessible deployment.
- ## Develop
- ```bash
- pnpm install --frozen-lockfile
- pnpm lint
- pnpm typecheck
- pnpm test
- pnpm build
- pnpm test:e2e
- ```
- `pnpm quality:gate` runs the full repository gate. Useful diagnostics:
- ```bash
- bash scripts/station-doctor.sh
- bash scripts/security-audit.sh
- pnpm api:parity
- ```
- Common local failures:
- | Symptom | Check |
- |---|---|
- | Login returns an internal error after changing Node versions | Run `pnpm rebuild better-sqlite3` |
- | Docker cannot reach the gateway | Set `OPENCLAW_GATEWAY_HOST=host.docker.internal` |
- | Browser WebSocket cannot connect | Leave `NEXT_PUBLIC_GATEWAY_HOST` empty or set a browser-reachable host |
- | Password text after `#` disappears | Quote `AUTH_PASS` or use `AUTH_PASS_B64` |
- See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution scope, coding standards, and review
- expectations. Community conduct is defined in [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
- ## Project status and support
- Release notes live in [CHANGELOG.md](CHANGELOG.md). Open issues are the current roadmap;
- the project does not promise dates for unassigned work.
- - Bugs and feature proposals: [GitHub Issues](https://github.com/builderz-labs/mission-control/issues)
- - Vulnerabilities: [private reporting instructions](SECURITY.md)
- - Builderz Labs: [builderz.dev](https://builderz.dev)
- - Maintained by [Nyk](https://nyk.dev). Sponsor [Nyk](https://github.com/sponsors/0xNyk) or [Builderz Labs](https://github.com/sponsors/builderz-labs). Follow [@nykdotdev](https://x.com/nykdotdev).
- <p align="center">
- <picture>
- <source media="(prefers-color-scheme: dark)" srcset="docs/star-history-dark.svg">
- <img src="docs/star-history-light.svg" alt="Mission Control star history" width="600">
- </picture>
- </p>
- ## License
- [MIT](LICENSE) © 2026 [Builderz Labs](https://github.com/builderz-labs)
install.sh · Bundled script · 470 lines · 1 finding marked
- #!/usr/bin/env bash
- # Mission Control — One-Command Installer
- # The mothership for your OpenClaw fleet.
- #
- # Usage:
- # curl -fsSL https://raw.githubusercontent.com/builderz-labs/mission-control/main/install.sh | bash
- Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
- Line 6 on GitHub
- # # or
- # bash install.sh [--docker|--local] [--port PORT] [--data-dir DIR]
- #
- # Installs Mission Control and optionally repairs/configures OpenClaw.
- set -euo pipefail
- # ── Defaults ──────────────────────────────────────────────────────────────────
- MC_PORT="${MC_PORT:-3000}"
- MC_DATA_DIR=""
- DEPLOY_MODE=""
- SKIP_OPENCLAW=false
- REPO_URL="https://github.com/builderz-labs/mission-control.git"
- INSTALL_DIR="${MC_INSTALL_DIR:-$(pwd)/mission-control}"
- # ── Parse arguments ───────────────────────────────────────────────────────────
- while [[ $# -gt 0 ]]; do
- case "$1" in
- --docker) DEPLOY_MODE="docker"; shift ;;
- --local) DEPLOY_MODE="local"; shift ;;
- --port) MC_PORT="$2"; shift 2 ;;
- --data-dir) MC_DATA_DIR="$2"; shift 2 ;;
- --skip-openclaw) SKIP_OPENCLAW=true; shift ;;
- --dir) INSTALL_DIR="$2"; shift 2 ;;
- -h|--help)
- echo "Usage: install.sh [--docker|--local] [--port PORT] [--data-dir DIR] [--dir INSTALL_DIR] [--skip-openclaw]"
- exit 0 ;;
- *) echo "Unknown option: $1"; exit 1 ;;
- esac
- done
- # ── Helpers ───────────────────────────────────────────────────────────────────
- info() { echo -e "\033[1;34m[MC]\033[0m $*"; }
- ok() { echo -e "\033[1;32m[OK]\033[0m $*"; }
- warn() { echo -e "\033[1;33m[!!]\033[0m $*"; }
- err() { echo -e "\033[1;31m[ERR]\033[0m $*" >&2; }
- die() { err "$*"; exit 1; }
- command_exists() { command -v "$1" &>/dev/null; }
- # Escape sed replacement metacharacters (|, &, \) in a value.
- # Does not handle newlines — callers must ensure single-line input.
- sed_escape() { printf '%s' "$1" | sed 's/[|&\\]/\\&/g'; }
- # Portable in-place sed (macOS requires -i '', Linux uses -i)
- portable_sed() {
- local pattern="$1" file="$2"
- if [[ "$(uname)" == "Darwin" ]]; then
- sed -i '' "$pattern" "$file"
- else
- sed -i "$pattern" "$file"
- fi
- }
- detect_os() {
- local os arch
- os="$(uname -s)"
- arch="$(uname -m)"
- case "$os" in
- Linux) OS="linux" ;;
- Darwin) OS="darwin" ;;
- *) die "Unsupported OS: $os" ;;
- esac
- case "$arch" in
- x86_64|amd64) ARCH="x64" ;;
- aarch64|arm64) ARCH="arm64" ;;
- *) die "Unsupported architecture: $arch" ;;
- esac
- ok "Detected $OS/$ARCH"
- }
- check_prerequisites() {
- local has_docker=false has_node=false
- if command_exists docker && docker info &>/dev/null 2>&1; then
- has_docker=true
- ok "Docker available ($(docker --version | head -1))"
- fi
- if command_exists node; then
- local node_major
- node_major=$(node -v | sed 's/v//' | cut -d. -f1)
- if [[ "$node_major" -ge 20 ]]; then
- has_node=true
- ok "Node.js $(node -v) available"
- else
- warn "Node.js $(node -v) found but v20+ required"
- fi
- fi
- if ! $has_docker && ! $has_node; then
- die "Either Docker or Node.js 20+ is required. Install one and retry."
- fi
- # Auto-select deploy mode if not specified
- if [[ -z "$DEPLOY_MODE" ]]; then
- if $has_docker; then
- DEPLOY_MODE="docker"
- info "Auto-selected Docker deployment (use --local to override)"
- else
- DEPLOY_MODE="local"
- info "Auto-selected local deployment (Docker not available)"
- fi
- fi
- # Validate chosen mode
- if [[ "$DEPLOY_MODE" == "docker" ]] && ! $has_docker; then
- die "Docker deployment requested but Docker is not available"
- fi
- if [[ "$DEPLOY_MODE" == "local" ]] && ! $has_node; then
- die "Local deployment requested but Node.js 20+ is not available"
- fi
- if [[ "$DEPLOY_MODE" == "local" ]] && ! command_exists pnpm; then
- info "Installing pnpm via corepack..."
- corepack enable && corepack prepare pnpm@latest --activate
- ok "pnpm installed"
- fi
- }
- # ── Clone or update repo ─────────────────────────────────────────────────────
- fetch_source() {
- if [[ -d "$INSTALL_DIR/.git" ]]; then
- info "Updating existing installation at $INSTALL_DIR..."
- cd "$INSTALL_DIR"
- git fetch --tags
- local latest_tag
- latest_tag=$(git describe --tags --abbrev=0 origin/main 2>/dev/null || echo "")
- if [[ -n "$latest_tag" ]]; then
- git checkout "$latest_tag"
- ok "Checked out $latest_tag"
- else
- git pull origin main
- ok "Updated to latest main"
- fi
- else
- info "Cloning Mission Control..."
- if command_exists git; then
- git clone --depth 1 "$REPO_URL" "$INSTALL_DIR"
- cd "$INSTALL_DIR"
- ok "Cloned to $INSTALL_DIR"
- else
- die "git is required to clone the repository"
- fi
- fi
- }
- # ── Generate .env ─────────────────────────────────────────────────────────────
- setup_env() {
- if [[ -f "$INSTALL_DIR/.env" ]]; then
- info "Existing .env found — keeping current configuration"
- return
- fi
- info "Generating secure .env configuration..."
- bash "$INSTALL_DIR/scripts/generate-env.sh" "$INSTALL_DIR/.env"
- # Set the port if non-default
- if [[ "$MC_PORT" != "3000" ]]; then
- portable_sed "s|^# PORT=3000|PORT=$(sed_escape "$MC_PORT")|" "$INSTALL_DIR/.env"
- fi
- # Auto-detect and write OpenClaw home directory into .env
- local oc_home="${OPENCLAW_HOME:-$HOME/.openclaw}"
- if [[ -d "$oc_home" ]]; then
- portable_sed "s|^OPENCLAW_HOME=.*|OPENCLAW_HOME=$(sed_escape "$oc_home")|" "$INSTALL_DIR/.env"
- info "Set OPENCLAW_HOME=$oc_home in .env"
- fi
- # In Docker mode, the gateway runs on the host, not inside the container.
- # Set OPENCLAW_GATEWAY_HOST to the Docker host gateway IP so the container
- # can reach the gateway. Users may override this with the gateway container
- # name if running OpenClaw in a container on the same network.
- if [[ "$DEPLOY_MODE" == "docker" ]]; then
- local gw_host="${OPENCLAW_GATEWAY_HOST:-}"
- if [[ -z "$gw_host" ]]; then
- # Detect Docker host IP (host-gateway alias or default bridge)
- if getent hosts host-gateway &>/dev/null 2>&1; then
- gw_host="host-gateway"
- else
- # Fallback: use the default Docker bridge gateway (172.17.0.1)
- gw_host=$(ip route show default 2>/dev/null | awk '/default/ {print $3; exit}' || echo "172.17.0.1")
- fi
- fi
- if [[ -n "$gw_host" && "$gw_host" != "127.0.0.1" ]]; then
- portable_sed "s|^OPENCLAW_GATEWAY_HOST=.*|OPENCLAW_GATEWAY_HOST=$(sed_escape "$gw_host")|" "$INSTALL_DIR/.env"
- info "Set OPENCLAW_GATEWAY_HOST=$gw_host in .env (Docker host IP)"
- info " If your gateway runs in a Docker container, update OPENCLAW_GATEWAY_HOST"
- info " to the container name and add it to the mc-net network."
- fi
- fi
- ok "Secure .env generated"
- }
- # ── Docker deployment ─────────────────────────────────────────────────────────
- deploy_docker() {
- info "Starting Docker deployment..."
- export MC_PORT
- docker compose up -d --build
- # Wait for healthy
- info "Waiting for Mission Control to become healthy..."
- local retries=30
- while [[ $retries -gt 0 ]]; do
- if docker compose ps --format json 2>/dev/null | grep -q '"Health":"healthy"'; then
- break
- fi
- # Fallback: try HTTP check
- if curl -sf "http://localhost:$MC_PORT/login" &>/dev/null; then
- break
- fi
- sleep 2
- ((retries--))
- done
- if [[ $retries -eq 0 ]]; then
- warn "Timeout waiting for health check — container may still be starting"
- docker compose logs --tail 20
- else
- ok "Mission Control is running in Docker"
- fi
- }
- # ── Local deployment ──────────────────────────────────────────────────────────
- deploy_local() {
- info "Starting local deployment..."
- cd "$INSTALL_DIR"
- pnpm install --frozen-lockfile 2>/dev/null || pnpm install
- pnpm rebuild better-sqlite3 2>/dev/null || true
- ok "Dependencies installed"
- info "Building Mission Control..."
- pnpm build
- ok "Build complete"
- # Create systemd service on Linux if systemctl is available
- if [[ "$OS" == "linux" ]] && command_exists systemctl; then
- setup_systemd
- fi
- info "Starting Mission Control..."
- PORT="$MC_PORT" nohup pnpm start > "$INSTALL_DIR/.data/mc.log" 2>&1 &
- local pid=$!
- echo "$pid" > "$INSTALL_DIR/.data/mc.pid"
- sleep 3
- if kill -0 "$pid" 2>/dev/null; then
- ok "Mission Control running (PID $pid)"
- else
- err "Failed to start. Check logs: $INSTALL_DIR/.data/mc.log"
- exit 1
- fi
- }
- # ── Systemd service ──────────────────────────────────────────────────────────
- setup_systemd() {
- local service_file="/etc/systemd/system/mission-control.service"
- if [[ -f "$service_file" ]]; then
- info "Systemd service already exists"
- return
- fi
- info "Creating systemd service..."
- local user
- user="$(whoami)"
- local node_path
- node_path="$(which node)"
- cat > /tmp/mission-control.service <<UNIT
- [Unit]
- Description=Mission Control - OpenClaw Agent Dashboard
- After=network.target
- [Service]
- Type=simple
- User=$user
- WorkingDirectory=$INSTALL_DIR
- ExecStart=$node_path $INSTALL_DIR/.next/standalone/server.js
- Restart=on-failure
- RestartSec=5
- Environment=NODE_ENV=production
- Environment=PORT=$MC_PORT
- EnvironmentFile=$INSTALL_DIR/.env
- [Install]
- WantedBy=multi-user.target
- UNIT
- if [[ "$(id -u)" -eq 0 ]]; then
- mv /tmp/mission-control.service "$service_file"
- systemctl daemon-reload
- systemctl enable mission-control
- ok "Systemd service installed and enabled"
- else
- info "Run as root to install systemd service:"
- info " sudo mv /tmp/mission-control.service $service_file"
- info " sudo systemctl daemon-reload && sudo systemctl enable --now mission-control"
- fi
- }
- # ── OpenClaw fleet check ─────────────────────────────────────────────────────
- check_openclaw() {
- if $SKIP_OPENCLAW; then
- info "Skipping OpenClaw checks (--skip-openclaw)"
- return
- fi
- echo ""
- info "=== OpenClaw Fleet Check ==="
- # Check if openclaw binary exists
- if command_exists openclaw; then
- local oc_version
- oc_version="$(openclaw --version 2>/dev/null || echo 'unknown')"
- ok "OpenClaw binary found: $oc_version"
- elif command_exists clawdbot; then
- local cb_version
- cb_version="$(clawdbot --version 2>/dev/null || echo 'unknown')"
- ok "ClawdBot binary found: $cb_version (legacy)"
- warn "Consider upgrading to openclaw CLI"
- else
- info "OpenClaw CLI not found — install it to enable agent orchestration"
- info " See: https://github.com/builderz-labs/openclaw"
- return
- fi
- # Check OpenClaw home directory
- local oc_home="${OPENCLAW_HOME:-$HOME/.openclaw}"
- if [[ -d "$oc_home" ]]; then
- ok "OpenClaw home: $oc_home"
- # Check config
- local oc_config="$oc_home/openclaw.json"
- if [[ -f "$oc_config" ]]; then
- ok "Config found: $oc_config"
- else
- warn "No openclaw.json found at $oc_config"
- info "Mission Control will create a default config on first gateway connection"
- fi
- # Check for stale PID files
- local stale_count=0
- for pidfile in "$oc_home"/*.pid "$oc_home"/pids/*.pid; do
- [[ -f "$pidfile" ]] || continue
- local pid
- pid="$(cat "$pidfile" 2>/dev/null)" || continue
- if ! kill -0 "$pid" 2>/dev/null; then
- rm -f "$pidfile"
- ((stale_count++))
- fi
- done
- if [[ $stale_count -gt 0 ]]; then
- ok "Cleaned $stale_count stale PID file(s)"
- fi
- # Check logs directory size
- local logs_dir="$oc_home/logs"
- if [[ -d "$logs_dir" ]]; then
- local logs_size
- if [[ "$(uname)" == "Darwin" ]]; then
- logs_size="$(du -sh "$logs_dir" 2>/dev/null | cut -f1)"
- else
- logs_size="$(du -sh "$logs_dir" 2>/dev/null | cut -f1)"
- fi
- info "Logs directory: $logs_size ($logs_dir)"
- # Clean old logs (> 30 days)
- local old_logs
- old_logs=$(find "$logs_dir" -name "*.log" -mtime +30 2>/dev/null | wc -l | tr -d ' ')
- if [[ "$old_logs" -gt 0 ]]; then
- find "$logs_dir" -name "*.log" -mtime +30 -delete 2>/dev/null || true
- ok "Cleaned $old_logs log file(s) older than 30 days"
- fi
- fi
- # Check workspace directory
- local workspace="$oc_home/workspace"
- if [[ -d "$workspace" ]]; then
- local agent_count
- agent_count=$(find "$workspace" -maxdepth 1 -type d 2>/dev/null | wc -l | tr -d ' ')
- ((agent_count--)) # subtract the workspace dir itself
- info "Workspace: $agent_count agent workspace(s) in $workspace"
- fi
- else
- info "OpenClaw home not found at $oc_home"
- info "Set OPENCLAW_HOME in .env to point to your OpenClaw state directory"
- fi
- # Check gateway port
- local gw_host="${OPENCLAW_GATEWAY_HOST:-127.0.0.1}"
- local gw_port="${OPENCLAW_GATEWAY_PORT:-18789}"
- if nc -z "$gw_host" "$gw_port" 2>/dev/null || (echo > "/dev/tcp/$gw_host/$gw_port") 2>/dev/null; then
- ok "Gateway reachable at $gw_host:$gw_port"
- else
- info "Gateway not reachable at $gw_host:$gw_port (start it with: openclaw gateway start)"
- fi
- }
- # ── Main ──────────────────────────────────────────────────────────────────────
- main() {
- echo ""
- echo " ╔══════════════════════════════════════╗"
- echo " ║ Mission Control Installer ║"
- echo " ║ The mothership for your fleet ║"
- echo " ╚══════════════════════════════════════╝"
- echo ""
- detect_os
- check_prerequisites
- # If running from within an existing clone, use current dir
- if [[ -f "$(pwd)/package.json" ]] && grep -q '"mission-control"' "$(pwd)/package.json" 2>/dev/null; then
- INSTALL_DIR="$(pwd)"
- info "Running from existing clone at $INSTALL_DIR"
- else
- fetch_source
- fi
- # Ensure data directory exists
- mkdir -p "$INSTALL_DIR/.data"
- setup_env
- case "$DEPLOY_MODE" in
- docker) deploy_docker ;;
- local) deploy_local ;;
- *) die "Unknown deploy mode: $DEPLOY_MODE" ;;
- esac
- check_openclaw
- # ── Print summary ──
- echo ""
- echo " ╔══════════════════════════════════════╗"
- echo " ║ Installation Complete ║"
- echo " ╚══════════════════════════════════════╝"
- echo ""
- info "Dashboard: http://localhost:$MC_PORT"
- info "Mode: $DEPLOY_MODE"
- info "Data: $INSTALL_DIR/.data/"
- echo ""
- info "Credentials are in: $INSTALL_DIR/.env"
- echo ""
- if [[ "$DEPLOY_MODE" == "docker" ]]; then
- info "Manage:"
- info " docker compose logs -f # view logs"
- info " docker compose restart # restart"
- info " docker compose down # stop"
- else
- info "Manage:"
- info " cat $INSTALL_DIR/.data/mc.log # view logs"
- info " kill \$(cat $INSTALL_DIR/.data/mc.pid) # stop"
- fi
- echo ""
- }
- main "$@"
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.