@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
231 lines • 6.64 kB
TypeScript
import { CacheEngine } from '../../core/cache-engine.js';
import { TokenCounter } from '../../core/token-counter.js';
import { MetricsCollector } from '../../core/metrics.js';
export interface PerformanceTrackerOptions {
operation: 'track' | 'query' | 'analyze-trends' | 'forecast' | 'compare' | 'detect-regressions' | 'get-baseline' | 'generate-report';
metricId?: string;
metricName?: string;
metricType?: 'cpu' | 'memory' | 'responseTime' | 'throughput' | 'custom';
value?: number;
tags?: Record<string, string>;
timeRange?: {
start: number;
end: number;
};
limit?: number;
analysisPeriod?: {
start: number;
end: number;
};
forecastHorizon?: number;
comparisonMetricId1?: string;
comparisonMetricId2?: string;
baselineId?: string;
regressionThreshold?: number;
reportFormat?: 'json' | 'markdown';
reportTitle?: string;
useCache?: boolean;
cacheTTL?: number;
}
export interface PerformanceTrackerResult {
success: boolean;
data?: {
metric?: PerformanceMetric;
metrics?: PerformanceMetric[];
trend?: PerformanceTrend;
forecast?: PerformanceForecast;
comparison?: PerformanceComparison;
regression?: PerformanceRegression;
baseline?: PerformanceBaseline;
report?: PerformanceReport;
};
metadata: {
tokensUsed?: number;
tokensSaved?: number;
cacheHit: boolean;
metricsTracked?: number;
metricsQueried?: number;
};
error?: string;
}
export interface PerformanceMetric {
id: string;
name: string;
type: 'cpu' | 'memory' | 'responseTime' | 'throughput' | 'custom';
value: number;
timestamp: number;
tags: Record<string, string>;
}
export interface PerformanceTrend {
metricId: string;
trendType: 'increasing' | 'decreasing' | 'stable' | 'volatile' | 'unknown';
slope?: number;
rSquared?: number;
analysisPeriod: {
start: number;
end: number;
};
recommendations: string[];
}
export interface PerformanceForecast {
metricId: string;
forecastPoints: Array<{
timestamp: number;
value: number;
}>;
modelUsed: 'linear-regression' | 'moving-average';
confidenceInterval?: number;
}
export interface PerformanceComparison {
metricId1: string;
metricId2: string;
comparisonResult: 'better' | 'worse' | 'similar' | 'inconclusive';
percentageChange?: number;
details: string;
}
export interface PerformanceRegression {
metricId: string;
regressionDetected: boolean;
changePoint?: number;
oldValue?: number;
newValue?: number;
thresholdExceeded?: number;
recommendations: string[];
}
export interface PerformanceBaseline {
id: string;
name: string;
metrics: PerformanceMetric[];
createdAt: number;
}
export interface PerformanceReport {
title: string;
generatedAt: number;
summary: string;
sections: Array<{
title: string;
content: string;
}>;
}
export declare class PerformanceTracker {
private cache;
private tokenCounter;
private metricsCollector;
constructor(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector);
run(options: PerformanceTrackerOptions): Promise<PerformanceTrackerResult>;
private trackMetric;
private queryMetrics;
private analyzeTrends;
private forecastPerformance;
private comparePerformance;
private detectRegressions;
private getBaseline;
private generateReport;
private generateMetricId;
}
export declare function createPerformanceTracker(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector): PerformanceTracker;
export declare const performanceTrackerTool: {
name: string;
description: string;
inputSchema: {
type: string;
properties: {
operation: {
type: string;
enum: string[];
description: string;
};
metricId: {
type: string;
description: string;
};
metricName: {
type: string;
description: string;
};
metricType: {
type: string;
enum: string[];
description: string;
};
value: {
type: string;
description: string;
};
tags: {
type: string;
additionalProperties: {
type: string;
};
description: string;
};
timeRange: {
type: string;
properties: {
start: {
type: string;
};
end: {
type: string;
};
};
description: string;
};
limit: {
type: string;
description: string;
};
analysisPeriod: {
type: string;
properties: {
start: {
type: string;
};
end: {
type: string;
};
};
description: string;
};
forecastHorizon: {
type: string;
description: string;
};
comparisonMetricId1: {
type: string;
description: string;
};
comparisonMetricId2: {
type: string;
description: string;
};
baselineId: {
type: string;
description: string;
};
regressionThreshold: {
type: string;
description: string;
};
reportFormat: {
type: string;
enum: string[];
description: string;
};
reportTitle: {
type: string;
description: string;
};
useCache: {
type: string;
description: string;
};
cacheTTL: {
type: string;
description: string;
};
};
required: string[];
};
};
//# sourceMappingURL=performance-tracker.d.ts.map