/** * agent-registry.ts — in-process agent lifecycle registry (BizarAgentRegistry). * * F-032 — ported from ruflo `v3/@claude-flow/swarm/src/coordination/agent-registry.ts` * (lines 33, 127, 159, 268, 286). Bizar does not ship a full agent runtime; * the registry is a stateful, in-memory record of agent metadata that the MCP * tools can read/write. The Claude Code Agent SDK is the actual orchestrator; * this registry is a thin coordination surface for `agent_spawn`, * `agent_list`, and `agent_terminate`. * * No subprocess, no event bus. Heartbeat is a no-op stub that updates a * timestamp so downstream observers can poll liveness. * * Persistence is opt-in: pass `{ persistPath }` to the constructor (or * to the `bizarAgentRegistry` singleton via its mutator) and the registry * writes a JSON snapshot to disk after every mutation. This keeps the * in-process test path pure while letting the MCP singleton survive a * Claude Code session restart. */ export type AgentStatus = "active" | "terminated"; /** * Bizar's typed-agent allowlist. Mirrors the six typed agents in * `config/agents/` (coder / tester / reviewer / system-architect / * planner / researcher) plus three ruflo-derived typed routes * (performance-engineer / security-auditor / context-specialist). * `registerAgent` rejects anything outside this set so the MCP tools * surface a typed vocabulary callers can rely on. */ export declare const AGENT_TYPES: readonly ["coder", "tester", "reviewer", "system-architect", "planner", "researcher", "performance-engineer", "security-auditor", "context-specialist"]; export type AllowedAgentType = (typeof AGENT_TYPES)[number]; export declare function isAllowedAgentType(t: unknown): t is AllowedAgentType; export interface AgentRecord { agentId: string; type: AllowedAgentType; name?: string; status: AgentStatus; priority?: "low" | "normal" | "high" | "critical"; metadata?: Record; taskCount: number; createdAt: string; lastHeartbeatAt: string; terminatedAt?: string; terminationReason?: string; gracefulTermination?: boolean; } export interface RegisterAgentInput { type: string; name?: string; priority?: "low" | "normal" | "high" | "critical"; metadata?: Record; } export interface RegisterAgentResult { agentId: string; status: AgentStatus; } export interface ListAgentsInput { status?: AgentStatus | "all"; type?: string; limit?: number; offset?: number; } export interface ListAgentsResult { agents: AgentRecord[]; total: number; } export interface TerminateAgentInput { agentId: string; reason?: string; graceful?: boolean; } export interface TerminateAgentResult { agentId: string; status: AgentStatus; terminatedAt: string; } export interface BizarAgentRegistryOpts { /** * When set, the registry loads from this file on construction (if it * exists) and writes a JSON snapshot after every mutation. The parent * directory is created on demand. Path resolution is the caller's * responsibility — the registry treats the value as final. */ persistPath?: string; } export declare class BizarAgentRegistry { private readonly agents; private readonly seenIds; private persistPath?; constructor(opts?: BizarAgentRegistryOpts); /** * Configure (or clear) the persistence path after construction. * The next mutation will write a snapshot to the new location. */ setPersistPath(path: string | undefined): void; /** * Generate a unique agent id of the form `agent-`. Uses * `crypto.randomUUID()` so the IDs are stable across processes * and there is no retry loop on collision (UUID v4 has a 122-bit * random payload). */ private nextAgentId; registerAgent(input: RegisterAgentInput): RegisterAgentResult; listAgents(input?: ListAgentsInput): ListAgentsResult; terminateAgent(input: TerminateAgentInput): TerminateAgentResult; getAgent(agentId: string): AgentRecord | undefined; /** * No-op heartbeat stub. Updates `lastHeartbeatAt` so callers can poll * liveness. Returns true if the agent was found. */ heartbeat(agentId: string): boolean; /** * Bump the per-agent task counter (used by orchestration callers). */ incrementTaskCount(agentId: string, by?: number): number; /** * Test/dev helper: drop everything. Not exposed via MCP. */ reset(): void; /** * Total agents currently tracked (any status). */ size(): number; private loadFromDisk; private persist; } /** * Process-wide singleton used by MCP tools. Persistence defaults to * `.harness/agents.json` in the current working directory so the * registry survives a Claude Code session restart on the same machine. * Tests should construct their own `new BizarAgentRegistry()` to get * an isolated, non-persistent instance. */ export declare const bizarAgentRegistry: BizarAgentRegistry; //# sourceMappingURL=agent-registry.d.ts.map