diff --git a/src/hooks/anthropic-context-window-limit-recovery/session-timeout-map.ts b/src/hooks/anthropic-context-window-limit-recovery/session-timeout-map.ts new file mode 100644 index 000000000..80712d03f --- /dev/null +++ b/src/hooks/anthropic-context-window-limit-recovery/session-timeout-map.ts @@ -0,0 +1,20 @@ +export function clearSessionTimeout( + timeoutBySession: Map>, + sessionID: string, +): void { + const timeoutID = timeoutBySession.get(sessionID) + if (timeoutID !== undefined) { + clearTimeout(timeoutID) + timeoutBySession.delete(sessionID) + } +} + +export function clearAllSessionTimeouts( + timeoutBySession: Map>, +): void { + for (const timeoutID of timeoutBySession.values()) { + clearTimeout(timeoutID) + } + + timeoutBySession.clear() +}