source-intelligence-tools.d.ts•13.5 kB
/**
* Source Intelligence Tools for WebSee MCP Server
*
* Provides advanced source mapping, debugging, and analysis capabilities
* for frontend applications through the Model Context Protocol.
*
* @module source-intelligence-tools
*/
import { z } from "zod";
import { Page } from "playwright";
/**
* Schema for source_map_resolve tool
* Resolves a minified location to its original source
*/
export declare const SourceMapResolveSchema: z.ZodObject<{
url: z.ZodString;
line: z.ZodNumber;
column: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
line?: number;
url?: string;
column?: number;
}, {
line?: number;
url?: string;
column?: number;
}>;
/**
* Schema for source_map_get_content tool
* Retrieves original source file content
*/
export declare const SourceMapGetContentSchema: z.ZodObject<{
file: z.ZodString;
startLine: z.ZodOptional<z.ZodNumber>;
endLine: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
file?: string;
startLine?: number;
endLine?: number;
}, {
file?: string;
startLine?: number;
endLine?: number;
}>;
/**
* Schema for source_trace_stack tool
* Enhances a complete stack trace with source maps
*/
export declare const SourceTraceStackSchema: z.ZodObject<{
stackTrace: z.ZodString;
}, "strip", z.ZodTypeAny, {
stackTrace?: string;
}, {
stackTrace?: string;
}>;
/**
* Schema for source_find_definition tool
* Finds function/class definition in source code
*/
export declare const SourceFindDefinitionSchema: z.ZodObject<{
functionName: z.ZodString;
file: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
file?: string;
functionName?: string;
}, {
file?: string;
functionName?: string;
}>;
/**
* Schema for source_get_symbols tool
* Lists exports, imports, and types from a source file
*/
export declare const SourceGetSymbolsSchema: z.ZodObject<{
file: z.ZodString;
}, "strip", z.ZodTypeAny, {
file?: string;
}, {
file?: string;
}>;
/**
* Schema for source_map_bundle tool
* Maps a bundle file to all its source files
*/
export declare const SourceMapBundleSchema: z.ZodObject<{
bundlePath: z.ZodString;
}, "strip", z.ZodTypeAny, {
bundlePath?: string;
}, {
bundlePath?: string;
}>;
/**
* Schema for source_coverage_map tool
* Maps code coverage data to source files
*/
export declare const SourceCoverageMapSchema: z.ZodObject<{
coverageData: z.ZodRecord<z.ZodString, z.ZodAny>;
}, "strip", z.ZodTypeAny, {
coverageData?: Record<string, any>;
}, {
coverageData?: Record<string, any>;
}>;
interface StackFrame {
functionName?: string;
fileName: string;
lineNumber: number;
columnNumber: number;
source?: string;
}
interface ResolvedStackFrame extends StackFrame {
original: StackFrame;
resolved: boolean;
}
/**
* SourceIntelligenceTools provides MCP-compatible source intelligence tools
* for debugging and analyzing frontend applications.
*/
export declare class SourceIntelligenceTools {
private sourceMapResolver;
private buildManager;
private initialized;
constructor(cacheSize?: number, projectRoot?: string);
/**
* Initialize the tools with a Playwright page
*/
initialize(page: Page): Promise<void>;
/**
* Resolve a minified location to its original source
*
* @param params - URL, line, and column of minified code
* @returns Original source location with file, line, column, name, and content
*/
sourceMapResolve(params: z.infer<typeof SourceMapResolveSchema>): Promise<{
file: string;
line: number;
column: number;
name?: string;
content?: string;
} | null>;
/**
* Get original source file content with optional line range
*
* @param params - File path and optional line range
* @returns File content with metadata
*/
sourceMapGetContent(params: z.infer<typeof SourceMapGetContentSchema>): Promise<{
file: string;
content: string;
language: string;
totalLines: number;
range?: {
start: number;
end: number;
};
} | null>;
/**
* Enhance a full stack trace with source map resolution
*
* @param params - Stack trace string
* @returns Original and resolved stack traces
*/
sourceTraceStack(params: z.infer<typeof SourceTraceStackSchema>): Promise<{
original: string[];
resolved: string[];
frames: ResolvedStackFrame[];
}>;
/**
* Find function or class definition in source code
*
* @param params - Function/class name and optional file filter
* @returns Definition location and code snippet
*/
sourceFindDefinition(params: z.infer<typeof SourceFindDefinitionSchema>): Promise<{
file: string;
line: number;
column: number;
code: string;
exports?: string[];
} | null>;
/**
* List exports, imports, and types from a source file
*
* @param params - Source file path
* @returns Symbols found in the file
*/
sourceGetSymbols(params: z.infer<typeof SourceGetSymbolsSchema>): Promise<{
file: string;
exports: Array<{
name: string;
type: string;
line: number;
}>;
imports: Array<{
name: string;
from: string;
line: number;
}>;
types: Array<{
name: string;
kind: string;
line: number;
}>;
} | null>;
/**
* Map a bundle file to all its source files
*
* @param params - Bundle file path or URL
* @returns Bundle info with all source files
*/
sourceMapBundle(params: z.infer<typeof SourceMapBundleSchema>): Promise<{
bundle: string;
sources: string[];
mappings: Array<{
source: string;
generatedLine: number;
generatedColumn: number;
originalLine: number;
originalColumn: number;
}>;
size?: number;
} | null>;
/**
* Map code coverage data to original source files
*
* @param params - V8 coverage data
* @returns Coverage mapped to source files
*/
sourceCoverageMap(params: z.infer<typeof SourceCoverageMapSchema>): Promise<{
covered: Array<{
file: string;
lines: number[];
percentage: number;
}>;
uncovered: Array<{
file: string;
lines: number[];
percentage: number;
}>;
percentage: number;
}>;
private ensureInitialized;
/**
* Get source file content from cached source maps
*/
private getSourceFileContent;
/**
* Detect programming language from file extension
*/
private detectLanguage;
/**
* Parse a stack frame line into structured data
*/
private parseStackFrame;
/**
* Format a stack frame into a readable string
*/
private formatStackFrame;
/**
* Search for function/class definition across source files
*/
private searchForDefinition;
/**
* Extract export statements from source code
*/
private extractExports;
/**
* Extract import statements from source code
*/
private extractImports;
/**
* Extract type definitions from source code
*/
private extractTypes;
/**
* Analyze bundle source map and extract all source files
*/
private analyzeBundleSourceMap;
/**
* Map V8 coverage data to original source files
*/
private mapCoverageToSources;
/**
* Cleanup and destroy resources
*/
destroy(): Promise<void>;
}
/**
* MCP tool definitions for registration with the server
*/
export declare const SOURCE_INTELLIGENCE_TOOL_DEFINITIONS: ({
name: string;
description: string;
inputSchema: {
type: string;
properties: {
url: {
type: string;
description: string;
};
line: {
type: string;
description: string;
};
column: {
type: string;
description: string;
};
file?: undefined;
startLine?: undefined;
endLine?: undefined;
stackTrace?: undefined;
functionName?: undefined;
bundlePath?: undefined;
coverageData?: undefined;
};
required: string[];
};
} | {
name: string;
description: string;
inputSchema: {
type: string;
properties: {
file: {
type: string;
description: string;
};
startLine: {
type: string;
description: string;
};
endLine: {
type: string;
description: string;
};
url?: undefined;
line?: undefined;
column?: undefined;
stackTrace?: undefined;
functionName?: undefined;
bundlePath?: undefined;
coverageData?: undefined;
};
required: string[];
};
} | {
name: string;
description: string;
inputSchema: {
type: string;
properties: {
stackTrace: {
type: string;
description: string;
};
url?: undefined;
line?: undefined;
column?: undefined;
file?: undefined;
startLine?: undefined;
endLine?: undefined;
functionName?: undefined;
bundlePath?: undefined;
coverageData?: undefined;
};
required: string[];
};
} | {
name: string;
description: string;
inputSchema: {
type: string;
properties: {
functionName: {
type: string;
description: string;
};
file: {
type: string;
description: string;
};
url?: undefined;
line?: undefined;
column?: undefined;
startLine?: undefined;
endLine?: undefined;
stackTrace?: undefined;
bundlePath?: undefined;
coverageData?: undefined;
};
required: string[];
};
} | {
name: string;
description: string;
inputSchema: {
type: string;
properties: {
file: {
type: string;
description: string;
};
url?: undefined;
line?: undefined;
column?: undefined;
startLine?: undefined;
endLine?: undefined;
stackTrace?: undefined;
functionName?: undefined;
bundlePath?: undefined;
coverageData?: undefined;
};
required: string[];
};
} | {
name: string;
description: string;
inputSchema: {
type: string;
properties: {
bundlePath: {
type: string;
description: string;
};
url?: undefined;
line?: undefined;
column?: undefined;
file?: undefined;
startLine?: undefined;
endLine?: undefined;
stackTrace?: undefined;
functionName?: undefined;
coverageData?: undefined;
};
required: string[];
};
} | {
name: string;
description: string;
inputSchema: {
type: string;
properties: {
coverageData: {
type: string;
description: string;
};
url?: undefined;
line?: undefined;
column?: undefined;
file?: undefined;
startLine?: undefined;
endLine?: undefined;
stackTrace?: undefined;
functionName?: undefined;
bundlePath?: undefined;
};
required: string[];
};
})[];
/**
* Handler for source_map_resolve tool
*/
export declare function sourceMapResolve(page: Page, params: z.infer<typeof SourceMapResolveSchema>): Promise<any>;
/**
* Handler for source_map_get_content tool
*/
export declare function sourceMapGetContent(page: Page, params: z.infer<typeof SourceMapGetContentSchema>): Promise<any>;
/**
* Handler for source_trace_stack tool
*/
export declare function sourceTraceStack(page: Page, params: z.infer<typeof SourceTraceStackSchema>): Promise<any>;
/**
* Handler for source_find_definition tool
*/
export declare function sourceFindDefinition(page: Page, params: z.infer<typeof SourceFindDefinitionSchema>): Promise<any>;
/**
* Handler for source_get_symbols tool
*/
export declare function sourceGetSymbols(page: Page, params: z.infer<typeof SourceGetSymbolsSchema>): Promise<any>;
/**
* Handler for source_map_bundle tool
*/
export declare function sourceMapBundle(page: Page, params: z.infer<typeof SourceMapBundleSchema>): Promise<any>;
/**
* Handler for source_coverage_map tool
*/
export declare function sourceCoverageMap(page: Page, params: z.infer<typeof SourceCoverageMapSchema>): Promise<any>;
export default SOURCE_INTELLIGENCE_TOOL_DEFINITIONS;
//# sourceMappingURL=source-intelligence-tools.d.ts.map