feat: add initial backend and frontend structure with models, DTOs, and WebSocket events
This commit is contained in:
56
apps/backend/prisma/models/character.prisma
Normal file
56
apps/backend/prisma/models/character.prisma
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
// Character model and character knowledge
|
||||||
|
|
||||||
|
enum ImportSourceType {
|
||||||
|
file
|
||||||
|
url
|
||||||
|
manual
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ImportStatus {
|
||||||
|
pending
|
||||||
|
processing
|
||||||
|
completed
|
||||||
|
failed
|
||||||
|
}
|
||||||
|
|
||||||
|
model Character {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
name String
|
||||||
|
avatarUrl String?
|
||||||
|
personalityPrompt String
|
||||||
|
attributes Json @default("{}")
|
||||||
|
config Json @default("{}")
|
||||||
|
isPublic Boolean @default(false)
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
userId String
|
||||||
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
|
conversations Conversation[]
|
||||||
|
knowledgeSources CharacterKnowledge[]
|
||||||
|
vectorMemories VectorMemory[]
|
||||||
|
|
||||||
|
@@index([userId])
|
||||||
|
@@index([name])
|
||||||
|
}
|
||||||
|
|
||||||
|
model CharacterKnowledge {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
name String
|
||||||
|
sourceType ImportSourceType
|
||||||
|
sourceName String
|
||||||
|
mimeType String?
|
||||||
|
fileSize BigInt?
|
||||||
|
rawContent String?
|
||||||
|
status ImportStatus @default(pending)
|
||||||
|
processingInfo Json?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
characterId String
|
||||||
|
character Character @relation(fields: [characterId], references: [id], onDelete: Cascade)
|
||||||
|
vectorMemories VectorMemory[]
|
||||||
|
|
||||||
|
@@index([characterId])
|
||||||
|
@@index([status])
|
||||||
|
}
|
||||||
38
apps/backend/prisma/models/conversation.prisma
Normal file
38
apps/backend/prisma/models/conversation.prisma
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
// Conversation and participant models
|
||||||
|
|
||||||
|
model Conversation {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
title String?
|
||||||
|
messageCount Int @default(0)
|
||||||
|
totalTokens Int @default(0)
|
||||||
|
settings Json @default("{}")
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
userId String
|
||||||
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
|
characterId String
|
||||||
|
character Character @relation(fields: [characterId], references: [id], onDelete: Cascade)
|
||||||
|
messages Message[]
|
||||||
|
vectorMemories VectorMemory[]
|
||||||
|
storyBranches StoryBranch[]
|
||||||
|
participants ConversationParticipant[]
|
||||||
|
|
||||||
|
@@index([userId])
|
||||||
|
@@index([characterId])
|
||||||
|
@@index([createdAt])
|
||||||
|
}
|
||||||
|
|
||||||
|
model ConversationParticipant {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
isActive Boolean @default(true)
|
||||||
|
autoRespond Boolean @default(true)
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
|
||||||
|
conversationId String
|
||||||
|
conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
||||||
|
characterId String
|
||||||
|
|
||||||
|
@@unique([conversationId, characterId])
|
||||||
|
@@index([conversationId])
|
||||||
|
}
|
||||||
21
apps/backend/prisma/models/importDocument.prisma
Normal file
21
apps/backend/prisma/models/importDocument.prisma
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// General import documents (not linked to characters)
|
||||||
|
|
||||||
|
model ImportDocument {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
sourceType ImportSourceType
|
||||||
|
sourceName String
|
||||||
|
mimeType String?
|
||||||
|
fileSize BigInt?
|
||||||
|
content String?
|
||||||
|
status ImportStatus @default(pending)
|
||||||
|
errorMessage String?
|
||||||
|
metadata Json?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
userId String
|
||||||
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
@@index([userId])
|
||||||
|
@@index([status])
|
||||||
|
}
|
||||||
24
apps/backend/prisma/models/message.prisma
Normal file
24
apps/backend/prisma/models/message.prisma
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// Message model
|
||||||
|
|
||||||
|
enum MessageRole {
|
||||||
|
user
|
||||||
|
assistant
|
||||||
|
system
|
||||||
|
}
|
||||||
|
|
||||||
|
model Message {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
role MessageRole
|
||||||
|
content String
|
||||||
|
tokensUsed Int?
|
||||||
|
model String?
|
||||||
|
metadata Json?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
|
||||||
|
conversationId String
|
||||||
|
conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
@@index([conversationId])
|
||||||
|
@@index([createdAt])
|
||||||
|
@@index([conversationId, createdAt])
|
||||||
|
}
|
||||||
21
apps/backend/prisma/models/storyBranch.prisma
Normal file
21
apps/backend/prisma/models/storyBranch.prisma
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// Story branching for narrative generation (Phase 2)
|
||||||
|
|
||||||
|
model StoryBranch {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
title String?
|
||||||
|
content String
|
||||||
|
userDirection String
|
||||||
|
generationParams Json?
|
||||||
|
depth Int @default(0)
|
||||||
|
branchOrder Int @default(0)
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
|
||||||
|
conversationId String
|
||||||
|
conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
||||||
|
parentId String?
|
||||||
|
parent StoryBranch? @relation("BranchTree", fields: [parentId], references: [id], onDelete: Cascade)
|
||||||
|
children StoryBranch[] @relation("BranchTree")
|
||||||
|
|
||||||
|
@@index([conversationId])
|
||||||
|
@@index([parentId])
|
||||||
|
}
|
||||||
25
apps/backend/prisma/models/user.prisma
Normal file
25
apps/backend/prisma/models/user.prisma
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// User model and related enums
|
||||||
|
|
||||||
|
enum UserRole {
|
||||||
|
USER
|
||||||
|
ADMIN
|
||||||
|
}
|
||||||
|
|
||||||
|
model User {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
email String @unique
|
||||||
|
username String @unique
|
||||||
|
passwordHash String?
|
||||||
|
keycloakSub String? @unique
|
||||||
|
role UserRole @default(USER)
|
||||||
|
isActive Boolean @default(true)
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
characters Character[]
|
||||||
|
conversations Conversation[]
|
||||||
|
importDocs ImportDocument[]
|
||||||
|
|
||||||
|
@@index([email])
|
||||||
|
@@index([keycloakSub])
|
||||||
|
}
|
||||||
29
apps/backend/prisma/models/vectorMemory.prisma
Normal file
29
apps/backend/prisma/models/vectorMemory.prisma
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// Vector memory for embeddings (conversation and character knowledge)
|
||||||
|
|
||||||
|
enum MemoryType {
|
||||||
|
conversation
|
||||||
|
character
|
||||||
|
}
|
||||||
|
|
||||||
|
model VectorMemory {
|
||||||
|
id String @id @default(uuid())
|
||||||
|
content String
|
||||||
|
embedding Unsupported("vector")?
|
||||||
|
memoryType MemoryType @default(conversation)
|
||||||
|
metadata Json?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
|
||||||
|
conversationId String?
|
||||||
|
conversation Conversation? @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
characterId String?
|
||||||
|
character Character? @relation(fields: [characterId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
knowledgeId String?
|
||||||
|
knowledge CharacterKnowledge? @relation(fields: [knowledgeId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
@@index([conversationId])
|
||||||
|
@@index([characterId])
|
||||||
|
@@index([knowledgeId])
|
||||||
|
@@index([memoryType])
|
||||||
|
}
|
||||||
8
apps/backend/src/app.module.ts
Normal file
8
apps/backend/src/app.module.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [],
|
||||||
|
controllers: [],
|
||||||
|
providers: [],
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
||||||
20
apps/backend/src/main.ts
Normal file
20
apps/backend/src/main.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
import { AppModule } from './app.module';
|
||||||
|
|
||||||
|
async function bootstrap() {
|
||||||
|
const app = await NestFactory.create(AppModule);
|
||||||
|
|
||||||
|
app.enableCors({
|
||||||
|
origin: ['http://localhost:5173'],
|
||||||
|
credentials: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
app.setGlobalPrefix('api');
|
||||||
|
|
||||||
|
const port = process.env.PORT || 3000;
|
||||||
|
await app.listen(port);
|
||||||
|
|
||||||
|
console.log(`🚀 Backend running on: http://localhost:${port}/api`);
|
||||||
|
}
|
||||||
|
|
||||||
|
bootstrap();
|
||||||
13
apps/frontend/index.html
Normal file
13
apps/frontend/index.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>DreamChat</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
6
apps/frontend/postcss.config.js
Normal file
6
apps/frontend/postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
},
|
||||||
|
};
|
||||||
0
apps/frontend/public/vite.svg
Normal file
0
apps/frontend/public/vite.svg
Normal file
14
apps/frontend/src/App.tsx
Normal file
14
apps/frontend/src/App.tsx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
function App() {
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen bg-background flex items-center justify-center">
|
||||||
|
<div className="text-center">
|
||||||
|
<h1 className="text-4xl font-bold text-primary mb-4">DreamChat</h1>
|
||||||
|
<p className="text-muted-foreground">
|
||||||
|
Character simulation and interactive storytelling platform
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App;
|
||||||
10
apps/frontend/src/main.tsx
Normal file
10
apps/frontend/src/main.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom/client';
|
||||||
|
import App from './App';
|
||||||
|
import './styles/globals.css';
|
||||||
|
|
||||||
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<App />
|
||||||
|
</React.StrictMode>
|
||||||
|
);
|
||||||
59
apps/frontend/src/styles/globals.css
Normal file
59
apps/frontend/src/styles/globals.css
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
:root {
|
||||||
|
--background: 0 0% 100%;
|
||||||
|
--foreground: 222.2 84% 4.9%;
|
||||||
|
--card: 0 0% 100%;
|
||||||
|
--card-foreground: 222.2 84% 4.9%;
|
||||||
|
--popover: 0 0% 100%;
|
||||||
|
--popover-foreground: 222.2 84% 4.9%;
|
||||||
|
--primary: 222.2 47.4% 11.2%;
|
||||||
|
--primary-foreground: 210 40% 98%;
|
||||||
|
--secondary: 210 40% 96.1%;
|
||||||
|
--secondary-foreground: 222.2 47.4% 11.2%;
|
||||||
|
--muted: 210 40% 96.1%;
|
||||||
|
--muted-foreground: 215.4 16.3% 46.9%;
|
||||||
|
--accent: 210 40% 96.1%;
|
||||||
|
--accent-foreground: 222.2 47.4% 11.2%;
|
||||||
|
--destructive: 0 84.2% 60.2%;
|
||||||
|
--destructive-foreground: 210 40% 98%;
|
||||||
|
--border: 214.3 31.8% 91.4%;
|
||||||
|
--input: 214.3 31.8% 91.4%;
|
||||||
|
--ring: 222.2 84% 4.9%;
|
||||||
|
--radius: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark {
|
||||||
|
--background: 222.2 84% 4.9%;
|
||||||
|
--foreground: 210 40% 98%;
|
||||||
|
--card: 222.2 84% 4.9%;
|
||||||
|
--card-foreground: 210 40% 98%;
|
||||||
|
--popover: 222.2 84% 4.9%;
|
||||||
|
--popover-foreground: 210 40% 98%;
|
||||||
|
--primary: 210 40% 98%;
|
||||||
|
--primary-foreground: 222.2 47.4% 11.2%;
|
||||||
|
--secondary: 217.2 32.6% 17.5%;
|
||||||
|
--secondary-foreground: 210 40% 98%;
|
||||||
|
--muted: 217.2 32.6% 17.5%;
|
||||||
|
--muted-foreground: 215 20.2% 65.1%;
|
||||||
|
--accent: 217.2 32.6% 17.5%;
|
||||||
|
--accent-foreground: 210 40% 98%;
|
||||||
|
--destructive: 0 62.8% 30.6%;
|
||||||
|
--destructive-foreground: 210 40% 98%;
|
||||||
|
--border: 217.2 32.6% 17.5%;
|
||||||
|
--input: 217.2 32.6% 17.5%;
|
||||||
|
--ring: 212.7 26.8% 83.9%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
* {
|
||||||
|
@apply border-border;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
@apply bg-background text-foreground;
|
||||||
|
}
|
||||||
|
}
|
||||||
38
apps/frontend/tailwind.config.ts
Normal file
38
apps/frontend/tailwind.config.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import type { Config } from 'tailwindcss';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
darkMode: ['class'],
|
||||||
|
content: ['./src/**/*.{js,ts,jsx,tsx}'],
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
colors: {
|
||||||
|
border: 'hsl(var(--border))',
|
||||||
|
input: 'hsl(var(--input))',
|
||||||
|
ring: 'hsl(var(--ring))',
|
||||||
|
background: 'hsl(var(--background))',
|
||||||
|
foreground: 'hsl(var(--foreground))',
|
||||||
|
primary: {
|
||||||
|
DEFAULT: 'hsl(var(--primary))',
|
||||||
|
foreground: 'hsl(var(--primary-foreground))',
|
||||||
|
},
|
||||||
|
secondary: {
|
||||||
|
DEFAULT: 'hsl(var(--secondary))',
|
||||||
|
foreground: 'hsl(var(--secondary-foreground))',
|
||||||
|
},
|
||||||
|
destructive: {
|
||||||
|
DEFAULT: 'hsl(var(--destructive))',
|
||||||
|
foreground: 'hsl(var(--destructive-foreground))',
|
||||||
|
},
|
||||||
|
muted: {
|
||||||
|
DEFAULT: 'hsl(var(--muted))',
|
||||||
|
foreground: 'hsl(var(--muted-foreground))',
|
||||||
|
},
|
||||||
|
accent: {
|
||||||
|
DEFAULT: 'hsl(var(--accent))',
|
||||||
|
foreground: 'hsl(var(--accent-foreground))',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
} satisfies Config;
|
||||||
86
packages/shared/src/api/dto.ts
Normal file
86
packages/shared/src/api/dto.ts
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/**
|
||||||
|
* Shared API DTOs
|
||||||
|
* Used by backend for validation and frontend for type safety
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Character DTOs
|
||||||
|
export interface CreateCharacterDto {
|
||||||
|
name: string;
|
||||||
|
personalityPrompt: string;
|
||||||
|
backstory?: string;
|
||||||
|
attributes?: Record<string, unknown>;
|
||||||
|
avatarUrl?: string;
|
||||||
|
config?: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateCharacterDto extends Partial<CreateCharacterDto> {}
|
||||||
|
|
||||||
|
export interface CharacterResponseDto {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
avatarUrl?: string;
|
||||||
|
personalityPrompt: string;
|
||||||
|
backstory?: string;
|
||||||
|
attributes: Record<string, unknown>;
|
||||||
|
config: Record<string, unknown>;
|
||||||
|
isPublic: boolean;
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conversation DTOs
|
||||||
|
export interface CreateConversationDto {
|
||||||
|
characterId: string;
|
||||||
|
title?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConversationResponseDto {
|
||||||
|
id: string;
|
||||||
|
title?: string;
|
||||||
|
characterId: string;
|
||||||
|
messageCount: number;
|
||||||
|
totalTokens: number;
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message DTOs
|
||||||
|
export interface CreateMessageDto {
|
||||||
|
content: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MessageResponseDto {
|
||||||
|
id: string;
|
||||||
|
role: 'user' | 'assistant' | 'system';
|
||||||
|
content: string;
|
||||||
|
tokensUsed?: number;
|
||||||
|
model?: string;
|
||||||
|
metadata?: Record<string, unknown>;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Auth DTOs
|
||||||
|
export interface LoginDto {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegisterDto {
|
||||||
|
email: string;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AuthResponseDto {
|
||||||
|
accessToken: string;
|
||||||
|
refreshToken: string;
|
||||||
|
expiresIn: number;
|
||||||
|
user: UserResponseDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserResponseDto {
|
||||||
|
id: string;
|
||||||
|
email: string;
|
||||||
|
username: string;
|
||||||
|
role: 'USER' | 'ADMIN';
|
||||||
|
}
|
||||||
1
packages/shared/src/api/index.ts
Normal file
1
packages/shared/src/api/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './dto.js';
|
||||||
2
packages/shared/src/index.ts
Normal file
2
packages/shared/src/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './websocket/index.js';
|
||||||
|
export * from './api/index.js';
|
||||||
84
packages/shared/src/websocket/events.ts
Normal file
84
packages/shared/src/websocket/events.ts
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
/**
|
||||||
|
* WebSocket Event Types
|
||||||
|
* Shared between frontend and backend for type-safe communication
|
||||||
|
*/
|
||||||
|
|
||||||
|
export enum WebSocketEventType {
|
||||||
|
// Client -> Server
|
||||||
|
JOIN_CONVERSATION = 'JOIN_CONVERSATION',
|
||||||
|
LEAVE_CONVERSATION = 'LEAVE_CONVERSATION',
|
||||||
|
SEND_MESSAGE = 'SEND_MESSAGE',
|
||||||
|
STOP_GENERATION = 'STOP_GENERATION',
|
||||||
|
|
||||||
|
// Server -> Client
|
||||||
|
CONVERSATION_JOINED = 'CONVERSATION_JOINED',
|
||||||
|
MESSAGE_ACK = 'MESSAGE_ACK',
|
||||||
|
STREAM_CHUNK = 'STREAM_CHUNK',
|
||||||
|
STREAM_COMPLETE = 'STREAM_COMPLETE',
|
||||||
|
ERROR = 'ERROR',
|
||||||
|
}
|
||||||
|
|
||||||
|
// Base message interface
|
||||||
|
export interface WebSocketMessage<T = unknown> {
|
||||||
|
type: WebSocketEventType;
|
||||||
|
payload: T;
|
||||||
|
timestamp: string;
|
||||||
|
requestId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Client -> Server payloads
|
||||||
|
export interface JoinConversationPayload {
|
||||||
|
conversationId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LeaveConversationPayload {
|
||||||
|
conversationId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SendMessagePayload {
|
||||||
|
conversationId: string;
|
||||||
|
content: string;
|
||||||
|
streaming?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StopGenerationPayload {
|
||||||
|
conversationId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Server -> Client payloads
|
||||||
|
export interface ConversationJoinedPayload {
|
||||||
|
conversationId: string;
|
||||||
|
history: MessageHistoryItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MessageHistoryItem {
|
||||||
|
id: string;
|
||||||
|
role: 'user' | 'assistant' | 'system';
|
||||||
|
content: string;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MessageAckPayload {
|
||||||
|
messageId: string;
|
||||||
|
status: 'received' | 'processing' | 'error';
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StreamChunkPayload {
|
||||||
|
conversationId: string;
|
||||||
|
chunk: string;
|
||||||
|
isComplete: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StreamCompletePayload {
|
||||||
|
conversationId: string;
|
||||||
|
messageId: string;
|
||||||
|
content: string;
|
||||||
|
tokensUsed?: number;
|
||||||
|
model?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ErrorPayload {
|
||||||
|
code: string;
|
||||||
|
message: string;
|
||||||
|
details?: Record<string, unknown>;
|
||||||
|
}
|
||||||
1
packages/shared/src/websocket/index.ts
Normal file
1
packages/shared/src/websocket/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './events.js';
|
||||||
Reference in New Issue
Block a user