openclaw-mission-control

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OpenClaw Mission Control

OpenClaw Mission Control

Skill by ara.so — Hermes Skills collection.
OpenClaw Mission Control is a centralized operations and governance platform for AI agent orchestration. It provides a unified dashboard for managing AI agents, assigning tasks, coordinating multi-agent collaboration, and implementing approval-driven governance. Built with TypeScript, it offers both web UI and API-first access for automation.
ara.so开发的Skill——Hermes Skills合集。
OpenClaw Mission Control是一款用于AI Agent编排的集中式运营与治理平台。它提供统一的控制面板,用于管理AI Agent、分配任务、协调多Agent协作,并实现基于审批的治理机制。该平台采用TypeScript构建,同时提供Web UI和API优先的访问方式以支持自动化操作。

What It Does

功能介绍

Mission Control serves as a control plane for OpenClaw operations:
  • Work Orchestration: Manage organizations, board groups, boards, tasks, and tags in hierarchical structures
  • Agent Operations: Create, inspect, and manage agent lifecycle from a unified interface
  • Governance & Approvals: Route sensitive actions through explicit approval workflows with audit trails
  • Gateway Management: Connect and operate distributed execution environments and gateway integrations
  • Activity Visibility: Review complete timeline of system actions for debugging and accountability
  • API-First Design: Support both web workflows and automation clients from the same platform
Mission Control作为OpenClaw运营的控制平面,具备以下功能:
  • 工作流编排:以层级结构管理组织、看板组、看板、任务及标签
  • Agent运营:通过统一界面创建、查看并管理Agent生命周期
  • 治理与审批:将敏感操作通过明确的审批流程进行流转,并保留审计轨迹
  • 网关管理:连接并操作分布式执行环境及网关集成
  • 活动可见性:查看系统操作的完整时间线,用于调试及责任追溯
  • API优先设计:同一平台同时支持Web工作流与自动化客户端

Installation

安装步骤

Quick Start with Installer

使用安装脚本快速启动

bash
undefined
bash
undefined

One-line installation (clones repo if needed)

一键安装(需要时自动克隆仓库)

Or if you already cloned the repo

若已克隆仓库

./install.sh

The installer is interactive and handles:
- Deployment mode selection (Docker or local)
- System dependency installation
- Environment file generation
- Bootstrap and startup
./install.sh

安装脚本为交互式,可处理以下事项:
- 部署模式选择(Docker或本地部署)
- 系统依赖安装
- 环境文件生成
- 初始化与启动

Manual Docker Setup

手动Docker部署

bash
undefined
bash
undefined

Clone repository

克隆仓库

git clone https://github.com/abhi1693/openclaw-mission-control.git cd openclaw-mission-control
git clone https://github.com/abhi1693/openclaw-mission-control.git cd openclaw-mission-control

Configure environment

配置环境

cp .env.example .env
cp .env.example .env

Edit .env and set required values:

编辑.env文件并设置必填值:

- LOCAL_AUTH_TOKEN (minimum 50 characters)

- LOCAL_AUTH_TOKEN(至少50个字符)

- BASE_URL (backend origin)

- BASE_URL(后端源地址)

- NEXT_PUBLIC_API_URL (frontend API endpoint)

- NEXT_PUBLIC_API_URL(前端API端点)

Start services

启动服务

docker compose -f compose.yml --env-file .env up -d --build
undefined
docker compose -f compose.yml --env-file .env up -d --build
undefined

Manual Local Setup

手动本地部署

Prerequisites: Node.js 22+, PostgreSQL, Redis
bash
undefined
前置依赖:Node.js 22+、PostgreSQL、Redis
bash
undefined

Backend setup

后端设置

cd backend cp .env.example .env
cd backend cp .env.example .env

Edit .env with database credentials and auth config

编辑.env文件,填入数据库凭证及认证配置

npm install npm run db:migrate npm run dev
npm install npm run db:migrate npm run dev

Frontend setup (in new terminal)

前端设置(在新终端中执行)

