/** * Agent Context Management System (Layer 2) * * This system maintains state across all agents without mixing implementation details. * It provides: * - Task registration and tracking * - Inter-agent dependency management * - Structured handoff protocols * - Context window allocation * - Conflict detection */ interface TechnologyStack { language: 'python' | 'nodejs' | 'go' | 'rust' | 'java' | 'unknown'; packageManager: string; framework?: string; projectFiles: string[]; suggestedAgents: string[]; } interface AgentRegistry { language: string; packageFiles: string[]; packageManager: string; agents: string[]; frameworkDetection?: (dependencies: string[]) => string | undefined; } interface Task { taskId: string; description: string; assignedTo: string; status: 'pending' | 'in_progress' | 'completed' | 'blocked'; dependencies: string[]; interfaces: Record; constraints: string[]; estimatedContextTokens: number; createdAt: Date; completedAt?: Date; artifacts?: AgentArtifact; } type InterfaceDefinition = any; type CompletionHandoff = AgentArtifact; interface AgentArtifact { agentId: string; taskId: string; files: string[]; interfaces: Array<{ name: string; file: string; }>; completedAt: Date; metadata: Record; } interface HandoffProtocol { fromAgent: string; toAgent: string; taskId: string; artifacts: { interfaces: Record; implementationNotes: Record; dependencies: string[]; testRequirements: string[]; }; contextBudget: number; } interface ConflictIssue { id: string; severity: 'HIGH' | 'MEDIUM' | 'LOW'; category: string; description: string; affectedTasks: string[]; suggestedFix?: string; detectedAt: Date; } declare class TechnologyDetector { private projectRoot; constructor(projectRoot?: string); /** * Detect the technology stack of the project */ detectStack(): Promise; /** * Find project files that match the given patterns */ private findProjectFiles; /** * Extract dependencies from project files using proper parsers */ private extractDependencies; /** * Get agent recommendations based on detected stack and task description */ getAgentRecommendations(stack: TechnologyStack, taskDescription: string): string[]; } declare class AgentContextHub { private statePath; private projectState; constructor(statePath?: string); registerTask(spec: { description: string; assignedTo: string; dependencies?: string[]; interfaces?: Record; constraints?: string[]; estimatedContextTokens?: number; }): Task; updateTaskStatus(taskId: string, status: Task['status'], artifacts?: Partial): void; getTask(taskId: string): Task | undefined; getAllTasks(): Task[]; getTasksByStatus(status: Task['status']): Task[]; getTasksByAgent(agentId: string): Task[]; canStartTask(taskId: string): { canStart: boolean; blockedBy?: string[]; }; getDependencyGraph(): Map; prepareHandoff(fromTaskId: string, toAgent: string): HandoffProtocol; private extractRelevantInterfaces; allocateContextWindow(agentId: string, tokens: number): void; getContextUsage(): { total: number; byAgent: Map; available: number; }; detectConflicts(): ConflictIssue[]; private detectInterfaceConflicts; private detectDependencyConflicts; getConflicts(): ConflictIssue[]; getProgressReport(): { totalTasks: number; byStatus: Record; completionRate: number; blockedTasks: string[]; activeAgents: string[]; }; /** * Get comprehensive orchestration status for tracking progress */ getOrchestrationStatus(): { progress: { totalTasks: number; byStatus: Record; completionRate: number; blockedTasks: string[]; activeAgents: string[]; }; tasks: Array<{ taskId: string; description: string; status: Task['status']; assignedTo: string; dependencies: string[]; artifacts?: Task['artifacts']; }>; conflicts: ConflictIssue[]; interfaces: Array<{ name: string; definition: InterfaceDefinition; }>; }; /** * Get detailed information for a specific task */ getTaskDetails(taskId: string): { task: Task | undefined; dependsOn: Task[]; blockedBy: Task[]; completion?: CompletionHandoff; }; /** * Get information needed to resume an orchestration session */ getResumableOrchestration(): { hasState: boolean; progress: { totalTasks: number; byStatus: Record; completionRate: number; blockedTasks: string[]; activeAgents: string[]; } | null; nextTasks: Task[]; blockedTasks: Array<{ task: Task; blockedBy: string[]; }>; }; private loadState; private saveState; clearState(): void; private generateTaskId; } declare class WaveOrchestrator { private contextHub; private maxContextPerWave; constructor(contextHub: AgentContextHub); deployWaves(tasks: Task[]): Task[][]; private topologicalSort; } export { type AgentArtifact, AgentContextHub, type AgentRegistry, type CompletionHandoff, type ConflictIssue, type HandoffProtocol, type InterfaceDefinition, type Task, TechnologyDetector, type TechnologyStack, WaveOrchestrator };