/** 与内核交互的数据类型 */ export interface Conversation { id: string; title: string; agentId?: string; pinned?: boolean; createdAt: string; updatedAt: string; messageCount: number; /** 最后一条消息的预览(真实聊天记录) */ preview?: string; } export interface Attachment { id: string; name: string; size: number; mime?: string; url?: string; path?: string; } export interface ChatMessage { role: 'user' | 'assistant' | 'system' | 'tool'; content: string; at?: string; attachments?: Attachment[]; /** 该条回复的思维链(模型返回 reasoning 时才有) */ reasoning?: string; /** 该条回复调用过的工具(用于在气泡下展示) */ toolTrace?: ToolTrace[]; pending?: boolean; error?: boolean; /** 本地反馈状态 */ feedback?: 'up' | 'down' | null; } export interface ToolTrace { id: string; name: string; args?: unknown; ok?: boolean; result?: string; } export interface Security { mode: 'open' | 'restricted'; allow: string[]; } export interface Settings { provider: string; baseUrl: string; model: string; apiKey: string; hasApiKey?: boolean; temperature: number; maxRounds: number; /** off / low / medium / high / auto */ thinkingLevel: string; /** 额外的工具目录(安卓端可以指到手机上的目录) */ toolsDir: string; systemPrompt: string; tools: { python: boolean; mcp: boolean }; security: Security; pythonBin: string; nickname: string; doubaoId: string; activeAgentId: string; } export interface Agent { id: string; name: string; avatar: string; tagline?: string; systemPrompt: string; builtin?: boolean; } export interface ProviderPreset { label: string; baseUrl: string; apiKeyEnv: string; defaultModel: string; modelHint: string; docs: string; models: string[]; } export interface PythonTool { name: string; description: string; parameters: Record; file: string; } export interface McpServer { name: string; enabled: boolean; transport: string; target: string; connected: boolean; error: string | null; tools: { name: string; description: string }[]; } export interface AppState { settings: Settings; provider: ProviderPreset; providers: Record; python: { tools: PythonTool[]; errors: { file: string; error: string }[]; interpreter: string | null }; mcp: McpServer[]; conversations: Conversation[]; agents: Agent[]; toolNames: string[]; suggestedAllow: string[]; /** 内核所在平台:win32 / linux / android */ platform?: string; shellKind?: string; } export type StreamEvent = | { type: 'start'; provider: string; model: string; tools: number; mode?: string; thinkingLevel?: string; agent?: { id: string; name: string } | null } | { type: 'delta'; text: string; round: number } | { type: 'reasoning'; text: string; round: number } | { type: 'tool_call'; id: string; name: string; args: unknown } | { type: 'tool_result'; id: string; name: string; ok: boolean; result: string } | { type: 'done'; content: string; reasoning?: string; rounds: number; toolCalls: number; usage?: unknown } | { type: 'saved'; conversationId: string; title?: string } | { type: 'error'; message: string; hint?: string };