cd frontend cp .env.example .env
cd frontend cp .env.example .env

Edit .env with API URL

编辑.env文件,填入API地址

npm install npm run dev

Access:
- UI: http://localhost:3000
- API: http://localhost:8000
- Health check: http://localhost:8000/healthz
npm install npm run dev

访问地址:
- UI: http://localhost:3000
- API: http://localhost:8000
- 健康检查: http://localhost:8000/healthz

Authentication Configuration

认证配置

Mission Control supports two authentication modes:
Mission Control支持两种认证模式:

Local Token Mode (Default for Self-Hosted)

本地令牌模式(自托管默认模式)

bash
undefined
bash
undefined

.env

.env

AUTH_MODE=local LOCAL_AUTH_TOKEN=your-secure-token-minimum-50-characters-required

Use in API requests:
```bash
curl -H "Authorization: Bearer ${LOCAL_AUTH_TOKEN}" \
  http://localhost:8000/api/organizations
AUTH_MODE=local LOCAL_AUTH_TOKEN=your-secure-token-minimum-50-characters-required

API请求中使用:
```bash
curl -H "Authorization: Bearer ${LOCAL_AUTH_TOKEN}" \
  http://localhost:8000/api/organizations

Clerk JWT Mode

Clerk JWT模式

bash
undefined
bash
undefined

.env

.env

AUTH_MODE=clerk CLERK_PUBLISHABLE_KEY=${CLERK_PUBLISHABLE_KEY} CLERK_SECRET_KEY=${CLERK_SECRET_KEY}
AUTH_MODE=clerk CLERK_PUBLISHABLE_KEY=${CLERK_PUBLISHABLE_KEY} CLERK_SECRET_KEY=${CLERK_SECRET_KEY}

frontend/.env

frontend/.env

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=${CLERK_PUBLISHABLE_KEY}
undefined
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=${CLERK_PUBLISHABLE_KEY}
undefined

Core Concepts

核心概念

Hierarchy Structure

层级结构

Organization
  └── Board Group
      └── Board
          └── Task
              └── Tag (optional)
Organization
  └── Board Group
      └── Board
          └── Task
              └── Tag (可选)

Agent Lifecycle

Agent生命周期

  1. Creation: Define agent with name, description, capabilities
  2. Assignment: Link agent to boards and tasks
  3. Execution: Agent processes tasks according to workflow
  4. Approval: Sensitive actions require explicit approval
  5. Audit: All actions logged in activity timeline
  1. 创建:定义Agent的名称、描述及能力
  2. 分配:将Agent关联到看板与任务
  3. 执行:Agent根据工作流处理任务
  4. 审批:敏感操作需经过明确审批
  5. 审计:所有操作记录在活动时间线中

API Usage

API使用示例

Organizations

组织

typescript
// Create organization
const createOrganization = async (token: string) => {
  const response = await fetch('http://localhost:8000/api/organizations', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Engineering Team',
      description: 'Primary engineering organization',
    }),
  });
  return response.json();
};

// List organizations
const listOrganizations = async (token: string) => {
  const response = await fetch('http://localhost:8000/api/organizations', {
    headers: {
      'Authorization': `Bearer ${token}`,
    },
  });
  return response.json();
};
typescript
// 创建组织
const createOrganization = async (token: string) => {
  const response = await fetch('http://localhost:8000/api/organizations', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Engineering Team',
      description: 'Primary engineering organization',
    }),
  });
  return response.json();
};

// 列出组织
const listOrganizations = async (token: string) => {
  const response = await fetch('http://localhost:8000/api/organizations', {
    headers: {
      'Authorization': `Bearer ${token}`,
    },
  });
  return response.json();
};

Board Groups

看板组

typescript
// Create board group
const createBoardGroup = async (token: string, orgId: string) => {
  const response = await fetch('http://localhost:8000/api/board-groups', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      organization_id: orgId,
      name: 'Q1 2026 Projects',
      description: 'First quarter project boards',
    }),
  });
  return response.json();
};
typescript
// 创建看板组
const createBoardGroup = async (token: string, orgId: string) => {
  const response = await fetch('http://localhost:8000/api/board-groups', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      organization_id: orgId,
      name: 'Q1 2026 Projects',
      description: 'First quarter project boards',
    }),
  });
  return response.json();
};

