/**
 * 聊天消息数据
 */
export interface BubbleMessage {
	id?: number | string
	key?: number | string
	content: string
	role: 'user' | 'ai'
	placement?: 'start' | 'end'
	loading?: boolean
	shape?: 'corner' | 'round'
	variant?: 'outlined' | 'filled' | 'borderless' | 'shadow'
	isMarkdown?: boolean
	typing?: boolean | { step: number; interval: number }
	isFog?: boolean
	updateTime?: string
	message_files?: string | string[]
	thinking?: string
	thinkingOpen?: boolean
	toolCalls?: ChatToolCall[]
	toolResults?: ChatToolResult[]
	references?: ChatReference[]
	assistantMessageId?: string
	streamCompleted?: boolean
	rawText?: string
	[key: string]: any
}

export type ChatTargetType = 'knowledge' | 'agent' | 'model'

export interface ChatTargetConfig {
	type: ChatTargetType
	knowledgeBaseIds: string[]
	knowledgeIds: string[]
	summaryModelId: string
	disableTitle: boolean
	enableMemory: boolean
	agentId: string
	agentEnabled: boolean
	webSearchEnabled: boolean
	images: string[]
}

export interface ChatToolCall {
	id?: string
	toolCallId?: string
	toolName?: string
	arguments?: Record<string, any>
	content?: string
}

export interface ChatToolResult {
	id?: string
	toolCallId?: string
	toolName?: string
	success?: boolean
	error?: string
	output?: string
	thought?: string
	durationMs?: number
	displayType?: string
	contentItems?: any[]
}

export interface ChatReference {
	id?: string
	knowledgeBaseId?: string
	knowledgeId?: string
	knowledgeTitle?: string
	knowledgeFilename?: string
	knowledgeDescription?: string
	content?: string
	matchedContent?: string
	score?: number
	chunkType?: string
}

export interface ChatSseMessage {
	id?: string
	response_type?: string
	content?: string
	done?: boolean
	data?: Record<string, any>
}

export interface ChatSessionRuntimeState {
	targetType: ChatTargetType
	config: ChatTargetConfig
	allowImageUpload: boolean
}

/**
 * 会话数据
 */
export interface Conversation {
	id: string
	title: string
	updatedAt: number
	sessionId: string
	targetType?: ChatTargetType
	targetConfig?: Partial<ChatTargetConfig>
}
