message flow
消息类型
Anthropic API 消息格式
type Message = {
role: 'user' | 'assistant';
content: string | ContentBlock[];
};
type ContentBlock =
| { type: 'text'; text: string }
| { type: 'tool_use'; id: string; name: string; input: any }
| { type: 'tool_result'; tool_use_id: string; content: string };内部消息格式
interface InternalMessage {
id: string;
role: 'user' | 'assistant' | 'system';
content: string;
timestamp: number;
metadata?: {
tokenCount?: number;
compressed?: boolean;
toolCalls?: ToolCall[];
};
}