Boards

看板

typescript
// Create board
const createBoard = async (token: string, groupId: string) => {
  const response = await fetch('http://localhost:8000/api/boards', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      board_group_id: groupId,
      name: 'API Development',
      description: 'Backend API development tasks',
    }),
  });
  return response.json();
};

// Get board with tasks
const getBoard = async (token: string, boardId: string) => {
  const response = await fetch(`http://localhost:8000/api/boards/${boardId}`, {
    headers: {
      'Authorization': `Bearer ${token}`,
    },
  });
  return response.json();
};
typescript
// 创建看板
const createBoard = async (token: string, groupId: string) => {
  const response = await fetch('http://localhost:8000/api/boards', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      board_group_id: groupId,
      name: 'API Development',
      description: 'Backend API development tasks',
    }),
  });
  return response.json();
};

// 获取包含任务的看板
const getBoard = async (token: string, boardId: string) => {
  const response = await fetch(`http://localhost:8000/api/boards/${boardId}`, {
    headers: {
      'Authorization': `Bearer ${token}`,
    },
  });
  return response.json();
};

Tasks

任务

typescript
// Create task
const createTask = async (token: string, boardId: string) => {
  const response = await fetch('http://localhost:8000/api/tasks', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      board_id: boardId,
      title: 'Implement user authentication',
      description: 'Add JWT-based authentication to API endpoints',
      status: 'todo',
      priority: 'high',
      assigned_agent_id: null, // Optional agent assignment
    }),
  });
  return response.json();
};

// Update task status
const updateTaskStatus = async (token: string, taskId: string, status: string) => {
  const response = await fetch(`http://localhost:8000/api/tasks/${taskId}`, {
    method: 'PATCH',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      status, // 'todo' | 'in_progress' | 'review' | 'done'
    }),
  });
  return response.json();
};
typescript
// 创建任务
const createTask = async (token: string, boardId: string) => {
  const response = await fetch('http://localhost:8000/api/tasks', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      board_id: boardId,
      title: 'Implement user authentication',
      description: 'Add JWT-based authentication to API endpoints',
      status: 'todo',
      priority: 'high',
      assigned_agent_id: null, // 可选Agent分配
    }),
  });
  return response.json();
};

// 更新任务状态
const updateTaskStatus = async (token: string, taskId: string, status: string) => {
  const response = await fetch(`http://localhost:8000/api/tasks/${taskId}`, {
    method: 'PATCH',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      status, // 'todo' | 'in_progress' | 'review' | 'done'
    }),
  });
  return response.json();
};

Agents

Agent

typescript
// Create agent
const createAgent = async (token: string) => {
  const response = await fetch('http://localhost:8000/api/agents', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Code Review Agent',
      description: 'Automated code review and quality checks',
      capabilities: ['code-analysis', 'security-scan', 'style-check'],
      config: {
        model: 'gpt-4',
        temperature: 0.3,
        max_tokens: 2000,
      },
    }),
  });
  return response.json();
};

// Assign agent to task
const assignAgent = async (token: string, taskId: string, agentId: string) => {
  const response = await fetch(`http://localhost:8000/api/tasks/${taskId}`, {
    method: 'PATCH',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      assigned_agent_id: agentId,
    }),
  });
  return response.json();
};
typescript
// 创建Agent
const createAgent = async (token: string) => {
  const response = await fetch('http://localhost:8000/api/agents', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Code Review Agent',
      description: 'Automated code review and quality checks',
      capabilities: ['code-analysis', 'security-scan', 'style-check'],
      config: {
        model: 'gpt-4',
        temperature: 0.3,
        max_tokens: 2000,
      },
    }),
  });
  return response.json();
};

