/** * Instance Matcher Service * Provides intelligent instance selection based on tags and connection status. */ /** * Minimal instance interface for matching - works with any instance type that has an id. */ export interface MatchableInstance { id: string; enabled?: boolean; tags?: Record; [key: string]: unknown; } /** * Extended service instance with connection status for matching. */ export interface InstanceWithStatus extends MatchableInstance { connected?: boolean; } /** * Calculates the match score between an instance and requested tags. * * The score ranges from 0.0 (no match) to 1.0 (perfect match). * Calculated as the ratio of matching tags to total requested tags. * * @param instance - The service instance to evaluate * @param requestedTags - The tags to match against * @returns Match score between 0.0 and 1.0 */ export declare function calculateMatchScore(instance: MatchableInstance, requestedTags: Record | undefined): number; /** * Filters instances to only include enabled ones. * * @param instances - Array of instances to filter * @returns Array of enabled instances */ export declare function filterEnabledInstances(instances: T[]): T[]; /** * Sorts instances by connection status (connected first). * * Preserves the original order within each status group. * * @param instances - Array of instances with connection status * @returns Sorted array with connected instances first */ export declare function sortByConnectionStatus(instances: T[]): T[]; /** * Selects the best matching instance based on tags and connection status. * * Selection priority: * 1. Only consider enabled instances * 2. Prioritize connected instances over disconnected ones (ALWAYS prefer connected if available) * 3. Among connected instances, select the one with highest tag match score * 4. Among disconnected instances, select the one with highest tag match score * 5. Only return undefined if NO connected instances AND tags requested but no match * * @param instances - Array of instances to choose from * @param requestedTags - Optional tags to match * @returns The best matching instance, or undefined if no suitable instance found */ export declare function selectBestMatch(instances: T[], requestedTags: Record | undefined): T | undefined; //# sourceMappingURL=instance-matcher.d.ts.map