import type { UIMessagePart, UIDataTypes, UITools } from "ai"; /** Tool-set-agnostic: only `type` and a few fields are read. */ export type AgentUIPart = UIMessagePart; /** * Folded from ai's 7-state tool machine. `awaiting` is a call parked on a human decision, distinct * from `running` so the feed never pulses it. */ export type AgentStepStatus = "running" | "awaiting" | "done" | "error"; /** `toolName` is raw; the renderer maps it (`resolveToolMeta`). */ export interface AgentStep { id: string; toolName: string; status: AgentStepStatus; /** * Read from the `approval` record, since the state forgets at settle. An `isAutomatic` approval * is the system's, not an operator's. */ decided: boolean; /** Revealed on demand, never inline. */ input?: unknown; output?: unknown; errorText?: string; } export type AgentSegment = { kind: "text"; id: string; text: string; } | { kind: "reasoning"; id: string; text: string; } | { kind: "group"; id: string; steps: AgentStep[]; }; /** * Consecutive tool parts collapse into one group; prose gets a synthesized index id. Kinds with no * feed representation are skipped, as chat's renderer skips them. */ export declare function toSegments(parts: readonly AgentUIPart[]): AgentSegment[]; export declare function anyRunning(segments: readonly AgentSegment[]): boolean; export declare function lastRunningStep(segments: readonly AgentSegment[]): AgentStep | undefined; /** * The split is positional: a model emits plan, aside and report all as `text`, so what follows the * last tool call is the answer and everything before it is the work. */ export interface AgentTimeline { process: AgentSegment[]; /** Empty when the run stopped on a tool call — exactly when the work must not fold away. */ result: AgentSegment[]; /** Flattened, for a run-level summary. */ steps: AgentStep[]; } /** Pure: fresh arrays, nothing mutated. */ export declare function splitTimeline(segments: readonly AgentSegment[]): AgentTimeline;