@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
262 lines • 7.48 kB
TypeScript
/**
* Track 2E Tool #6: SmartDashboard
*
* Purpose: Unified dashboard management with widget management and multi-source data integration.
* Target Lines: 1,980
* Token Reduction: 90%
*
* Operations:
* 1. check - Run health checks
* 2. register-check - Register new health check
* 3. update-check - Modify existing health check
* 4. delete-check - Remove health check
* 5. get-status - Get current health status
* 6. get-history - Get health check history
* 7. configure-dependencies - Define service dependencies
* 8. get-impact - Analyze impact of service failures
*/
import { CacheEngine } from '../../core/cache-engine.js';
import { TokenCounter } from '../../core/token-counter.js';
import { MetricsCollector } from '../../core/metrics.js';
export interface SmartDashboardOptions {
operation: 'check' | 'register-check' | 'update-check' | 'delete-check' | 'get-status' | 'get-history' | 'configure-dependencies' | 'get-impact';
checkId?: string;
checkName?: string;
checkType?: 'http' | 'tcp' | 'database' | 'command' | 'custom';
checkConfig?: {
url?: string;
method?: string;
expectedStatus?: number;
expectedBody?: string;
timeout?: number;
host?: string;
port?: number;
query?: string;
command?: string;
args?: string[];
custom?: Record<string, unknown>;
};
interval?: number;
timeout?: number;
retries?: number;
dependencies?: {
service: string;
dependsOn: string[];
critical?: boolean;
};
includeDetails?: boolean;
includeDependencies?: boolean;
timeRange?: {
start: number;
end: number;
};
limit?: number;
service?: string;
scenario?: 'failure' | 'degraded' | 'maintenance';
useCache?: boolean;
cacheTTL?: number;
}
export interface SmartDashboardResult {
success: boolean;
data?: {
check?: HealthCheck;
checks?: HealthCheck[];
status?: ServiceStatus;
history?: HealthCheckEvent[];
dependencies?: DependencyGraph;
impact?: ImpactAnalysis;
};
metadata: {
tokensUsed?: number;
tokensSaved?: number;
cacheHit: boolean;
checksRun?: number;
healthyCount?: number;
unhealthyCount?: number;
};
error?: string;
}
export interface HealthCheck {
id: string;
name: string;
type: 'http' | 'tcp' | 'database' | 'command' | 'custom';
config: Record<string, unknown>;
interval: number;
timeout: number;
retries: number;
enabled: boolean;
lastCheck?: number;
lastStatus?: 'pass' | 'fail' | 'warn';
createdAt: number;
updatedAt: number;
}
export interface ServiceStatus {
service: string;
status: 'healthy' | 'degraded' | 'unhealthy' | 'unknown';
checks: Array<{
name: string;
status: 'pass' | 'fail' | 'warn';
message?: string;
duration?: number;
}>;
dependencies?: Array<{
service: string;
status: 'healthy' | 'degraded' | 'unhealthy' | 'unknown';
critical: boolean;
}>;
lastChecked: number;
}
export interface HealthCheckEvent {
checkId: string;
checkName: string;
timestamp: number;
status: 'pass' | 'fail' | 'warn';
duration: number;
message?: string;
metadata?: Record<string, unknown>;
}
export interface DependencyGraph {
services: Array<{
name: string;
dependencies: string[];
dependents: string[];
critical: boolean;
}>;
edges: Array<{
from: string;
to: string;
critical: boolean;
}>;
}
export interface ImpactAnalysis {
service: string;
scenario: 'failure' | 'degraded' | 'maintenance';
directImpact: string[];
cascadingImpact: string[];
totalAffected: number;
criticalServices: string[];
estimatedDowntime?: number;
recommendations: string[];
}
export declare class SmartDashboard {
private cache;
private tokenCounter;
private metricsCollector;
constructor(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector);
run(options: SmartDashboardOptions): Promise<SmartDashboardResult>;
private executeCheck;
private registerCheck;
private updateCheck;
private deleteCheck;
private getStatus;
private getHistory;
private configureDependencies;
private getImpact;
private generateCheckId;
private aggregateHistory;
}
export declare function createSmartDashboard(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector): SmartDashboard;
export declare const smartDashboardTool: {
name: string;
description: string;
inputSchema: {
type: string;
properties: {
operation: {
type: string;
enum: string[];
description: string;
};
checkId: {
type: string;
description: string;
};
checkName: {
type: string;
description: string;
};
checkType: {
type: string;
enum: string[];
description: string;
};
checkConfig: {
type: string;
description: string;
};
interval: {
type: string;
description: string;
};
timeout: {
type: string;
description: string;
};
retries: {
type: string;
description: string;
};
dependencies: {
type: string;
properties: {
service: {
type: string;
};
dependsOn: {
type: string;
items: {
type: string;
};
};
critical: {
type: string;
};
};
description: string;
};
includeDetails: {
type: string;
description: string;
};
includeDependencies: {
type: string;
description: string;
};
timeRange: {
type: string;
properties: {
start: {
type: string;
};
end: {
type: string;
};
};
description: string;
};
limit: {
type: string;
description: string;
};
service: {
type: string;
description: string;
};
scenario: {
type: string;
enum: string[];
description: string;
};
useCache: {
type: string;
description: string;
};
cacheTTL: {
type: string;
description: string;
};
};
required: string[];
};
};
//# sourceMappingURL=smart-dashboard.d.ts.map