import type { AgentLifecycleHooks, SwarmAgentDef } from "./types.js"; export type SwarmEventType = "agent_start" | "agent_complete" | "agent_error"; export interface SwarmEvent { type: SwarmEventType; agentId: string; timestamp: number; data?: unknown; } export type SwarmEventListener = (event: SwarmEvent) => void; export declare class SwarmTracer { private events; private listeners; private readonly maxEvents; constructor(maxEvents?: number); /** * Subscribe to live events. The callback fires synchronously on each * `record()` call. Returns an unsubscribe function for convenience. */ subscribe(listener: SwarmEventListener): () => void; /** Remove a previously registered listener. */ unsubscribe(listener: SwarmEventListener): void; /** * Generate lifecycle hooks for a specific agent that record events * into this tracer's timeline. */ hooksFor(_agentId: string): AgentLifecycleHooks; /** * Auto-attach tracing hooks to all agents in the array. * Returns a new array with hooks set — does not mutate the input. */ instrument>(agents: SwarmAgentDef[]): SwarmAgentDef[]; /** Record a custom event into the timeline. Notifies all live subscribers. */ record(event: SwarmEvent): void; /** Get a copy of the full event timeline. */ getTimeline(): SwarmEvent[]; /** Get events for a specific agent. */ getAgentEvents(agentId: string): SwarmEvent[]; /** Compute aggregate metrics from the timeline. */ metrics(): SwarmMetrics; /** Clear all recorded events. */ clear(): void; } export interface SwarmMetrics { /** Total wall-clock duration from first event to last event. */ totalDurationMs: number; /** How many agents started, completed, and errored. */ agentCount: { started: number; completed: number; errored: number; }; /** Per-agent latency (start → complete/error) in ms. */ agentLatency: Record; /** Average latency across all agents that finished. */ avgLatencyMs: number; /** Maximum latency across all agents that finished. */ maxLatencyMs: number; } //# sourceMappingURL=tracer.d.ts.map