import type { HTMLAttributes, ReactNode } from 'react'
import type { ReasoningStepDetail } from '../reasoning-step'
// ===== 基础类型 =====
export type ResponsePhase = 'thinking' | 'streaming' | 'done' | 'imageGenerating'
export type ResponseStepToolType = 'read' | 'edit' | 'search'
export interface ResponseStep {
text: string
description?: string
details?: ReasoningStepDetail[]
toolType?: ResponseStepToolType
}
export interface ResponseRound {
step: ResponseStep
simpleMd: string
}
// ===== Block 类型(内部) =====
export type BlockType = 'think' | 'composer' | 'md'
export interface ResponseBlock {
type: BlockType
step?: ResponseStep
md?: string
}
// ===== 组件 Props =====
export interface ResponseRootProps {
/** 是否启用流式模拟 */
simulate?: boolean
/** 当前阶段 */
phase?: ResponsePhase
/** 响应轮次数据 */
rounds?: ResponseRound[]
/** 最终 Markdown 内容 */
finalMarkdown?: string
/** 模拟完成回调 */
onSimulateComplete?: () => void
/** 步骤变化回调 */
onStepChange?: (text: string, toolType?: ResponseStepToolType) => void
/** 自定义 ThinkingIndicator(主库注入 Lottie) */
thinkingIndicator?: ReactNode
/** 自定义 className */
className?: string
/** 子组件 */
children?: ReactNode
}
export interface ResponseProps extends Omit, 'children'>, ResponseRootProps {}
export interface ResponseThinkingProps {
className?: string
}
export interface ResponseStepsProps {
className?: string
children?: ReactNode
}
export interface ResponseStepProps {
step: ResponseStep
status?: 'completed' | 'in-progress'
}
export interface ResponseContentProps {
/** Markdown 内容 */
markdown?: string
/** 是否流式渲染 */
streaming?: boolean
/** 流式渲染完成回调 */
onStreamComplete?: () => void
className?: string
}
export interface ResponseImageGeneratingProps {
width?: string
height?: string
className?: string
}
export interface ResponseDefaultLayoutProps {
className?: string
}
// ===== Context 类型 =====
export interface ResponseContextValue {
// 阶段控制
phase: ResponsePhase
simulate: boolean
// 数据
rounds: ResponseRound[]
finalMarkdown: string
blocks: ResponseBlock[]
// 状态
visibleIndex: number
setVisibleIndex: React.Dispatch>
isSimDone: boolean
currentBlock: ResponseBlock | null
showThink: boolean
// 回调
onSimulateComplete?: () => void
onStepChange?: (text: string, toolType?: ResponseStepToolType) => void
// 注入
thinkingIndicator: ReactNode
}
// ===== 复合组件类型 =====
export interface ResponseCompound {
Root: React.FC
Thinking: React.FC
Steps: React.FC
Step: React.FC
Content: React.FC
ImageGenerating: React.FC
DefaultLayout: React.FC
}