/**
* VSCode Automation MCP Server - Type Definitions
*
* @author Sukarth Acharya
* @license MIT
*/
import type { WebDriver, WebElement } from 'vscode-extension-tester';
/**
* Result type for all MCP tool operations
*/
export interface ToolResult<T = unknown> {
success: boolean;
data?: T;
error?: string;
message?: string;
}
/**
* Configuration options for the VSCode driver
*/
export interface VSCodeDriverConfig {
/** Path to store VS Code and ChromeDriver */
storagePath?: string;
/** VS Code version to use (e.g., "1.84.2" or "latest") */
vscodeVersion?: string;
/** Path to extensions directory */
extensionsDir?: string;
/** Path to workspace folder to open */
workspacePath?: string;
/** Custom settings.json path */
settingsPath?: string;
/** Log level: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'silent' */
logLevel?: string;
/** Whether to run in offline mode */
offline?: boolean;
}
/**
* State of the VSCode driver
*/
export type DriverState = 'idle' | 'initializing' | 'ready' | 'error' | 'disposed';
/**
* Screenshot result
*/
export interface ScreenshotResult {
/** Base64 encoded screenshot data */
base64?: string;
/** Path where screenshot was saved */
filePath?: string;
/** Width of screenshot */
width?: number;
/** Height of screenshot */
height?: number;
/** MIME type of the image (image/png or image/jpeg if compressed) */
mimeType?: string;
}
/**
* Element information from inspection
*/
export interface ElementInfo {
/** Tag name of the element */
tagName: string;
/** Text content of the element */
text: string;
/** Whether the element is displayed */
isDisplayed: boolean;
/** Whether the element is enabled */
isEnabled: boolean;
/** Whether the element is selected */
isSelected: boolean;
/** Element's location on screen */
location: { x: number; y: number };
/** Element's size */
size: { width: number; height: number };
/** Element's attributes */
attributes: Record<string, string>;
/** Element's CSS classes */
cssClasses: string[];
}
/**
* Diagnostic message from Problems panel
*/
export interface DiagnosticMessage {
/** Severity: 'error' | 'warning' | 'info' | 'hint' */
severity: 'error' | 'warning' | 'info' | 'hint';
/** The diagnostic message text */
message: string;
/** Source file path */
filePath?: string;
/** Line number (1-indexed) */
line?: number;
/** Column number (1-indexed) */
column?: number;
/** Source of the diagnostic (e.g., "typescript", "eslint") */
source?: string;
}
/**
* Editor information
*/
export interface EditorInfo {
/** File name of the editor */
fileName: string;
/** Full file path */
filePath?: string;
/** Whether the editor has unsaved changes */
isDirty: boolean;
/** Current line number (1-indexed) */
currentLine?: number;
/** Current column number (1-indexed) */
currentColumn?: number;
/** Total number of lines */
lineCount: number;
/** Language mode of the editor */
languageId?: string;
}
/**
* Command information
*/
export interface CommandInfo {
/** Command ID */
id: string;
/** Command title/label */
title: string;
/** Command category */
category?: string;
}
/**
* Webview information
*/
export interface WebviewInfo {
/** Webview title */
title: string;
/** Whether the webview is visible */
isVisible: boolean;
/** Webview type */
type?: string;
}
/**
* Click options for UI actions
*/
export interface ClickOptions {
/** Perform double click */
doubleClick?: boolean;
/** Perform right click */
rightClick?: boolean;
/** Timeout in milliseconds */
timeout?: number;
}
/**
* Type options for text input
*/
export interface TypeOptions {
/** Clear existing text before typing */
clear?: boolean;
/** Delay between keystrokes in milliseconds */
delay?: number;
/** Press Enter after typing */
pressEnter?: boolean;
}
/**
* Open file options
*/
export interface OpenFileOptions {
/** Line number to navigate to (1-indexed) */
line?: number;
/** Column number to navigate to (1-indexed) */
column?: number;
/** Whether to preview the file (vs. open in editor) */
preview?: boolean;
}
/**
* Selector type for finding elements
*/
export type SelectorType = 'css' | 'xpath' | 'accessibility' | 'text';
/**
* Selector definition for finding elements
*/
export interface ElementSelector {
/** The selector value */
value: string;
/** Type of selector */
type: SelectorType;
/** Timeout for finding element in milliseconds */
timeout?: number;
}
/**
* Internal session state
*/
export interface SessionState {
/** Session ID */
id: string;
/** When the session was created */
createdAt: Date;
/** Last activity timestamp */
lastActivityAt: Date;
/** Current workspace path */
workspacePath?: string;
/** Whether VS Code is initialized */
isInitialized: boolean;
}
/**
* WebDriver wrapper with additional utilities
*/
export interface EnhancedWebDriver extends WebDriver {
/** Find element with retry logic */
findElementSafe: (selector: ElementSelector) => Promise<WebElement | null>;
/** Wait for element to be visible */
waitForElement: (selector: ElementSelector, timeout?: number) => Promise<WebElement>;
/** Execute JavaScript in VS Code window */
executeScript: <T>(script: string, ...args: unknown[]) => Promise<T>;
}
/**
* MCP Server configuration
*/
export interface MCPServerConfig {
/** Server name */
name: string;
/** Server version */
version: string;
/** VSCode driver configuration */
driverConfig?: VSCodeDriverConfig;
}
/**
* Tool execution context
*/
export interface ToolContext {
/** Request ID */
requestId: string;
/** Session state */
session: SessionState;
/** Abort signal for cancellation */
signal?: AbortSignal;
}