UNPKG

@ai-capabilities-suite/mcp-debugger-core

Version:

Core debugging engine for Node.js and TypeScript applications. Provides Inspector Protocol integration, breakpoint management, variable inspection, execution control, profiling, hang detection, and source map support.

119 lines (118 loc) 3.46 kB
/** * Resource Limiter * Enforces resource limits and quotas for production readiness */ export interface ResourceLimits { /** * Maximum concurrent sessions per user */ maxSessionsPerUser: number; /** * Maximum breakpoints per session */ maxBreakpointsPerSession: number; /** * Maximum memory usage per session in bytes */ maxMemoryPerSession: number; /** * Maximum session duration in milliseconds */ maxSessionDuration: number; /** * Maximum watched variables per session */ maxWatchedVariablesPerSession: number; } export interface ResourceUsage { sessionsPerUser: Map<string, number>; breakpointsPerSession: Map<string, number>; memoryPerSession: Map<string, number>; sessionStartTimes: Map<string, number>; watchedVariablesPerSession: Map<string, number>; } export declare class ResourceLimiter { private limits; private usage; constructor(limits: ResourceLimits); /** * Check if user can create a new session * @param userId User identifier * @returns True if allowed, false otherwise * @throws Error if limit exceeded */ checkSessionLimit(userId: string): boolean; /** * Register a new session * @param userId User identifier * @param sessionId Session identifier */ registerSession(userId: string, sessionId: string): void; /** * Unregister a session * @param userId User identifier * @param sessionId Session identifier */ unregisterSession(userId: string, sessionId: string): void; /** * Check if session can add a breakpoint * @param sessionId Session identifier * @returns True if allowed, false otherwise * @throws Error if limit exceeded */ checkBreakpointLimit(sessionId: string): boolean; /** * Register a breakpoint * @param sessionId Session identifier */ registerBreakpoint(sessionId: string): void; /** * Unregister a breakpoint * @param sessionId Session identifier */ unregisterBreakpoint(sessionId: string): void; /** * Check if session can add a watched variable * @param sessionId Session identifier * @returns True if allowed, false otherwise * @throws Error if limit exceeded */ checkWatchedVariableLimit(sessionId: string): boolean; /** * Register a watched variable * @param sessionId Session identifier */ registerWatchedVariable(sessionId: string): void; /** * Unregister a watched variable * @param sessionId Session identifier */ unregisterWatchedVariable(sessionId: string): void; /** * Check if session has exceeded duration limit * @param sessionId Session identifier * @returns True if exceeded, false otherwise */ checkSessionDuration(sessionId: string): boolean; /** * Update memory usage for a session * @param sessionId Session identifier * @param memoryBytes Memory usage in bytes * @throws Error if limit exceeded */ updateMemoryUsage(sessionId: string, memoryBytes: number): void; /** * Get current resource usage * @returns Current resource usage */ getUsage(): ResourceUsage; /** * Get resource limits * @returns Resource limits */ getLimits(): ResourceLimits; /** * Reset all usage tracking */ reset(): void; }