/** * Conversation Block Types * * Atomic units of conversation state. Each discrete event in a session * is represented as a separate block, allowing for granular state updates * and flexible syncing. * * These types are architecture-agnostic and can be built from either * Claude SDK or Gemini CLI message formats. */ /** * Text content - simple string message */ export interface TextContent { type: 'text'; text: string; } /** * Image content - base64 or URL */ export interface ImageContent { type: 'image'; source: { type: 'base64' | 'url'; data: string; mediaType?: string; }; } /** * Multimodal content - mix of text, images, etc. */ export type ContentPart = TextContent | ImageContent; export type MessageContent = string | ContentPart[]; /** * Status of a tool execution */ export type ToolExecutionStatus = 'pending' | 'running' | 'success' | 'error'; /** * Tool execution input/output */ export interface ToolIO { input: Record; output?: unknown; } /** * Common fields for all conversation blocks */ export interface BaseBlock { /** * Unique identifier for this block */ id: string; /** * ISO timestamp when this block was created */ timestamp: string; } /** * User message block * Represents user input to the agent */ export interface UserMessageBlock extends BaseBlock { type: 'user_message'; content: MessageContent; } /** * Assistant text response block * Represents text output from the agent */ export interface AssistantTextBlock extends BaseBlock { type: 'assistant_text'; content: string; /** * Model that generated this text (e.g., "claude-sonnet-4-5") */ model?: string; } /** * Tool use block * Represents the agent deciding to use a tool */ export interface ToolUseBlock extends BaseBlock { type: 'tool_use'; /** * Name of the tool (e.g., "Read", "Bash", "Edit") */ toolName: string; /** * Unique ID for this specific tool invocation * Used to match with corresponding ToolResultBlock */ toolUseId: string; /** * Tool input parameters */ input: Record; /** * Current execution status */ status: ToolExecutionStatus; /** * Display name for the tool (if different from toolName) */ displayName?: string; /** * Human-readable description of what this tool does */ description?: string; } /** * Tool result block * Represents the result of a tool execution */ export interface ToolResultBlock extends BaseBlock { type: 'tool_result'; /** * Links back to the ToolUseBlock via toolUseId */ toolUseId: string; /** * Tool execution output */ output: unknown; /** * Whether the tool execution failed */ isError: boolean; /** * How long the tool took to execute (milliseconds) */ durationMs?: number; /** * Display formatting hint for UI */ renderOutputAsMarkdown?: boolean; } /** * Thinking block * Represents agent's internal reasoning/thought process */ export interface ThinkingBlock extends BaseBlock { type: 'thinking'; /** * The thinking content (extended thinking tokens) */ content: string; /** * Optional summary of the thought (for Gemini ThoughtSummary) */ summary?: string; } /** * System block * Represents system-level events and messages */ export interface SystemBlock extends BaseBlock { type: 'system'; /** * Category of system message */ subtype: 'session_start' | 'session_end' | 'error' | 'status' | 'hook_response' | 'auth_status'; /** * Human-readable message */ message: string; /** * Additional structured metadata */ metadata?: Record; } /** * Subagent execution status */ export type SubagentStatus = 'pending' | 'running' | 'success' | 'error'; /** * Subagent block * Represents a subagent invocation in the main conversation. * Acts as a reference/link to the subagent's own conversation thread. * * Only applicable for Claude SDK (Gemini doesn't have subagents) */ export interface SubagentBlock extends BaseBlock { type: 'subagent'; /** * Unique identifier for this subagent * Used to reference the subagent's conversation thread */ subagentId: string; /** * Name/type of the subagent (e.g., "code-reviewer", "test-runner") */ name?: string; /** * The input/prompt given to the subagent */ input: string; /** * Current execution status */ status: SubagentStatus; /** * Final output from the subagent (once completed) */ output?: string; /** * How long the subagent took to complete (milliseconds) */ durationMs?: number; /** * The tool_use_id of the Task tool that spawned this subagent * Useful for linking back to the original tool use in Claude SDK */ toolUseId?: string; } /** * Error block * Represents an error that occurred during agent processing. * Used to display errors inline in the conversation. */ export interface ErrorBlock extends BaseBlock { type: 'error'; /** * Error message to display to the user */ message: string; /** * Error code if available (e.g., "SANDBOX_FAILED", "SDK_TIMEOUT") */ code?: string; } /** * All possible conversation block types */ export type ConversationBlock = UserMessageBlock | AssistantTextBlock | ToolUseBlock | ToolResultBlock | ThinkingBlock | SystemBlock | SubagentBlock | ErrorBlock; export declare function isUserMessageBlock(block: ConversationBlock): block is UserMessageBlock; export declare function isAssistantTextBlock(block: ConversationBlock): block is AssistantTextBlock; export declare function isToolUseBlock(block: ConversationBlock): block is ToolUseBlock; export declare function isToolResultBlock(block: ConversationBlock): block is ToolResultBlock; export declare function isThinkingBlock(block: ConversationBlock): block is ThinkingBlock; export declare function isSystemBlock(block: ConversationBlock): block is SystemBlock; export declare function isSubagentBlock(block: ConversationBlock): block is SubagentBlock; export declare function isErrorBlock(block: ConversationBlock): block is ErrorBlock; //# sourceMappingURL=blocks.d.ts.map