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

@@ -13,11 +13,13 @@ A Clawdbot skill for integrating with Mosaic Stack's Ideas/Brain API.
## Installation
1. Copy this skill to your Clawdbot skills directory or link it:
```bash
ln -s ~/src/mosaic-stack/packages/skills/brain ~/.config/clawdbot/skills/mosaic-brain
```
2. Configure your Mosaic Stack connection:
```bash
mkdir -p ~/.config/mosaic
cat > ~/.config/mosaic/brain.conf <<EOF

View File

@@ -2,7 +2,7 @@
name: mosaic-brain
description: Capture ideas, brain dumps, and semantic search across your Mosaic Stack knowledge base.
homepage: https://mosaicstack.dev
metadata: {"clawdbot":{"emoji":"🧠","requires":{"bins":["curl","jq"]}}}
metadata: { "clawdbot": { "emoji": "🧠", "requires": { "bins": ["curl", "jq"] } } }
---
# Mosaic Brain
@@ -13,6 +13,7 @@ Capture and search ideas, brain dumps, and notes in your Mosaic Stack workspace.
1. Ensure Mosaic Stack API is running (default: `http://localhost:3001`)
2. Set environment variables:
```bash
export MOSAIC_API_URL="http://localhost:3001"
export MOSAIC_WORKSPACE_ID="your-workspace-uuid"
@@ -29,7 +30,9 @@ Capture and search ideas, brain dumps, and notes in your Mosaic Stack workspace.
## Common Commands
### Quick Brain Dump
Capture an idea quickly without thinking about categorization:
```bash
# Quick capture
./brain.sh capture "Had a great idea about using AI for code reviews"
@@ -39,7 +42,9 @@ Capture an idea quickly without thinking about categorization:
```
### Create Detailed Idea
Create an idea with full metadata:
```bash
./brain.sh create \
--title "New Feature Idea" \
@@ -49,7 +54,9 @@ Create an idea with full metadata:
```
### Semantic Search
Search your brain using natural language:
```bash
# Query your knowledge base
./brain.sh query "What did I say about AI and code reviews?"
@@ -59,6 +66,7 @@ Search your brain using natural language:
```
### List Ideas
```bash
# List recent ideas
./brain.sh list
@@ -68,11 +76,13 @@ Search your brain using natural language:
```
### Get Specific Idea
```bash
./brain.sh get <idea-id>
```
### Update Idea
```bash
./brain.sh update <idea-id> \
--title "Updated Title" \
@@ -81,11 +91,13 @@ Search your brain using natural language:
```
### Delete Idea
```bash
./brain.sh delete <idea-id>
```
### Tag Management
```bash
# List all tags
./brain.sh tags
@@ -113,11 +125,13 @@ The skill uses these Mosaic Stack API endpoints:
## Configuration
Config file priority:
1. Environment variables
2. `~/.config/mosaic/brain.conf`
3. Default values
Required settings:
- `MOSAIC_API_URL` - API base URL (default: http://localhost:3001)
- `MOSAIC_WORKSPACE_ID` - Your workspace UUID
- `MOSAIC_API_TOKEN` - Authentication token
@@ -125,6 +139,7 @@ Required settings:
## Usage from Clawdbot
Natural language examples:
- "Remember this..." / "Note to self..." → Quick capture
- "What did I say about..." → Semantic search
- "Show me my recent ideas" → List ideas