@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
162 lines • 4.67 kB
TypeScript
/**
* SmartProcess - Intelligent Process Management
*
* Track 2C - System Operations & Output
* Target Token Reduction: 88%+
*
* Provides cross-platform process management with smart caching:
* - Start, stop, monitor processes
* - Resource usage tracking (CPU, memory, handles)
* - Process tree analysis
* - Automatic restart on failure
* - Cross-platform support (Windows/Linux/macOS)
*/
import { CacheEngine } from '../../core/cache-engine.js';
import { TokenCounter } from '../../core/token-counter.js';
import { MetricsCollector } from '../../core/metrics.js';
export interface SmartProcessOptions {
operation: 'start' | 'stop' | 'status' | 'monitor' | 'tree' | 'restart';
pid?: number;
name?: string;
command?: string;
args?: string[];
cwd?: string;
env?: Record<string, string>;
detached?: boolean;
autoRestart?: boolean;
interval?: number;
duration?: number;
useCache?: boolean;
ttl?: number;
}
export interface ProcessInfo {
pid: number;
name: string;
command: string;
cpu: number;
memory: number;
status: 'running' | 'sleeping' | 'stopped' | 'zombie';
startTime: number;
handles?: number;
threads?: number;
}
export interface ProcessTreeNode {
pid: number;
name: string;
children: ProcessTreeNode[];
}
export interface ResourceSnapshot {
timestamp: number;
cpu: number;
memory: number;
handles?: number;
threads?: number;
}
export interface SmartProcessResult {
success: boolean;
operation: string;
data: {
process?: ProcessInfo;
processes?: ProcessInfo[];
tree?: ProcessTreeNode;
snapshots?: ResourceSnapshot[];
output?: string;
error?: string;
};
metadata: {
tokensUsed: number;
tokensSaved: number;
cacheHit: boolean;
executionTime: number;
};
}
export declare class SmartProcess {
private cache;
private tokenCounter;
private metricsCollector;
private runningProcesses;
constructor(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector);
run(options: SmartProcessOptions): Promise<SmartProcessResult>;
private startProcess;
private stopProcess;
private getProcessStatus;
private monitorProcess;
private getProcessTree;
private restartProcess;
private listProcesses;
private listProcessesWindows;
private listProcessesUnix;
private parseUnixStatus;
private buildProcessTree;
private buildProcessTreeWindows;
private buildProcessTreeUnix;
}
export declare function getSmartProcess(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector): SmartProcess;
export declare function runSmartProcess(options: SmartProcessOptions, cache?: CacheEngine, tokenCounter?: TokenCounter, metricsCollector?: MetricsCollector): Promise<SmartProcessResult>;
export declare const SMART_PROCESS_TOOL_DEFINITION: {
name: string;
description: string;
inputSchema: {
type: "object";
properties: {
operation: {
type: "string";
enum: string[];
description: string;
};
pid: {
type: "number";
description: string;
};
name: {
type: "string";
description: string;
};
command: {
type: "string";
description: string;
};
args: {
type: "array";
items: {
type: "string";
};
description: string;
};
cwd: {
type: "string";
description: string;
};
env: {
type: "object";
description: string;
};
detached: {
type: "boolean";
description: string;
};
autoRestart: {
type: "boolean";
description: string;
};
interval: {
type: "number";
description: string;
};
duration: {
type: "number";
description: string;
};
useCache: {
type: "boolean";
description: string;
};
ttl: {
type: "number";
description: string;
};
};
required: string[];
};
};
//# sourceMappingURL=smart-process.d.ts.map