@lobehub/chat 1.36.31 → 1.36.33

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +18 -0
  3. package/docs/self-hosting/environment-variables/model-provider.mdx +7 -0
  4. package/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx +7 -0
  5. package/docs/self-hosting/server-database/dokploy.zh-CN.mdx +12 -12
  6. package/package.json +1 -1
  7. package/src/config/modelProviders/github.ts +19 -10
  8. package/src/database/repositories/dataImporter/__tests__/index.test.ts +11 -18
  9. package/src/database/repositories/dataImporter/index.ts +31 -46
  10. package/src/database/server/models/__tests__/_test_template.ts +1 -1
  11. package/src/database/server/models/__tests__/agent.test.ts +1 -1
  12. package/src/database/server/models/__tests__/asyncTask.test.ts +1 -1
  13. package/src/database/server/models/__tests__/chunk.test.ts +1 -1
  14. package/src/database/server/models/__tests__/file.test.ts +1 -1
  15. package/src/database/server/models/__tests__/knowledgeBase.test.ts +1 -2
  16. package/src/database/server/models/__tests__/message.test.ts +35 -72
  17. package/src/database/server/models/__tests__/nextauth.test.ts +1 -1
  18. package/src/database/server/models/__tests__/session.test.ts +1 -1
  19. package/src/database/server/models/__tests__/sessionGroup.test.ts +1 -2
  20. package/src/database/server/models/__tests__/topic.test.ts +1 -1
  21. package/src/database/server/models/__tests__/user.test.ts +1 -1
  22. package/src/database/server/models/_template.ts +2 -2
  23. package/src/database/server/models/agent.ts +17 -25
  24. package/src/database/server/models/asyncTask.ts +2 -2
  25. package/src/database/server/models/chunk.ts +14 -14
  26. package/src/database/server/models/embedding.ts +1 -1
  27. package/src/database/server/models/file.ts +8 -10
  28. package/src/database/server/models/knowledgeBase.ts +4 -6
  29. package/src/database/server/models/message.ts +54 -65
  30. package/src/database/server/models/plugin.ts +2 -2
  31. package/src/database/server/models/ragEval/dataset.ts +2 -2
  32. package/src/database/server/models/ragEval/datasetRecord.ts +3 -8
  33. package/src/database/server/models/ragEval/evaluation.ts +3 -2
  34. package/src/database/server/models/ragEval/evaluationRecord.ts +2 -2
  35. package/src/database/server/models/session.ts +38 -35
  36. package/src/database/server/models/sessionGroup.ts +4 -4
  37. package/src/database/server/models/thread.ts +2 -2
  38. package/src/database/server/models/topic.ts +48 -53
  39. package/src/database/server/models/user.ts +12 -12
  40. package/src/libs/agent-runtime/github/index.test.ts +68 -41
  41. package/src/libs/agent-runtime/github/index.ts +51 -1
  42. package/src/libs/agent-runtime/togetherai/index.ts +2 -1
  43. package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +10 -9
  44. package/src/libs/agent-runtime/utils/streams/azureOpenai.test.ts +0 -1
  45. package/src/libs/next-auth/adapter/index.ts +1 -1
  46. package/src/server/routers/lambda/chunk.ts +2 -2
  47. package/vercel.json +1 -1
@@ -46,10 +46,10 @@ export class MessageModel {
46
46
  }
47
47
 
48
48
  // **************** Query *************** //
49
- async query(
49
+ query = async (
50
50
  { current = 0, pageSize = 1000, sessionId, topicId }: QueryMessageParams = {},
51
51
  options: { postProcessUrl?: (path: string | null) => Promise<string> } = {},
52
- ): Promise<MessageItem[]> {
52
+ ): Promise<MessageItem[]> => {
53
53
  const offset = current * pageSize;
54
54
 
55
55
  // 1. get basic messages
@@ -212,15 +212,15 @@ export class MessageModel {
212
212
  };
213
213
  },
214
214
  );
