/** * Swarm Observer * ADR-031: Strange Loop Self-Awareness * * Collects swarm state through self-observation. This is the "Observe" step * in the strange loop: Observe -> Model -> Decide -> Act */ import type { SwarmHealthObservation, AgentHealthMetrics, AgentNode, CommunicationEdge } from './types.js'; /** * Interface for retrieving agent information from the swarm */ export interface AgentProvider { /** Get all active agents */ getAgents(): Promise; /** Get communication edges between agents */ getEdges(): Promise; /** Get health metrics for a specific agent */ getAgentHealth(agentId: string): Promise; /** Get the current observer's agent ID */ getObserverId(): string; } /** * Default in-memory agent provider for testing and simple deployments */ export declare class InMemoryAgentProvider implements AgentProvider { private agents; private edges; private healthMetrics; private observerId; constructor(observerId?: string); getAgents(): Promise; getEdges(): Promise; getAgentHealth(agentId: string): Promise; getObserverId(): string; addAgent(agent: AgentNode): void; removeAgent(agentId: string): void; addEdge(edge: CommunicationEdge): void; setHealthMetrics(agentId: string, metrics: AgentHealthMetrics): void; clear(): void; } /** * Observes the swarm state and produces health observations */ export declare class SwarmObserver { private provider; private topologyAnalyzer; private lastObservation; constructor(provider: AgentProvider); /** * Perform a complete observation of the swarm state */ observe(): Promise; /** * Get the last observation (if any) */ getLastObservation(): SwarmHealthObservation | null; /** * Detect the type of topology based on structure */ private detectTopologyType; /** * Calculate degree (number of connections) for an agent */ private calculateDegree; /** * Detect vulnerabilities in the swarm */ private detectVulnerabilities; /** * Find agents that depend on a given agent */ private findDependentAgents; /** * Calculate overall swarm health score (0-1) */ private calculateOverallHealth; } /** * Create a swarm observer with the given provider */ export declare function createSwarmObserver(provider: AgentProvider): SwarmObserver; /** * Create a swarm observer with an in-memory provider */ export declare function createInMemorySwarmObserver(observerId?: string): { observer: SwarmObserver; provider: InMemoryAgentProvider; }; //# sourceMappingURL=swarm-observer.d.ts.map