// 将Agent分配给任务
const assignAgent = async (token: string, taskId: string, agentId: string) => {
  const response = await fetch(`http://localhost:8000/api/tasks/${taskId}`, {
    method: 'PATCH',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      assigned_agent_id: agentId,
    }),
  });
  return response.json();
};

Approvals

审批

typescript
// Request approval for sensitive action
const requestApproval = async (token: string, taskId: string) => {
  const response = await fetch('http://localhost:8000/api/approvals', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      task_id: taskId,
      action: 'deploy_to_production',
      reason: 'Deploy feature to production environment',
      metadata: {
        environment: 'production',
        service: 'api-gateway',
      },
    }),
  });
  return response.json();
};

// Approve or reject
const processApproval = async (token: string, approvalId: string, approved: boolean) => {
  const response = await fetch(`http://localhost:8000/api/approvals/${approvalId}`, {
    method: 'PATCH',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      status: approved ? 'approved' : 'rejected',
      comment: approved ? 'LGTM' : 'Needs additional testing',
    }),
  });
  return response.json();
};
typescript
// 为敏感操作请求审批
const requestApproval = async (token: string, taskId: string) => {
  const response = await fetch('http://localhost:8000/api/approvals', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      task_id: taskId,
      action: 'deploy_to_production',
      reason: 'Deploy feature to production environment',
      metadata: {
        environment: 'production',
        service: 'api-gateway',
      },
    }),
  });
  return response.json();
};

// 批准或拒绝
const processApproval = async (token: string, approvalId: string, approved: boolean) => {
  const response = await fetch(`http://localhost:8000/api/approvals/${approvalId}`, {
    method: 'PATCH',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      status: approved ? 'approved' : 'rejected',
      comment: approved ? 'LGTM' : 'Needs additional testing',
    }),
  });
  return response.json();
};

Gateway Management

网关管理

typescript
// Register gateway
const registerGateway = async (token: string) => {
  const response = await fetch('http://localhost:8000/api/gateways', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Production Gateway',
      endpoint: 'https://gateway.example.com',
      auth_token: process.env.GATEWAY_AUTH_TOKEN,
      capabilities: ['task-execution', 'log-streaming'],
    }),
  });
  return response.json();
};

// Execute task via gateway
const executeViaGateway = async (token: string, gatewayId: string, taskId: string) => {
  const response = await fetch(`http://localhost:8000/api/gateways/${gatewayId}/execute`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      task_id: taskId,
      parameters: {
        environment: 'production',
      },
    }),
  });
  return response.json();
};
typescript
// 注册网关
const registerGateway = async (token: string) => {
  const response = await fetch('http://localhost:8000/api/gateways', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Production Gateway',
      endpoint: 'https://gateway.example.com',
      auth_token: process.env.GATEWAY_AUTH_TOKEN,
      capabilities: ['task-execution', 'log-streaming'],
    }),
  });
  return response.json();
};

// 通过网关执行任务
const executeViaGateway = async (token: string, gatewayId: string, taskId: string) => {
  const response = await fetch(`http://localhost:8000/api/gateways/${gatewayId}/execute`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      task_id: taskId,
      parameters: {
        environment: 'production',
      },
    }),
  });
  return response.json();
};

Activity Timeline

活动时间线

typescript
// Get activity log
const getActivity = async (token: string, filters?: object) => {
  const params = new URLSearchParams(filters as Record<string, string>);
  const response = await fetch(`http://localhost:8000/api/activity?${params}`, {
    headers: {
      'Authorization': `Bearer ${token}`,
    },
  });
  return response.json();
};

// Get activity for specific resource
const getResourceActivity = async (token: string, resourceType: string, resourceId: string) => {
  const response = await fetch(
    `http://localhost:8000/api/activity?resource_type=${resourceType}&resource_id=${resourceId}`,
    {
      headers: {
        'Authorization': `Bearer ${token}`,
      },
    }
  );
  return response.json();
};
typescript
// 获取活动日志
const getActivity = async (token: string, filters?: object) => {
  const params = new URLSearchParams(filters as Record<string, string>);
  const response = await fetch(`http://localhost:8000/api/activity?${params}`, {
    headers: {
      'Authorization': `Bearer ${token}`,
    },
  });
  return response.json();
};