215
- }
215
+ };
216
216
 
217
- async findById(id: string) {
217
+ findById = async (id: string) => {
218
218
  return this.db.query.messages.findFirst({
219
219
  where: and(eq(messages.id, id), eq(messages.userId, this.userId)),
220
220
  });
221
- }
221
+ };
222
222
 
223
- async findMessageQueriesById(messageId: string) {
223
+ findMessageQueriesById = async (messageId: string) => {
224
224
  const result = await this.db
225
225
  .select({
226
226
  embeddings: embeddings.embeddings,
@@ -236,47 +236,43 @@ export class MessageModel {
236
236
  if (result.length === 0) return undefined;
237
237
 
238
238
  return result[0];
239
- }
239
+ };
240
240
 
241
- async queryAll(): Promise<MessageItem[]> {
241
+ queryAll = async (): Promise<MessageItem[]> => {
242
242
  return this.db
243
243
  .select()
244
244
  .from(messages)
245
245
  .orderBy(messages.createdAt)
246
- .where(eq(messages.userId, this.userId))
247
-
248
- .execute();
249
- }
246
+ .where(eq(messages.userId, this.userId));
247
+ };
250
248
 
251
- async queryBySessionId(sessionId?: string | null): Promise<MessageItem[]> {
249
+ queryBySessionId = async (sessionId?: string | null): Promise<MessageItem[]> => {
252
250
  return this.db.query.messages.findMany({
253
251
  orderBy: [asc(messages.createdAt)],
254
252
  where: and(eq(messages.userId, this.userId), this.matchSession(sessionId)),
255
253
  });
256
- }
254
+ };
257
255
 
258
- async queryByKeyword(keyword: string): Promise<MessageItem[]> {
256
+ queryByKeyword = async (keyword: string): Promise<MessageItem[]> => {
259
257
  if (!keyword) return [];
260
-
261
258
  return this.db.query.messages.findMany({
262
259
  orderBy: [desc(messages.createdAt)],
263
260
  where: and(eq(messages.userId, this.userId), like(messages.content, `%${keyword}%`)),
264
261
  });
265
- }
262
+ };
266
263
 
267
- async count() {
264
+ count = async (): Promise<number> => {
268
265
  const result = await this.db
269
266
  .select({
270
- count: count(),
267
+ count: count(messages.id),
271
268
  })
272
269
  .from(messages)
273
- .where(eq(messages.userId, this.userId))
274
- .execute();
270
+ .where(eq(messages.userId, this.userId));
275
271
 
276
272
  return result[0].count;
277
- }
273
+ };
278
274
 
279
- async countToday() {
275
+ countToday = async (): Promise<number> => {
280
276
  const today = new Date();
281
277
  today.setHours(0, 0, 0, 0);
282
278
  const tomorrow = new Date(today);
@@ -284,7 +280,7 @@ export class MessageModel {
284
280
 
285
281
  const result = await this.db
286
282
  .select({
287
- count: count(),
283
+ count: count(messages.id),
288
284
  })
289
285
  .from(messages)
290
286
  .where(
@@ -293,15 +289,14 @@ export class MessageModel {
293
289
  gte(messages.createdAt, today),
294
290
  lt(messages.createdAt, tomorrow),
295
291
  ),
296
- )
297
- .execute();
292
+ );
298
293
 
299
294
  return result[0].count;
300
- }
295
+ };
301
296
 
302
297
  // **************** Create *************** //
303
298
 
304
- async create(
299
+ create = async (
305
300
  {
306
301
  fromModel,
307
302
  fromProvider,
@@ -313,7 +308,7 @@ export class MessageModel {
313
308
  ...message
314
309
  }: CreateMessageParams,
315
310
  id: string = this.genId(),
316
- ): Promise<MessageItem> {
311
+ ): Promise<MessageItem> => {
317
312
  return this.db.transaction(async (trx) => {
318
313
  const [item] = (await trx
319
314
  .insert(messages)
@@ -358,31 +353,31 @@ export class MessageModel {
358
353
 
359
354
  return item;
360
355
  });
361
- }
356
+ };
362
357
 
363
- async batchCreate(newMessages: MessageItem[]) {
358
+ batchCreate = async (newMessages: MessageItem[]) => {
364
359
  const messagesToInsert = newMessages.map((m) => {
365
360
  return { ...m, userId: this.userId };
366
361
  });
367
362
 
368
363
  return this.db.insert(messages).values(messagesToInsert);
369
- }
364
+ };
370
365
 
371
- async createMessageQuery(params: NewMessageQuery) {
366
+ createMessageQuery = async (params: NewMessageQuery) => {
372
367
  const result = await this.db.insert(messageQueries).values(params).returning();
373
368
 
374
369
  return result[0];
375
- }
370
+ };
376
371
  // **************** Update *************** //
377
372
 
378
- async update(id: string, message: Partial<MessageItem>) {
373
+ update = async (id: string, message: Partial<MessageItem>) => {
379
374
  return this.db
380
375
  .update(messages)
381
376
  .set(message)
382
377
  .where(and(eq(messages.id, id), eq(messages.userId, this.userId)));
383
- }
378
+ };
384
379
 
385
- async updatePluginState(id: string, state: Record<string, any>) {
380
+ updatePluginState = async (id: string, state: Record<string, any>) => {
386
381
  const item = await this.db.query.messagePlugins.findFirst({
387
382
  where: eq(messagePlugins.id, id),
388
383
  });
@@ -392,18 +387,18 @@ export class MessageModel {
392
387
  .update(messagePlugins)
393
388
  .set({ state: merge(item.state || {}, state) })
394
389
  .where(eq(messagePlugins.id, id));
395
- }
390
+ };
396
391
 
397
- async updateMessagePlugin(id: string, value: Partial<MessagePluginItem>) {
392
+ updateMessagePlugin = async (id: string, value: Partial<MessagePluginItem>) => {
398
393
  const item = await this.db.query.messagePlugins.findFirst({
399
394
  where: eq(messagePlugins.id, id),
400
395
  });
401
396
  if (!item) throw new Error('Plugin not found');
402
397
 
403
398
  return this.db.update(messagePlugins).set(value).where(eq(messagePlugins.id, id));
404
- }
399
+ };
405
400
 
406
- async updateTranslate(id: string, translate: Partial<MessageItem>) {
401
+ updateTranslate = async (id: string, translate: Partial<MessageItem>) => {
407
402
  const result = await this.db.query.messageTranslates.findFirst({
408
403
  where: and(eq(messageTranslates.id, id)),
409
404
  });
@@ -415,9 +410,9 @@ export class MessageModel {
415
410
 
416
411
  // or just update the existing one
417
412
  return this.db.update(messageTranslates).set(translate).where(eq(messageTranslates.id, id));
418
- }
413
+ };
419
414
 
420
- async updateTTS(id: string, tts: Partial<ChatTTS>) {
415
+ updateTTS = async (id: string, tts: Partial<ChatTTS>) => {
421
416
  const result = await this.db.query.messageTTS.findFirst({
422
417
  where: and(eq(messageTTS.id, id)),
423
418
  });
@@ -434,11 +429,11 @@ export class MessageModel {
434
429
  .update(messageTTS)
435
430
  .set({ contentMd5: tts.contentMd5, fileId: tts.file, voice: tts.voice })
436
431
  .where(eq(messageTTS.id, id));
437
- }
432
+ };
438
433
 
439
434
  // **************** Delete *************** //
440
435
 
441
- async deleteMessage(id: string) {
436
+ deleteMessage = async (id: string) => {
442
437
  return this.db.transaction(async (tx) => {
443
438
  // 1. 查询要删除的 message 的完整信息
444
439
  const message = await tx
@@ -460,8 +455,7 @@ export class MessageModel {
460
455
  const res = await tx
461
456
  .select({ id: messagePlugins.id })
462
457
  .from(messagePlugins)
463
- .where(inArray(messagePlugins.toolCallId, toolCallIds))
464
- .execute();
458
+ .where(inArray(messagePlugins.toolCallId, toolCallIds));
465
459
 
466
460
  relatedMessageIds = res.map((row) => row.id);
467
461
  }
@@ -472,28 +466,24 @@ export class MessageModel {
472
466
  // 5. 删除所有相关的 message
473
467
  await tx.delete(messages).where(inArray(messages.id, messageIdsToDelete));
474
468
  });
475
- }
469
+ };
476
470
 
477
- async deleteMessages(ids: string[]) {
478
- return this.db
471
+ deleteMessages = async (ids: string[]) =>
472
+ this.db
479
473
  .delete(messages)
480
474
  .where(and(eq(messages.userId, this.userId), inArray(messages.id, ids)));
481
- }
482
475
 
483
- async deleteMessageTranslate(id: string) {
484
- return this.db.delete(messageTranslates).where(and(eq(messageTranslates.id, id)));
485
- }
476
+ deleteMessageTranslate = async (id: string) =>
477
+ this.db.delete(messageTranslates).where(and(eq(messageTranslates.id, id)));
486
478
 
487
- async deleteMessageTTS(id: string) {
488
- return this.db.delete(messageTTS).where(and(eq(messageTTS.id, id)));
489
- }
479
+ deleteMessageTTS = async (id: string) =>
480
+ this.db.delete(messageTTS).where(and(eq(messageTTS.id, id)));
490
481
 
491
- async deleteMessageQuery(id: string) {
492
- return this.db.delete(messageQueries).where(and(eq(messageQueries.id, id)));
493
- }
482
+ deleteMessageQuery = async (id: string) =>
483
+ this.db.delete(messageQueries).where(and(eq(messageQueries.id, id)));
494
484
 
495
- async deleteMessagesBySession(sessionId?: string | null, topicId?: string | null) {
496
- return this.db
485
+ deleteMessagesBySession = async (sessionId?: string | null, topicId?: string | null) =>
486
+ this.db
497
487
  .delete(messages)
498
488
  .where(
499
489
  and(
@@ -502,11 +492,10 @@ export class MessageModel {
502
492
  this.matchTopic(topicId),
503
493
  ),
504
494
  );
505
- }
506
495
 
507
- async deleteAllMessages() {
496
+ deleteAllMessages = async () => {
508
497
  return this.db.delete(messages).where(eq(messages.userId, this.userId));
509
- }
498
+ };
510
499
 
511
500
  // **************** Helper *************** //
512
501
 
@@ -60,10 +60,10 @@ export class PluginModel {
60
60
  });
61
61
  };
62
62
 
63
- async update(id: string, value: Partial<InstalledPluginItem>) {
63
+ update = async (id: string, value: Partial<InstalledPluginItem>) => {
64
64
  return this.db
65
65
  .update(installedPlugins)
66
66
  .set({ ...value, updatedAt: new Date() })
67
67
  .where(and(eq(installedPlugins.identifier, id), eq(installedPlugins.userId, this.userId)));
68
- }
68
+ };
69
69
  }
@@ -1,7 +1,7 @@
1
- import { and, desc, eq } from 'drizzle-orm';
1
+ import { and, desc, eq } from 'drizzle-orm/expressions';
2
2
 
3
- import { serverDB } from '@/database/server';
4
3
  import { NewEvalDatasetsItem, evalDatasets } from '@/database/schemas';
4
+ import { serverDB } from '@/database/server';
5
5
  import { RAGEvalDataSetItem } from '@/types/eval';
6
6
 
7
7
  export class EvalDatasetModel {
@@ -1,11 +1,7 @@
1
- import { and, eq, inArray } from 'drizzle-orm';
1
+ import { and, eq, inArray } from 'drizzle-orm/expressions';
2
2
 
3
+ import { NewEvalDatasetRecordsItem, evalDatasetRecords, files } from '@/database/schemas';
3
4
  import { serverDB } from '@/database/server';
4
- import {
5
- NewEvalDatasetRecordsItem,
6
- evalDatasetRecords,
7
- files,
8
- } from '@/database/schemas';
9
5
  import { EvalDatasetRecordRefFile } from '@/types/eval';
10
6
 
11
7
  export class EvalDatasetRecordModel {
@@ -50,8 +46,7 @@ export class EvalDatasetRecordModel {
50
46
  const fileItems = await serverDB
51
47
  .select({ fileType: files.fileType, id: files.id, name: files.name })
52
48
  .from(files)
53
- .where(and(inArray(files.id, fileList), eq(files.userId, this.userId)))
54
- .execute();
49
+ .where(and(inArray(files.id, fileList), eq(files.userId, this.userId)));
55
50
 
56
51
  return list.map((item) => {
57
52
  return {
@@ -1,12 +1,13 @@
1
- import { SQL, and, count, desc, eq, inArray } from 'drizzle-orm';
1
+ import { SQL, count } from 'drizzle-orm';
2
+ import { and, desc, eq, inArray } from 'drizzle-orm/expressions';
2
3
 
3
- import { serverDB } from '@/database/server';
4
4
  import {
5
5
  NewEvalEvaluationItem,
6
6
  evalDatasets,
7
7
  evalEvaluation,
8
8
  evaluationRecords,
9
9
  } from '@/database/schemas';
10
+ import { serverDB } from '@/database/server';
10
11
  import { EvalEvaluationStatus, RAGEvalEvaluationItem } from '@/types/eval';
11
12
 
12
13
  export class EvalEvaluationModel {
@@ -1,7 +1,7 @@
1
- import { and, eq } from 'drizzle-orm';
1
+ import { and, eq } from 'drizzle-orm/expressions';
2
2
 
3
- import { serverDB } from '@/database/server';
4
3
  import { NewEvaluationRecordsItem, evaluationRecords } from '@/database/schemas';
4
+ import { serverDB } from '@/database/server';
5
5
 
6
6
  export class EvaluationRecordModel {
7
7
  private userId: string;
@@ -31,7 +31,7 @@ export class SessionModel {
31
31
  }
32
32
  // **************** Query *************** //
33
33
 
34
- async query({ current = 0, pageSize = 9999 } = {}) {
34
+ query = async ({ current = 0, pageSize = 9999 } = {}) => {
35
35
  const offset = current * pageSize;
36
36
 
37
37
  return this.db.query.sessions.findMany({
@@ -41,9 +41,9 @@ export class SessionModel {
41
41
  where: and(eq(sessions.userId, this.userId), not(eq(sessions.slug, INBOX_SESSION_ID))),
42
42
  with: { agentsToSessions: { columns: {}, with: { agent: true } }, group: true },
43
43
  });
44
- }
44
+ };
45
45
 
46
- async queryWithGroups(): Promise<ChatSessionList> {
46
+ queryWithGroups = async (): Promise<ChatSessionList> => {
47
47
  // 查询所有会话
48
48
  const result = await this.query();
49
49
 
@@ -56,9 +56,9 @@ export class SessionModel {
56
56
  sessionGroups: groups as unknown as ChatSessionList['sessionGroups'],
57
57
  sessions: result.map((item) => this.mapSessionItem(item as any)),
58
58
  };
59
- }
59
+ };
60
60
 
61
- async queryByKeyword(keyword: string) {
61
+ queryByKeyword = async (keyword: string) => {
62
62
  if (!keyword) return [];
63
63
 
64
64
  const keywordLowerCase = keyword.toLowerCase();
@@ -66,11 +66,11 @@ export class SessionModel {
66
66
  const data = await this.findSessionsByKeywords({ keyword: keywordLowerCase });
67
67
 
68
68
  return data.map((item) => this.mapSessionItem(item as any));
69
- }
69
+ };
70
70
 
71
- async findByIdOrSlug(
71
+ findByIdOrSlug = async (
72
72
  idOrSlug: string,
73
- ): Promise<(SessionItem & { agent: AgentItem }) | undefined> {
73
+ ): Promise<(SessionItem & { agent: AgentItem }) | undefined> => {
74
74
  const result = await this.db.query.sessions.findFirst({
75
75
  where: and(
76
76
  or(eq(sessions.id, idOrSlug), eq(sessions.slug, idOrSlug)),
@@ -82,23 +82,22 @@ export class SessionModel {
82
82
  if (!result) return;
83
83
 
84
84
  return { ...result, agent: (result?.agentsToSessions?.[0] as any)?.agent } as any;
85
- }
85
+ };
86
86
 
87
- async count() {
87
+ count = async (): Promise<number> => {
88
88
  const result = await this.db
89
89
  .select({
90
- count: count(),
90
+ count: count(sessions.id),
91
91
  })
92
92
  .from(sessions)
93
- .where(eq(sessions.userId, this.userId))
94
- .execute();
93
+ .where(eq(sessions.userId, this.userId));
95
94
 
96
95
  return result[0].count;
97
- }
96
+ };
98
97
 
99
98
  // **************** Create *************** //
100
99
 
101
- async create({
100
+ create = async ({
102
101
  id = idGenerator('sessions'),
103
102
  type = 'agent',
104
103
  session = {},
@@ -110,7 +109,7 @@ export class SessionModel {
110
109
  session?: Partial<NewSession>;
111
110
  slug?: string;
112
111
  type: 'agent' | 'group';
113
- }): Promise<SessionItem> {
112
+ }): Promise<SessionItem> => {
114
113
  return this.db.transaction(async (trx) => {
115
114
  const newAgents = await trx
116
115
  .insert(agents)
@@ -143,9 +142,9 @@ export class SessionModel {
143
142
 
144
143
  return result[0];
145
144
  });
146
- }
145
+ };
147
146
 
148
- async createInbox() {
147
+ createInbox = async () => {
149
148
  const item = await this.db.query.sessions.findFirst({
150
149
  where: and(eq(sessions.userId, this.userId), eq(sessions.slug, INBOX_SESSION_ID)),
151
150
  });
@@ -158,9 +157,9 @@ export class SessionModel {
158
157
  slug: INBOX_SESSION_ID,
159
158
  type: 'agent',
160
159
  });
161
- }
160
+ };
162
161
 
163
- async batchCreate(newSessions: NewSession[]) {
162
+ batchCreate = async (newSessions: NewSession[]) => {
164
163
  const sessionsToInsert = newSessions.map((s) => {
165
164
  return {
166
165
  ...s,
@@ -170,9 +169,9 @@ export class SessionModel {
170
169
  });
171
170
 
172
171
  return this.db.insert(sessions).values(sessionsToInsert);
173
- }
172
+ };
174
173
 
175
- async duplicate(id: string, newTitle?: string) {
174
+ duplicate = async (id: string, newTitle?: string) => {
176
175
  const result = await this.findByIdOrSlug(id);
177
176
 
178
177
  if (!result) return;
@@ -193,49 +192,49 @@ export class SessionModel {
193
192
  },
194
193
  type: 'agent',
195
194
  });
196
- }
195
+ };
197
196
 
198
197
  // **************** Delete *************** //
199
198
 
200
199
  /**
201
200
  * Delete a session, also delete all messages and topics associated with it.
202
201
  */
203
- async delete(id: string) {
202
+ delete = async (id: string) => {
204
203
  return this.db
205
204
  .delete(sessions)
206
205
  .where(and(eq(sessions.id, id), eq(sessions.userId, this.userId)));
207
- }
206
+ };
208
207
 
209
208
  /**
210
209
  * Batch delete sessions, also delete all messages and topics associated with them.
211
210
  */
212
- async batchDelete(ids: string[]) {
211
+ batchDelete = async (ids: string[]) => {
213
212
  return this.db
214
213
  .delete(sessions)
215
214
  .where(and(inArray(sessions.id, ids), eq(sessions.userId, this.userId)));
216
- }
215
+ };
217
216
 
218
- async deleteAll() {
217
+ deleteAll = async () => {
219
218
  return this.db.delete(sessions).where(eq(sessions.userId, this.userId));
220
- }
219
+ };
221
220
  // **************** Update *************** //
222
221
 
223
- async update(id: string, data: Partial<SessionItem>) {
222
+ update = async (id: string, data: Partial<SessionItem>) => {
224
223
  return this.db
225
224
  .update(sessions)
226
225
  .set(data)
227
226
  .where(and(eq(sessions.id, id), eq(sessions.userId, this.userId)))
228
227
  .returning();
229
- }
228
+ };
230
229
 
231
- async updateConfig(id: string, data: Partial<AgentItem>) {
230
+ updateConfig = async (id: string, data: Partial<AgentItem>) => {
232
231
  if (Object.keys(data).length === 0) return;
233
232
 
234
233
  return this.db
235
234
  .update(agents)
236
235
  .set(data)
237
236
  .where(and(eq(agents.id, id), eq(agents.userId, this.userId)));
238
- }
237
+ };
239
238
 
240
239
  // **************** Helper *************** //
241
240
 
@@ -266,7 +265,11 @@ export class SessionModel {
266
265
  } as any;
267
266
  };
268
267
 
269
- async findSessionsByKeywords(params: { current?: number; keyword: string; pageSize?: number }) {
268
+ findSessionsByKeywords = async (params: {
269
+ current?: number;
270
+ keyword: string;
271
+ pageSize?: number;
272
+ }) => {
270
273
  const { keyword, pageSize = 9999, current = 0 } = params;
271
274
  const offset = current * pageSize;
272
275
  const results = await this.db.query.agents.findMany({
@@ -290,5 +293,5 @@ export class SessionModel {
290
293
  return results.map((item) => item.agentsToSessions[0].session);
291
294
  } catch {}
292
295
  return [];
293
- }
296
+ };
294
297
  }
@@ -46,14 +46,14 @@ export class SessionGroupModel {
46
46
  });
47
47
  };
48
48
 
49
- async update(id: string, value: Partial<SessionGroupItem>) {
49
+ update = async (id: string, value: Partial<SessionGroupItem>) => {
50
50
  return this.db
51
51
  .update(sessionGroups)
52
52
  .set({ ...value, updatedAt: new Date() })
53
53
  .where(and(eq(sessionGroups.id, id), eq(sessionGroups.userId, this.userId)));
54
- }
54
+ };
55
55
 
56
- async updateOrder(sortMap: { id: string; sort: number }[]) {
56
+ updateOrder = async (sortMap: { id: string; sort: number }[]) => {
57
57
  await this.db.transaction(async (tx) => {
58
58
  const updates = sortMap.map(({ id, sort }) => {
59
59
  return tx
@@ -64,7 +64,7 @@ export class SessionGroupModel {
64
64
 
65
65
  await Promise.all(updates);
66
66
  });
67
- }
67
+ };
68
68
 
69
69
  private genId = () => idGenerator('sessionGroups');
70
70
  }
@@ -71,10 +71,10 @@ export class ThreadModel {
71
71
  });
72
72
  };
73
73
 
74
- async update(id: string, value: Partial<ThreadItem>) {
74
+ update = async (id: string, value: Partial<ThreadItem>) => {
75
75
  return this.db
76
76
  .update(threads)
77
77
  .set({ ...value, updatedAt: new Date() })
78
78
  .where(and(eq(threads.id, id), eq(threads.userId, this.userId)));
79
- }
79
+ };
80
80
  }