/** * Base Source Adapter * Abstract base class providing common functionality for source adapters * * SMI-1013: Enhanced with token bucket rate limiting and request queuing */ import type { ISourceAdapter } from './ISourceAdapter.js'; import { RateLimiter, type RateLimitConfig as TokenBucketConfig } from '../security/index.js'; import { type RetryConfig } from '../utils/retry.js'; import type { SourceConfig, SourceLocation, SourceRepository, SourceSearchOptions, SourceSearchResult, SkillContent, SourceHealth } from './types.js'; /** * Extended source config with token bucket rate limiting (SMI-1013) */ export interface ExtendedSourceConfig extends SourceConfig { /** Use token bucket rate limiter with queue support (SMI-1013) */ useTokenBucket?: boolean; /** Token bucket configuration (overrides legacy rateLimit) */ tokenBucketConfig?: TokenBucketConfig; /** Enable retry logic for transient network failures (SMI-880) */ enableRetry?: boolean; /** Retry configuration (SMI-880) */ retryConfig?: RetryConfig; } /** * Abstract base class for source adapters * * Provides: * - Configuration management * - Rate limiting * - Request timing * - Error handling utilities * * Subclasses must implement: * - search() * - getRepository() * - fetchSkillContent() * - doHealthCheck() */ export declare abstract class BaseSourceAdapter implements ISourceAdapter { readonly config: ExtendedSourceConfig; readonly id: string; readonly name: string; readonly type: string; protected initialized: boolean; protected lastRequestTime: number; protected requestCount: number; protected windowStart: number; /** Token bucket rate limiter (SMI-1013) */ protected rateLimiter: RateLimiter | null; constructor(config: SourceConfig | ExtendedSourceConfig); /** * Initialize the adapter * Override in subclasses for custom initialization */ initialize(): Promise; /** * Subclass initialization hook */ protected doInitialize(): Promise; /** * Check source health */ checkHealth(): Promise; /** * Subclass health check implementation */ protected abstract doHealthCheck(): Promise>; /** * Search for repositories */ abstract search(options: SourceSearchOptions): Promise; /** * Get repository metadata */ abstract getRepository(location: SourceLocation): Promise; /** * Fetch skill content */ abstract fetchSkillContent(location: SourceLocation): Promise; /** * Check if skill exists at location */ skillExists(location: SourceLocation): Promise; /** * Get skill file SHA for change detection */ getSkillSha(location: SourceLocation): Promise; /** * Dispose of resources */ dispose(): Promise; /** * Subclass disposal hook */ protected doDispose(): Promise; /** * Wait for rate limit before making a request */ protected waitForRateLimit(): Promise; /** * Make a rate-limited fetch request with retry support * * SMI-1013: Uses token bucket rate limiter with queue support when enabled, * otherwise falls back to legacy window-based rate limiting. * * SMI-880: Automatically retries on transient network failures (ETIMEDOUT, * ECONNRESET, 5xx) with exponential backoff when enableRetry is true. */ protected fetchWithRateLimit(url: string, options?: RequestInit): Promise; /** * Get rate limiter status (SMI-1013) * * Returns information about the token bucket rate limiter state, * including queue status if queuing is enabled. */ getRateLimiterStatus(): { usingTokenBucket: boolean; queueStatus?: { totalQueued: number; queues: Map; } | number; }; /** * Update rate limit tracking from response headers */ protected updateRateLimitFromResponse(response: Response): void; /** * Build the default skill file path */ protected getDefaultSkillPath(location: SourceLocation): string; /** * Build the default branch */ protected getDefaultBranch(location: SourceLocation): string; /** * Delay helper */ protected delay(ms: number): Promise; /** * Validate configuration */ protected validateConfig(): void; } //# sourceMappingURL=BaseSourceAdapter.d.ts.map