@firstlovecenter/ai-chat 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/drizzle/index.cjs +24 -16
- package/dist/drizzle/index.cjs.map +1 -1
- package/dist/drizzle/index.d.cts +17 -17
- package/dist/drizzle/index.d.ts +17 -17
- package/dist/drizzle/index.js +24 -16
- package/dist/drizzle/index.js.map +1 -1
- package/dist/prisma/index.cjs +20 -4
- package/dist/prisma/index.cjs.map +1 -1
- package/dist/prisma/index.d.cts +19 -10
- package/dist/prisma/index.d.ts +19 -10
- package/dist/prisma/index.js +20 -4
- package/dist/prisma/index.js.map +1 -1
- package/dist/server/index.cjs +5 -5
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +5 -5
- package/dist/server/index.js.map +1 -1
- package/dist/{types-BnwUkqKb.d.cts → types-BOgBJ7CD.d.cts} +14 -8
- package/dist/{types-BnwUkqKb.d.ts → types-BOgBJ7CD.d.ts} +14 -8
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +3 -3
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
- package/prisma/chat-models.prisma +7 -3
|
@@ -114,8 +114,14 @@ type SystemBlock = {
|
|
|
114
114
|
* regardless of the chosen ORM.
|
|
115
115
|
*/
|
|
116
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Chat session and message identifiers are short URL-safe UIDs (12 chars,
|
|
119
|
+
* ~72 bits of entropy, alphabet matches nanoid's URL-safe set). The
|
|
120
|
+
* package generates them in `createSession`/`appendMessage` so adapters
|
|
121
|
+
* never need to know about auto-increment vs UID.
|
|
122
|
+
*/
|
|
117
123
|
type ChatSession = {
|
|
118
|
-
id:
|
|
124
|
+
id: string;
|
|
119
125
|
userId: number;
|
|
120
126
|
title: string;
|
|
121
127
|
createdAt: Date;
|
|
@@ -129,8 +135,8 @@ type ChatMessageRole = 'user' | 'assistant';
|
|
|
129
135
|
* narrator. `errorJson` is set when an assistant turn failed mid-stream.
|
|
130
136
|
*/
|
|
131
137
|
type ChatMessage = {
|
|
132
|
-
id:
|
|
133
|
-
sessionId:
|
|
138
|
+
id: string;
|
|
139
|
+
sessionId: string;
|
|
134
140
|
role: ChatMessageRole;
|
|
135
141
|
question: string | null;
|
|
136
142
|
blocks: unknown | null;
|
|
@@ -244,7 +250,7 @@ type CreateSessionInput = {
|
|
|
244
250
|
title: string;
|
|
245
251
|
};
|
|
246
252
|
type AppendMessageInput = {
|
|
247
|
-
sessionId:
|
|
253
|
+
sessionId: string;
|
|
248
254
|
role: ChatMessageRole;
|
|
249
255
|
question?: string | null;
|
|
250
256
|
blocks?: unknown | null;
|
|
@@ -277,15 +283,15 @@ type AiSettingsPatch = {
|
|
|
277
283
|
type PersistencePort = {
|
|
278
284
|
createSession(input: CreateSessionInput): Promise<ChatSession>;
|
|
279
285
|
/** Returns null when the session doesn't exist OR doesn't belong to this user. */
|
|
280
|
-
getSession(id:
|
|
286
|
+
getSession(id: string, userId: number): Promise<ChatSession | null>;
|
|
281
287
|
listSessionsForUser(userId: number, opts?: ListSessionsOpts): Promise<ChatSession[]>;
|
|
282
288
|
/** No-op when session doesn't exist or doesn't belong to user — caller asserted authorisation. */
|
|
283
|
-
updateSession(id:
|
|
289
|
+
updateSession(id: string, userId: number, patch: {
|
|
284
290
|
title?: string;
|
|
285
291
|
}): Promise<void>;
|
|
286
|
-
deleteSession(id:
|
|
292
|
+
deleteSession(id: string, userId: number): Promise<void>;
|
|
287
293
|
appendMessage(input: AppendMessageInput): Promise<ChatMessage>;
|
|
288
|
-
listMessagesForSession(sessionId:
|
|
294
|
+
listMessagesForSession(sessionId: string, userId: number): Promise<ChatMessage[]>;
|
|
289
295
|
/** Returns the singleton row, applying defaults if it's never been written. */
|
|
290
296
|
getAiSettings(): Promise<AiSettings>;
|
|
291
297
|
/**
|
|
@@ -114,8 +114,14 @@ type SystemBlock = {
|
|
|
114
114
|
* regardless of the chosen ORM.
|
|
115
115
|
*/
|
|
116
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Chat session and message identifiers are short URL-safe UIDs (12 chars,
|
|
119
|
+
* ~72 bits of entropy, alphabet matches nanoid's URL-safe set). The
|
|
120
|
+
* package generates them in `createSession`/`appendMessage` so adapters
|
|
121
|
+
* never need to know about auto-increment vs UID.
|
|
122
|
+
*/
|
|
117
123
|
type ChatSession = {
|
|
118
|
-
id:
|
|
124
|
+
id: string;
|
|
119
125
|
userId: number;
|
|
120
126
|
title: string;
|
|
121
127
|
createdAt: Date;
|
|
@@ -129,8 +135,8 @@ type ChatMessageRole = 'user' | 'assistant';
|
|
|
129
135
|
* narrator. `errorJson` is set when an assistant turn failed mid-stream.
|
|
130
136
|
*/
|
|
131
137
|
type ChatMessage = {
|
|
132
|
-
id:
|
|
133
|
-
sessionId:
|
|
138
|
+
id: string;
|
|
139
|
+
sessionId: string;
|
|
134
140
|
role: ChatMessageRole;
|
|
135
141
|
question: string | null;
|
|
136
142
|
blocks: unknown | null;
|
|
@@ -244,7 +250,7 @@ type CreateSessionInput = {
|
|
|
244
250
|
title: string;
|
|
245
251
|
};
|
|
246
252
|
type AppendMessageInput = {
|
|
247
|
-
sessionId:
|
|
253
|
+
sessionId: string;
|
|
248
254
|
role: ChatMessageRole;
|
|
249
255
|
question?: string | null;
|
|
250
256
|
blocks?: unknown | null;
|
|
@@ -277,15 +283,15 @@ type AiSettingsPatch = {
|
|
|
277
283
|
type PersistencePort = {
|
|
278
284
|
createSession(input: CreateSessionInput): Promise<ChatSession>;
|
|
279
285
|
/** Returns null when the session doesn't exist OR doesn't belong to this user. */
|
|
280
|
-
getSession(id:
|
|
286
|
+
getSession(id: string, userId: number): Promise<ChatSession | null>;
|
|
281
287
|
listSessionsForUser(userId: number, opts?: ListSessionsOpts): Promise<ChatSession[]>;
|
|
282
288
|
/** No-op when session doesn't exist or doesn't belong to user — caller asserted authorisation. */
|
|
283
|
-
updateSession(id:
|
|
289
|
+
updateSession(id: string, userId: number, patch: {
|
|
284
290
|
title?: string;
|
|
285
291
|
}): Promise<void>;
|
|
286
|
-
deleteSession(id:
|
|
292
|
+
deleteSession(id: string, userId: number): Promise<void>;
|
|
287
293
|
appendMessage(input: AppendMessageInput): Promise<ChatMessage>;
|
|
288
|
-
listMessagesForSession(sessionId:
|
|
294
|
+
listMessagesForSession(sessionId: string, userId: number): Promise<ChatMessage[]>;
|
|
289
295
|
/** Returns the singleton row, applying defaults if it's never been written. */
|
|
290
296
|
getAiSettings(): Promise<AiSettings>;
|
|
291
297
|
/**
|