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:
Jason Woltje
2026-02-03 14:37:06 -06:00
parent a8c8af21e5
commit 12abdfe81d
405 changed files with 13545 additions and 2153 deletions

View File

@@ -7,24 +7,28 @@ The Mosaic Stack web UI provides a PDA-friendly interface for managing tasks and
## Features
### Authentication
- **Login Page:** Clean landing page with Authentik OIDC integration
- **Session Management:** Automatic session refresh and validation
- **Protected Routes:** Automatic redirect for unauthenticated users
- **Logout:** Clean session termination
### Task Management
- **Task List View:** Grouped by date (Today, Tomorrow, This Week, etc.)
- **PDA-Friendly Language:** No demanding terms like "overdue" or "urgent"
- **Status Indicators:** Visual emoji-based status (🟢 In Progress, ⚪ Not Started, etc.)
- **Priority Badges:** Calm, non-aggressive priority display
### Calendar
- **Event List View:** Chronological event display
- **Time Display:** Clear start/end times with location
- **Date Grouping:** Same grouping as tasks for consistency
- **All-Day Events:** Proper handling of all-day events
### Navigation
- **Fixed Header:** Always accessible navigation
- **Active Route Highlighting:** Clear visual indication
- **User Display:** Shows logged-in user name/email
@@ -33,10 +37,12 @@ The Mosaic Stack web UI provides a PDA-friendly interface for managing tasks and
## PDA-Friendly Design Principles
### Language
-**Never Use:** OVERDUE, URGENT, CRITICAL, MUST DO, REQUIRED
-**Always Use:** Target passed, Approaching target, High priority, Recommended
### Status Indicators
- 🟢 In Progress / Active
- 🔵 Not Started / Upcoming
- ⏸️ Paused / On hold
@@ -45,6 +51,7 @@ The Mosaic Stack web UI provides a PDA-friendly interface for managing tasks and
- ⚪ Default/Other
### Visual Design
- **10-second scannability:** Key info immediately visible
- **Visual chunking:** Clear sections with headers
- **Single-line items:** Compact, scannable lists
@@ -90,11 +97,13 @@ apps/web/src/
## API Integration
### Authentication Endpoints
- `GET /auth/session` - Get current session
- `POST /auth/sign-out` - Logout
- `GET /auth/callback/authentik` - OIDC callback
### Future Endpoints (Mock Data Ready)
- `GET /api/tasks` - List tasks
- `GET /api/events` - List events
@@ -127,12 +136,14 @@ pnpm test:coverage
## Testing
### Test Coverage
- **API Client:** 100% coverage
- **Auth Context:** Comprehensive tests
- **Date Utilities:** All functions tested
- **Components:** Tests for all major components
### Running Tests
```bash
# All tests
pnpm test
@@ -173,6 +184,7 @@ pnpm test:coverage
### For Developers
**Adding a New Component:**
1. Create component in appropriate directory
2. Write tests FIRST (TDD)
3. Implement component
@@ -180,6 +192,7 @@ pnpm test:coverage
5. Export from index if needed
**Connecting Real API:**
```typescript
// Replace mock data with real API call
import { useQuery } from "@tanstack/react-query";
@@ -192,6 +205,7 @@ const { data: tasks, isLoading } = useQuery({
```
**Using Shared Types:**
```typescript
import type { Task, Event, AuthUser } from "@mosaic/shared";
import { TaskStatus, TaskPriority } from "@mosaic/shared";