// 获取特定资源的活动记录
const getResourceActivity = async (token: string, resourceType: string, resourceId: string) => {
  const response = await fetch(
    `http://localhost:8000/api/activity?resource_type=${resourceType}&resource_id=${resourceId}`,
    {
      headers: {
        'Authorization': `Bearer ${token}`,
      },
    }
  );
  return response.json();
};

Common Patterns

常见模式

Multi-Agent Workflow

多Agent工作流

typescript
// Create workflow with multiple agents
const createMultiAgentWorkflow = async (token: string) => {
  // 1. Create organization and board
  const org = await createOrganization(token);
  const group = await createBoardGroup(token, org.id);
  const board = await createBoard(token, group.id);
  
  // 2. Create specialized agents
  const codeAgent = await createAgent(token, {
    name: 'Code Generator',
    capabilities: ['code-generation'],
  });
  
  const reviewAgent = await createAgent(token, {
    name: 'Code Reviewer',
    capabilities: ['code-review'],
  });
  
  const testAgent = await createAgent(token, {
    name: 'Test Runner',
    capabilities: ['test-execution'],
  });
  
  // 3. Create sequential tasks
  const codeTask = await createTask(token, board.id, {
    title: 'Generate feature code',
    assigned_agent_id: codeAgent.id,
  });
  
  const reviewTask = await createTask(token, board.id, {
    title: 'Review generated code',
    assigned_agent_id: reviewAgent.id,
    dependencies: [codeTask.id],
  });
  
  const testTask = await createTask(token, board.id, {
    title: 'Run integration tests',
    assigned_agent_id: testAgent.id,
    dependencies: [reviewTask.id],
  });
  
  return { board, tasks: [codeTask, reviewTask, testTask] };
};
typescript
// 创建包含多个Agent的工作流
const createMultiAgentWorkflow = async (token: string) => {
  // 1. 创建组织和看板
  const org = await createOrganization(token);
  const group = await createBoardGroup(token, org.id);
  const board = await createBoard(token, group.id);
  
  // 2. 创建专业Agent
  const codeAgent = await createAgent(token, {
    name: 'Code Generator',
    capabilities: ['code-generation'],
  });
  
  const reviewAgent = await createAgent(token, {
    name: 'Code Reviewer',
    capabilities: ['code-review'],
  });
  
  const testAgent = await createAgent(token, {
    name: 'Test Runner',
    capabilities: ['test-execution'],
  });
  
  // 3. 创建顺序任务
  const codeTask = await createTask(token, board.id, {
    title: 'Generate feature code',
    assigned_agent_id: codeAgent.id,
  });
  
  const reviewTask = await createTask(token, board.id, {
    title: 'Review generated code',
    assigned_agent_id: reviewAgent.id,
    dependencies: [codeTask.id],
  });
  
  const testTask = await createTask(token, board.id, {
    title: 'Run integration tests',
    assigned_agent_id: testAgent.id,
    dependencies: [reviewTask.id],
  });
  
  return { board, tasks: [codeTask, reviewTask, testTask] };
};

Approval-Gated Deployment

审批驱动的部署

