@lobehub/lobehub 2.0.0-next.26 → 2.0.0-next.28

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 (73) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +18 -0
  3. package/package.json +1 -1
  4. package/packages/types/src/discover/mcp.ts +6 -0
  5. package/packages/types/src/plugins/mcp.ts +4 -1
  6. package/packages/types/src/topic/topic.ts +14 -0
  7. package/renovate.json +4 -30
  8. package/src/features/MCP/utils.test.ts +91 -0
  9. package/src/features/MCP/utils.ts +20 -2
  10. package/src/features/PluginStore/Content.tsx +2 -3
  11. package/src/features/PluginStore/McpList/index.tsx +6 -2
  12. package/src/server/routers/lambda/market/index.ts +4 -2
  13. package/src/server/routers/lambda/topic.ts +7 -1
  14. package/src/services/aiModel/index.test.ts +3 -3
  15. package/src/services/aiModel/index.ts +56 -2
  16. package/src/services/aiProvider/index.test.ts +2 -2
  17. package/src/services/aiProvider/index.ts +48 -2
  18. package/src/services/chatGroup/index.ts +66 -2
  19. package/src/services/export/index.ts +10 -2
  20. package/src/services/file/index.ts +61 -2
  21. package/src/services/import/index.ts +133 -2
  22. package/src/services/mcp.ts +40 -6
  23. package/src/services/message/index.ts +176 -2
  24. package/src/services/message/{__tests__/server.test.ts → server.test.ts} +3 -3
  25. package/src/services/plugin/index.test.ts +8 -0
  26. package/src/services/plugin/index.ts +53 -2
  27. package/src/services/session/index.test.ts +8 -0
  28. package/src/services/session/index.ts +145 -2
  29. package/src/services/thread/index.test.ts +8 -0
  30. package/src/services/thread/index.ts +38 -2
  31. package/src/services/topic/index.test.ts +8 -0
  32. package/src/services/topic/index.ts +76 -2
  33. package/src/services/user/index.test.ts +8 -0
  34. package/src/services/user/index.ts +53 -2
  35. package/src/store/aiInfra/slices/aiModel/action.test.ts +17 -9
  36. package/src/store/chat/slices/aiChat/actions/__tests__/helpers.ts +4 -2
  37. package/src/store/chat/slices/topic/action.test.ts +1 -1
  38. package/src/store/chat/slices/topic/action.ts +1 -2
  39. package/src/store/chat/slices/topic/reducer.ts +1 -2
  40. package/src/store/file/slices/chat/action.ts +1 -4
  41. package/src/store/file/slices/fileManager/action.ts +2 -3
  42. package/src/store/session/slices/sessionGroup/action.test.ts +5 -5
  43. package/src/store/tool/slices/mcpStore/action.test.ts +95 -3
  44. package/src/store/tool/slices/mcpStore/action.ts +177 -53
  45. package/src/store/tool/slices/oldStore/initialState.ts +1 -2
  46. package/src/store/user/slices/common/action.test.ts +1 -1
  47. package/src/services/aiModel/server.test.ts +0 -122
  48. package/src/services/aiModel/server.ts +0 -51
  49. package/src/services/aiModel/type.ts +0 -32
  50. package/src/services/aiProvider/server.ts +0 -43
  51. package/src/services/aiProvider/type.ts +0 -27
  52. package/src/services/chatGroup/server.ts +0 -67
  53. package/src/services/chatGroup/type.ts +0 -22
  54. package/src/services/export/server.ts +0 -9
  55. package/src/services/export/type.ts +0 -5
  56. package/src/services/file/server.ts +0 -53
  57. package/src/services/file/type.ts +0 -13
  58. package/src/services/import/server.ts +0 -133
  59. package/src/services/import/type.ts +0 -17
  60. package/src/services/message/server.ts +0 -151
  61. package/src/services/message/type.ts +0 -55
  62. package/src/services/plugin/server.ts +0 -42
  63. package/src/services/plugin/type.ts +0 -23
  64. package/src/services/session/server.test.ts +0 -260
  65. package/src/services/session/server.ts +0 -125
  66. package/src/services/session/type.ts +0 -82
  67. package/src/services/thread/server.ts +0 -32
  68. package/src/services/thread/type.ts +0 -21
  69. package/src/services/topic/server.ts +0 -57
  70. package/src/services/topic/type.ts +0 -40
  71. package/src/services/user/server.test.ts +0 -149
  72. package/src/services/user/server.ts +0 -47
  73. package/src/services/user/type.ts +0 -21
