/** * SMI-643: SwarmIndexer - Parallel repository indexing with swarm coordination * * Provides: * - Partition repositories by letter range (A-F, G-L, M-R, S-Z) * - Spawn parallel indexer workers * - Coordinate via claude-flow swarm * - Aggregate results to shared database * - Rate limit coordination across workers */ import { type GitHubIndexerOptions, type IndexResult } from './GitHubIndexer.js'; import { PartitionStrategy, type Partition, type PartitionStats, type PartitionOptions } from './PartitionStrategy.js'; import type { SkillCreateInput } from '../types/skill.js'; /** * Worker status for tracking parallel execution */ export type WorkerStatus = 'idle' | 'running' | 'completed' | 'failed'; /** * Individual worker state */ export interface WorkerState { id: string; partition: Partition; status: WorkerStatus; startedAt?: Date; completedAt?: Date; result?: IndexResult; error?: string; } /** * Options for swarm indexing */ export interface SwarmIndexerOptions extends GitHubIndexerOptions { /** Partition strategy options */ partition?: PartitionOptions; /** Maximum concurrent workers (default: 4) */ maxConcurrentWorkers?: number; /** Global rate limit per second across all workers */ globalRateLimit?: number; /** Whether to use claude-flow swarm coordination */ useSwarmCoordination?: boolean; /** Callback for worker status updates */ onWorkerUpdate?: (worker: WorkerState) => void; /** Callback for progress updates */ onProgress?: (progress: SwarmProgress) => void; } /** * Progress tracking for swarm indexing */ export interface SwarmProgress { totalWorkers: number; completedWorkers: number; runningWorkers: number; failedWorkers: number; totalRepositories: number; indexedRepositories: number; percentage: number; } /** * Aggregated result from all workers */ export interface SwarmIndexResult { /** Total execution time in ms */ duration: number; /** Individual worker results */ workers: WorkerState[]; /** Aggregated index result */ aggregated: IndexResult; /** Partition statistics */ partitionStats: PartitionStats; /** Rate limit information */ rateLimitInfo: RateLimitInfo; } /** * Rate limit tracking */ export interface RateLimitInfo { totalRequests: number; requestsPerSecond: number; throttledRequests: number; remainingQuota: number; } /** * Coordinates parallel repository indexing across multiple workers */ export declare class SwarmIndexer { private indexer; private strategy; private options; private workers; private rateLimitTokens; private lastTokenRefill; constructor(options?: SwarmIndexerOptions); /** * Get rate limit token for a request */ private acquireRateLimitToken; /** * Delay helper */ private delay; /** * Update worker state and notify callbacks */ private updateWorkerState; /** * Calculate and notify progress */ private notifyProgress; /** * Index repositories for a single partition */ private indexPartition; /** * Run a single worker */ private runWorker; /** * Run workers with concurrency control */ private runWorkersWithConcurrency; /** * Aggregate results from all workers */ private aggregateResults; /** * Generate ruflo swarm command (for external execution) */ generateSwarmCommand(): string; /** * Run parallel indexing across all partitions */ indexAll(): Promise; /** * Index a specific partition (for external worker coordination) */ indexPartitionById(partitionId: string): Promise; /** * Convert all indexed repositories to SkillCreateInput */ convertToSkills(result: SwarmIndexResult): SkillCreateInput[]; /** * Get the partition strategy */ getStrategy(): PartitionStrategy; /** * Get current worker states */ getWorkerStates(): WorkerState[]; /** * Reset the indexer state */ reset(): void; } /** * Create a SwarmIndexer with default options */ export declare function createSwarmIndexer(options?: SwarmIndexerOptions): SwarmIndexer; /** * Create a SwarmIndexer configured for claude-flow coordination */ export declare function createClaudeFlowSwarmIndexer(token?: string): SwarmIndexer; //# sourceMappingURL=SwarmIndexer.d.ts.map