feat(#93): implement agent spawn via federation
Implements FED-010: Agent Spawn via Federation feature that enables spawning and managing Claude agents on remote federated Mosaic Stack instances via COMMAND message type. Features: - Federation agent command types (spawn, status, kill) - FederationAgentService for handling agent operations - Integration with orchestrator's agent spawner/lifecycle services - API endpoints for spawning, querying status, and killing agents - Full command routing through federation COMMAND infrastructure - Comprehensive test coverage (12/12 tests passing) Architecture: - Hub → Spoke: Spawn agents on remote instances - Command flow: FederationController → FederationAgentService → CommandService → Remote Orchestrator - Response handling: Remote orchestrator returns agent status/results - Security: Connection validation, signature verification Files created: - apps/api/src/federation/types/federation-agent.types.ts - apps/api/src/federation/federation-agent.service.ts - apps/api/src/federation/federation-agent.service.spec.ts Files modified: - apps/api/src/federation/command.service.ts (agent command routing) - apps/api/src/federation/federation.controller.ts (agent endpoints) - apps/api/src/federation/federation.module.ts (service registration) - apps/orchestrator/src/api/agents/agents.controller.ts (status endpoint) - apps/orchestrator/src/api/agents/agents.module.ts (lifecycle integration) Testing: - 12/12 tests passing for FederationAgentService - All command service tests passing - TypeScript compilation successful - Linting passed Refs #93 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,30 +68,30 @@ docker compose up -d
|
||||
|
||||
### Environment Variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `TRAEFIK_MODE` | `none` | Traefik mode: `bundled`, `upstream`, or `none` |
|
||||
| `TRAEFIK_ENABLE` | `false` | Enable Traefik labels on services |
|
||||
| `MOSAIC_API_DOMAIN` | `api.mosaic.local` | Domain for API service |
|
||||
| `MOSAIC_WEB_DOMAIN` | `mosaic.local` | Domain for Web service |
|
||||
| `MOSAIC_AUTH_DOMAIN` | `auth.mosaic.local` | Domain for Authentik service |
|
||||
| `TRAEFIK_NETWORK` | `traefik-public` | External Traefik network (upstream mode) |
|
||||
| `TRAEFIK_TLS_ENABLED` | `true` | Enable TLS/HTTPS |
|
||||
| `TRAEFIK_ACME_EMAIL` | - | Email for Let's Encrypt (production) |
|
||||
| `TRAEFIK_CERTRESOLVER` | - | Cert resolver name (e.g., `letsencrypt`) |
|
||||
| `TRAEFIK_DASHBOARD_ENABLED` | `true` | Enable Traefik dashboard (bundled mode) |
|
||||
| `TRAEFIK_DASHBOARD_PORT` | `8080` | Dashboard port (bundled mode) |
|
||||
| `TRAEFIK_ENTRYPOINT` | `websecure` | Traefik entrypoint (`web` or `websecure`) |
|
||||
| `TRAEFIK_DOCKER_NETWORK` | `mosaic-public` | Docker network for Traefik routing |
|
||||
| Variable | Default | Description |
|
||||
| --------------------------- | ------------------- | ---------------------------------------------- |
|
||||
| `TRAEFIK_MODE` | `none` | Traefik mode: `bundled`, `upstream`, or `none` |
|
||||
| `TRAEFIK_ENABLE` | `false` | Enable Traefik labels on services |
|
||||
| `MOSAIC_API_DOMAIN` | `api.mosaic.local` | Domain for API service |
|
||||
| `MOSAIC_WEB_DOMAIN` | `mosaic.local` | Domain for Web service |
|
||||
| `MOSAIC_AUTH_DOMAIN` | `auth.mosaic.local` | Domain for Authentik service |
|
||||
| `TRAEFIK_NETWORK` | `traefik-public` | External Traefik network (upstream mode) |
|
||||
| `TRAEFIK_TLS_ENABLED` | `true` | Enable TLS/HTTPS |
|
||||
| `TRAEFIK_ACME_EMAIL` | - | Email for Let's Encrypt (production) |
|
||||
| `TRAEFIK_CERTRESOLVER` | - | Cert resolver name (e.g., `letsencrypt`) |
|
||||
| `TRAEFIK_DASHBOARD_ENABLED` | `true` | Enable Traefik dashboard (bundled mode) |
|
||||
| `TRAEFIK_DASHBOARD_PORT` | `8080` | Dashboard port (bundled mode) |
|
||||
| `TRAEFIK_ENTRYPOINT` | `websecure` | Traefik entrypoint (`web` or `websecure`) |
|
||||
| `TRAEFIK_DOCKER_NETWORK` | `mosaic-public` | Docker network for Traefik routing |
|
||||
|
||||
### Docker Compose Profiles
|
||||
|
||||
| Profile | Description |
|
||||
|---------|-------------|
|
||||
| Profile | Description |
|
||||
| ----------------- | --------------------------------- |
|
||||
| `traefik-bundled` | Activates bundled Traefik service |
|
||||
| `authentik` | Enables Authentik SSO services |
|
||||
| `ollama` | Enables Ollama AI service |
|
||||
| `full` | Enables all optional services |
|
||||
| `authentik` | Enables Authentik SSO services |
|
||||
| `ollama` | Enables Ollama AI service |
|
||||
| `full` | Enables all optional services |
|
||||
|
||||
## Deployment Scenarios
|
||||
|
||||
@@ -131,6 +131,7 @@ MOSAIC_AUTH_DOMAIN=auth.example.com
|
||||
```
|
||||
|
||||
**Prerequisites:**
|
||||
|
||||
1. DNS records pointing to your server
|
||||
2. Ports 80 and 443 accessible from internet
|
||||
3. Uncomment ACME configuration in `docker/traefik/traefik.yml`
|
||||
@@ -216,6 +217,7 @@ services:
|
||||
```
|
||||
|
||||
Generate basic auth password:
|
||||
|
||||
```bash
|
||||
echo $(htpasswd -nb admin your-password) | sed -e s/\\$/\\$\\$/g
|
||||
```
|
||||
@@ -233,6 +235,7 @@ tls:
|
||||
```
|
||||
|
||||
Mount certificate directory:
|
||||
|
||||
```yaml
|
||||
# docker-compose.override.yml
|
||||
services:
|
||||
@@ -248,7 +251,6 @@ Route multiple domains to different services:
|
||||
```yaml
|
||||
# .env
|
||||
MOSAIC_WEB_DOMAIN=mosaic.local,app.mosaic.local,www.mosaic.local
|
||||
|
||||
# Traefik will match all domains
|
||||
```
|
||||
|
||||
@@ -271,11 +273,13 @@ services:
|
||||
### Services Not Accessible via Domain
|
||||
|
||||
**Check Traefik is running:**
|
||||
|
||||
```bash
|
||||
docker ps | grep traefik
|
||||
```
|
||||
|
||||
**Check Traefik dashboard:**
|
||||
|
||||
```bash
|
||||
# Bundled mode
|
||||
open http://localhost:8080
|
||||
@@ -285,11 +289,13 @@ curl http://localhost:8080/api/http/routers | jq
|
||||
```
|
||||
|
||||
**Verify labels are applied:**
|
||||
|
||||
```bash
|
||||
docker inspect mosaic-api | jq '.Config.Labels'
|
||||
```
|
||||
|
||||
**Check DNS/hosts file:**
|
||||
|
||||
```bash
|
||||
# Local development
|
||||
cat /etc/hosts | grep mosaic
|
||||
@@ -298,10 +304,12 @@ cat /etc/hosts | grep mosaic
|
||||
### Certificate Errors
|
||||
|
||||
**Self-signed certificates (development):**
|
||||
|
||||
- Browser warnings are expected
|
||||
- Add exception in browser or import CA certificate
|
||||
|
||||
**Let's Encrypt failures:**
|
||||
|
||||
```bash
|
||||
# Check Traefik logs
|
||||
docker logs mosaic-traefik
|
||||
@@ -316,21 +324,25 @@ docker exec mosaic-traefik ls -la /letsencrypt/
|
||||
### Upstream Mode Not Connecting
|
||||
|
||||
**Verify external network exists:**
|
||||
|
||||
```bash
|
||||
docker network ls | grep traefik-public
|
||||
```
|
||||
|
||||
**Create network if missing:**
|
||||
|
||||
```bash
|
||||
docker network create traefik-public
|
||||
```
|
||||
|
||||
**Check service network attachment:**
|
||||
|
||||
```bash
|
||||
docker inspect mosaic-api | jq '.NetworkSettings.Networks'
|
||||
```
|
||||
|
||||
**Verify external Traefik can see services:**
|
||||
|
||||
```bash
|
||||
# From external Traefik container
|
||||
docker exec <external-traefik-container> traefik healthcheck
|
||||
@@ -339,6 +351,7 @@ docker exec <external-traefik-container> traefik healthcheck
|
||||
### Port Conflicts
|
||||
|
||||
**Bundled mode port conflicts:**
|
||||
|
||||
```bash
|
||||
# Check what's using ports
|
||||
sudo lsof -i :80
|
||||
@@ -354,17 +367,20 @@ TRAEFIK_DASHBOARD_PORT=8081
|
||||
### Dashboard Not Accessible
|
||||
|
||||
**Check dashboard is enabled:**
|
||||
|
||||
```bash
|
||||
# In .env
|
||||
TRAEFIK_DASHBOARD_ENABLED=true
|
||||
```
|
||||
|
||||
**Verify Traefik configuration:**
|
||||
|
||||
```bash
|
||||
docker exec mosaic-traefik cat /etc/traefik/traefik.yml | grep -A5 "api:"
|
||||
```
|
||||
|
||||
**Access dashboard:**
|
||||
|
||||
```bash
|
||||
# Default
|
||||
http://localhost:8080/dashboard/
|
||||
@@ -389,11 +405,13 @@ http://localhost:${TRAEFIK_DASHBOARD_PORT}/dashboard/
|
||||
### Securing the Dashboard
|
||||
|
||||
**Option 1: Disable in production**
|
||||
|
||||
```bash
|
||||
TRAEFIK_DASHBOARD_ENABLED=false
|
||||
```
|
||||
|
||||
**Option 2: Add basic authentication**
|
||||
|
||||
```yaml
|
||||
# docker-compose.override.yml
|
||||
services:
|
||||
@@ -409,6 +427,7 @@ services:
|
||||
```
|
||||
|
||||
**Option 3: IP whitelist**
|
||||
|
||||
```yaml
|
||||
# docker-compose.override.yml
|
||||
services:
|
||||
|
||||
Reference in New Issue
Block a user