23f7624596
ADR-166 MCP Bridge Security Lock / Static-source security lock (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / Compose default binds loopback + Mongo has auth (push) Failing after 2s
CodeQL Advanced / Analyze (rust) (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / plugin-agent-federation bindHost default (push) Failing after 1s
ADR-166 MCP Bridge Security Lock / Runtime behavior — 401 + terminal gate + fail-closed (push) Failing after 4s
business-pods-smoke / smoke (push) Failing after 1s
all-plugins-smoke / smoke-all (push) Failing after 2s
CI/CD Pipeline / Security & Code Quality (push) Failing after 1s
CI/CD Pipeline / Test Suite (ubuntu-latest) (push) Failing after 1s
CI/CD Pipeline / Build & Package (macos-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (ubuntu-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (windows-latest) (push) Has been skipped
CI/CD Pipeline / Documentation & Examples (push) Failing after 1s
Clone Tracker (14-day rolling) / Snapshot clones for ruflo ecosystem (push) Failing after 1s
CodeQL Advanced / Analyze (actions) (push) Failing after 1s
CodeQL Advanced / Analyze (javascript-typescript) (push) Failing after 1s
federation-peer-rust / stable-noop (push) Failing after 1s
metaharness-ci / score (push) Failing after 1s
metaharness-ci / router-compat (push) Failing after 0s
metaharness-ci / similarity-tests (push) Failing after 0s
no-agentbbs-smoke / smoke-without-agentbbs (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (windows-latest) (push) Has been skipped
codex-integration-audit / Codex integration audit (push) Failing after 1s
helpers-manifest-guard / guard (push) Failing after 1s
🔗 Cross-Agent Integration Tests / 🤝 Agent Coordination Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🧠 Memory Sharing Integration (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🛡️ Fault Tolerance Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / ⚡ Performance Integration Tests (push) Has been skipped
metaharness-ci / mcp-scan (push) Failing after 1s
metaharness-ci / eject-dryrun (push) Failing after 1s
metaharness-ci / metaharness-real-data (push) Failing after 0s
no-cli-optdep-bloat-2561 / guard (push) Failing after 1s
no-metaharness-smoke / smoke-without-metaharness (push) Failing after 1s
no-phantom-agentic-flow-subpath / guard (push) Failing after 1s
🔄 Automated Rollback Manager / 🚨 Failure Detection (push) Failing after 1s
V3 CI/CD Pipeline / Plugin hooks smoke / ubuntu-latest / Node 22 (push) Failing after 1s
V3 CI/CD Pipeline / ruflo-graph-intelligence build + test smoke (#2044, ADR-123) (push) Failing after 1s
CVE Audit Gate / Audit root (critical-blocking) (push) Failing after 2s
cost-tracker-smoke / smoke (push) Failing after 3s
oia-audit-weekly / audit (push) Failing after 2s
ruflo-agent-smoke / ruflo-agent structural smoke (push) Failing after 1s
📊 Status Badges Update / 📊 Update Status Badges (push) Failing after 1s
V3 CI/CD Pipeline / Static regression guards (#2267 YAML + (push) Failing after 1s
V3 CI/CD Pipeline / Test V3 Packages (push) Failing after 0s
V3 CI/CD Pipeline / agent_execute provider routing smoke (#2042) (push) Failing after 0s
CVE Audit Gate / Audit v3 (critical-blocking) (push) Failing after 1s
federation-peer-rust / stable-native (push) Failing after 2s
🔗 Cross-Agent Integration Tests / 🚀 Integration Test Setup (push) Failing after 2s
neural-trader-smoke / runtime-smoke (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (macos-latest) (push) Has been skipped
V3 CI/CD Pipeline / Build V3 (ubuntu-latest) (push) Has been skipped
V3 CI/CD Pipeline / Type Check V3 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 24 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 22 (push) Failing after 2s
V3 CI/CD Pipeline / browser rvf create flag smoke (#2015) (push) Failing after 0s
V3 CI/CD Pipeline / Dependency review (#2046) (push) Has been skipped
V3 CI/CD Pipeline / Supply-chain audit (#2046) (push) Failing after 0s
V3 CI/CD Pipeline / witness marker drift smoke (#2021) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader portfolio CG smoke (#2068, ADR-126 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader backtest signing smoke (#2068, ADR-126 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / kg-extract type-import classification smoke (#2049) (push) Failing after 0s
V3 CI/CD Pipeline / witness verify precondition smoke (#1880) (push) Failing after 2s
V3 CI/CD Pipeline / neural-trader pipeline risk-gate smoke (#2068, ADR-126 Phase 5) (push) Failing after 0s
V3 CI/CD Pipeline / neural-trader feature attribution smoke (#2068, ADR-126 Phase 6) (push) Failing after 0s
V3 CI/CD Pipeline / plugin-registry signature verification smoke (#1922, CWE-347) (push) Failing after 4s
V3 CI/CD Pipeline / memory stats legacy-DB smoke (#2120) (push) Failing after 4s
V3 CI/CD Pipeline / github deprecated actions smoke (#2089, ADR-127 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / graph query + pathfinder smoke (ADR-130 P2+P5) (push) Has been skipped
V3 CI/CD Pipeline / graph trajectory hooks smoke (ADR-130 P3) (push) Has been skipped
V3 CI/CD Pipeline / graph plugin adapter smoke (ADR-130 P4) (push) Has been skipped
V3 CI/CD Pipeline / graph benchmark (ADR-130 P6) (push) Has been skipped
V3 CI/CD Pipeline / statusline generator delegation smoke (#2195) (push) Failing after 1s
V3 CI/CD Pipeline / wizard init regression guard (#2206 (push) Failing after 1s
V3 CI/CD Pipeline / memory no-stray-db smoke (ADR-125 P7) (push) Failing after 1s
V3 CI/CD Pipeline / github-safe injection smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github actions pin smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github attribution opt-in smoke (#2089, ADR-127 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / pre-bash hook safety smoke (#2017) (push) Failing after 1s
V3 CI/CD Pipeline / Memory import smoke / ubuntu-latest (push) Failing after 0s
V3 CI/CD Pipeline / MCP protocol smoke / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / ruvllm WASM auto-init smoke (#2086) (push) Failing after 4s
V3 CI/CD Pipeline / MCP paired-tool round-trip smoke (#1889) (push) Failing after 1s
V3 CI/CD Pipeline / Plugin package install-safety (#1902/#1903/#1904) (push) Failing after 1s
V3 CI/CD Pipeline / Tool description discoverability (ADR-112) (push) Failing after 3s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (22) (push) Failing after 1s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (24) (push) Failing after 1s
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Vector-index dimension audit (#1947) (push) Failing after 0s
V3 CI/CD Pipeline / Hook-command install safety (#1921) (push) Failing after 1s
V3 CI/CD Pipeline / ToolOutputGuardrail smoke (ADR-131, (push) Failing after 1s
V3 CI/CD Pipeline / init-bundle invariants smoke (#2095, ADR-128 Phase 5) (push) Failing after 1s
V3 CI/CD Pipeline / wasm provider bridge smoke (ADR-129 P1) (push) Failing after 2s
V3 CI/CD Pipeline / wasm gallery CRUD smoke (ADR-129 P3) (push) Failing after 1s
V3 CI/CD Pipeline / wasm plugin bridge smoke (ADR-129 P4) (push) Failing after 0s
V3 CI/CD Pipeline / wasm compose smoke (ADR-129 P2) (push) Failing after 4s
V3 CI/CD Pipeline / graph schema smoke (ADR-130 P1) (push) Failing after 0s
Validate Marketplace / validate (push) Failing after 1s
🔍 Verification Pipeline / 🚀 Setup Verification (push) Failing after 1s
🔍 Verification Pipeline / 🛡️ Security Verification (push) Has been skipped
🔍 Verification Pipeline / 📝 Code Quality (push) Has been skipped
🔍 Verification Pipeline / 🧪 Test Verification (${{ matrix.os }}, Node ${{ matrix.node }}) (push) Has been skipped
🔍 Verification Pipeline / 🏗️ Build Verification (push) Has been skipped
🔍 Verification Pipeline / 📚 Documentation Verification (push) Has been skipped
CVE Audit Gate / High-severity report (warn only) (push) Has been cancelled
🔄 Automated Rollback Manager / 🔄 Execute Rollback (push) Has been cancelled
🔄 Automated Rollback Manager / ✅ Post-Rollback Verification (push) Has been cancelled
🔄 Automated Rollback Manager / 📊 Rollback Monitoring (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / windows-latest (push) Has been cancelled
🔄 Automated Rollback Manager / ⏳ Manual Rollback Approval (push) Has been cancelled
V3 CI/CD Pipeline / MCP protocol smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Memory import smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / ubuntu-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Publish to npm (alpha) (push) Has been cancelled
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / macos-latest / Node 22 (push) Has been cancelled
V3 CI/CD Pipeline / Plugin hooks smoke / macos-latest / Node 22 (push) Has been cancelled
CI/CD Pipeline / Deploy & Release (push) Has been cancelled
CI/CD Pipeline / CI Status (push) Has been cancelled
🔗 Cross-Agent Integration Tests / 📊 Integration Test Report (push) Has been cancelled
🔄 Automated Rollback Manager / 🔍 Pre-Rollback Validation (push) Has been cancelled
🔍 Verification Pipeline / ⚡ Performance Verification (push) Has been cancelled
🔍 Verification Pipeline / 📊 Verification Report (push) Has been cancelled
499 lines
15 KiB
JavaScript
499 lines
15 KiB
JavaScript
/**
|
|
* V3 MCP Federation Tools
|
|
*
|
|
* MCP tools for federation hub and ephemeral agent management:
|
|
* - federation/status - Get federation status
|
|
* - federation/spawn-ephemeral - Spawn ephemeral agent
|
|
* - federation/terminate-ephemeral - Terminate ephemeral agent
|
|
* - federation/list-ephemeral - List ephemeral agents
|
|
* - federation/register-swarm - Register swarm with federation
|
|
* - federation/broadcast - Broadcast message to all swarms
|
|
* - federation/propose - Propose federation-wide consensus
|
|
* - federation/vote - Vote on consensus proposal
|
|
*
|
|
* Implements ADR-005: MCP-First API Design
|
|
* Implements ADR-001: agentic-flow@alpha compatibility
|
|
*/
|
|
import { z } from 'zod';
|
|
import { getDefaultFederationHub, } from '../../@claude-flow/swarm/src/federation-hub.js';
|
|
// ============================================================================
|
|
// Input Schemas
|
|
// ============================================================================
|
|
const spawnEphemeralSchema = z.object({
|
|
type: z.string()
|
|
.describe('Agent type (e.g., "coder", "researcher", "tester")'),
|
|
task: z.string()
|
|
.describe('Task description for the ephemeral agent'),
|
|
swarmId: z.string().optional()
|
|
.describe('Target swarm ID (auto-select if not specified)'),
|
|
ttl: z.number().optional()
|
|
.describe('Time-to-live in milliseconds'),
|
|
capabilities: z.array(z.string()).optional()
|
|
.describe('Required capabilities'),
|
|
priority: z.enum(['low', 'normal', 'high', 'critical']).default('normal')
|
|
.describe('Priority for swarm selection'),
|
|
waitForCompletion: z.boolean().default(false)
|
|
.describe('Wait for agent to complete'),
|
|
completionTimeout: z.number().optional()
|
|
.describe('Timeout when waiting for completion (ms)'),
|
|
});
|
|
const terminateEphemeralSchema = z.object({
|
|
agentId: z.string()
|
|
.describe('Ephemeral agent ID to terminate'),
|
|
reason: z.string().optional()
|
|
.describe('Reason for termination'),
|
|
});
|
|
const listEphemeralSchema = z.object({
|
|
swarmId: z.string().optional()
|
|
.describe('Filter by swarm ID'),
|
|
status: z.enum(['spawning', 'active', 'completing', 'terminated']).optional()
|
|
.describe('Filter by status'),
|
|
limit: z.number().default(50)
|
|
.describe('Maximum results to return'),
|
|
});
|
|
const registerSwarmSchema = z.object({
|
|
swarmId: z.string()
|
|
.describe('Unique swarm identifier'),
|
|
name: z.string()
|
|
.describe('Human-readable swarm name'),
|
|
capabilities: z.array(z.string())
|
|
.describe('Swarm capabilities'),
|
|
maxAgents: z.number().default(100)
|
|
.describe('Maximum agents this swarm can handle'),
|
|
endpoint: z.string().optional()
|
|
.describe('Swarm communication endpoint'),
|
|
});
|
|
const broadcastSchema = z.object({
|
|
sourceSwarmId: z.string()
|
|
.describe('Source swarm ID'),
|
|
message: z.unknown()
|
|
.describe('Message payload to broadcast'),
|
|
});
|
|
const proposeSchema = z.object({
|
|
proposerId: z.string()
|
|
.describe('Proposer swarm ID'),
|
|
type: z.string()
|
|
.describe('Proposal type'),
|
|
value: z.unknown()
|
|
.describe('Proposal value'),
|
|
timeoutMs: z.number().default(30000)
|
|
.describe('Proposal timeout in milliseconds'),
|
|
});
|
|
const voteSchema = z.object({
|
|
swarmId: z.string()
|
|
.describe('Voting swarm ID'),
|
|
proposalId: z.string()
|
|
.describe('Proposal ID to vote on'),
|
|
approve: z.boolean()
|
|
.describe('Whether to approve the proposal'),
|
|
});
|
|
// ============================================================================
|
|
// Global Hub Instance
|
|
// ============================================================================
|
|
let hubInstance = null;
|
|
function getHub() {
|
|
if (!hubInstance) {
|
|
hubInstance = getDefaultFederationHub();
|
|
}
|
|
return hubInstance;
|
|
}
|
|
// ============================================================================
|
|
// Tool Handlers
|
|
// ============================================================================
|
|
/**
|
|
* Get federation status
|
|
*/
|
|
async function handleFederationStatus(input, context) {
|
|
const hub = getHub();
|
|
const stats = hub.getStats();
|
|
const swarms = hub.getSwarms();
|
|
return {
|
|
stats,
|
|
swarms: swarms.map(s => ({
|
|
swarmId: s.swarmId,
|
|
name: s.name,
|
|
status: s.status,
|
|
agentCount: s.currentAgents,
|
|
maxAgents: s.maxAgents,
|
|
})),
|
|
};
|
|
}
|
|
/**
|
|
* Spawn an ephemeral agent
|
|
*/
|
|
async function handleSpawnEphemeral(input, context) {
|
|
const hub = getHub();
|
|
return hub.spawnEphemeralAgent({
|
|
type: input.type,
|
|
task: input.task,
|
|
swarmId: input.swarmId,
|
|
ttl: input.ttl,
|
|
capabilities: input.capabilities,
|
|
priority: input.priority,
|
|
waitForCompletion: input.waitForCompletion,
|
|
completionTimeout: input.completionTimeout,
|
|
});
|
|
}
|
|
/**
|
|
* Terminate an ephemeral agent
|
|
*/
|
|
async function handleTerminateEphemeral(input, context) {
|
|
const hub = getHub();
|
|
const error = input.reason ? new Error(input.reason) : undefined;
|
|
const terminated = await hub.terminateAgent(input.agentId, error);
|
|
return {
|
|
terminated,
|
|
agentId: input.agentId,
|
|
reason: input.reason,
|
|
};
|
|
}
|
|
/**
|
|
* List ephemeral agents
|
|
*/
|
|
async function handleListEphemeral(input, context) {
|
|
const hub = getHub();
|
|
let agents = hub.getAgents(input.swarmId);
|
|
// Filter by status
|
|
if (input.status) {
|
|
agents = agents.filter(a => a.status === input.status);
|
|
}
|
|
// Limit results
|
|
agents = agents.slice(0, input.limit);
|
|
return {
|
|
agents: agents.map(a => ({
|
|
id: a.id,
|
|
swarmId: a.swarmId,
|
|
type: a.type,
|
|
task: a.task,
|
|
status: a.status,
|
|
ttl: a.ttl,
|
|
createdAt: a.createdAt.toISOString(),
|
|
expiresAt: a.expiresAt.toISOString(),
|
|
})),
|
|
total: agents.length,
|
|
};
|
|
}
|
|
/**
|
|
* Register a swarm with the federation
|
|
*/
|
|
async function handleRegisterSwarm(input, context) {
|
|
const hub = getHub();
|
|
hub.registerSwarm({
|
|
swarmId: input.swarmId,
|
|
name: input.name,
|
|
capabilities: input.capabilities,
|
|
maxAgents: input.maxAgents,
|
|
currentAgents: 0,
|
|
status: 'active',
|
|
endpoint: input.endpoint,
|
|
});
|
|
return {
|
|
registered: true,
|
|
swarmId: input.swarmId,
|
|
};
|
|
}
|
|
/**
|
|
* Broadcast message to all swarms
|
|
*/
|
|
async function handleBroadcast(input, context) {
|
|
const hub = getHub();
|
|
const sent = await hub.broadcast(input.sourceSwarmId, input.message);
|
|
return {
|
|
sent,
|
|
sourceSwarmId: input.sourceSwarmId,
|
|
};
|
|
}
|
|
/**
|
|
* Propose federation-wide consensus
|
|
*/
|
|
async function handlePropose(input, context) {
|
|
const hub = getHub();
|
|
const proposal = await hub.propose(input.proposerId, input.type, input.value, input.timeoutMs);
|
|
return {
|
|
proposalId: proposal.id,
|
|
status: proposal.status,
|
|
expiresAt: proposal.expiresAt.toISOString(),
|
|
};
|
|
}
|
|
/**
|
|
* Vote on a consensus proposal
|
|
*/
|
|
async function handleVote(input, context) {
|
|
const hub = getHub();
|
|
const voted = hub.vote(input.swarmId, input.proposalId, input.approve);
|
|
return {
|
|
voted,
|
|
proposalId: input.proposalId,
|
|
swarmId: input.swarmId,
|
|
approve: input.approve,
|
|
};
|
|
}
|
|
// ============================================================================
|
|
// Tool Definitions
|
|
// ============================================================================
|
|
export const federationStatusTool = {
|
|
name: 'federation/status',
|
|
description: 'Get federation hub status including swarms and ephemeral agents',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {},
|
|
},
|
|
handler: async (input, context) => {
|
|
return handleFederationStatus({}, context);
|
|
},
|
|
category: 'federation',
|
|
tags: ['federation', 'status', 'monitoring'],
|
|
version: '1.0.0',
|
|
cacheable: true,
|
|
cacheTTL: 5000,
|
|
};
|
|
export const spawnEphemeralTool = {
|
|
name: 'federation/spawn-ephemeral',
|
|
description: 'Spawn an ephemeral agent for a short-lived task',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
type: {
|
|
type: 'string',
|
|
description: 'Agent type',
|
|
},
|
|
task: {
|
|
type: 'string',
|
|
description: 'Task description',
|
|
},
|
|
swarmId: {
|
|
type: 'string',
|
|
description: 'Target swarm ID (optional)',
|
|
},
|
|
ttl: {
|
|
type: 'number',
|
|
description: 'Time-to-live in milliseconds',
|
|
},
|
|
capabilities: {
|
|
type: 'array',
|
|
items: { type: 'string' },
|
|
description: 'Required capabilities',
|
|
},
|
|
priority: {
|
|
type: 'string',
|
|
enum: ['low', 'normal', 'high', 'critical'],
|
|
description: 'Priority for swarm selection',
|
|
default: 'normal',
|
|
},
|
|
waitForCompletion: {
|
|
type: 'boolean',
|
|
description: 'Wait for agent completion',
|
|
default: false,
|
|
},
|
|
completionTimeout: {
|
|
type: 'number',
|
|
description: 'Completion timeout (ms)',
|
|
},
|
|
},
|
|
required: ['type', 'task'],
|
|
},
|
|
handler: async (input, context) => {
|
|
const validated = spawnEphemeralSchema.parse(input);
|
|
return handleSpawnEphemeral(validated, context);
|
|
},
|
|
category: 'federation',
|
|
tags: ['federation', 'ephemeral', 'spawn', 'agent'],
|
|
version: '1.0.0',
|
|
};
|
|
export const terminateEphemeralTool = {
|
|
name: 'federation/terminate-ephemeral',
|
|
description: 'Terminate an ephemeral agent',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
agentId: {
|
|
type: 'string',
|
|
description: 'Ephemeral agent ID',
|
|
},
|
|
reason: {
|
|
type: 'string',
|
|
description: 'Termination reason',
|
|
},
|
|
},
|
|
required: ['agentId'],
|
|
},
|
|
handler: async (input, context) => {
|
|
const validated = terminateEphemeralSchema.parse(input);
|
|
return handleTerminateEphemeral(validated, context);
|
|
},
|
|
category: 'federation',
|
|
tags: ['federation', 'ephemeral', 'terminate', 'agent'],
|
|
version: '1.0.0',
|
|
};
|
|
export const listEphemeralTool = {
|
|
name: 'federation/list-ephemeral',
|
|
description: 'List ephemeral agents in the federation',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
swarmId: {
|
|
type: 'string',
|
|
description: 'Filter by swarm ID',
|
|
},
|
|
status: {
|
|
type: 'string',
|
|
enum: ['spawning', 'active', 'completing', 'terminated'],
|
|
description: 'Filter by status',
|
|
},
|
|
limit: {
|
|
type: 'number',
|
|
description: 'Maximum results',
|
|
default: 50,
|
|
},
|
|
},
|
|
},
|
|
handler: async (input, context) => {
|
|
const validated = listEphemeralSchema.parse(input);
|
|
return handleListEphemeral(validated, context);
|
|
},
|
|
category: 'federation',
|
|
tags: ['federation', 'ephemeral', 'list', 'agent'],
|
|
version: '1.0.0',
|
|
cacheable: true,
|
|
cacheTTL: 2000,
|
|
};
|
|
export const registerSwarmTool = {
|
|
name: 'federation/register-swarm',
|
|
description: 'Register a swarm with the federation hub',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
swarmId: {
|
|
type: 'string',
|
|
description: 'Unique swarm identifier',
|
|
},
|
|
name: {
|
|
type: 'string',
|
|
description: 'Human-readable swarm name',
|
|
},
|
|
capabilities: {
|
|
type: 'array',
|
|
items: { type: 'string' },
|
|
description: 'Swarm capabilities',
|
|
},
|
|
maxAgents: {
|
|
type: 'number',
|
|
description: 'Maximum agents',
|
|
default: 100,
|
|
},
|
|
endpoint: {
|
|
type: 'string',
|
|
description: 'Communication endpoint',
|
|
},
|
|
},
|
|
required: ['swarmId', 'name', 'capabilities'],
|
|
},
|
|
handler: async (input, context) => {
|
|
const validated = registerSwarmSchema.parse(input);
|
|
return handleRegisterSwarm(validated, context);
|
|
},
|
|
category: 'federation',
|
|
tags: ['federation', 'swarm', 'register'],
|
|
version: '1.0.0',
|
|
};
|
|
export const broadcastTool = {
|
|
name: 'federation/broadcast',
|
|
description: 'Broadcast a message to all swarms in the federation',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
sourceSwarmId: {
|
|
type: 'string',
|
|
description: 'Source swarm ID',
|
|
},
|
|
message: {
|
|
description: 'Message payload',
|
|
},
|
|
},
|
|
required: ['sourceSwarmId', 'message'],
|
|
},
|
|
handler: async (input, context) => {
|
|
const validated = broadcastSchema.parse(input);
|
|
return handleBroadcast(validated, context);
|
|
},
|
|
category: 'federation',
|
|
tags: ['federation', 'broadcast', 'message'],
|
|
version: '1.0.0',
|
|
};
|
|
export const proposeTool = {
|
|
name: 'federation/propose',
|
|
description: 'Propose a value for federation-wide consensus',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
proposerId: {
|
|
type: 'string',
|
|
description: 'Proposer swarm ID',
|
|
},
|
|
type: {
|
|
type: 'string',
|
|
description: 'Proposal type',
|
|
},
|
|
value: {
|
|
description: 'Proposal value',
|
|
},
|
|
timeoutMs: {
|
|
type: 'number',
|
|
description: 'Proposal timeout (ms)',
|
|
default: 30000,
|
|
},
|
|
},
|
|
required: ['proposerId', 'type', 'value'],
|
|
},
|
|
handler: async (input, context) => {
|
|
const validated = proposeSchema.parse(input);
|
|
return handlePropose(validated, context);
|
|
},
|
|
category: 'federation',
|
|
tags: ['federation', 'consensus', 'propose'],
|
|
version: '1.0.0',
|
|
};
|
|
export const voteTool = {
|
|
name: 'federation/vote',
|
|
description: 'Vote on a federation consensus proposal',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
swarmId: {
|
|
type: 'string',
|
|
description: 'Voting swarm ID',
|
|
},
|
|
proposalId: {
|
|
type: 'string',
|
|
description: 'Proposal ID',
|
|
},
|
|
approve: {
|
|
type: 'boolean',
|
|
description: 'Approve or reject',
|
|
},
|
|
},
|
|
required: ['swarmId', 'proposalId', 'approve'],
|
|
},
|
|
handler: async (input, context) => {
|
|
const validated = voteSchema.parse(input);
|
|
return handleVote(validated, context);
|
|
},
|
|
category: 'federation',
|
|
tags: ['federation', 'consensus', 'vote'],
|
|
version: '1.0.0',
|
|
};
|
|
// ============================================================================
|
|
// Exports
|
|
// ============================================================================
|
|
export const federationTools = [
|
|
federationStatusTool,
|
|
spawnEphemeralTool,
|
|
terminateEphemeralTool,
|
|
listEphemeralTool,
|
|
registerSwarmTool,
|
|
broadcastTool,
|
|
proposeTool,
|
|
voteTool,
|
|
];
|
|
export default federationTools;
|
|
//# sourceMappingURL=federation-tools.js.map
|