typescript
// Deployment with approval requirement
const deployWithApproval = async (token: string, taskId: string) => {
  // 1. Request approval
  const approval = await requestApproval(token, taskId);
  
  // 2. Wait for approval (polling or webhook)
  let approvalStatus = approval;
  while (approvalStatus.status === 'pending') {
    await new Promise(resolve => setTimeout(resolve, 5000));
    const response = await fetch(
      `http://localhost:8000/api/approvals/${approval.id}`,
      { headers: { 'Authorization': `Bearer ${token}` } }
    );
    approvalStatus = await response.json();
  }
  
  // 3. Execute if approved
  if (approvalStatus.status === 'approved') {
    await fetch(`http://localhost:8000/api/tasks/${taskId}/execute`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json',
      },
    });
    return { success: true };
  }
  
  return { success: false, reason: approvalStatus.comment };
};
typescript
// 需要审批的部署流程
const deployWithApproval = async (token: string, taskId: string) => {
  // 1. 请求审批
  const approval = await requestApproval(token, taskId);
  
  // 2. 等待审批(轮询或Webhook)
  let approvalStatus = approval;
  while (approvalStatus.status === 'pending') {
    await new Promise(resolve => setTimeout(resolve, 5000));
    const response = await fetch(
      `http://localhost:8000/api/approvals/${approval.id}`,
      { headers: { 'Authorization': `Bearer ${token}` } }
    );
    approvalStatus = await response.json();
  }
  
  // 3. 若审批通过则执行
  if (approvalStatus.status === 'approved') {
    await fetch(`http://localhost:8000/api/tasks/${taskId}/execute`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json',
      },
    });
    return { success: true };
  }
  
  return { success: false, reason: approvalStatus.comment };
};

Gateway-Based Distributed Execution

基于网关的分布式执行

typescript
// Execute tasks across multiple gateways
const distributeExecution = async (token: string, tasks: any[], gateways: any[]) => {
  const executions = [];
  
  for (let i = 0; i < tasks.length; i++) {
    const gateway = gateways[i % gateways.length]; // Round-robin
    const execution = await executeViaGateway(token, gateway.id, tasks[i].id);
    executions.push({ task: tasks[i], gateway: gateway.name, execution });
  }
  
  return executions;
};
typescript
// 在多个网关间分发任务执行
const distributeExecution = async (token: string, tasks: any[], gateways: any[]) => {
  const executions = [];
  
  for (let i = 0; i < tasks.length; i++) {
    const gateway = gateways[i % gateways.length]; // 轮询分配
    const execution = await executeViaGateway(token, gateway.id, tasks[i].id);
    executions.push({ task: tasks[i], gateway: gateway.name, execution });
  }
  
  return executions;
};

Environment Configuration

环境配置

Docker Deployment

Docker部署

bash
undefined
bash
undefined

.env

.env

AUTH_MODE=local LOCAL_AUTH_TOKEN=${LOCAL_AUTH_TOKEN} BASE_URL=http://localhost:8000 NEXT_PUBLIC_API_URL=auto
AUTH_MODE=local LOCAL_AUTH_TOKEN=${LOCAL_AUTH_TOKEN} BASE_URL=http://localhost:8000 NEXT_PUBLIC_API_URL=auto

Database

数据库

DATABASE_URL=postgresql://postgres:postgres@db:5432/mission_control REDIS_URL=redis://redis:6379
DATABASE_URL=postgresql://postgres:postgres@db:5432/mission_control REDIS_URL=redis://redis:6379

Optional: Clerk authentication

可选:Clerk认证

AUTH_MODE=clerk

AUTH_MODE=clerk

CLERK_PUBLISHABLE_KEY=${CLERK_PUBLISHABLE_KEY}

CLERK_PUBLISHABLE_KEY=${CLERK_PUBLISHABLE_KEY}

CLERK_SECRET_KEY=${CLERK_SECRET_KEY}

CLERK_SECRET_KEY=${CLERK_SECRET_KEY}

undefined
undefined

Production Configuration

生产环境配置

bash
undefined
bash
undefined

.env

.env

AUTH_MODE=clerk BASE_URL=https://api.yourdomain.com NEXT_PUBLIC_API_URL=https://api.yourdomain.com
AUTH_MODE=clerk BASE_URL=https://api.yourdomain.com NEXT_PUBLIC_API_URL=https://api.yourdomain.com

Database (managed PostgreSQL)

数据库(托管PostgreSQL)

DATABASE_URL=${DATABASE_URL} REDIS_URL=${REDIS_URL}
DATABASE_URL=${DATABASE_URL} REDIS_URL=${REDIS_URL}

Clerk

Clerk

