/** * Orchestrator Context - Shared state and service access for all services * * This interface provides a clean abstraction for services to access * shared state without tight coupling to the orchestrator. */ import { EventEmitter } from 'events'; import type { MCPDefinition, MCPConnection, ToolDefinition } from '../types/connection.js'; import type { ToolInfo } from '../types/discovery.js'; /** * Events emitted by the orchestrator for cross-service communication */ export interface OrchestratorEvents { 'mcp:indexed': { mcpName: string; tools: ToolDefinition[]; }; 'mcp:failed': { mcpName: string; error: Error; }; 'mcp:connected': { mcpName: string; }; 'mcp:disconnected': { mcpName: string; }; 'skill:added': { skillName: string; }; 'skill:removed': { skillName: string; }; 'skill:updated': { skillName: string; }; 'photon:loaded': { photonName: string; }; 'photon:removed': { photonName: string; }; 'photon:updated': { photonName: string; }; 'tools:changed': { added: string[]; removed: string[]; }; 'state:saved': { timestamp: number; }; 'state:restored': { timestamp: number; }; } /** * Type-safe event emitter for orchestrator events */ export declare class TypedEventEmitter extends EventEmitter { emit(event: K, data: OrchestratorEvents[K]): boolean; on(event: K, listener: (data: OrchestratorEvents[K]) => void): this; once(event: K, listener: (data: OrchestratorEvents[K]) => void): this; off(event: K, listener: (data: OrchestratorEvents[K]) => void): this; } /** * Service names for the service container */ export type ServiceName = 'stateManager' | 'connectionPool' | 'toolDiscovery' | 'toolExecution' | 'skills' | 'photons' | 'cache' | 'indexing' | 'resourcePrompts'; /** * Read-only view of orchestrator state for services * * Services should NOT mutate this state directly - they should use * the appropriate service methods and events instead. */ export interface OrchestratorState { readonly definitions: Map; readonly connections: Map; readonly toolToMCP: Map; readonly allTools: ToolInfo[]; readonly skillPrompts: Map; } /** * Mutable state that can be updated by the StateManager * Only StateManager should have access to this interface */ export interface MutableOrchestratorState { definitions: Map; connections: Map; toolToMCP: Map; allTools: ToolInfo[]; skillPrompts: Map; } /** * Orchestrator context passed to all services * * Provides access to: * - Read-only state views * - Event emitter for cross-service communication * - Service locator for accessing other services */ export interface OrchestratorContext { /** * Read-only view of the current state */ readonly state: OrchestratorState; /** * Event emitter for cross-service communication */ readonly events: TypedEventEmitter; /** * Get a service by name */ getService(name: ServiceName): T; /** * Profile name being used */ readonly profileName: string; /** * Client info for MCP connections */ readonly clientInfo: { name: string; version: string; }; } /** * Interface for services that need to update shared state * Only StateManager implements this fully */ export interface StateUpdater { /** * Update definitions map */ setDefinition(name: string, definition: MCPDefinition): void; /** * Remove a definition */ removeDefinition(name: string): void; /** * Add a tool mapping */ addToolMapping(toolName: string, mcpName: string): void; /** * Remove a tool mapping */ removeToolMapping(toolName: string): void; /** * Add a tool to allTools */ addTool(tool: ToolInfo): void; /** * Remove a tool from allTools */ removeTool(toolName: string, mcpName: string): void; /** * Set a skill prompt */ setSkillPrompt(name: string, prompt: unknown): void; /** * Remove a skill prompt */ removeSkillPrompt(name: string): void; } //# sourceMappingURL=orchestrator-context.d.ts.map