UNPKG

il2cpp-dump-analyzer-mcp

Version:

Agentic RAG system for analyzing IL2CPP dump.cs files from Unity games

183 lines (182 loc) 5.61 kB
/** * Extract Metadata Tool Implementation * Extracts assembly metadata, version information, and compilation flags from IL2CPP dumps * Implements comprehensive metadata parsing with validation and error handling */ import { z } from 'zod'; import { BaseAnalysisToolHandler, ToolExecutionContext } from '../base-tool-handler'; import { ValidationResult } from '../../utils/parameter-validator'; import { MCPResponse } from '../../utils/mcp-response-formatter'; /** * Assembly metadata information extracted from IL2CPP dumps */ export interface AssemblyMetadata { name: string; version: string; culture: string; publicKeyToken: string; imageName: string; imageIndex: number; dependencies?: string[]; } /** * Build and compilation information */ export interface BuildInformation { unityVersion?: string; il2cppVersion?: string; buildConfiguration?: string; targetPlatform?: string; scriptingBackend?: string; buildFlags?: string[]; } /** * Generic type metadata */ export interface GenericTypeMetadata { name: string; namespace: string; typeDefIndex: number; genericParameters: string[]; constraints: string[]; baseType?: string; interfaces: string[]; isGenericDefinition: boolean; isGenericInstance: boolean; } /** * Type system metadata */ export interface TypeSystemMetadata { totalTypes: number; genericTypes: GenericTypeMetadata[]; } /** * Validation results for metadata extraction */ export interface MetadataValidationResult { isValid: boolean; errors: string[]; warnings: string[]; suggestions: string[]; } /** * Processing statistics */ export interface MetadataStatistics { totalAssemblies: number; totalTypes: number; totalMethods: number; totalFields: number; processingTime: number; memoryUsage: number; validationErrors: number; validationWarnings: number; } /** * Complete metadata extraction result */ export interface IL2CPPMetadata { assemblies: AssemblyMetadata[]; buildInfo: BuildInformation; typeSystem: TypeSystemMetadata; validationResults: MetadataValidationResult; statistics: MetadataStatistics; extractionDate: Date; sourceFile?: string; } /** * Extract metadata tool parameters interface */ interface ExtractMetadataParams { content?: string; file_path?: string; include_generic_instantiations?: boolean; include_method_signatures?: boolean; include_field_offsets?: boolean; validate_structure?: boolean; enable_performance_tracking?: boolean; max_processing_time?: number; } /** * Extract Metadata Tool Handler * Provides comprehensive IL2CPP metadata extraction capabilities */ export declare class ExtractMetadataToolHandler extends BaseAnalysisToolHandler<ExtractMetadataParams, IL2CPPMetadata> { private extractionStartTime; private content; private lines; constructor(context: ToolExecutionContext); /** * Validate extract metadata specific parameters */ protected validateParameters(params: ExtractMetadataParams): Promise<ValidationResult>; /** * Execute the core metadata extraction logic */ protected executeCore(params: ExtractMetadataParams): Promise<IL2CPPMetadata>; /** * Load content from parameters */ private loadContent; /** * Extract assembly metadata from image mappings */ private extractAssemblyMetadata; /** * Extract build and compilation information */ private extractBuildInformation; /** * Extract type system metadata including generics and constraints */ private extractTypeSystemMetadata; /** * Validate extracted metadata for consistency and completeness */ private validateMetadata; /** * Calculate processing statistics */ private calculateStatistics; /** * Format the metadata extraction response */ protected formatResponse(result: IL2CPPMetadata, warnings?: string[]): MCPResponse; } /** * Zod schema for extract metadata tool parameters */ export declare const extractMetadataSchema: z.ZodObject<{ content: z.ZodOptional<z.ZodString>; file_path: z.ZodOptional<z.ZodString>; include_generic_instantiations: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; include_method_signatures: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; include_field_offsets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; validate_structure: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; enable_performance_tracking: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; max_processing_time: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; }, "strip", z.ZodTypeAny, { max_processing_time: number; include_generic_instantiations: boolean; include_method_signatures: boolean; include_field_offsets: boolean; validate_structure: boolean; enable_performance_tracking: boolean; file_path?: string | undefined; content?: string | undefined; }, { file_path?: string | undefined; content?: string | undefined; max_processing_time?: number | undefined; include_generic_instantiations?: boolean | undefined; include_method_signatures?: boolean | undefined; include_field_offsets?: boolean | undefined; validate_structure?: boolean | undefined; enable_performance_tracking?: boolean | undefined; }>; /** * Factory function to create and register the extract metadata tool */ export declare function createExtractMetadataTool(server: any, context: ToolExecutionContext): ExtractMetadataToolHandler; export {};