/** * Auto-retry for **non-loop** sessions that fail with a transient provider * timeout. The loop event handler (`src/hooks/loop.ts`) already takes care of * loop sessions — it marks `modelFailed` and falls through to the fallback * chain on the next iteration. Non-loop sessions (plain muse/sage/forge chat, * plan-execute dispatch, agent-as-tool, ...) have no such safety net, so a * single SSE timeout surfaces as "Tool execution aborted / The operation * timed out" and the user has to manually re-send. * * This hook performs **one** retry per user message on: * - classified kind === 'timeout' AND * - error name is NOT MessageAbortedError / AbortError (those mean the user * pressed Esc — we must not re-dispatch automatically). * * Budget: 1 retry per messageID, 2s backoff. Prevents infinite retry storms * when the provider is genuinely down. */ import type { OpencodeClient } from '@opencode-ai/sdk/v2'; import type { LoopService } from '../services/loop'; import type { Logger } from '../types'; export interface SessionRetryHookDeps { loopService: LoopService; v2: OpencodeClient; directory: string; logger: Logger; /** Optional override for the retry backoff (ms). Default 2000. */ backoffMs?: number; } export interface SessionRetryHooks { onMessagesTransform: (output: { messages: Array<{ info: { role: string; agent?: string; id?: string; sessionID?: string; }; parts: Array>; }>; }) => void; onEvent: (input: { event: { type: string; properties?: Record; }; }) => Promise; /** Testing helper. */ __reset(): void; } export declare function createSessionRetryHooks(deps: SessionRetryHookDeps): SessionRetryHooks; //# sourceMappingURL=session-retry.d.ts.map