CLERK_PUBLISHABLE_KEY=${CLERK_PUBLISHABLE_KEY} CLERK_SECRET_KEY=${CLERK_SECRET_KEY}
CLERK_PUBLISHABLE_KEY=${CLERK_PUBLISHABLE_KEY} CLERK_SECRET_KEY=${CLERK_SECRET_KEY}

Security

安全配置

NODE_ENV=production CORS_ORIGINS=https://app.yourdomain.com
undefined
NODE_ENV=production CORS_ORIGINS=https://app.yourdomain.com
undefined

Docker Commands

Docker命令

bash
undefined
bash
undefined

Start services

启动服务

docker compose -f compose.yml --env-file .env up -d --build
docker compose -f compose.yml --env-file .env up -d --build

Watch mode (auto-rebuild on changes)

监听模式(文件变更时自动重建)

docker compose -f compose.yml --env-file .env up --build --watch
docker compose -f compose.yml --env-file .env up --build --watch

View logs

查看日志

docker compose -f compose.yml --env-file .env logs -f
docker compose -f compose.yml --env-file .env logs -f

Rebuild after pulling changes

拉取更新后重建

docker compose -f compose.yml --env-file .env up -d --build --force-recreate
docker compose -f compose.yml --env-file .env up -d --build --force-recreate

Clean rebuild (no cache)

清理重建(无缓存)

docker compose -f compose.yml --env-file .env build --no-cache --pull docker compose -f compose.yml --env-file .env up -d --force-recreate
docker compose -f compose.yml --env-file .env build --no-cache --pull docker compose -f compose.yml --env-file .env up -d --force-recreate

Stop services

停止服务

docker compose -f compose.yml --env-file .env down
docker compose -f compose.yml --env-file .env down

Stop and remove volumes

停止并移除卷

docker compose -f compose.yml --env-file .env down -v
undefined
docker compose -f compose.yml --env-file .env down -v
undefined

Troubleshooting

故障排查

Authentication Errors

认证错误

Problem:
401 Unauthorized
responses
bash
undefined
问题:返回
401 Unauthorized
响应
bash
undefined

Verify token is set and long enough (50+ chars)

验证令牌已设置且长度足够(50+字符)

echo ${LOCAL_AUTH_TOKEN} | wc -c
echo ${LOCAL_AUTH_TOKEN} | wc -c

Check AUTH_MODE matches configuration

检查AUTH_MODE与配置是否匹配

grep AUTH_MODE .env
grep AUTH_MODE .env

Test authentication

测试认证

curl -H "Authorization: Bearer ${LOCAL_AUTH_TOKEN}"
http://localhost:8000/healthz
undefined
curl -H "Authorization: Bearer ${LOCAL_AUTH_TOKEN}"
http://localhost:8000/healthz
undefined

Database Connection Issues

数据库连接问题

Problem: Backend fails to connect to database
bash
undefined
问题:后端无法连接数据库
bash
undefined

Check database is running

检查数据库是否运行

docker compose -f compose.yml --env-file .env ps db
docker compose -f compose.yml --env-file .env ps db

Verify DATABASE_URL format

验证DATABASE_URL格式

Should be: postgresql://user:pass@host:port/dbname

格式应为:postgresql://user:pass@host:port/dbname

grep DATABASE_URL .env
grep DATABASE_URL .env

Check database logs

查看数据库日志

docker compose -f compose.yml --env-file .env logs db
docker compose -f compose.yml --env-file .env logs db

Run migrations manually

手动运行迁移

docker compose -f compose.yml --env-file .env exec backend npm run db:migrate
undefined
docker compose -f compose.yml --env-file .env exec backend npm run db:migrate
undefined

Frontend Can't Reach API

前端无法访问API

Problem: API requests fail from frontend
bash
undefined
问题:前端发起的API请求失败
bash
undefined

Check NEXT_PUBLIC_API_URL configuration

检查NEXT_PUBLIC_API_URL配置

grep NEXT_PUBLIC_API_URL frontend/.env
grep NEXT_PUBLIC_API_URL frontend/.env

