bboxwtf a8a8ea1ee2 feat(swarm): autonomous agent containers, Swarm Manager with auto-stop, /nodes UI overhaul
## 1. Fix /nodes Swarm Status Display
- Add SwarmStatusBanner component: clear green/red/loading state
- Shows nodeId, managerAddr, isManager badge
- Error state explains what to check (docker.sock mount)
- Header now shows 'swarm unreachable — check gateway' vs 'active'
- swarmOk now checks nodeId presence, not just data existence

## 2. Autonomous Agent Container
- New docker/Dockerfile.agent — builds Go agent binary from gateway/cmd/agent/
- New gateway/cmd/agent/main.go — standalone HTTP microservice:
  * GET /health — liveness probe with idle time info
  * POST /task — receives task, forwards to Gateway orchestrator
  * GET /info  — agent metadata (id, hostname, gateway url)
  * Idle watchdog: calls /api/swarm/agents/{name}/stop after IdleTimeoutMinutes
  * Connects to Swarm overlay network (goclaw-net) → reaches DB/Gateway by DNS
  * Env: AGENT_ID, GATEWAY_URL, DATABASE_URL, IDLE_TIMEOUT_MINUTES

## 3. Swarm Manager Agent (auto-stop after 15min idle)
- New gateway/internal/api/swarm_manager.go:
  * SwarmManager goroutine checks every 60s
  * Scales idle GoClaw agent services to 0 replicas after 15 min
  * Tracks lastActivity from task UpdatedAt timestamps
- New REST endpoints in gateway:
  * GET  /api/swarm/agents           — list agents with idleMinutes
  * POST /api/swarm/agents/{name}/start — scale up agent
  * POST /api/swarm/agents/{name}/stop  — scale to 0
  * DELETE /api/swarm/services/{id}     — remove service permanently
- SwarmManager started as background goroutine in main.go with context cancel

## 4. Docker Client Enhancements
- Added NetworkAttachment type and Networks field to ServiceSpec
- CreateAgentServiceFull(opts) — supports overlay networks, custom labels
- CreateAgentService() delegates to CreateAgentServiceFull for backward compat
- RemoveService(id) — DELETE /v1.44/services/{id}
- GetServiceLastActivity(id) — finds latest task UpdatedAt for idle detection

## 5. tRPC & Gateway Proxy
- New functions: removeSwarmService, listSwarmAgents, startSwarmAgent, stopSwarmAgent
- SwarmAgentInfo type with idleMinutes, lastActivity, desiredReplicas
- createAgentService now accepts networks[] parameter
- New tRPC endpoints: nodes.removeService, nodes.listAgents, nodes.startAgent, nodes.stopAgent

## 6. Nodes.tsx UI Overhaul
- SwarmStatusBanner component at top — no more silent 'connecting…'
- New 'Agents' tab with AgentManagerRow: idle time, auto-stop warning, start/stop/remove buttons
- IdleColor coding: green < 5m, yellow 5-10m, red 10m+ with countdown to auto-stop
- ServiceRow: added Remove button with confirmation dialog
- RemoveConfirmDialog component
- DeployAgentDialog: added overlay networks field, default env includes GATEWAY_URL
- All queries refetch after agent start/stop/remove
2026-03-21 20:37:21 +00:00
2026-03-20 16:39:29 -04:00
2026-03-20 15:24:10 -04:00
2026-03-20 16:39:29 -04:00
2026-03-20 15:24:10 -04:00
2026-03-20 15:24:10 -04:00
2026-03-20 16:39:29 -04:00
2026-03-20 17:34:20 -04:00
2026-03-20 17:34:20 -04:00
2026-03-20 16:39:29 -04:00
2026-03-20 17:34:20 -04:00
2026-03-20 15:24:10 -04:00

GoClaw Control Center

Mission Control для вашего AI-агентского кластера. Веб-интерфейс для мониторинга Docker Swarm, управления AI-агентами и общения с оркестратором через реальный LLM (Ollama Cloud API).


Запуск одной командой

curl -fsSL https://git.softuniq.eu/UniqAI/GoClaw/raw/branch/main/install.sh | bash

Или вручную через Docker Compose:

git clone https://git.softuniq.eu/UniqAI/GoClaw.git && cd GoClaw && cp .env.example .env && docker compose up -d

После запуска откройте: http://localhost:3000


Быстрый старт (без Docker)

# 1. Клонировать репозиторий
git clone https://git.softuniq.eu/UniqAI/GoClaw.git
cd GoClaw

# 2. Установить зависимости
pnpm install

# 3. Настроить переменные окружения
cp .env.example .env
# Отредактируйте .env — укажите OLLAMA_BASE_URL и OLLAMA_API_KEY

# 4. Запустить базу данных
pnpm db:push

# 5. Запустить dev-сервер
pnpm dev

Архитектура

