Files
ruvnet__ruflo/v3/implementation/adrs/ADR-027-GAPS.md
rUv f0168962c8 feat: Add @claude-flow/teammate-plugin with MCP tools and IPFS registry (#1013)
* feat(adr): Add ADR-027 Native TeammateTool Integration

Comprehensive architecture for integrating Claude Flow with Claude Code's
native TeammateTool multi-agent orchestration system (v2.1.19+).

Key features:
- TeammateBridge: Core bridge class with all 13 TeammateTool operations
- Team management: spawn, discover, join/leave workflows
- Mailbox integration: Inter-agent messaging via ~/.claude/teams/
- Plan approval: Submit, approve/reject, launch swarm workflow
- MCP tools: 9 new tools exposing native capabilities
- Claude Flow integration: Topology and agent type mapping
- Security model: Explicit tool grants, approval quorums
- Migration path: Native when available, MCP fallback

Based on analysis of Claude Code v2.1.19 binary confirming:
- 34 TeammateTool references
- 154 Teammate class references
- 22 spawnTeam operations
- CLAUDE_CODE_TEAM_NAME environment variable
- tmux and in_process spawn backends

Refs: ADR-018, gist/kieranklaassen/d2b35569be2c7f1412c64861a219d51f

* docs: Add architectural comparison between Claude Flow V3 and TeammateTool

Detailed side-by-side analysis showing 92% architectural overlap between
Claude Flow V3's swarm system and Claude Code's TeammateTool (v2.1.19).

Key findings:
- Identical concepts: team/swarm, topology, agent types, message bus
- Same workflows: join/leave approval, plan consensus, broadcast
- Matching structures: agent state, message format, spawn backends
- Different terminology: same underlying architecture

Comparison includes:
- Core architecture mapping
- Data structure comparison
- Code examples from both systems
- Timeline analysis
- 30+ side-by-side comparisons

Refs: Claude Flow V3 source, Claude Code v2.1.19 binary analysis

* docs(adr): Add ADR-027 gap analysis - 15 missing features identified

Comprehensive analysis of features missing from the TeammateTool plugin:

CRITICAL (Phase 1):
- Delegate mode: Authority delegation between teammates
- Team context: Shared variables, permissions, environment
- Permission updates: Dynamic permission changes mid-execution
- Session memory: Persist context across sessions

HIGH PRIORITY (Phase 2):
- Remote sync: pushToRemote to Claude.ai
- Transcript sharing: Share messages between teammates
- Error handling: Recovery strategies, error types
- Memory bridge: Sync to Claude Flow HNSW

MEDIUM (Phase 3):
- Teleport: Resume teams across terminal instances
- Plan control: Pause/resume/reentry for plans
- Hook integration: Claude Flow hook system
- Consensus bridge: Native vs advanced algorithms

LOW (Phase 4):
- tmux backend config: Pane layouts, prefix keys
- Worker threads: Parallel execution within teammate
- Swarm teammate type: Optimized for parallel tasks

Estimated additional code: ~1,550 lines (total: ~2,950)

* feat(teammate-plugin): Complete @claude-flow/teammate-plugin implementation

Implements all 15 features from ADR-027 gap analysis:

Core Features:
- TeammateBridge class with version detection (>= 2.1.19)
- Team management (spawn, discover, load teams)
- Teammate spawning with AgentInput schema
- Mailbox messaging (direct and broadcast)
- Plan approval workflow (submit, approve, reject, launch)

Extended Features:
- Delegate mode (delegateToTeammate, revokeDelegation)
- Remote sync (pushToRemote, pullFromRemote, syncWithRemote)
- Session memory persistence (save/load)
- Team context management (shared variables, permissions)
- Teleport (resume teams across terminal instances)
- Plan control (pause, resume, re-enter plan mode)
- Transcript sharing between teammates
- Error handling with 18 error codes

Package includes:
- 16 MCP tools for complete TeammateTool integration
- TDD test suite with Vitest
- Comprehensive README with version requirements
- TypeScript definitions (~500 lines)
- ~2000 lines total implementation

Requires Claude Code >= 2.1.19 for native TeammateTool support.

* security+perf(teammate-plugin): Add comprehensive security hardening and optimizations

Security Improvements:
- Add input validation for team/teammate names (path traversal prevention)
- Implement SAFE_NAME_PATTERN regex for alphanumeric+dash+underscore only
- Add RESERVED_NAMES blocklist to prevent .., config, state exploitation
- Implement validatePath() to ensure paths stay within teams directory
- Add safeJSONParse() with size limits (1MB max) to prevent DoS
- Sanitize environment variables to remove control characters
- Set restrictive file permissions (0o600 for files, 0o700 for dirs)
- Add MAX_PARAM_LENGTH and MAX_ARRAY_ITEMS validation in MCP tools
- Export SECURITY_LIMITS constants for configurability

Performance Optimizations:
- Add debounced file writes (500ms) to reduce I/O operations
- Implement team config caching with 30s TTL
- Add flushPendingWrites() for graceful cleanup
- Add invalidateConfigCache() on team changes

Security Constants:
- MAX_NAME_LENGTH: 64 characters
- MAX_PAYLOAD_SIZE: 1MB
- MAX_TEAMMATES_PER_TEAM: 50
- MAX_MESSAGES_PER_MAILBOX: 1000
- MAX_DELEGATION_DEPTH: 5

Addresses OWASP:
- A01:2021 Path Traversal
- A03:2021 Injection
- A05:2021 Security Misconfiguration

* feat(teammate-plugin): Add rate limiting, metrics, health checks, and circuit breaker

Production-ready features for enterprise deployment:

Rate Limiting:
- Configurable limits for spawn, messages, broadcasts, plans
- Per-minute sliding window with automatic reset
- Remaining quota tracking and rate limit state access
- Default: 10 spawns, 100 messages, 20 broadcasts per minute

Metrics & Telemetry:
- Counter metrics: teams, teammates, messages, errors, etc.
- Gauge metrics: active teams, active teammates, pending plans
- Histogram metrics: spawn latency, message latency, approval latency
- Percentile calculations (p50, p95, p99)
- MetricSnapshot for point-in-time observability

Health Checks:
- Per-teammate health monitoring with configurable intervals
- Health states: healthy, degraded, unhealthy, unknown
- Consecutive failure/success thresholds
- Team-level health reports with overall status
- Auto-emit events on status changes

Circuit Breaker Pattern:
- States: closed, open, half-open
- Configurable failure/success thresholds
- Timeout protection on external calls
- Automatic reset after cooldown period

Retry Logic:
- Exponential backoff with configurable multiplier
- Max delay cap to prevent infinite waits
- Retryable error codes for selective retry
- withRetry() helper function

New Configuration Constants:
- RATE_LIMIT_DEFAULTS
- HEALTH_CHECK_DEFAULTS
- RETRY_DEFAULTS
- DEFAULT_CIRCUIT_BREAKER_CONFIG

Public API Additions:
- getMetrics(), getLatencyPercentile(), resetMetrics()
- getTeammateHealth(), getTeamHealth()
- getRateLimitRemaining(), isRateLimited(), resetRateLimits()
- getCircuitBreakerState(), resetCircuitBreaker()

Integrated into operations:
- spawnTeammate: rate limiting + latency tracking + health checks
- sendMessage: rate limiting + latency tracking
- broadcast: rate limiting + metrics

* feat(teammate-plugin): Add BMSSP-powered optimization (10-15x faster)

- Add @ruvnet/bmssp dependency for WebAssembly graph optimization
- Create TopologyOptimizer with WasmGraph integration for shortest path
  computation, topology statistics, and optimization suggestions
- Create SemanticRouter with WasmNeuralBMSSP for intelligent task-to-
  teammate matching using skill embeddings and neural pathfinding
- Integrate optimizers into TeammateBridge with enableOptimizers(),
  findOptimalPath(), getTopologyStats(), findBestTeammateForTask()
- Add 5 new MCP tools for optimization (21 total):
  - teammate_enable_optimizers
  - teammate_find_optimal_path
  - teammate_get_topology_stats
  - teammate_route_task
  - teammate_batch_route
- JavaScript fallback when WASM unavailable
- Performance learning via updateTeammatePerformance()

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:09:07Z
- Changes: 6 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:09:17Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:10:35Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:10:36Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:10:37Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:10:38Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:10:39Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:10:40Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:11:39Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:11:47Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:12:00Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:13:27Z
- Changes: 33 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:13:50Z
- Changes: 2 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:14:34Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:17:14Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:17:41Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:17:55Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:18:40Z
- Changes: 2 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:19:21Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:19:52Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:20:03Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:20:10Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:20:16Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:22:03Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:22:10Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:22:16Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:29:59Z
- Changes: 6 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:30:47Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:31:00Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: claude/review-claude-flow-integration-A0c3R
- Timestamp: 2026-01-25T15:32:20Z
- Changes: 2 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update README.md: Revise badge section and enhance documentation structure

* fix: Use main branch README.md to resolve conflicts

Co-Authored-By: claude-flow <ruv@ruv.net>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-25 10:35:31 -05:00

14 KiB

ADR-027 Gap Analysis: Missing Plugin Features

Date: 2026-01-25 Status: Action Required Related: ADR-027-teammate-tool-integration.md


Executive Summary

Analysis of Claude Code v2.1.19 reveals 15 major capabilities not yet addressed in ADR-027's plugin design. These represent significant functionality gaps that would limit the plugin's effectiveness.


1. Critical Missing Features

1.1 Delegate Mode (Priority: HIGH)

Evidence in binary:

"delegate" (17 refs)
"delegate_mode" (4 refs)
"delegate_mode_exit" (4 refs)
"delegateMode" (1 ref)

What it does:

  • Allows coordinator to delegate authority to teammates
  • Teammates can make decisions without approval
  • Reduces round-trip approval latency

Missing from plugin:

// NEED TO ADD
interface TeammateSpawnConfig {
  // ...existing fields...
  delegateAuthority?: boolean;       // Can this teammate delegate?
  delegatedPermissions?: string[];   // What can they approve?
  delegationDepth?: number;          // How many levels of delegation?
}

// NEED TO ADD
async delegateToTeammate(
  teamName: string,
  fromId: string,
  toId: string,
  permissions: string[]
): Promise<void>;

async revokeDelegation(
  teamName: string,
  fromId: string,
  toId: string
): Promise<void>;

1.2 Remote Agent / Push to Remote (Priority: HIGH)

Evidence in binary:

"remote_agent" (11 refs)
"pushToRemote" (in ExitPlanModeInput)
"remoteSessionId" (in ExitPlanModeInput)
"remoteSessionUrl" (in ExitPlanModeInput)

What it does:

  • Sync local session to Claude.ai web interface
  • Allow teammates to continue work in browser
  • Cross-device session continuity

Missing from plugin:

// NEED TO ADD
interface RemoteSyncConfig {
  enabled: boolean;
  autoSync: boolean;
  syncInterval: number;  // ms
}

// NEED TO ADD
async pushTeamToRemote(teamName: string): Promise<{
  remoteSessionId: string;
  remoteSessionUrl: string;
}>;

async pullFromRemote(remoteSessionId: string): Promise<TeamState>;

async syncWithRemote(teamName: string): Promise<SyncResult>;

1.3 Session Memory & Transcript (Priority: HIGH)

Evidence in binary:

"session_memory" (8 refs)
"session_transcript" (5 refs)
"nested_memory" (4 refs)
"ultramemory" (3 refs)
"tengu_session_memory" (2 refs)

What it does:

  • Persist teammate context across sessions
  • Share transcripts between teammates
  • Nested memory for hierarchical context

Missing from plugin:

// NEED TO ADD
interface TeammateMemory {
  sessionId: string;
  teammateId: string;
  transcript: Message[];
  context: Record<string, unknown>;
  nestedMemories: TeammateMemory[];  // For hierarchical teams
}

// NEED TO ADD
async saveTeammateMemory(
  teamName: string,
  teammateId: string
): Promise<void>;

async loadTeammateMemory(
  teamName: string,
  teammateId: string
): Promise<TeammateMemory | null>;

async shareTranscript(
  teamName: string,
  fromId: string,
  toId: string,
  messageRange?: { start: number; end: number }
): Promise<void>;

1.4 Teleport / Session Resume (Priority: MEDIUM)

Evidence in binary:

"tengu_teleport_resume_session" (2 refs)
"tengu_teleport_resume_error" (3 refs)
"tengu_teleport_error_repo_not_in_git_dir_sessions_api" (1 ref)
"tengu_teleport_error_repo_mismatch_sessions_api" (1 ref)

What it does:

  • Resume team sessions across terminal instances
  • Maintain team state when switching contexts
  • Git-aware session resumption

Missing from plugin:

// NEED TO ADD
interface TeleportConfig {
  autoResume: boolean;
  gitAware: boolean;
  preserveMailbox: boolean;
}

// NEED TO ADD
async teleportTeam(
  teamName: string,
  targetContext: {
    workingDirectory?: string;
    gitRepo?: string;
    sessionId?: string;
  }
): Promise<TeamState>;

async canTeleport(teamName: string): Promise<{
  canTeleport: boolean;
  blockers?: string[];
}>;

1.5 Team Context & Permissions (Priority: HIGH)

Evidence in binary:

"team_context" (4 refs)
"team_permission_update" (3 refs)
"no_team_context" (1 ref)
"team_not_found" (3 refs)

What it does:

  • Shared context across all teammates
  • Dynamic permission updates during execution
  • Context inheritance for new teammates

Missing from plugin:

// NEED TO ADD
interface TeamContext {
  teamName: string;
  sharedVariables: Record<string, unknown>;
  inheritedPermissions: string[];
  workingDirectory: string;
  gitBranch?: string;
  environmentVariables: Record<string, string>;
}

// NEED TO ADD
async updateTeamContext(
  teamName: string,
  updates: Partial<TeamContext>
): Promise<void>;

async updateTeammatePermissions(
  teamName: string,
  teammateId: string,
  permissions: {
    add?: string[];
    remove?: string[];
  }
): Promise<void>;

async getTeamContext(teamName: string): Promise<TeamContext>;

1.6 Plan Mode Re-entry (Priority: MEDIUM)

Evidence in binary:

"plan_mode" (7 refs)
"plan_mode_exit" (6 refs)
"plan_mode_reentry" (4 refs)

What it does:

  • Re-enter plan mode after partial execution
  • Modify plan mid-execution
  • Handle plan failures gracefully

Missing from plugin:

// NEED TO ADD
async reenterPlanMode(
  teamName: string,
  planId: string,
  options?: {
    fromStep?: number;
    modifications?: PlanStep[];
  }
): Promise<TeamPlan>;

async pausePlanExecution(
  teamName: string,
  planId: string
): Promise<void>;

async resumePlanExecution(
  teamName: string,
  planId: string,
  fromStep?: number
): Promise<void>;

1.7 Worker Threads (Priority: LOW)

Evidence in binary:

"worker_threads" (2 refs)
"workers" (1 ref)
"worker" (1 ref)
"worker_permission_prompt" (3 refs)

What it does:

  • Parallel execution within a single teammate
  • CPU-intensive task offloading
  • Shared memory between workers

Missing from plugin:

// NEED TO ADD (for advanced use cases)
interface WorkerConfig {
  maxWorkers: number;
  sharedMemory: boolean;
  taskQueue: 'fifo' | 'priority';
}

async spawnWorker(
  teamName: string,
  teammateId: string,
  task: WorkerTask
): Promise<string>;  // Returns worker ID

1.8 Swarm Teammate Type (Priority: MEDIUM)

Evidence in binary:

"swarm_teammate" (1 ref)

What it does:

  • Special teammate type for swarm coordination
  • Different spawning behavior than regular teammates
  • Optimized for parallel task execution

Missing from plugin:

// NEED TO ADD
type TeammateType = 'regular' | 'swarm' | 'coordinator' | 'worker';

interface TeammateSpawnConfig {
  // ...existing fields...
  teammateType?: TeammateType;
}

2. Missing Spawn Backend Details

2.1 tmux Backend Configuration

Evidence:

"tmux" (26 refs)
CLAUDE_CODE_TMUX_SESSION
CLAUDE_CODE_TMUX_PREFIX

Missing from plugin:

// NEED TO ADD
interface TmuxBackendConfig {
  sessionName?: string;
  windowName?: string;
  paneLayout?: 'tiled' | 'even-horizontal' | 'even-vertical';
  prefixKey?: string;
  shellCommand?: string;
  environment?: Record<string, string>;
}

async configureTmuxBackend(config: TmuxBackendConfig): Promise<void>;

async getTmuxPanes(sessionName: string): Promise<{
  paneId: string;
  teammateId: string;
  active: boolean;
}[]>;

async focusTmuxPane(sessionName: string, paneId: string): Promise<void>;

2.2 In-Process Backend Details

Evidence:

"in_process_teammate" (18 refs)
"InProcessTeammateTask" (1 ref)

Missing from plugin:

// NEED TO ADD
interface InProcessConfig {
  maxConcurrent: number;
  memoryLimit: number;  // bytes
  timeoutMs: number;
  isolationLevel: 'none' | 'vm' | 'worker';
}

async getInProcessTeammates(): Promise<{
  teammateId: string;
  memoryUsage: number;
  cpuTime: number;
  status: string;
}[]>;

3. Missing MCP Tools

The following MCP tools should be added:

Tool Purpose Priority
teammate_delegate Delegate authority to teammate HIGH
teammate_push_remote Sync team to Claude.ai HIGH
teammate_save_memory Persist teammate context HIGH
teammate_share_transcript Share messages between teammates HIGH
teammate_update_context Update team shared context HIGH
teammate_update_permissions Dynamic permission changes HIGH
teammate_teleport Resume team in new context MEDIUM
teammate_pause_plan Pause plan execution MEDIUM
teammate_resume_plan Resume paused plan MEDIUM
teammate_reenter_plan Modify and re-enter plan mode MEDIUM
teammate_configure_tmux Configure tmux backend LOW
teammate_spawn_worker Spawn worker thread LOW

4. Missing Event Handlers

The bridge should emit these additional events:

// NEED TO ADD to TeammateBridge
interface TeammateBridgeEvents {
  // Existing events...

  // Missing events:
  'delegate:granted': { team: string; from: string; to: string; permissions: string[] };
  'delegate:revoked': { team: string; from: string; to: string };
  'remote:pushed': { team: string; remoteUrl: string };
  'remote:synced': { team: string; changes: number };
  'memory:saved': { team: string; teammateId: string };
  'memory:loaded': { team: string; teammateId: string };
  'transcript:shared': { team: string; from: string; to: string };
  'context:updated': { team: string; keys: string[] };
  'permissions:updated': { team: string; teammateId: string };
  'plan:paused': { team: string; planId: string };
  'plan:resumed': { team: string; planId: string };
  'teleport:started': { team: string; target: object };
  'teleport:completed': { team: string; target: object };
  'worker:spawned': { team: string; teammateId: string; workerId: string };
  'worker:completed': { team: string; workerId: string; result: unknown };
}

5. Missing Integration with Claude Flow

5.1 Memory System Bridge

Need to bridge TeammateTool's session_memory with Claude Flow's HNSW-indexed memory:

// NEED TO ADD
class MemoryBridge {
  async syncTeammateMemoryToHNSW(
    teamName: string,
    teammateId: string
  ): Promise<void>;

  async queryTeammateContext(
    teamName: string,
    query: string,
    limit?: number
  ): Promise<ContextMatch[]>;

  async embedTeammateTranscript(
    teamName: string,
    teammateId: string
  ): Promise<void>;
}

5.2 Hook Integration

Need hooks for TeammateTool events:

// NEED TO ADD to Claude Flow hooks
const teammateHooks = {
  'teammate:pre-spawn': async (config: TeammateSpawnConfig) => { /* validate */ },
  'teammate:post-spawn': async (teammate: TeammateInfo) => { /* track */ },
  'teammate:pre-message': async (message: MailboxMessage) => { /* filter */ },
  'teammate:post-message': async (message: MailboxMessage) => { /* log */ },
  'teammate:plan-submitted': async (plan: TeamPlan) => { /* analyze */ },
  'teammate:plan-approved': async (plan: TeamPlan) => { /* notify */ },
};

5.3 Consensus Integration

Bridge TeammateTool's approval with Claude Flow's consensus:

// NEED TO ADD
class Consensusbridge {
  async mapTeammatePlanToConsensus(
    plan: TeamPlan
  ): Promise<ConsensusProposal>;

  async mapConsensusToTeammatePlan(
    proposal: ConsensusProposal
  ): Promise<TeamPlan>;

  async hybridConsensus(
    teamName: string,
    proposal: unknown,
    algorithm: 'native' | 'raft' | 'byzantine'
  ): Promise<ConsensusResult>;
}

6. Missing Error Handling

6.1 Error Types

// NEED TO ADD
class TeammateError extends Error {
  constructor(
    message: string,
    public code: TeammateErrorCode,
    public teamName?: string,
    public teammateId?: string
  ) {
    super(message);
  }
}

enum TeammateErrorCode {
  TEAM_NOT_FOUND = 'TEAM_NOT_FOUND',
  TEAMMATE_NOT_FOUND = 'TEAMMATE_NOT_FOUND',
  ALREADY_IN_TEAM = 'ALREADY_IN_TEAM',
  NO_TEAM_CONTEXT = 'NO_TEAM_CONTEXT',
  PLAN_NOT_APPROVED = 'PLAN_NOT_APPROVED',
  DELEGATION_DENIED = 'DELEGATION_DENIED',
  REMOTE_SYNC_FAILED = 'REMOTE_SYNC_FAILED',
  TELEPORT_FAILED = 'TELEPORT_FAILED',
  MAILBOX_FULL = 'MAILBOX_FULL',
  PERMISSION_DENIED = 'PERMISSION_DENIED',
  TIMEOUT = 'TIMEOUT',
}

6.2 Recovery Strategies

// NEED TO ADD
interface RecoveryConfig {
  maxRetries: number;
  retryDelayMs: number;
  fallbackToMCP: boolean;
  autoCleanupOnError: boolean;
}

async recoverFromError(
  error: TeammateError,
  context: RecoveryContext
): Promise<RecoveryResult>;

7. Summary: Priority Implementation Order

Phase 1 (Critical - Week 1)

  1. ✅ Core bridge (already in ADR-027)
  2. ⚠️ ADD: Team Context management
  3. ⚠️ ADD: Permission updates
  4. ⚠️ ADD: Delegate mode
  5. ⚠️ ADD: Session memory persistence

Phase 2 (High Priority - Week 2)

  1. ⚠️ ADD: Remote sync (pushToRemote)
  2. ⚠️ ADD: Transcript sharing
  3. ⚠️ ADD: Error handling & recovery
  4. ⚠️ ADD: Memory bridge to HNSW

Phase 3 (Medium Priority - Week 3)

  1. ⚠️ ADD: Teleport/session resume
  2. ⚠️ ADD: Plan pause/resume/reentry
  3. ⚠️ ADD: Hook integration
  4. ⚠️ ADD: Consensus bridge

Phase 4 (Nice to Have - Week 4)

  1. ⚠️ ADD: tmux backend configuration
  2. ⚠️ ADD: Worker threads
  3. ⚠️ ADD: Swarm teammate type
  4. ⚠️ ADD: In-process backend configuration

8. Estimated Additional Code

Component Lines of Code Complexity
Delegate Mode ~150 Medium
Remote Sync ~200 High
Session Memory ~250 Medium
Team Context ~100 Low
Teleport ~150 High
Plan Control ~100 Medium
Error Handling ~150 Low
Memory Bridge ~200 High
Hook Integration ~100 Low
Consensus Bridge ~150 Medium
Total Additional ~1,550 -

Current ADR-027 implementation: ~1,400 lines Total plugin size needed: ~2,950 lines


9. Next Steps

  1. Update ADR-027 with missing features
  2. Prioritize Phase 1 implementation
  3. Create test cases for each feature
  4. Document all new MCP tools
  5. Add migration guide for existing Claude Flow users