/** * 通道会话持久化:与 Web/Desktop 统一使用同一套 session + chat_messages 入库。 * 由 Gateway 启动时注入 AgentsService,通道在处理消息前后调用 ensureSession / appendMessage。 */ export type SessionType = "chat" | "scheduled" | "system"; export interface IChannelSessionPersistence { getOrCreateSession(sessionId: string, options?: { agentId?: string; workspace?: string; title?: string; type?: SessionType; }): Promise; getSession(sessionId: string): { agentId?: string; } | undefined; appendMessage(sessionId: string, role: "user" | "assistant", content: string, options?: { toolCalls?: unknown[]; contentParts?: unknown[]; }): void; } export declare function setChannelSessionPersistence(service: IChannelSessionPersistence | null): void; export declare function getChannelSessionPersistence(): IChannelSessionPersistence | null; /** * 确保通道会话已入库(getOrCreateSession),并追加一条用户消息。 * 在跑 Agent 前调用;若未注入持久化则静默跳过。 */ export declare function persistChannelUserMessage(sessionId: string, options: { agentId: string; title?: string; messageText: string; }): Promise; /** * 通道本轮助手回复结束时,将助手消息入库。 * 在 onDone 时调用;若未注入持久化则静默跳过。 */ export declare function persistChannelAssistantMessage(sessionId: string, content: string): void;