| |
| |
| |
| |
| |
| |
|
|
| import type { UIMessage } from 'ai'; |
| import type { ThinkingConfig } from './provider'; |
|
|
| |
| export type SessionType = 'qa' | 'discussion' | 'lecture'; |
| export type SessionStatus = 'idle' | 'active' | 'interrupted' | 'completed'; |
|
|
| |
| |
| |
| export interface ChatMessageMetadata { |
| senderName?: string; |
| senderAvatar?: string; |
| originalRole?: 'teacher' | 'agent' | 'user'; |
| actions?: MessageAction[]; |
| agentId?: string; |
| agentColor?: string; |
| createdAt?: number; |
| interrupted?: boolean; |
| } |
|
|
| |
| |
| |
| export interface MessageAction { |
| id: string; |
| label: string; |
| icon?: string; |
| variant?: 'spotlight' | 'highlight' | 'reset' | 'insert' | 'draw'; |
| } |
|
|
| |
| |
| |
| export interface ChatSession { |
| id: string; |
| type: SessionType; |
| title: string; |
| status: SessionStatus; |
| messages: UIMessage<ChatMessageMetadata>[]; |
| config: SessionConfig; |
| toolCalls: ToolCallRecord[]; |
| pendingToolCalls: ToolCallRequest[]; |
| createdAt: number; |
| updatedAt: number; |
| sceneId?: string; |
| lastActionIndex?: number; |
| } |
|
|
| |
| |
| |
| export interface SessionConfig { |
| agentIds: string[]; |
| maxTurns: number; |
| currentTurn: number; |
| triggerAgentId?: string; |
| defaultAgentId?: string; |
| } |
|
|
| |
| |
| |
| export interface ToolCallRequest { |
| toolCallId: string; |
| toolName: string; |
| args: Record<string, unknown>; |
| agentId: string; |
| status: 'pending' | 'executing'; |
| requestedAt: number; |
| } |
|
|
| |
| |
| |
| export interface ToolCallRecord { |
| toolCallId: string; |
| toolName: string; |
| args: Record<string, unknown>; |
| agentId: string; |
| result?: unknown; |
| error?: string; |
| status: 'pending' | 'executing' | 'completed' | 'failed'; |
| requestedAt: number; |
| completedAt?: number; |
| } |
|
|
| |
| |
| |
| export type SessionEvent = |
| | { type: 'message'; data: UIMessage<ChatMessageMetadata> } |
| | { |
| type: 'tool_request'; |
| data: { sessionId: string; toolCalls: ToolCallRequest[] }; |
| } |
| | { type: 'tool_complete'; data: ToolCallRecord } |
| | { |
| type: 'agent_switch'; |
| data: { fromAgentId: string | null; toAgentId: string }; |
| } |
| | { type: 'session_status'; data: { status: SessionStatus; reason?: string } } |
| | { type: 'error'; data: { message: string } } |
| | { type: 'done'; data: SessionSummary } |
| | { |
| type: 'text_start'; |
| data: { messageId: string; agentId: string; agentName: string }; |
| } |
| | { type: 'text_delta'; data: { messageId: string; delta: string } } |
| | { type: 'text_end'; data: { messageId: string; content: string } }; |
|
|
| |
| |
| |
| export interface SessionSummary { |
| sessionId: string; |
| totalTurns: number; |
| totalMessages: number; |
| totalToolCalls: number; |
| endReason: string; |
| } |
|
|
| |
| |
| |
| export interface CreateSessionRequest { |
| type: SessionType; |
| title?: string; |
| trigger: { |
| message?: string; |
| agentIds: string[]; |
| triggerAgentId?: string; |
| maxTurns?: number; |
| }; |
| } |
|
|
| |
| |
| |
| export interface SendMessageRequest { |
| content: string; |
| apiKey?: string; |
| baseUrl?: string; |
| model?: string; |
| storeState: { |
| stage: unknown; |
| scenes: unknown[]; |
| currentSceneId: string | null; |
| mode: 'autonomous' | 'playback'; |
| whiteboardOpen: boolean; |
| }; |
| } |
|
|
| |
| |
| |
| export interface ToolResultsRequest { |
| results: ToolCallRecord[]; |
| } |
|
|
| |
| |
| |
| export interface SessionListItem { |
| id: string; |
| type: SessionType; |
| title: string; |
| status: SessionStatus; |
| messageCount: number; |
| toolCallCount: number; |
| createdAt: number; |
| updatedAt: number; |
| } |
|
|
| |
| |
| |
| export function toSessionListItem(session: ChatSession): SessionListItem { |
| return { |
| id: session.id, |
| type: session.type, |
| title: session.title, |
| status: session.status, |
| messageCount: session.messages.length, |
| toolCallCount: session.toolCalls.length, |
| createdAt: session.createdAt, |
| updatedAt: session.updatedAt, |
| }; |
| } |
|
|
| |
| |
| |
| |
| export type LectureNoteItem = |
| | { kind: 'speech'; text: string } |
| | { kind: 'action'; type: string; label?: string }; |
|
|
| |
| |
| |
| |
| export interface LectureNoteEntry { |
| sceneId: string; |
| sceneTitle: string; |
| sceneOrder: number; |
| items: LectureNoteItem[]; |
| completedAt: number; |
| } |
|
|
| |
|
|
| import type { Stage, Scene, StageMode } from '@/lib/types/stage'; |
| import type { AgentTurnSummary, WhiteboardActionRecord } from '@/lib/orchestration/types'; |
|
|
| |
| |
| |
| |
| export interface DirectorState { |
| turnCount: number; |
| agentResponses: AgentTurnSummary[]; |
| whiteboardLedger: WhiteboardActionRecord[]; |
| } |
|
|
| |
| |
| |
| |
| export interface StatelessChatRequest { |
| |
| messages: UIMessage<ChatMessageMetadata>[]; |
| |
| storeState: { |
| stage: Stage | null; |
| scenes: Scene[]; |
| currentSceneId: string | null; |
| mode: StageMode; |
| whiteboardOpen: boolean; |
| }; |
| |
| config: { |
| agentIds: string[]; |
| sessionType?: 'qa' | 'discussion'; |
| |
| discussionTopic?: string; |
| |
| discussionPrompt?: string; |
| |
| triggerAgentId?: string; |
| |
| agentConfigs?: Array<{ |
| id: string; |
| name: string; |
| role: string; |
| persona: string; |
| avatar: string; |
| color: string; |
| allowedActions: string[]; |
| priority: number; |
| isGenerated?: boolean; |
| boundStageId?: string; |
| }>; |
| }; |
| |
| directorState?: DirectorState; |
| |
| userProfile?: { |
| nickname?: string; |
| bio?: string; |
| }; |
| |
| apiKey: string; |
| baseUrl?: string; |
| model?: string; |
| providerType?: string; |
| |
| |
| |
| |
| |
| thinking?: ThinkingConfig; |
| |
| thinkingConfig?: ThinkingConfig; |
| } |
|
|
| |
| |
| |
| export interface ParsedAction { |
| actionId: string; |
| actionName: string; |
| params: Record<string, unknown>; |
| } |
|
|
| |
| export type ParsedToolCall = ParsedAction; |
|
|
| |
| |
| |
| export type StatelessEvent = |
| | { |
| type: 'agent_start'; |
| data: { |
| messageId: string; |
| agentId: string; |
| agentName: string; |
| agentAvatar?: string; |
| agentColor?: string; |
| }; |
| } |
| | { type: 'agent_end'; data: { messageId: string; agentId: string } } |
| | { type: 'text_delta'; data: { content: string; messageId?: string } } |
| | { |
| type: 'action'; |
| data: { |
| actionId: string; |
| actionName: string; |
| params: Record<string, unknown>; |
| agentId: string; |
| messageId?: string; |
| }; |
| } |
| | { |
| type: 'thinking'; |
| data: { stage: 'director' | 'agent_loading'; agentId?: string }; |
| } |
| | { type: 'cue_user'; data: { fromAgentId?: string; prompt?: string } } |
| | { |
| type: 'done'; |
| data: { |
| totalActions: number; |
| totalAgents: number; |
| agentHadContent?: boolean; |
| directorState?: DirectorState; |
| }; |
| } |
| | { type: 'error'; data: { message: string } }; |
|
|