export type PipelineHealth = { state: "starting" | "running" | "stopping" | "stopped" | "degraded"; startedAt: number; inflightRunIds: string[]; lastError?: string; }; export type ChatQueueState = { chatId: string; state: "idle" | "buffering" | "busy" | "stopped" | "degraded"; activeRunId: string | null; bufferMessageIds: number[]; pendingRunIds: string[]; updatedAt: number; lastError?: string; }; export type RunStage = "queued" | "agent_running" | "sending_response" | "done" | "failed" | "stopped"; export type RuntimeStateEventName = "started" | "stage_changed" | "timeout" | "failed" | "stopped" | "done" | "failed_by_restart"; export type RuntimeStateEvent = { chatId: string; scopeKey: string; threadId?: string; runId: string; messageIds: number[]; stage: RunStage; event: RuntimeStateEventName; error?: string; elapsedMs: number; }; export type RunState = { runId: string; chatId: string; scopeKey: string; threadId?: string; triggerMessageIds: number[]; triggerPlatformMsgIds: string[]; replyToPlatformMsgId?: string; mergedText: string; stage: RunStage; startedAt: number; updatedAt: number; lastError?: string; }; type RuntimeStateStoreOptions = { now?: () => number; createRunId?: () => string; onEvent?: (event: RuntimeStateEvent) => void; }; type CreateRunInput = { chatId: string; scopeKey?: string; threadId?: string; triggerMessageIds: number[]; triggerPlatformMsgIds: string[]; replyToPlatformMsgId?: string; mergedText: string; }; export declare class RuntimeStateStore { private readonly now; private readonly createRunId; private readonly onEvent?; private readonly pipelineHealth; private readonly chats; private readonly runs; constructor(options?: RuntimeStateStoreOptions); getPipelineHealth(): PipelineHealth; getChatState(chatId: string): ChatQueueState; getScopeState(scopeKey: string): ChatQueueState; getRun(runId: string): RunState | undefined; getRunsForChat(chatId: string): RunState[]; getRunsForScope(scopeKey: string): RunState[]; getActiveRun(chatId: string): RunState | null; getActiveRunForScope(scopeKey: string): RunState | null; createRun(input: CreateRunInput): RunState; markRunStage(runId: string, stage: RunStage, lastError?: string): RunState; recordRunEvent(runId: string, event: RuntimeStateEventName, error?: string): void; updateChatBuffer(chatId: string, bufferMessageIds: number[]): ChatQueueState; updateScopeBuffer(scopeKey: string, bufferMessageIds: number[]): ChatQueueState; markChatStopped(chatId: string, lastError?: string): ChatQueueState; markScopeStopped(scopeKey: string, lastError?: string): ChatQueueState; private ensureChatState; private setInflight; private recordError; private emitRunEvent; } export {};