/** * In-flight web chat run snapshots. * * React state (activity accordion, "接收中", run timeline) is wiped on * refresh / WS reconnect because HISTORY only carries role/content. This * module keeps a per-thread snapshot so get-history can replay the live * (or just-finished) run, and so chunk/activity emits can retarget the * reconnecting socket instead of a closed one. */ export type ActiveRunStepStatus = 'pending' | 'running' | 'success' | 'error' | 'denied'; export type ActiveRunStepKind = 'tool' | 'skill' | 'status' | 'approval' | 'ask' | 'agent'; export interface ActiveRunStep { id: string; kind: ActiveRunStepKind; label: string; status: ActiveRunStepStatus; startedAt: number; finishedAt?: number; preview?: string; todoItems?: Array<{ content: string; status: 'pending' | 'in_progress' | 'completed'; }>; } export interface ActiveRunSnapshot { threadId: string; runId: string; agent: string; startedAt: number; status: 'running' | 'success' | 'error'; steps: ActiveRunStep[]; partialText: string; finishedAt?: number; durationMs?: number; error?: string; } export declare function startActiveRun(input: { threadId: string; runId: string; agent: string; startedAt: number; }): ActiveRunSnapshot; export declare function upsertActiveRunStep(threadId: string, step: ActiveRunStep): void; export declare function appendActiveRunChunk(threadId: string, chunk: string): void; export declare function setActiveRunPartialText(threadId: string, text: string): void; export declare function finishActiveRun(threadId: string, outcome: { status: 'success' | 'error'; finishedAt: number; durationMs: number; finalText?: string; error?: string; }): void; export declare function getActiveRun(threadId: string): ActiveRunSnapshot | undefined; export declare function clearActiveRun(threadId: string): void; /** Convert a snapshot into the durable ChatMessage.activity shape. */ export declare function snapshotToPersistedActivity(snap: ActiveRunSnapshot): { runId: string; status: 'running' | 'success' | 'error'; startedAt: number; finishedAt?: number; durationMs?: number; error?: string; steps: ActiveRunStep[]; }; /** Test helper. */ export declare function _resetActiveRunsForTests(): void; //# sourceMappingURL=active-runs.d.ts.map