/** * Reliability Runtime Helpers * * Purpose: * - Provide shared timeout/retry policy contracts and chat-scoped wait-status emission helpers. * * Key features: * - Canonical reliability policy/error-category types. * - Chat-scoped per-second system status emitter with immediate first emission. * - Automatic elapsed/remaining second computation for bounded waits. * - No-op behavior when world/chat context is unavailable. * * Implementation notes: * - Keep helpers dependency-light so runtime boundaries (MCP/queue/LLM/etc.) can reuse them. * - Emitter lifecycle is explicit; caller must call `stop()` on completion/error/abort paths. * * Recent changes: * - 2026-03-05: Initial shared reliability contract + wait-status emitter implementation. */ import type { World } from './types.js'; export type ReliabilityErrorCategory = 'timeout' | 'retry_exhausted' | 'transport_error'; export type RetryDelayStrategy = (attempt: number) => number; export interface ReliabilityPolicy { timeoutMs?: number; maxAttempts: number; retryDelayMs: RetryDelayStrategy; terminalErrorCategory: ReliabilityErrorCategory; } export interface WaitStatusSnapshot { phase: string; reason?: string; elapsedSeconds: number; remainingSeconds: number | null; attempt?: number; maxAttempts?: number; attemptsRemaining?: number; } type WaitStatusEmitterOptions = { world?: World | null; chatId?: string | null; phase: string; reason?: string; durationMs?: number | null; attempt?: number; maxAttempts?: number; contentBuilder?: (snapshot: WaitStatusSnapshot) => string; }; export type WaitStatusEmitterHandle = { stop: () => void; emitNow: () => void; }; export declare function startChatScopedWaitStatusEmitter(options: WaitStatusEmitterOptions): WaitStatusEmitterHandle; export {};