@debugmcp/mcp-debugger
Version:
Run-time step-through debugging for LLM agents.
52 lines (51 loc) • 2.18 kB
TypeScript
/**
* Type guards and validation utilities for runtime type safety
* These guards ensure type safety at critical boundaries (IPC, serialization, etc.)
*/
import { AdapterCommand } from '../adapters/debug-adapter-interface.js';
import { ProxyInitPayload } from '../proxy/dap-proxy-interfaces.js';
/**
* Type guard for AdapterCommand
* Validates that an object has the required structure for an adapter command
*/
export declare function isValidAdapterCommand(obj: unknown): obj is AdapterCommand;
/**
* Validates and returns a typed AdapterCommand
* Throws descriptive error if validation fails
*/
export declare function validateAdapterCommand(obj: unknown, source: string): AdapterCommand;
/**
* Type guard for ProxyInitPayload adapter command
* Validates the optional adapterCommand field
*/
export declare function hasValidAdapterCommand(payload: ProxyInitPayload): boolean;
/**
* Validates ProxyInitPayload
* Ensures all required fields are present and valid
*/
export declare function validateProxyInitPayload(payload: unknown): ProxyInitPayload;
/**
* Safely serialize adapter command for IPC
* Validates before serialization to prevent undefined propagation
*/
export declare function serializeAdapterCommand(cmd: AdapterCommand): string;
/**
* Safely deserialize adapter command from IPC
* Validates after parsing to ensure type safety
*/
export declare function deserializeAdapterCommand(data: string, source: string): AdapterCommand;
/**
* Create a type-safe adapter command with defaults
* Ensures all required fields are present
*/
export declare function createAdapterCommand(command: string, args?: string[], env?: Record<string, string>): AdapterCommand;
/**
* Type-safe property access for adapter commands
* Prevents accessing properties on undefined
*/
export declare function getAdapterCommandProperty<K extends keyof AdapterCommand>(cmd: unknown, property: K, defaultValue: AdapterCommand[K]): AdapterCommand[K];
/**
* Logging utility for adapter command validation
* Provides consistent logging format
*/
export declare function logAdapterCommandValidation(cmd: unknown, source: string, isValid: boolean, details?: unknown): void;