xc-mcp
Version:
MCP server that wraps Xcode command-line tools for iOS/macOS development workflows
125 lines • 3.69 kB
TypeScript
import { ViewFingerprint } from '../utils/view-fingerprinting.js';
/**
* Cached coordinate with confidence tracking
* Following xcode-agent recommendation for confidence decay
*/
export interface CachedCoordinate {
elementId: string;
elementType: string;
x: number;
y: number;
relativeX?: number;
relativeY?: number;
bounds?: {
width: number;
height: number;
};
confidence: number;
successCount: number;
failureCount: number;
createdAt: Date;
lastUsed: Date;
}
/**
* View coordinate mapping for a specific app screen
*/
export interface ViewCoordinateMapping {
cacheKey: string;
fingerprint: ViewFingerprint;
bundleId: string;
appVersion?: string;
coordinates: Map<string, CachedCoordinate>;
createdAt: Date;
lastAccessed: Date;
hitCount: number;
}
/**
* Cache configuration following xcode-agent recommendations
*/
export interface ViewCacheConfig {
enabled: boolean;
maxAge: number;
minConfidence: number;
maxCachedViews: number;
maxCoordinatesPerView: number;
autoDisableThreshold: number;
}
/**
* View Coordinate Cache
*
* Implements intelligent coordinate caching with:
* - Element structure hash as primary key (per xcode-agent)
* - Confidence tracking with auto-invalidation
* - Auto-disable on low hit rate
* - Conservative defaults for Phase 1
*/
export declare class ViewCoordinateCache {
private static instance;
private cache;
private config;
private hitCount;
private missCount;
private totalQueries;
private constructor();
static getInstance(): ViewCoordinateCache;
setConfig(config: Partial<ViewCacheConfig>): void;
getConfig(): ViewCacheConfig;
enable(): void;
disable(): void;
isEnabled(): boolean;
/**
* Get cached coordinate for an element on a specific view
*/
getCachedCoordinate(fingerprint: ViewFingerprint, bundleId: string, elementId: string, appVersion?: string): Promise<CachedCoordinate | null>;
/**
* Store successful tap coordinates in cache
*/
storeCoordinate(fingerprint: ViewFingerprint, bundleId: string, elementId: string, elementType: string, x: number, y: number, bounds?: {
width: number;
height: number;
}, appVersion?: string): Promise<void>;
/**
* Record successful tap using cached coordinate
*/
recordSuccess(fingerprint: ViewFingerprint, bundleId: string, elementId: string, appVersion?: string): Promise<void>;
/**
* Invalidate coordinate on tap failure
*/
invalidateCoordinate(fingerprint: ViewFingerprint, bundleId: string, elementId: string, appVersion?: string): Promise<void>;
/**
* Clear entire cache
*/
clear(): void;
/**
* Clear cache for specific bundle ID
*/
clearForBundle(bundleId: string): void;
getStatistics(): {
enabled: boolean;
hitRate: number;
missRate: number;
totalQueries: number;
hitCount: number;
missCount: number;
cachedViews: number;
totalCoordinates: number;
config: ViewCacheConfig;
};
/**
* Auto-disable cache if hit rate falls below threshold
* Per xcode-agent recommendation
*/
private checkAutoDisable;
/**
* Evict least recently used view mapping (LRU eviction)
*/
private evictLRU;
/**
* Evict least recently used coordinate from a view mapping
*/
private evictLRUCoordinate;
private persistState;
private loadPersistedState;
}
export declare const viewCoordinateCache: ViewCoordinateCache;
//# sourceMappingURL=view-coordinate-cache.d.ts.map