export interface ToolBridgeContent { action: string; payload?: unknown; } export interface ContentBlock { type: "text" | "thinking" | "tool_use" | "tool_result" | "tool_ui" | "tool_bridge" | "system_notification" | "mode_change" | "plan_status" | "ask_user_answer"; content: unknown; /** Stable history-entry identity for a tool_bridge delivery. */ delivery_id?: string | null; tool_call_id?: string | null; tool_name?: string | null; display_name?: string | null; } export interface PendingQuestionRef { child_loop_name: string; child_tool_call_id: string; description?: string | null; } /** 一次运行(用户轮或子智能体)的实际墙钟区间。 */ export interface RunTiming { run_id: string; scope: "chat" | "subagent"; loop_id: string; started_at?: string | null; duration_ms?: number | null; status: "completed" | "failed" | "cancelled" | "paused" | "incomplete"; } export interface ToolCallProjection { id: string; tool_name: string; display_name: string; arguments: string; status: "pending" | "done" | "error" | "cancelled" | "awaiting_answer" | string; result?: unknown; duration_ms?: number | null; /** 工具真正进入执行的墙钟起点;排队/待审批的调用没有该值。 */ started_at?: string | null; ran_in_parallel?: boolean; /** 该工具派生的子智能体运行区间,仅作外层展示。 */ subagent_runs?: RunTiming[]; pending_question_ref?: PendingQuestionRef | null; } export interface MemoryRef { id: number; content_preview: string; skill_name?: string | null; } export interface FinalArtifact { kind: "file" | "link"; target: string; label: string; } export interface PostChatFollowup { assistant_entry_id: string; recaption?: string; suggestions: string[]; final_artifacts?: FinalArtifact[]; feedback_eligible: boolean; feedback_scope: "latest_result"; } export interface TurnProjection { id: string; sequence: number; turn_id: string; loop_id: string; kind?: "message" | "context" | "compaction"; role: "user" | "assistant" | "system"; status: "streaming" | "completed" | "paused" | "failed" | "interrupted"; blocks: ContentBlock[]; tool_calls: ToolCallProjection[]; model?: string | null; usage?: Record | null; /** 模型请求区间(不含后续工具);未知时为 null,不用 0 冒充。 */ duration_ms?: number | null; /** Root chat wall time; model/tool samples remain separate. */ chat_run?: RunTiming | null; first_token_ms?: number | null; stream_duration_ms?: number | null; first_token_delivery_ms?: number | null; started_at?: string | null; /** started_at 是否来自生产者上报(而非旧会话的落盘回落)。瀑布只承认前者。 */ has_reported_timing?: boolean; context_window?: number; memory_refs?: MemoryRef[] | null; parent_fork_tool_call_id?: string | null; context_kind?: string | null; context_key?: string | null; context_name?: string | null; context_order?: number | null; context_action?: import("./context").ContextAction | null; context_revision?: string | null; /** 原始 Context 内容仅供开发者模式诊断;常规消息投影不消费。 */ context_content?: unknown; display_title?: string | null; display_summary?: string | null; sources?: import("./context").ContextSourceInfo[] | null; /** Client-only stable identity for reconciling an optimistic user turn. */ client_render_id?: string | null; /** Send identity echoed by the server for exact optimistic reconciliation. */ client_request_id?: string | null; compaction_id?: string | null; summary_preview?: string | null; summary_full?: string | null; archived_count?: number | null; archived_files?: ArchivedFileInfo[] | null; archived_tool_calls?: ArchivedToolCallInfo[] | null; tokens_before?: number | null; tokens_after?: number | null; saved_ratio?: number | null; trigger?: "auto" | "manual" | "forced_retry" | null; failure_reason?: string | null; fallback_applied?: boolean | null; post_chat_followup?: PostChatFollowup | null; } export interface ArchivedFileInfo { tool_name?: string | null; filename?: string | null; relative_path?: string | null; size_bytes?: number | null; } export interface ArchivedToolCallInfo { tool_call_id?: string | null; tool_name?: string | null; archive_path?: string | null; replacement_content?: string | null; entry_id?: string | null; } export interface PatchEnvelope { sequence: number; turn_id: string; loop_id: string; patch_type: string; data: { turn?: TurnProjection; workspace_changed?: { tool_call_id?: string; tool_name?: string; workspace_path?: string; }; }; }