@@ -1,67 +0,0 @@
1
- import {
2
- ChatGroupAgentItem,
3
- ChatGroupItem,
4
- NewChatGroup,
5
- NewChatGroupAgent,
6
- } from '@/database/schemas';
7
- import { lambdaClient } from '@/libs/trpc/client';
8
-
9
- import { IChatGroupService } from './type';
10
-
11
- export class ServerService implements IChatGroupService {
12
- createGroup(params: Omit<NewChatGroup, 'userId'>): Promise<ChatGroupItem> {
13
- return lambdaClient.group.createGroup.mutate({
14
- ...params,
15
- config: params.config as any,
16
- });
17
- }
18
-
19
- updateGroup(id: string, value: Partial<ChatGroupItem>): Promise<ChatGroupItem> {
20
- return lambdaClient.group.updateGroup.mutate({
21
- id,
22
- value: {
23
- ...value,
24
- config: value.config as any,
25
- },
26
- });
27
- }
28
-
29
- deleteGroup(id: string): Promise<any> {
30
- return lambdaClient.group.deleteGroup.mutate({ id });
31
- }
32
-
33
- getGroup(id: string): Promise<ChatGroupItem | undefined> {
34
- return lambdaClient.group.getGroup.query({ id });
35
- }
36
-
37
- getGroups(): Promise<ChatGroupItem[]> {
38
- return lambdaClient.group.getGroups.query();
39
- }
40
-
41
- addAgentsToGroup(groupId: string, agentIds: string[]): Promise<ChatGroupAgentItem[]> {
42
- return lambdaClient.group.addAgentsToGroup.mutate({ agentIds, groupId });
43
- }
44
-
45
- removeAgentsFromGroup(groupId: string, agentIds: string[]): Promise<any> {
46
- return lambdaClient.group.removeAgentsFromGroup.mutate({ agentIds, groupId });
47
- }
48
-
49
- updateAgentInGroup(
50
- groupId: string,
51
- agentId: string,
52
- updates: Partial<Pick<NewChatGroupAgent, 'order' | 'role'>>,
53
- ): Promise<ChatGroupAgentItem> {
54
- return lambdaClient.group.updateAgentInGroup.mutate({
55
- agentId,
56
- groupId,
57
- updates: {
58
- order: updates.order === null ? undefined : updates.order,
59
- role: updates.role === null ? undefined : updates.role,
60
- },
61
- });
62
- }
63
-
64
- getGroupAgents(groupId: string): Promise<ChatGroupAgentItem[]> {
65
- return lambdaClient.group.getGroupAgents.query({ groupId });
66
- }
67
- }
@@ -1,22 +0,0 @@
1
- import {
2
- ChatGroupAgentItem,
3
- ChatGroupItem,
4
- NewChatGroup,
5
- NewChatGroupAgent,
6
- } from '@/database/schemas';
7
-
8
- export interface IChatGroupService {
9
- addAgentsToGroup(groupId: string, agentIds: string[]): Promise<ChatGroupAgentItem[]>;
10
- createGroup(params: Omit<NewChatGroup, 'userId'>): Promise<ChatGroupItem>;
11
- deleteGroup(id: string): Promise<any>;
12
- getGroup(id: string): Promise<ChatGroupItem | undefined>;
13
- getGroupAgents(groupId: string): Promise<ChatGroupAgentItem[]>;
14
- getGroups(): Promise<ChatGroupItem[]>;
15
- removeAgentsFromGroup(groupId: string, agentIds: string[]): Promise<any>;
16
- updateAgentInGroup(
17
- groupId: string,
18
- agentId: string,
19
- updates: Partial<Pick<NewChatGroupAgent, 'order' | 'role'>>,
20
- ): Promise<ChatGroupAgentItem>;
21
- updateGroup(id: string, value: Partial<ChatGroupItem>): Promise<ChatGroupItem>;
22
- }
@@ -1,9 +0,0 @@
1
- import { lambdaClient } from '@/libs/trpc/client';
2
-
3
- import { IExportService } from './type';
4
-
5
- export class ServerService implements IExportService {
6
- exportData: IExportService['exportData'] = async () => {
7
- return await lambdaClient.exporter.exportData.mutate();
8
- };
9
- }
@@ -1,5 +0,0 @@
1
- import { ExportDatabaseData } from '@/types/export';
2
-
3
- export interface IExportService {
4
- exportData(): Promise<ExportDatabaseData>;
5
- }
@@ -1,53 +0,0 @@
1
- import { lambdaClient } from '@/libs/trpc/client';
2
- import { QueryFileListParams, QueryFileListSchemaType, UploadFileParams } from '@/types/files';
3
-
4
- import { IFileService } from './type';
5
-
6
- interface CreateFileParams extends Omit<UploadFileParams, 'url'> {
7
- knowledgeBaseId?: string;
8
- url: string;
9
- }
10
-
11
- export class ServerService implements IFileService {
12
- createFile: IFileService['createFile'] = async (params, knowledgeBaseId) => {
13
- return lambdaClient.file.createFile.mutate({ ...params, knowledgeBaseId } as CreateFileParams);
14
- };
15
-
16
- getFile: IFileService['getFile'] = async (id) => {
17
- const item = await lambdaClient.file.findById.query({ id });
18
-
19
- if (!item) {
20
- throw new Error('file not found');
21
- }
22
-
23
- return { ...item, type: item.fileType };
24
- };
25
-
26
- removeFile: IFileService['removeFile'] = async (id) => {
27
- await lambdaClient.file.removeFile.mutate({ id });
28
- };
29
-
30
- removeFiles: IFileService['removeFiles'] = async (ids) => {
31
- await lambdaClient.file.removeFiles.mutate({ ids });
32
- };
33
-
34
- removeAllFiles: IFileService['removeAllFiles'] = async () => {
35
- await lambdaClient.file.removeAllFiles.mutate();
36
- };
37
-
38
- getFiles = async (params: QueryFileListParams) => {
39
- return lambdaClient.file.getFiles.query(params as QueryFileListSchemaType);
40
- };
41
-
42
- getFileItem = async (id: string) => {
43
- return lambdaClient.file.getFileItemById.query({ id });
44
- };
45
-
46
- checkFileHash: IFileService['checkFileHash'] = async (hash) => {
47
- return lambdaClient.file.checkFileHash.mutate({ hash });
48
- };
49
-
50
- removeFileAsyncTask = async (id: string, type: 'embedding' | 'chunk') => {
51
- return lambdaClient.file.removeFileAsyncTask.mutate({ id, type });
52
- };
53
- }
@@ -1,13 +0,0 @@
1
- import { CheckFileHashResult, FileItem, UploadFileParams } from '@/types/files';
2
-
3
- export interface IFileService {
4
- checkFileHash(hash: string): Promise<CheckFileHashResult>;
5
- createFile(
6
- file: UploadFileParams,
7
- knowledgeBaseId?: string,
8
- ): Promise<{ id: string; url: string }>;
9
- getFile(id: string): Promise<FileItem>;
10
- removeAllFiles(): Promise<any>;
11
- removeFile(id: string): Promise<void>;
12
- removeFiles(ids: string[]): Promise<void>;
13
- }
@@ -1,133 +0,0 @@
1
- import { DefaultErrorShape } from '@trpc/server/unstable-core-do-not-import';
2
-
3
- import { lambdaClient } from '@/libs/trpc/client';
4
- import { uploadService } from '@/services/upload';
5
- import { useUserStore } from '@/store/user';
6
- import { ImportPgDataStructure } from '@/types/export';
7
- import { ImportStage, OnImportCallbacks } from '@/types/importer';
8
- import { uuid } from '@/utils/uuid';
9
-
10
- import { IImportService } from './type';
11
-
12
- export class ServerService implements IImportService {
13
- importSettings: IImportService['importSettings'] = async (settings) => {
14
- await useUserStore.getState().importAppSettings(settings);
15
- };
16
-
17
- importData: IImportService['importData'] = async (data, callbacks) => {
18
- const handleError = (e: unknown) => {
19
- callbacks?.onStageChange?.(ImportStage.Error);
20
- const error = e as DefaultErrorShape;
21
-
22
- callbacks?.onError?.({
23
- code: error.data.code,
24
- httpStatus: error.data.httpStatus,
25
- message: error.message,
26
- path: error.data.path,
27
- });
28
- };
29
-
30
- const totalLength =
31
- (data.messages?.length || 0) +
32
- (data.sessionGroups?.length || 0) +
33
- (data.sessions?.length || 0) +
34
- (data.topics?.length || 0);
35
-
36
- if (totalLength < 500) {
37
- callbacks?.onStageChange?.(ImportStage.Importing);
38
- const time = Date.now();
39
- try {
40
- const result = await lambdaClient.importer.importByPost.mutate({ data });
41
- const duration = Date.now() - time;
42
-
43
- callbacks?.onStageChange?.(ImportStage.Success);
44
- callbacks?.onSuccess?.(result.results, duration);
45
- } catch (e) {
46
- handleError(e);
47
- }
48
-
49
- return;
50
- }
51
-
52
- await this.uploadData(data, { callbacks, handleError });
53
- };
54
-
55
- importPgData: IImportService['importPgData'] = async (
56
- data: ImportPgDataStructure,
57
- {
58
- callbacks,
59
- }: {
60
- callbacks?: OnImportCallbacks;
61
- overwriteExisting?: boolean;
62
- } = {},
63
- ): Promise<void> => {
64
- const handleError = (e: unknown) => {
65
- callbacks?.onStageChange?.(ImportStage.Error);
66
- const error = e as DefaultErrorShape;
67
-
68
- callbacks?.onError?.({
69
- code: error.data.code,
70
- httpStatus: error.data.httpStatus,
71
- message: error.message,
72
- path: error.data.path,
73
- });
74
- };
75
-
76
- const totalLength = Object.values(data.data)
77
- .map((d) => d.length)
78
- .reduce((a, b) => a + b, 0);
79
-
80
- if (totalLength < 500) {
81
- callbacks?.onStageChange?.(ImportStage.Importing);
82
- const time = Date.now();
83
- try {
84
- const result = await lambdaClient.importer.importPgByPost.mutate(data);
85
- const duration = Date.now() - time;
86
-
87
- callbacks?.onStageChange?.(ImportStage.Success);
88
- callbacks?.onSuccess?.(result.results, duration);
89
- } catch (e) {
90
- handleError(e);
91
- }
92
-
93
- return;
94
- }
95
-
96
- await this.uploadData(data, { callbacks, handleError });
97
- };
98
-
99
- private uploadData = async (
100
- data: object,
101
- { callbacks, handleError }: { callbacks?: OnImportCallbacks; handleError: (e: unknown) => any },
102
- ) => {
103
- // if the data is too large, upload it to S3 and upload by file
104
- const filename = `${uuid()}.json`;
105
-
106
- let pathname;
107
- try {
108
- callbacks?.onStageChange?.(ImportStage.Uploading);
109
- const result = await uploadService.uploadDataToS3(data, {
110
- filename,
111
- onProgress: (status, state) => {
112
- callbacks?.onFileUploading?.(state);
113
- },
114
- pathname: `import_config/${filename}`,
115
- });
116
- pathname = result.data.path;
117
- console.log(pathname);
118
- } catch {
119
- throw new Error('Upload Error');
120
- }
121
-
122
- callbacks?.onStageChange?.(ImportStage.Importing);
123
- const time = Date.now();
124
- try {
125
- const result = await lambdaClient.importer.importByFile.mutate({ pathname });
126
- const duration = Date.now() - time;
127
- callbacks?.onStageChange?.(ImportStage.Success);
128
- callbacks?.onSuccess?.(result.results, duration);
129
- } catch (e) {
130
- handleError(e);
131
- }
132
- };
133
- }
@@ -1,17 +0,0 @@
1
- import { ImportPgDataStructure } from '@/types/export';
2
- import { ImporterEntryData, OnImportCallbacks } from '@/types/importer';
3
- import { UserSettings } from '@/types/user/settings';
4
-
5
- export interface IImportService {
6
- importData(data: ImporterEntryData, callbacks?: OnImportCallbacks): Promise<void>;
7
-
8
- importPgData(
9
- data: ImportPgDataStructure,
10
- options?: {
11
- callbacks?: OnImportCallbacks;
12
- overwriteExisting?: boolean;
13
- },
14
- ): Promise<void>;
15
-
16
- importSettings(settings: UserSettings): Promise<void>;
17
- }
@@ -1,151 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import { ChatTranslate, UIChatMessage } from '@lobechat/types';
3
-
4
- import { INBOX_SESSION_ID } from '@/const/session';
5
- import { lambdaClient } from '@/libs/trpc/client';
6
- import { useUserStore } from '@/store/user';
7
- import { labPreferSelectors } from '@/store/user/selectors';
8
-
9
- import { IMessageService } from './type';
10
-
11
- export class ServerService implements IMessageService {
12
- createMessage: IMessageService['createMessage'] = async ({ sessionId, ...params }) => {
13
- return lambdaClient.message.createMessage.mutate({
14
- ...params,
15
- sessionId: sessionId ? this.toDbSessionId(sessionId) : undefined,
16
- });
17
- };
18
-
19
- createNewMessage: IMessageService['createNewMessage'] = async ({ sessionId, ...params }) => {
20
- return lambdaClient.message.createNewMessage.mutate({
21
- ...params,
22
- sessionId: sessionId ? this.toDbSessionId(sessionId) : undefined,
23
- });
24
- };
25
-
26
- getMessages: IMessageService['getMessages'] = async (sessionId, topicId, groupId) => {
27
- // Get user lab preference for message grouping
28
- const useGroup = labPreferSelectors.enableAssistantMessageGroup(useUserStore.getState());
29
-
30
- const data = await lambdaClient.message.getMessages.query({
31
- groupId,
32
- sessionId: this.toDbSessionId(sessionId),
33
- topicId,
34
- useGroup,
35
- });
36
-
37
- return data as unknown as UIChatMessage[];
38
- };
39
-
40
- getGroupMessages: IMessageService['getGroupMessages'] = async (groupId, topicId) => {
41
- // Get user lab preference for message grouping
42
- const useGroup = labPreferSelectors.enableAssistantMessageGroup(useUserStore.getState());
43
-
44
- const data = await lambdaClient.message.getMessages.query({
45
- groupId,
46
- topicId,
47
- useGroup,
48
- });
49
- return data as unknown as UIChatMessage[];
50
- };
51
-
52
- countMessages: IMessageService['countMessages'] = async (params) => {
53
- return lambdaClient.message.count.query(params);
54
- };
55
-
56
- countWords: IMessageService['countWords'] = async (params) => {
57
- return lambdaClient.message.countWords.query(params);
58
- };
59
-
60
- rankModels: IMessageService['rankModels'] = async () => {
61
- return lambdaClient.message.rankModels.query();
62
- };
63
-
64
- getHeatmaps: IMessageService['getHeatmaps'] = async () => {
65
- return lambdaClient.message.getHeatmaps.query();
66
- };
67
-
68
- updateMessageError: IMessageService['updateMessageError'] = async (id, error) => {
69
- return lambdaClient.message.update.mutate({ id, value: { error } });
70
- };
71
-
72
- updateMessagePluginArguments: IMessageService['updateMessagePluginArguments'] = async (
73
- id,
74
- value,
75
- ) => {
76
- const args = typeof value === 'string' ? value : JSON.stringify(value);
77
- return lambdaClient.message.updateMessagePlugin.mutate({ id, value: { arguments: args } });
78
- };
79
-
80
- updateMessage: IMessageService['updateMessage'] = async (id, value, options) => {
81
- return lambdaClient.message.update.mutate({
82
- id,
83
- sessionId: options?.sessionId,
84
- topicId: options?.topicId,
85
- value,
86
- });
87
- };
88
-
89
- updateMessageTranslate: IMessageService['updateMessageTranslate'] = async (id, translate) => {
90
- return lambdaClient.message.updateTranslate.mutate({ id, value: translate as ChatTranslate });
91
- };
92
-
93
- updateMessageTTS: IMessageService['updateMessageTTS'] = async (id, tts) => {
94
- return lambdaClient.message.updateTTS.mutate({ id, value: tts });
95
- };
96
-
97
- updateMessagePluginState: IMessageService['updateMessagePluginState'] = async (id, value) => {
98
- return lambdaClient.message.updatePluginState.mutate({ id, value });
99
- };
100
-
101
- updateMessagePluginError: IMessageService['updateMessagePluginError'] = async (id, error) => {
102
- return lambdaClient.message.updatePluginError.mutate({ id, value: error as any });
103
- };
104
-
105
- updateMessageRAG: IMessageService['updateMessageRAG'] = async (id, data) => {
106
- return lambdaClient.message.updateMessageRAG.mutate({ id, value: data });
107
- };
108
-
109
- removeMessage: IMessageService['removeMessage'] = async (id) => {
110
- return lambdaClient.message.removeMessage.mutate({ id });
111
- };
112
-
113
- removeMessages: IMessageService['removeMessages'] = async (ids) => {
114
- return lambdaClient.message.removeMessages.mutate({ ids });
115
- };
116
-
117
- removeMessagesByAssistant: IMessageService['removeMessagesByAssistant'] = async (
118
- sessionId,
119
- topicId,
120
- ) => {
121
- return lambdaClient.message.removeMessagesByAssistant.mutate({
122
- sessionId: this.toDbSessionId(sessionId),
123
- topicId,
124
- });
125
- };
126
-
127
- removeMessagesByGroup: IMessageService['removeMessagesByGroup'] = async (groupId, topicId) => {
128
- return lambdaClient.message.removeMessagesByGroup.mutate({
129
- groupId,
130
- topicId,
131
- });
132
- };
133
-
134
- removeAllMessages: IMessageService['removeAllMessages'] = async () => {
135
- return lambdaClient.message.removeAllMessages.mutate();
136
- };
137
-
138
- private toDbSessionId = (sessionId: string | undefined) => {
139
- return sessionId === INBOX_SESSION_ID ? null : sessionId;
140
- };
141
-
142
- hasMessages: IMessageService['hasMessages'] = async () => {
143
- const number = await this.countMessages();
144
- return number > 0;
145
- };
146
-
147
- messageCountToCheckTrace: IMessageService['messageCountToCheckTrace'] = async () => {
148
- const number = await this.countMessages();
149
- return number >= 4;
150
- };
151
- }
@@ -1,55 +0,0 @@
1
- import {
2
- ChatMessageError,
3
- ChatMessagePluginError,
4
- ChatTTS,
5
- ChatTranslate,
6
- CreateMessageParams,
7
- CreateMessageResult,
8
- ModelRankItem,
9
- UIChatMessage,
10
- UpdateMessageParams,
11
- UpdateMessageRAGParams,
12
- UpdateMessageResult,
13
- } from '@lobechat/types';
14
- import type { HeatmapsProps } from '@lobehub/charts';
15
-
16
- /* eslint-disable typescript-sort-keys/interface */
17
-
18
- export interface IMessageService {
19
- createMessage(data: CreateMessageParams): Promise<string>;
20
- createNewMessage(data: CreateMessageParams): Promise<CreateMessageResult>;
21
-
22
- getMessages(sessionId: string, topicId?: string, groupId?: string): Promise<UIChatMessage[]>;
23
- getGroupMessages(groupId: string, topicId?: string): Promise<UIChatMessage[]>;
24
- countMessages(params?: {
25
- endDate?: string;
26
- range?: [string, string];
27
- startDate?: string;
28
- }): Promise<number>;
29
- countWords(params?: {
30
- endDate?: string;
31
- range?: [string, string];
32
- startDate?: string;
33
- }): Promise<number>;
34
- rankModels(): Promise<ModelRankItem[]>;
35
- getHeatmaps(): Promise<HeatmapsProps['data']>;
36
- updateMessageError(id: string, error: ChatMessageError): Promise<any>;
37
- updateMessage(
38
- id: string,
39
- message: Partial<UpdateMessageParams>,
40
- options?: { sessionId?: string | null; topicId?: string | null },
41
- ): Promise<UpdateMessageResult>;
42
- updateMessageTTS(id: string, tts: Partial<ChatTTS> | false): Promise<any>;
43
- updateMessageTranslate(id: string, translate: Partial<ChatTranslate> | false): Promise<any>;
44
- updateMessagePluginState(id: string, value: Record<string, any>): Promise<any>;
45
- updateMessagePluginError(id: string, value: ChatMessagePluginError | null): Promise<any>;
46
- updateMessageRAG(id: string, value: UpdateMessageRAGParams): Promise<void>;
47
- updateMessagePluginArguments(id: string, value: string | Record<string, any>): Promise<any>;
48
- removeMessage(id: string): Promise<any>;
49
- removeMessages(ids: string[]): Promise<any>;
50
- removeMessagesByAssistant(assistantId: string, topicId?: string): Promise<any>;
51
- removeMessagesByGroup(groupId: string, topicId?: string): Promise<any>;
52
- removeAllMessages(): Promise<any>;
53
- messageCountToCheckTrace(): Promise<boolean>;
54
- hasMessages(): Promise<boolean>;
55
- }
@@ -1,42 +0,0 @@
1
- import { lambdaClient } from '@/libs/trpc/client';
2
-
3
- import { IPluginService } from './type';
4
-
5
- export class ServerService implements IPluginService {
6
- installPlugin: IPluginService['installPlugin'] = async (plugin) => {
7
- await lambdaClient.plugin.createOrInstallPlugin.mutate(plugin);
8
- };
9
-
10
- getInstalledPlugins: IPluginService['getInstalledPlugins'] = () => {
11
- return lambdaClient.plugin.getPlugins.query();
12
- };
13
-
14
- uninstallPlugin: IPluginService['uninstallPlugin'] = async (identifier) => {
15
- await lambdaClient.plugin.removePlugin.mutate({ id: identifier });
16
- };
17
-
18
- createCustomPlugin: IPluginService['createCustomPlugin'] = async (customPlugin) => {
19
- await lambdaClient.plugin.createPlugin.mutate({ ...customPlugin, type: 'customPlugin' });
20
- };
21
-
22
- updatePlugin: IPluginService['updatePlugin'] = async (id, value) => {
23
- await lambdaClient.plugin.updatePlugin.mutate({
24
- customParams: value.customParams,
25
- id,
26
- manifest: value.manifest,
27
- settings: value.settings,
28
- });
29
- };
30
-
31
- updatePluginManifest: IPluginService['updatePluginManifest'] = async (id, manifest) => {
32
- await lambdaClient.plugin.updatePlugin.mutate({ id, manifest });
33
- };
34
-
35
- removeAllPlugins: IPluginService['removeAllPlugins'] = async () => {
36
- await lambdaClient.plugin.removeAllPlugins.mutate();
37
- };
38
-
39
- updatePluginSettings: IPluginService['updatePluginSettings'] = async (id, settings, signal) => {
40
- await lambdaClient.plugin.updatePlugin.mutate({ id, settings }, { signal });
41
- };
42
- }
@@ -1,23 +0,0 @@
1
- import { LobeTool } from '@lobechat/types';
2
- import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';
3
-
4
- import { LobeToolCustomPlugin } from '@/types/tool/plugin';
5
-
6
- export interface InstallPluginParams {
7
- customParams?: Record<string, any>;
8
- identifier: string;
9
- manifest: LobeChatPluginManifest;
10
- settings?: Record<string, any>;
11
- type: 'plugin' | 'customPlugin';
12
- }
13
-
14
- export interface IPluginService {
15
- createCustomPlugin: (customPlugin: LobeToolCustomPlugin) => Promise<void>;
16
- getInstalledPlugins: () => Promise<LobeTool[]>;
17
- installPlugin: (plugin: InstallPluginParams) => Promise<void>;
18
- removeAllPlugins: () => Promise<void>;
19
- uninstallPlugin: (identifier: string) => Promise<void>;
20
- updatePlugin: (id: string, value: Partial<LobeToolCustomPlugin>) => Promise<void>;
21
- updatePluginManifest: (id: string, manifest: LobeChatPluginManifest) => Promise<void>;
22
- updatePluginSettings: (id: string, settings: any, signal?: AbortSignal) => Promise<void>;
23
- }