@ooples/token-optimizer-mcp
Version:
Intelligent context window optimization for Claude Code - store content externally via caching and compression, freeing up your context window for what matters
226 lines • 5.22 kB
TypeScript
/**
* Smart System Metrics Tool - System Resource Monitoring
*
* Provides intelligent system monitoring with:
* - CPU, memory, disk usage tracking
* - Anomaly detection
* - Performance recommendations
* - Token-optimized output
*/
import { CacheEngine } from '../../core/cache-engine.js';
interface SmartSystemMetricsOptions {
/**
* Force operation (ignore cache)
*/
force?: boolean;
/**
* Project root directory
*/
projectRoot?: string;
/**
* Include disk metrics
*/
includeDisk?: boolean;
/**
* Disk paths to monitor (default: root partition)
*/
diskPaths?: string[];
/**
* Detect anomalies by comparing with previous snapshot
*/
detectAnomalies?: boolean;
/**
* Maximum cache age in seconds (default: 60 = 1 minute for metrics)
*/
maxCacheAge?: number;
}
interface SmartSystemMetricsOutput {
/**
* Summary
*/
summary: {
success: boolean;
timestamp: string;
uptime: string;
duration: number;
fromCache: boolean;
};
/**
* CPU metrics
*/
cpu: {
usage: number;
cores: number;
model: string;
speed: number;
status: 'normal' | 'high' | 'critical';
};
/**
* Memory metrics
*/
memory: {
total: string;
used: string;
free: string;
usagePercent: number;
status: 'normal' | 'high' | 'critical';
};
/**
* Disk metrics
*/
disk: Array<{
path: string;
total: string;
used: string;
free: string;
usagePercent: number;
status: 'normal' | 'high' | 'critical';
}>;
/**
* Detected anomalies
*/
anomalies: Array<{
type: string;
severity: string;
message: string;
}>;
/**
* Performance recommendations
*/
recommendations: Array<{
type: 'cpu' | 'memory' | 'disk' | 'general';
message: string;
impact: 'high' | 'medium' | 'low';
}>;
/**
* Token reduction metrics
*/
metrics: {
originalTokens: number;
compactedTokens: number;
reductionPercentage: number;
};
}
export declare class SmartSystemMetrics {
private cache;
private cacheNamespace;
constructor(cache: CacheEngine, _projectRoot?: string);
/**
* Collect and analyze system metrics
*/
run(options?: SmartSystemMetricsOptions): Promise<SmartSystemMetricsOutput>;
/**
* Collect system metrics
*/
private collectMetrics;
/**
* Get CPU metrics
*/
private getCpuMetrics;
/**
* Calculate CPU usage percentage
*/
private calculateCpuUsage;
/**
* Get memory metrics
*/
private getMemoryMetrics;
/**
* Get disk metrics
*/
private getDiskMetrics;
/**
* Get disk info for a specific path
*/
private getDiskInfo;
/**
* Parse disk output
*/
private parseDiskOutput;
/**
* Detect anomalies by comparing current with previous
*/
private detectAnomalies;
/**
* Generate performance recommendations
*/
private generateRecommendations;
/**
* Generate cache key
*/
private generateCacheKey;
/**
* Get cached result
*/
private getCachedResult;
/**
* Cache result
*/
private cacheResult;
/**
* Transform to smart output
*/
private transformOutput;
/**
* Estimate original output size
*/
private estimateOriginalOutputSize;
/**
* Estimate compact output size
*/
private estimateCompactSize;
/**
* Close cache connection
*/
close(): void;
}
/**
* Factory function for dependency injection
*/
export declare function getSmartSystemMetrics(cache: CacheEngine, projectRoot?: string): SmartSystemMetrics;
/**
* CLI-friendly function for running smart system metrics
*/
export declare function runSmartSystemMetrics(options?: SmartSystemMetricsOptions): Promise<string>;
export declare const SMART_SYSTEM_METRICS_TOOL_DEFINITION: {
name: string;
description: string;
inputSchema: {
type: string;
properties: {
force: {
type: string;
description: string;
default: boolean;
};
projectRoot: {
type: string;
description: string;
};
includeDisk: {
type: string;
description: string;
default: boolean;
};
diskPaths: {
type: string;
items: {
type: string;
};
description: string;
};
detectAnomalies: {
type: string;
description: string;
default: boolean;
};
maxCacheAge: {
type: string;
description: string;
default: number;
};
};
};
};
export {};
//# sourceMappingURL=smart-system-metrics.d.ts.map