feat(api): add conversation archive with vector search (MS22-DB-004, MS22-API-004)
- Add ConversationArchive Prisma model with pgvector(1536) embedding field - Migration: 20260228000000_ms22_conversation_archive - NestJS module at apps/api/src/conversation-archive/ with service, controller, DTOs, spec - POST /api/conversations/ingest — ingest session logs, auto-embed via EmbeddingService - POST /api/conversations/search — vector similarity search with agentId filter - GET /api/conversations — paginated list with agentId + date range filters - GET /api/conversations/:id — fetch full conversation including messages - Register ConversationArchiveModule in app.module.ts - 8 unit tests, all passing (vitest) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -313,6 +313,7 @@ model Workspace {
|
||||
llmUsageLogs LlmUsageLog[]
|
||||
userCredentials UserCredential[]
|
||||
terminalSessions TerminalSession[]
|
||||
conversationArchives ConversationArchive[]
|
||||
|
||||
@@index([ownerId])
|
||||
@@map("workspaces")
|
||||
@@ -1575,3 +1576,33 @@ model TerminalSession {
|
||||
@@index([workspaceId, status])
|
||||
@@map("terminal_sessions")
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// CONVERSATION ARCHIVE MODULE
|
||||
// ============================================
|
||||
|
||||
model ConversationArchive {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
workspaceId String @map("workspace_id") @db.Uuid
|
||||
sessionId String @map("session_id")
|
||||
agentId String @map("agent_id")
|
||||
messages Json
|
||||
messageCount Int @map("message_count")
|
||||
summary String @db.Text
|
||||
// Note: vector dimension (1536) must match EMBEDDING_DIMENSION constant in @mosaic/shared
|
||||
embedding Unsupported("vector(1536)")?
|
||||
startedAt DateTime @map("started_at") @db.Timestamptz
|
||||
endedAt DateTime? @map("ended_at") @db.Timestamptz
|
||||
metadata Json @default("{}")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz
|
||||
|
||||
// Relations
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([workspaceId, sessionId])
|
||||
@@index([workspaceId])
|
||||
@@index([agentId])
|
||||
@@index([startedAt])
|
||||
@@map("conversation_archives")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user