mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-02 13:39:41 +02:00
Create 6 domain-focused config files in src/config/ to centralize operational tuning knobs that were scattered across 15+ source files: - server-timing.ts: SSE batching, state debounce, scheduled runs, error recovery - auth-config.ts: session TTL, rate limits, hook timeout - tunnel-config.ts: QR token rotation, tunnel process lifecycle - terminal-limits.ts: input length, terminal cols/rows, session name - ai-defaults.ts: AI model string, idle/plan context limits - team-config.ts: poll interval, cache sizes Eliminates all cross-file duplicates: - AI model string: 5 occurrences → 1 (config only) - STATS_COLLECTION_INTERVAL_MS: 2 → 1 - timeout: 10000 in hooks-config: 6 → 0 (now HOOK_TIMEOUT_MS) - MAX_TRACKED_AGENTS shadow: removed, imports from map-limits Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
/**
|
||
* @fileoverview Centralized Map size limits for memory management.
|
||
*
|
||
* These constants define maximum sizes for Maps that track ephemeral data.
|
||
* Without limits, long-running sessions can accumulate unbounded entries
|
||
* leading to memory leaks.
|
||
*
|
||
* Memory Budget Rationale:
|
||
* - Assuming average entry size of ~1KB
|
||
* - MAX_TRACKED_AGENTS=500 × 1KB = ~500KB for agent tracking
|
||
* - Activity/results per agent × agents = bounded by these limits
|
||
* - Total Map overhead: <50MB even under heavy load
|
||
*
|
||
* @module config/map-limits
|
||
*/
|
||
|
||
// ============================================================================
|
||
// Session Tracking Limits
|
||
// ============================================================================
|
||
|
||
/**
|
||
* Maximum concurrent sessions allowed.
|
||
* Each session consumes significant resources (PTY, buffers, watchers).
|
||
*/
|
||
export const MAX_CONCURRENT_SESSIONS = 50;
|
||
|
||
// ============================================================================
|
||
// SSE Client Limits
|
||
// ============================================================================
|
||
|
||
/**
|
||
* Maximum concurrent SSE client connections.
|
||
* Each connection holds an open HTTP response and receives all broadcast events.
|
||
*/
|
||
export const MAX_SSE_CLIENTS = 100;
|
||
|
||
// ============================================================================
|
||
// Todo Item Limits (Ralph Tracker)
|
||
// ============================================================================
|
||
|
||
/**
|
||
* Maximum todo items to track per session.
|
||
*/
|
||
export const MAX_TODOS_PER_SESSION = 500;
|
||
|
||
// ============================================================================
|
||
// Pending Tool Calls Limits
|
||
// ============================================================================
|
||
|
||
// ============================================================================
|
||
// Agent Tracking Limits
|
||
// ============================================================================
|
||
|
||
/**
|
||
* Maximum agents to track across all sessions (LRU eviction when exceeded).
|
||
*/
|
||
export const MAX_TRACKED_AGENTS = 500;
|
||
|
||
/**
|
||
* Maximum pending tool calls to track per subagent.
|
||
* Entries should be cleaned up on tool_result, but this prevents leaks.
|
||
*/
|
||
export const MAX_PENDING_TOOL_CALLS = 100;
|
||
|
||
/**
|
||
* TTL for orphaned pending tool calls (5 minutes).
|
||
* If no tool_result received, entry is cleaned up.
|
||
*/
|
||
export const PENDING_TOOL_CALL_TTL_MS = 5 * 60 * 1000;
|