import { DatabaseService } from '../database/database.service.js'; export type SessionType = 'scheduled' | 'chat' | 'system'; export interface AgentSession { id: string; createdAt: number; lastActiveAt: number; messageCount: number; status: 'idle' | 'active' | 'error'; /** 绑定的智能体 ID,不选则为 default(主智能体) */ agentId?: string; workspace?: string; provider?: string; model?: string; title?: string; preview?: string; type?: SessionType; } export interface ChatMessage { id: string; sessionId: string; role: 'user' | 'assistant' | 'system'; content: string; timestamp: number; toolCalls?: any[]; } /** * Agents service: session + history storage in SQLite. * Conversation is done via frontend -> Gateway (WebSocket) -> agent; NestJS is not in the chat path. */ export declare class AgentsService { private readonly db; private eventListeners; constructor(db: DatabaseService); addEventListener(event: string, listener: (data: any) => void): () => void; private emitEvent; private rowToSession; private rowToMessage; createSession(options?: { id?: string; agentId?: string; workspace?: string; provider?: string; model?: string; title?: string; type?: SessionType; }): Promise; /** 获取或创建会话(指定 id 时复用同一会话,用于定时任务固定 sessionId) */ getOrCreateSession(sessionId: string, options?: { agentId?: string; workspace?: string; title?: string; type?: SessionType; }): Promise; getSessions(): AgentSession[]; getSession(sessionId: string): AgentSession | undefined; /** 更新会话的当前 agent(同一 session 内切换 agent 时调用) */ updateSessionAgentId(sessionId: string, agentId: string): void; deleteSession(sessionId: string): Promise; getMessageHistory(sessionId: string): ChatMessage[]; addAssistantMessage(sessionId: string, content: string): void; appendMessage(sessionId: string, role: 'user' | 'assistant', content: string, options?: { toolCalls?: any[]; contentParts?: any[]; }): void; /** 清除会话的所有对话消息(保留会话本身,message_count 置 0) */ clearSessionMessages(sessionId: string): void; }