feat(chat): conversations persistantes + mémoire multi-tour (v0.36.0)
Store SQLite conversations/messages (propriété par actor, fenêtre 20), historique rejoué au LLM (runAgentTurn history), ChatService persiste et renvoie conversationId. API GET/DELETE /conversations + chat avec conversationId. UI Chat: sidebar conversations (drawer mobile), nouvelle, reprise, suppression. docs/conversations.md. 83 tests verts, build web vert. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016w5jRe87MGdd6AMvXQcHNi
This commit is contained in:
+25
-3
@@ -14,6 +14,19 @@ export interface Asset {
|
||||
docLink: string | null;
|
||||
}
|
||||
|
||||
export interface ConversationMeta {
|
||||
id: string;
|
||||
title: string;
|
||||
createdAt: number;
|
||||
updatedAt: number;
|
||||
}
|
||||
|
||||
export interface ChatMessage {
|
||||
role: "user" | "assistant";
|
||||
content: string;
|
||||
ts: number;
|
||||
}
|
||||
|
||||
export class ApiError extends Error {
|
||||
constructor(
|
||||
public status: number,
|
||||
@@ -41,12 +54,21 @@ export const api = {
|
||||
body: JSON.stringify({ user, password, totp }),
|
||||
}),
|
||||
|
||||
chat: (token: string, message: string) =>
|
||||
req<{ reply: string }>("/chat", token, {
|
||||
chat: (token: string, message: string, conversationId?: string | null) =>
|
||||
req<{ reply: string; conversationId: string | null }>("/chat", token, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ message }),
|
||||
body: JSON.stringify({ message, conversationId: conversationId ?? undefined }),
|
||||
}),
|
||||
|
||||
conversations: (token: string) =>
|
||||
req<{ conversations: ConversationMeta[] }>("/conversations", token),
|
||||
|
||||
conversation: (token: string, id: string) =>
|
||||
req<{ messages: ChatMessage[] }>(`/conversations/${encodeURIComponent(id)}`, token),
|
||||
|
||||
deleteConversation: (token: string, id: string) =>
|
||||
req<{ ok: boolean }>(`/conversations/${encodeURIComponent(id)}`, token, { method: "DELETE" }),
|
||||
|
||||
review: (token: string) => req<{ assets: Asset[] }>("/review", token),
|
||||
|
||||
approve: (token: string, id: string) =>
|
||||
|
||||
Reference in New Issue
Block a user