Project Files
src / constants.ts
// Command execution limits - shell will reject truly absurd lengths
export const EXEC_DEFAULT_TIMEOUT_MS = 30_000;
export const EXEC_MAX_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes max to prevent hanging tasks
export const EXEC_MIN_OUTPUT_BYTES = 1024; // Minimum 1KB buffer
export const EXEC_DEFAULT_OUTPUT_BYTES = 10 * 1024 * 1024; // 10 MB default
export const EXEC_MAX_COMMAND_LENGTH = 32767; // Windows MAX_COMMAND_LINE length
// Script limits
export const SCRIPT_MAX_CODE_LENGTH = 50_000; // Reasonable limit for inline code
export const SCRIPT_TEMP_PREFIX = "lms-terminal-";
// Cache configuration
export const CACHE_DEFAULT_TTL = 60_000; // 1 minute
export const CACHE_MAX_ENTRIES = 100;
// Progress reporting thresholds
export const PROGRESS_THRESHOLD_MS = 5_000; // Show progress for commands >5s
export const PROGRESS_UPDATE_INTERVAL_MS = 1_000;
// Security thresholds
export const RATE_LIMIT_WINDOW_MS = 60_000; // 1 minute window
export const RATE_LIMIT_MAX_CALLS = 100;
export const COMMAND_HISTORY_SIZE = 1000;
// Resource monitoring
export const MEMORY_WARNING_THRESHOLD_MB = 500;
export const CPU_WARNING_THRESHOLD_PERCENT = 80;
// File operation limits
export const MAX_FILE_SIZE_FOR_DIFF = 1_000_000; // 1MB for file diff operations
export const ARCHIVE_MAX_SIZE_MB = 100;
export const MAX_FILE_SIZE_FOR_TEXT = 10 * 1024 * 1024; // 10MB for text operations
// Additional constants
export const CACHE_THRESHOLD_MS = 1_000; // Cache results only if execution time >1s
export const STREAMING_OUTPUT_THRESHOLD_MS = 5_000; // Stream output if command runs longer than this
export const SIGTERM_GRACE_PERIOD_MS = 2_000;