@wonderwhy-er/desktop-commander
Version:
MCP server for terminal operations and file editing
79 lines (78 loc) • 2.11 kB
TypeScript
import { ChildProcess } from 'child_process';
import { FilteredStdioServerTransport } from './custom-stdio.js';
import type { PreviewFileType } from './ui/file-preview/shared/preview-file-types.js';
declare global {
var mcpTransport: FilteredStdioServerTransport | undefined;
var disableOnboarding: boolean | undefined;
}
export interface ProcessInfo {
pid: number;
command: string;
cpu: string;
memory: string;
}
export interface TerminalSession {
pid: number;
process: ChildProcess;
outputLines: string[];
lastReadIndex: number;
isBlocked: boolean;
startTime: Date;
}
export interface CommandExecutionResult {
pid: number;
output: string;
isBlocked: boolean;
timingInfo?: TimingInfo;
}
export interface TimingInfo {
startTime: number;
endTime: number;
totalDurationMs: number;
exitReason: 'early_exit_quick_pattern' | 'early_exit_periodic_check' | 'process_exit' | 'timeout';
firstOutputTime?: number;
lastOutputTime?: number;
timeToFirstOutputMs?: number;
outputEvents?: OutputEvent[];
}
export interface OutputEvent {
timestamp: number;
deltaMs: number;
source: 'stdout' | 'stderr';
length: number;
snippet: string;
matchedPattern?: string;
}
export interface ActiveSession {
pid: number;
isBlocked: boolean;
runtime: number;
}
export interface CompletedSession {
pid: number;
output: string;
exitCode: number | null;
startTime: Date;
endTime: Date;
}
export interface ServerResponseContent {
type: string;
text?: string;
data?: string;
mimeType?: string;
}
export interface FilePreviewStructuredContent {
fileName: string;
filePath: string;
fileType: PreviewFileType;
content?: string;
imageData?: string;
mimeType?: string;
}
export interface ServerResult {
content: ServerResponseContent[];
structuredContent?: FilePreviewStructuredContent | Record<string, unknown>;
isError?: boolean;
_meta?: Record<string, unknown>;
}
export type ToolHandler<T = unknown> = (args: T) => Promise<ServerResult>;