@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
186 lines • 5.22 kB
TypeScript
/**
* SmartService - Intelligent Service Management
*
* Track 2C - Tool #2: Service management with smart caching (86%+ token reduction)
*
* Capabilities:
* - Systemd service management (Linux)
* - Windows Service management
* - Docker container management
* - Service health monitoring
* - Automatic dependency resolution
*
* Token Reduction Strategy:
* - Cache service configurations (94% reduction)
* - Incremental status updates (86% reduction)
* - Compressed dependency graphs (88% reduction)
*/
import { CacheEngine } from '../../core/cache-engine.js';
import { TokenCounter } from '../../core/token-counter.js';
import { MetricsCollector } from '../../core/metrics.js';
export type ServiceType = 'systemd' | 'windows' | 'docker';
export type ServiceStatus = 'active' | 'inactive' | 'failed' | 'running' | 'stopped' | 'exited' | 'restarting';
export interface SmartServiceOptions {
operation: 'start' | 'stop' | 'restart' | 'status' | 'enable' | 'disable' | 'health-check' | 'list-dependencies';
serviceType?: ServiceType;
serviceName: string;
autoDetect?: boolean;
useCache?: boolean;
ttl?: number;
}
export interface ServiceInfo {
name: string;
type: ServiceType;
status: ServiceStatus;
enabled?: boolean;
uptime?: number;
pid?: number;
memory?: number;
cpu?: number;
restartCount?: number;
lastStartTime?: number;
dependencies?: string[];
ports?: number[];
health?: {
status: 'healthy' | 'unhealthy' | 'unknown';
checks: HealthCheck[];
};
}
export interface HealthCheck {
name: string;
status: 'pass' | 'fail' | 'warn';
message?: string;
timestamp: number;
}
export interface DependencyGraph {
service: string;
dependencies: string[];
dependents: string[];
circular?: boolean;
depth: number;
}
export interface SmartServiceResult {
success: boolean;
operation: string;
data: {
service?: ServiceInfo;
services?: ServiceInfo[];
dependencies?: DependencyGraph;
health?: HealthCheck[];
output?: string;
error?: string;
};
metadata: {
tokensUsed: number;
tokensSaved: number;
cacheHit: boolean;
executionTime: number;
};
}
export declare class SmartService {
private cache;
private tokenCounter;
private metricsCollector;
constructor(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector);
/**
* Main entry point for service operations
*/
run(options: SmartServiceOptions): Promise<SmartServiceResult>;
/**
* Auto-detect service type based on platform and service name
*/
private detectServiceType;
/**
* Get service status with smart caching
*/
private getServiceStatus;
/**
* Get detailed service information based on type
*/
private getServiceInfo;
/**
* Get systemd service information
*/
private getSystemdServiceInfo;
/**
* Get Windows service information
*/
private getWindowsServiceInfo;
/**
* Get Docker container information
*/
private getDockerServiceInfo;
/**
* Start a service
*/
private startService;
/**
* Stop a service
*/
private stopService;
/**
* Restart a service
*/
private restartService;
/**
* Enable a service (auto-start on boot)
*/
private enableService;
/**
* Disable a service (prevent auto-start on boot)
*/
private disableService;
/**
* Perform health check on a service
*/
private performHealthCheck;
/**
* List service dependencies with caching
*/
private listDependencies;
/**
* Build dependency graph for a service
*/
private buildDependencyGraph;
}
export declare function getSmartService(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector): SmartService;
export declare function runSmartService(options: SmartServiceOptions, cache?: CacheEngine, tokenCounter?: TokenCounter, metricsCollector?: MetricsCollector): Promise<SmartServiceResult>;
export declare const SMART_SERVICE_TOOL_DEFINITION: {
name: string;
description: string;
inputSchema: {
type: "object";
properties: {
operation: {
type: "string";
enum: string[];
description: string;
};
serviceType: {
type: "string";
enum: string[];
description: string;
};
serviceName: {
type: "string";
description: string;
};
autoDetect: {
type: "boolean";
description: string;
default: boolean;
};
useCache: {
type: "boolean";
description: string;
default: boolean;
};
ttl: {
type: "number";
description: string;
};
};
required: string[];
};
};
//# sourceMappingURL=smart-service.d.ts.map