/** * Anthropic canonical content block types * Per constraint #6: Anthropic canonical content blocks * * @module packages/contracts/src/content-block */ /** * Text content block */ export interface TextBlock { type: 'text' text: string } /** * Thinking/reasoning block (for models that support it) */ export interface ThinkingBlock { type: 'thinking' thinking: string } /** * Tool use block - represents a tool call request */ export interface ToolUseBlock { type: 'tool_use' id: string name: string input: Record } /** * Tool result block - represents the result of a tool execution */ export interface ToolResultBlock { type: 'tool_result' tool_use_id: string content: string | ContentBlock[] is_error?: boolean } /** * Union of all canonical content block types */ export type ContentBlock = TextBlock | ThinkingBlock | ToolUseBlock | ToolResultBlock /** * Canonical message format using content blocks */ export interface CanonicalMessage { role: 'user' | 'assistant' | 'system' content: string | ContentBlock[] // Optional thinking for assistant messages thinking?: string } /** * Tool definition for tool use blocks */ export interface ToolDefinitionBlock { name: string description: string input_schema: Record } /** * Tool choice specification */ export type ToolChoice = | { type: 'auto' } | { type: 'any' } | { type: 'tool'; name: string }