GoClaw Control Center
├── client/                  # React 19 + Tailwind 4 + shadcn/ui (фронтенд)
│   └── src/
│       ├── pages/           # Dashboard, Agents, Nodes, Chat, Settings
│       └── components/      # DashboardLayout, UI-компоненты
├── server/                  # Express 4 + tRPC 11 (бэкенд)
│   ├── ollama.ts            # Прокси-клиент для Ollama API
│   ├── routers.ts           # tRPC роуты (ollama.health, models, chat)
│   └── _core/               # Auth, DB, LLM, Storage хелперы
├── drizzle/                 # Схема БД и миграции (MySQL/TiDB)
├── docker/                  # Docker Stack для Swarm-деплоя
│   ├── docker-stack.yml     # Полный стек: Gateway + Agents + Control Center
│   ├── Dockerfile.gateway   # Образ основного шлюза GoClaw
│   ├── Dockerfile.agent     # Образ AI-агента
│   └── Dockerfile.control-center # Образ веб-интерфейса (nginx)
└── docs/                    # Документация и спецификации
    ├── swarm_architecture.md
    └── goclaw_swarm_cloud_guide.md

Возможности

Раздел Что умеет
Dashboard Мониторинг Swarm-нод, статус агентов, лента активности, live-статус Ollama API
Agents Просмотр всех AI-агентов с их ролями, моделями и текущими задачами
Nodes Мониторинг Docker Swarm нод: CPU, RAM, контейнеры, статус
Chat Терминальный чат с оркестратором через реальный LLM (34 модели Ollama)
Settings Управление API-провайдерами, сканирование доступных моделей, настройки Telegram

Переменные окружения

Скопируйте .env.example в .env и заполните:

# Ollama API (обязательно)
OLLAMA_BASE_URL=https://ollama.com/v1
OLLAMA_API_KEY=your_api_key_here

# База данных (обязательно для production)
DATABASE_URL=mysql://user:password@host:3306/goclaw

# JWT (сгенерируйте случайную строку)
JWT_SECRET=your_random_secret_here

# Telegram Bot (опционально)
TELEGRAM_BOT_TOKEN=your_bot_token

Docker Swarm деплой

# Инициализировать Swarm (если ещё не сделано)
docker swarm init

# Задать секреты
export OLLAMA_API_KEY=your_key
export DATABASE_URL=mysql://...
export JWT_SECRET=your_secret

# Развернуть стек
docker stack deploy -c docker/docker-stack.yml goclaw

# Проверить статус
docker stack services goclaw

Добавление новой ноды в кластер:

# На manager-ноде получить токен
docker swarm join-token worker

# На новой ноде выполнить команду из вывода выше
docker swarm join --token SWMTKN-... manager-ip:2377

Технологический стек

Слой Технологии
Фронтенд React 19, Tailwind CSS 4, shadcn/ui, Framer Motion, tRPC Client
Бэкенд Node.js, Express 4, tRPC 11, Drizzle ORM, Zod
База данных MySQL / TiDB (через Drizzle)
LLM Ollama Cloud API (OpenAI-совместимый, 34+ модели)
Оркестрация Docker Swarm, Overlay Network
Агенты (Go) gRPC, Docker SDK, Goroutines, Channels
Тесты Vitest

Структура GoClaw Swarm

                    ┌─────────────────────────────────┐
                    │     goclaw-net (Overlay Network) │
                    └─────────────────────────────────┘
                                    │
              ┌─────────────────────┼─────────────────────┐
              │                     │                     │
    ┌─────────▼──────┐   ┌──────────▼──────┐   ┌─────────▼──────┐
    │  Control Center │   │    Gateway       │   │   Agents        │
    │  (Web UI :3000) │   │  (Orchestrator)  │   │  (Docker Svc)   │
    │  React + tRPC   │   │  Go + gRPC       │   │  Coder/Browser  │
    └────────────────┘   └─────────────────┘   │  Mail/Monitor   │
                                │               └─────────────────┘
                    ┌───────────▼──────────┐
                    │   Ollama Cloud API   │
                    │  (34 LLM Models)     │
                    └──────────────────────┘

Разработка

# Запустить тесты
pnpm test

# Проверить типы
pnpm check

# Форматировать код
pnpm format

# Применить миграции БД
pnpm db:push

Дорожная карта

  • Dashboard с мониторингом кластера
  • Реальная интеграция Ollama API (34 модели)
  • Терминальный чат с LLM
  • Docker Swarm Stack
  • gRPC API для агентов (Go)
  • Стриминг ответов LLM в чате
  • CRUD агентов через UI
  • Подключение реального Docker API для нод
  • Telegram-коннектор
  • Система скиллов (Self-Evolution)
  • Аутентификация и RBAC

Лицензия

MIT — используйте свободно для личных и коммерческих проектов.


Разработано в рамках проекта GoClaw — распределённой системы AI-агентов на Go + Docker Swarm.

Description
No description provided
Readme 3 MiB
Languages
TypeScript 84.1%
Go 10.1%
JavaScript 4.4%
Shell 0.8%
CSS 0.5%