import type { ChatUiMessageChunk, MessageMetadata } from "../../../chat/types.js"; import type { StreamLifecyclePhase } from "./types.js"; /** Default value for chat stream idle timeout ms. */ export declare const DEFAULT_CHAT_STREAM_IDLE_TIMEOUT_MS = 120000; /** Default value for chat stream tool running timeout ms. */ export declare const DEFAULT_CHAT_STREAM_TOOL_RUNNING_TIMEOUT_MS = 300000; /** Public API contract for chat stream watchdog phase. */ export type ChatStreamWatchdogPhase = "response_pending" | "tool_input_streaming" | "tool_running" | "post_tool_idle"; /** State for chat stream watchdog. */ export type ChatStreamWatchdogState = { phase: ChatStreamWatchdogPhase; timeoutMs: number; toolCallId?: string; toolName?: string; }; /** Options accepted by chat stream watchdog. */ export type ChatStreamWatchdogOptions = { idleTimeoutMs?: number; toolRunningTimeoutMs?: number; longRunningToolNames?: Iterable; longRunningToolPrefixes?: Iterable; /** * Strict lifecycle deadline semantics: telemetry (all message-metadata and * tool-call-status chunks, empty deltas) never advances the deadline, and * configured long-running tools run under the absolute * `toolRunningTimeoutMs` cap instead of disabling the deadline. * * Defaults from `VF_STREAM_LIFECYCLE_MODE`: strict in `shadow`/`active`, * legacy-compatible otherwise, so the rollout mode flag governs the full * behavior change and `legacy` remains byte-compatible with the * pre-lifecycle watchdog. */ strictDeadlines?: boolean; setTimeoutFn?: typeof globalThis.setTimeout; clearTimeoutFn?: typeof globalThis.clearTimeout; }; /** Error shape for chat stream idle timeout. */ export declare class ChatStreamIdleTimeoutError extends Error { readonly state: ChatStreamWatchdogState; constructor(state: ChatStreamWatchdogState); } /** State for create chat stream watchdog. */ export declare function createChatStreamWatchdogState(phase: ChatStreamWatchdogPhase, metadata?: { toolCallId?: string; toolName?: string; }, options?: Pick, "idleTimeoutMs" | "toolRunningTimeoutMs">): ChatStreamWatchdogState; /** * Compatibility helper. Under strict lifecycle deadlines long-running tool * names no longer disable the absolute tool-running deadline; in legacy mode * they still do. Also exported for callers that classify tool activity. */ export declare function isLongRunningToolRunning(current: ChatStreamWatchdogState, longRunningToolNames: ReadonlySet, longRunningToolPrefixes?: readonly string[]): boolean; /** State for get next chat stream watchdog. */ export declare function getNextChatStreamWatchdogState(currentState: ChatStreamWatchdogState, chunk: ChatUiMessageChunk, options?: ChatStreamWatchdogOptions): ChatStreamWatchdogState; /** Check whether a chunk only carries heartbeat metadata. */ export declare function isHeartbeatOnlyMetadataChunk(chunk: ChatUiMessageChunk): boolean; /** Lifecycle-shaped classification of a compatibility UI chunk. */ export type WatchdogLifecycleActivity = { type: "semantic_progress"; phase: StreamLifecyclePhase; toolCallId?: string; toolName?: string; } | { type: "phase_transition"; phase: StreamLifecyclePhase; toolCallId?: string; toolName?: string; } | { type: "telemetry"; } | { type: "completed"; }; /** Map a compatibility chunk into lifecycle activity for the watchdog. */ export declare function mapWatchdogChunkToLifecycleActivity(current: ChatStreamWatchdogState, chunk: ChatUiMessageChunk): WatchdogLifecycleActivity; /** Create chat stream watchdog backed by the lifecycle deadline primitive. */ export declare function createChatStreamWatchdog(options?: ChatStreamWatchdogOptions): { signal: AbortSignal; readonly lastTimeoutState: ChatStreamWatchdogState | null; keepAlive(): void; observe(chunk: ChatUiMessageChunk): void; dispose(): void; }; //# sourceMappingURL=watchdog-compat-adapter.d.ts.map