/** * Resource Manager * * Manages worktree resource limits including count, disk usage, * stale detection, and automatic cleanup. */ import type { WorktreeManager } from "./manager.js"; import type { ResourceLimits, ResourceUsage, WorktreeMetrics, ResourceReport, Worktree, WorktreeStatus } from "../types.js"; export declare class ResourceManager { private readonly worktreeManager; private readonly limits; private readonly logger; constructor(worktreeManager: WorktreeManager, limits?: Partial); /** * Get current resource usage. */ getCurrentUsage(): Promise; /** * Check if a new worktree can be allocated. */ canAllocate(): Promise<{ allowed: boolean; reason?: string; }>; /** * Get detailed metrics for all worktrees. */ getAllWorktreeMetrics(): Promise; /** * Get metrics for a specific worktree. */ getWorktreeMetrics(worktreeId: string): Promise; /** * Find stale worktrees (idle beyond threshold). */ findStaleWorktrees(maxIdleTimeMs?: number): Worktree[]; /** * Check if cleanup should be triggered. */ shouldTriggerCleanup(): Promise; /** * Cleanup stale worktrees. */ cleanupStale(maxIdleTimeMs?: number): Promise; /** * Cleanup worktrees by status. */ cleanupByStatus(status: WorktreeStatus): Promise; /** * Force cleanup specific worktrees. */ forceCleanup(worktreeIds: string[]): Promise<{ cleaned: string[]; failed: string[]; }>; /** * Get full resource report. */ getReport(): Promise; /** * Calculate disk usage for a path in MB. * * Note: Uses execSync with shell for the du command. The dirPath parameter * is system-controlled (comes from WorktreeManager internal state) and is * quoted to prevent any injection. This is safe as worktree paths are * generated internally and not from user input. */ private calculateDiskUsage; /** * Get the configured limits. */ getLimits(): ResourceLimits; } //# sourceMappingURL=resource-manager.d.ts.map