// src/types/agent.ts export interface ToolStep { tool: string; arguments: Record; call_id?: string; result?: any; is_error?: boolean; status: 'running' | 'completed' | 'failed'; startedAt?: number; completedAt?: number; } export interface AgentToolFunction { name: string; description: string; parameters?: Record; } export interface AgentToolMetadata { name: string; description: string; is_dangerous?: boolean; schema?: { type?: string; function?: AgentToolFunction; }; } export interface AgentDangerousAction { tool: string; arguments: Record; call_id?: string; description?: string; confirmed?: boolean; cancelled?: boolean; } export interface AgentMessage { id: string; role: 'user' | 'assistant' | 'system'; content: string; timestamp: number; steps?: ToolStep[]; thinking?: { status: 'started' | 'planning' | 'executing' | 'idle'; step?: number; }; isStreaming?: boolean; error?: string; dangerousAction?: AgentDangerousAction; } export interface AgentSession { id: string; title: string; createdAt: number; updatedAt: number; messageCount: number; lastMessageSnippet?: string; } export interface AgentChatParams { message: string; session_id?: string; stream?: boolean; max_steps?: number; model?: string; } export interface SSEStreamHandlers { onThink?: (step: number, status?: string) => void; onToolStart?: (tool: string, args: Record, callId?: string) => void; onToolEnd?: (tool: string, result: any, isError: boolean, callId?: string) => void; onMessage?: (delta: string, full: string) => void; onFinish?: (finalAnswer: string, stepsCount: number, sessionId?: string) => void; onError?: (err: any) => void; }