export type ChatToolSurface = 'site' | 'web' | 'internal'; export type ChatActivityState = 'running' | 'done' | 'error'; export interface ChatActivity { id: string; requestId?: string; name: string; surface: ChatToolSurface; state: ChatActivityState; label: string; target?: string; summary?: string; batchId?: string; } export interface ChatApprovalState { state: 'needed'; tool: string; target?: string; } export type ThinkingTimelineEntry = | { id: string; kind: 'work_step'; label: string; state: ChatActivityState; source?: 'reasoning_summary' | 'tool' | 'approval' | 'preamble' } | { id: string; kind: 'tool'; name?: string; label: string; state: ChatActivityState; target?: string }; export interface FinalizedThinkingSummary { durationMs: number; activities: ChatActivity[]; approvalState?: ChatApprovalState; timeline: ThinkingTimelineEntry[]; } export type ChatBackendStreamEvent = | { type: 'work_step'; id: string; label: string; state?: 'done'; source?: 'reasoning_summary' } | { type: 'message_delta'; text: string } | { type: 'error'; message: string }; export type ChatRuntimeUiEvent = | { type: 'tool_start'; id: string; name: string; surface: ChatToolSurface; target?: string; batchId?: string; label?: string } | { type: 'tool_end'; id: string; ok: boolean; summary?: string; batchId?: string } | { type: 'approval'; id: string; state: 'needed' | 'granted' | 'rejected'; tool: string; target?: string; batchId?: string };