For auto mode, ensure BASE_URL is correct

若为auto模式,确保BASE_URL正确

grep BASE_URL .env
grep BASE_URL .env

Test API accessibility

测试API可访问性

Check CORS settings if using different origins

若使用不同源,检查CORS设置

grep CORS_ORIGINS .env
undefined
grep CORS_ORIGINS .env
undefined

Port Conflicts

端口冲突

Problem: Ports 3000 or 8000 already in use
bash
undefined
问题:端口3000或8000已被占用
bash
undefined

Find processes using ports

查找占用端口的进程

lsof -i :3000 lsof -i :8000
lsof -i :3000 lsof -i :8000

Change ports in .env

在.env中修改端口

Backend: PORT=8001

后端:PORT=8001

Frontend: edit docker-compose.yml or run locally on different port

前端:编辑docker-compose.yml或在本地使用其他端口运行

undefined
undefined

Watch Mode Not Working

监听模式不生效

Problem: Docker Compose watch not detecting changes
bash
undefined
问题:Docker Compose监听未检测到文件变更
bash
undefined

Verify Docker Compose version (requires 2.22.0+)

验证Docker Compose版本(需2.22.0+)

docker compose version
docker compose version

Upgrade Docker Compose if needed

若需升级Docker Compose

Then restart with watch

然后重新启动监听模式

docker compose -f compose.yml --env-file .env down docker compose -f compose.yml --env-file .env up --build --watch
undefined
docker compose -f compose.yml --env-file .env down docker compose -f compose.yml --env-file .env up --build --watch
undefined

Gateway Connection Failures

网关连接失败

Problem: Gateway registration or execution fails
bash
undefined
问题:网关注册或执行失败
bash
undefined

Verify gateway endpoint is accessible

验证网关端点可访问

curl -H "Authorization: Bearer ${GATEWAY_AUTH_TOKEN}"
https://gateway.example.com/healthz
curl -H "Authorization: Bearer ${GATEWAY_AUTH_TOKEN}"
https://gateway.example.com/healthz

Check gateway configuration

检查网关配置

curl -H "Authorization: Bearer ${LOCAL_AUTH_TOKEN}"
http://localhost:8000/api/gateways
curl -H "Authorization: Bearer ${LOCAL_AUTH_TOKEN}"
http://localhost:8000/api/gateways

Review gateway logs in activity timeline

在活动时间线中查看网关日志

curl -H "Authorization: Bearer ${LOCAL_AUTH_TOKEN}"
"http://localhost:8000/api/activity?resource_type=gateway"
undefined
curl -H "Authorization: Bearer ${LOCAL_AUTH_TOKEN}"
"http://localhost:8000/api/activity?resource_type=gateway"
undefined

Reset Database

重置数据库

bash
undefined
bash
undefined

Stop services

停止服务

docker compose -f compose.yml --env-file .env down
docker compose -f compose.yml --env-file .env down

Remove database volume

移除数据库卷

docker volume rm openclaw-mission-control_postgres-data
docker volume rm openclaw-mission-control_postgres-data

Restart and migrations will run automatically

重启服务,迁移将自动运行

docker compose -f compose.yml --env-file .env up -d --build
undefined
docker compose -f compose.yml --env-file .env up -d --build
undefined

Testing

测试

bash
undefined
bash
undefined

Backend tests

后端测试

cd backend npm test
cd backend npm test

Frontend tests

前端测试

cd frontend npm test
cd frontend npm test

E2E tests (if configured)

端到端测试(若已配置)

npm run test:e2e
undefined
npm run test:e2e
undefined

Production Deployment

生产环境部署

See
docs/
for:
  • Production deployment guide
  • Security hardening checklist
  • Performance optimization
  • Monitoring and observability setup
  • Backup and disaster recovery
查看
docs/
获取以下内容:
  • 生产环境部署指南
  • 安全加固清单
  • 性能优化方案
  • 监控与可观测性设置
  • 备份与灾难恢复