@lobehub/lobehub 2.0.0-next.45 → 2.0.0-next.47

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 (44) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +18 -0
  3. package/package.json +1 -1
  4. package/packages/database/src/models/file.ts +15 -1
  5. package/packages/database/src/repositories/aiInfra/index.test.ts +1 -1
  6. package/packages/database/src/repositories/dataExporter/index.test.ts +1 -1
  7. package/packages/database/src/repositories/tableViewer/index.test.ts +1 -1
  8. package/packages/types/src/aiProvider.ts +1 -1
  9. package/packages/types/src/document/index.ts +38 -38
  10. package/packages/types/src/exportConfig.ts +15 -15
  11. package/packages/types/src/generation/index.ts +5 -5
  12. package/packages/types/src/openai/chat.ts +15 -15
  13. package/packages/types/src/plugins/mcp.ts +29 -29
  14. package/packages/types/src/plugins/protocol.ts +43 -43
  15. package/packages/types/src/search.ts +4 -4
  16. package/packages/types/src/tool/plugin.ts +3 -3
  17. package/src/app/(backend)/f/[id]/route.ts +55 -0
  18. package/src/app/[variants]/(main)/chat/components/conversation/features/ChatList/ChatItem/Thread.tsx +1 -1
  19. package/src/app/[variants]/(main)/chat/components/conversation/features/ChatList/ChatItem/index.tsx +9 -16
  20. package/src/envs/app.ts +4 -3
  21. package/src/features/Conversation/Messages/Assistant/Actions/index.tsx +3 -5
  22. package/src/features/Conversation/Messages/Assistant/Extra/index.test.tsx +3 -3
  23. package/src/features/Conversation/Messages/Assistant/Extra/index.tsx +8 -5
  24. package/src/features/Conversation/Messages/Assistant/index.tsx +29 -15
  25. package/src/features/Conversation/Messages/Group/Actions/WithContentId.tsx +3 -5
  26. package/src/features/Conversation/Messages/Group/index.tsx +12 -20
  27. package/src/features/Conversation/Messages/Supervisor/index.tsx +14 -5
  28. package/src/features/Conversation/Messages/User/index.tsx +14 -8
  29. package/src/features/Conversation/Messages/index.tsx +16 -26
  30. package/src/features/Conversation/components/Extras/Usage/UsageDetail/index.tsx +7 -6
  31. package/src/features/Conversation/components/Extras/Usage/UsageDetail/tokens.ts +2 -5
  32. package/src/features/Conversation/components/Extras/Usage/index.tsx +13 -6
  33. package/src/features/Conversation/components/VirtualizedList/index.tsx +2 -1
  34. package/src/features/PluginsUI/Render/MCPType/index.tsx +26 -6
  35. package/src/server/modules/ContentChunk/index.test.ts +372 -0
  36. package/src/server/routers/desktop/mcp.ts +23 -8
  37. package/src/server/routers/tools/mcp.ts +24 -4
  38. package/src/server/services/file/impls/local.ts +4 -1
  39. package/src/server/services/file/index.ts +96 -1
  40. package/src/server/services/mcp/contentProcessor.ts +101 -0
  41. package/src/server/services/mcp/index.test.ts +52 -10
  42. package/src/server/services/mcp/index.ts +29 -26
  43. package/src/services/session/index.ts +0 -14
  44. package/src/utils/server/routeVariants.test.ts +340 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 2.0.0-next.47](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.46...v2.0.0-next.47)
6
+
7
+ <sup>Released on **2025-11-11**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix mcp server return image error.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix mcp server return image error, closes [#10113](https://github.com/lobehub/lobe-chat/issues/10113) ([e5640d4](https://github.com/lobehub/lobe-chat/commit/e5640d4))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ## [Version 2.0.0-next.46](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.45...v2.0.0-next.46)
31
+
32
+ <sup>Released on **2025-11-11**</sup>
33
+
34
+ #### ♻ Code Refactoring
35
+
36
+ - **misc**: Fix thread display.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Code refactoring
44
+
45
+ - **misc**: Fix thread display, closes [#10153](https://github.com/lobehub/lobe-chat/issues/10153) ([8fda83e](https://github.com/lobehub/lobe-chat/commit/8fda83e))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ## [Version 2.0.0-next.45](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.44...v2.0.0-next.45)
6
56
 
7
57
  <sup>Released on **2025-11-10**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,22 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "fixes": [
5
+ "Fix mcp server return image error."
6
+ ]
7
+ },
8
+ "date": "2025-11-11",
9
+ "version": "2.0.0-next.47"
10
+ },
11
+ {
12
+ "children": {
13
+ "improvements": [
14
+ "Fix thread display."
15
+ ]
16
+ },
17
+ "date": "2025-11-11",
18
+ "version": "2.0.0-next.46"
19
+ },
2
20
  {
3
21
  "children": {
4
22
  "improvements": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/lobehub",
3
- "version": "2.0.0-next.45",
3
+ "version": "2.0.0-next.47",
4
4
  "description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -25,8 +25,22 @@ export class FileModel {
25
25
  this.db = db;
26
26
  }
27
27
 
28
+ /**
29
+ * Get file by ID without userId filter (public access)
30
+ * Use this for scenarios like file proxy where file should be accessible by ID alone
31
+ *
32
+ * @param db - Database instance
33
+ * @param id - File ID
34
+ * @returns File record or undefined
35
+ */
36
+ static async getFileById(db: LobeChatDatabase, id: string): Promise<FileItem | undefined> {
37
+ return db.query.files.findFirst({
38
+ where: eq(files.id, id),
39
+ });
40
+ }
41
+
28
42
  create = async (
29
- params: Omit<NewFile, 'id' | 'userId'> & { knowledgeBaseId?: string },
43
+ params: Omit<NewFile, 'id' | 'userId'> & { id?: string; knowledgeBaseId?: string },
30
44
  insertToGlobalFiles?: boolean,
31
45
  trx?: Transaction,
32
46
  ) => {
@@ -25,7 +25,7 @@ beforeEach(async () => {
25
25
  vi.clearAllMocks();
26
26
 
27
27
  repo = new AiInfraRepos(clientDB as any, userId, mockProviderConfigs);
28
- });
28
+ }, 30000);
29
29
 
30
30
  describe('AiInfraRepos', () => {
31
31
  describe('getAiProviderList', () => {
@@ -157,7 +157,7 @@ describe('DataExporterRepos', () => {
157
157
 
158
158
  // 插入测试数据
159
159
  await setupTestData();
160
- });
160
+ }, 30000);
161
161
 
162
162
  afterEach(async () => {
163
163
  await db.delete(users);
@@ -16,7 +16,7 @@ const mockDB = {
16
16
  beforeEach(async () => {
17
17
  await initializeDB();
18
18
  vi.clearAllMocks();
19
- });
19
+ }, 30000);
20
20
 
21
21
  describe('TableViewerRepo', () => {
22
22
  describe('getAllTables', () => {
@@ -247,7 +247,7 @@ export const UpdateAiProviderConfigSchema = z.object({
247
247
  z.string(),
248
248
  z.union([
249
249
  z.string().optional(),
250
- z.record(z.string(), z.string()).optional(), // 支持嵌套对象,如 customHeaders
250
+ z.record(z.string(), z.string()).optional(), // Support nested objects, e.g. customHeaders
251
251
  ]),
252
252
  )
253
253
  .optional(),
@@ -1,172 +1,172 @@
1
1
  /**
2
- * LobeChat 中的文档对象
2
+ * Document object in LobeChat
3
3
  */
4
4
  export interface LobeDocument {
5
5
  /**
6
- * 文件内容
6
+ * File content
7
7
  */
8
8
  content: string | null;
9
9
  /**
10
- * 文件创建时间戳。
10
+ * File creation timestamp
11
11
  */
12
12
  createdAt: Date;
13
13
 
14
14
  /**
15
- * 文件类型或扩展名
15
+ * File type or extension
16
16
  */
17
17
  fileType: string;
18
18
 
19
19
  /**
20
- * 原始文件名。
20
+ * Original filename
21
21
  */
22
22
  filename: string;
23
23
 
24
24
  id: string;
25
25
 
26
26
  /**
27
- * 文件级别的元数据。
28
- * 例如从文件属性中提取的标题、作者,或整个文件加载失败时的错误。
27
+ * File-level metadata
28
+ * For example, title and author extracted from file properties, or errors when the entire file fails to load
29
29
  */
30
30
  metadata: {
31
31
  /**
32
- * 允许添加其他文件级别的元数据。
32
+ * Allow adding other file-level metadata
33
33
  */
34
34
  [key: string]: any;
35
35
  /**
36
- * 文档作者 (如果可用)
36
+ * Document author (if available)
37
37
  */
38
38
  author?: string;
39
39
  /**
40
- * 如果整个文件加载失败,记录错误信息。
40
+ * Error information if the entire file fails to load
41
41
  */
42
42
  error?: string;
43
43
  };
44
44
 
45
45
  /**
46
- * 包含文档中所有逻辑页面/块的数组。
47
- * 顺序通常对应文件中的自然顺序。
46
+ * Array containing all logical pages/blocks in the document
47
+ * Order typically corresponds to the natural order in the file
48
48
  */
49
49
  pages?: LobeDocumentPage[];
50
50
 
51
51
  /**
52
- * 原始文件的完整路径。
52
+ * Full path of the original file
53
53
  */
54
54
  source: string;
55
55
 
56
56
  /**
57
- * 文档标题 (如果可用)
57
+ * Document title (if available)
58
58
  */
59
59
  title?: string;
60
60
 
61
61
  /**
62
- * 整个文档的总字符数 (所有 Page charCount 之和)
63
- * 需要在所有 Page 加载和计算后得出。
62
+ * Total character count of the entire document (sum of charCount of all Pages)
63
+ * Obtained after all Pages are loaded and calculated
64
64
  */
65
65
  totalCharCount: number;
66
66
 
67
67
  /**
68
- * 整个文档的总行数 (所有 Page lineCount 之和)
69
- * 需要在所有 Page 加载和计算后得出。
68
+ * Total line count of the entire document (sum of lineCount of all Pages)
69
+ * Obtained after all Pages are loaded and calculated
70
70
  */
71
71
  totalLineCount: number;
72
72
 
73
73
  /**
74
- * 文件最后修改时间戳。
74
+ * File last modified timestamp
75
75
  */
76
76
  updatedAt: Date;
77
77
  }
78
78
 
79
79
  /**
80
- * 代表文件中的一个逻辑单元/页面/块。
80
+ * Represents a logical unit/page/block in a file
81
81
  */
82
82
  export interface LobeDocumentPage {
83
83
  /**
84
- * 此页/块内容的字符数。
84
+ * Character count of this page/block content
85
85
  */
86
86
  charCount: number;
87
87
 
88
88
  /**
89
- * 此页/块内容的行数。
89
+ * Line count of this page/block content
90
90
  */
91
91
  lineCount: number;
92
92
 
93
93
  /**
94
- * 与此页/块相关的元数据。
94
+ * Metadata related to this page/block
95
95
  */
96
96
  metadata: {
97
97
  /**
98
- * 允许添加其他特定于页/块的元数据。
98
+ * Allow adding other page/block-specific metadata
99
99
  */
100
100
  [key: string]: any;
101
101
 
102
102
  /**
103
- * 如果原始文件单元被进一步分割成块,这是当前块的索引。
103
+ * If the original file unit is further split into chunks, this is the index of the current chunk
104
104
  */
105
105
  chunkIndex?: number;
106
106
 
107
107
  /**
108
- * 处理此页/块时发生的错误。
108
+ * Errors that occurred while processing this page/block
109
109
  */
110
110
  error?: string;
111
111
 
112
112
  /**
113
- * 此页/块在原始文件中的结束行号。
113
+ * Ending line number of this page/block in the original file
114
114
  */
115
115
  lineNumberEnd?: number;
116
116
 
117
117
  /**
118
- * 此页/块在原始文件中的起始行号。
118
+ * Starting line number of this page/block in the original file
119
119
  */
120
120
  lineNumberStart?: number;
121
121
 
122
122
  /**
123
- * 页码 (适用于 PDF, DOCX)
123
+ * Page number (applicable to PDF, DOCX)
124
124
  */
125
125
  pageNumber?: number;
126
126
 
127
127
  /**
128
- * 与此页/块相关的章节标题。
128
+ * Section title related to this page/block
129
129
  */
130
130
  sectionTitle?: string;
131
131
 
132
132
  /**
133
- * 工作表名称 (适用于 XLSX)
133
+ * Worksheet name (applicable to XLSX)
134
134
  */
135
135
  sheetName?: string;
136
136
 
137
137
  /**
138
- * 幻灯片编号 (适用于 PPTX)
138
+ * Slide number (applicable to PPTX)
139
139
  */
140
140
  slideNumber?: number;
141
141
 
142
142
  /**
143
- * 如果原始文件单元被进一步分割成块,这是该单元的总块数。
143
+ * If the original file unit is further split into chunks, this is the total number of chunks for that unit
144
144
  */
145
145
  totalChunks?: number;
146
146
  };
147
147
 
148
148
  /**
149
- * 此页/块的核心文本内容。
149
+ * Core text content of this page/block
150
150
  */
151
151
  pageContent: string;
152
152
  }
153
153
 
154
154
  /**
155
- * 文档来源类型
155
+ * Document source type
156
156
  */
157
157
  export enum DocumentSourceType {
158
158
  /**
159
- * 来自 API 的内容
159
+ * Content from API
160
160
  */
161
161
  API = 'api',
162
162
 
163
163
  /**
164
- * 本地或上传的文件
164
+ * Local or uploaded files
165
165
  */
166
166
  FILE = 'file',
167
167
 
168
168
  /**
169
- * 网页内容
169
+ * Web content
170
170
  */
171
171
  WEB = 'web',
172
172
  }
@@ -6,14 +6,14 @@ import { UserSettings } from './user/settings';
6
6
  // ---------- TODO: this file need to be deleted in V2 ---------- //
7
7
 
8
8
  /**
9
- * 导出方式
9
+ * Export type
10
10
  * @enum ['agents', 'sessions', 'singleSession', 'settings', 'all']
11
11
  * @enumNames ['agents', 'sessions', 'singleSession', 'settings', 'all']
12
12
  */
13
13
  export type ExportType = 'agents' | 'sessions' | 'singleSession' | 'settings' | 'all';
14
14
 
15
15
  /**
16
- * 配置模型映射
16
+ * Config model map
17
17
  */
18
18
  export interface ConfigModelMap {
19
19
  agents: {
@@ -38,10 +38,10 @@ export interface ConfigModelMap {
38
38
  };
39
39
  }
40
40
 
41
- // ============= 配置数据结构 ============= //
41
+ // ============= Config Data Structures ============= //
42
42
 
43
43
  /**
44
- * 配置状态:会话
44
+ * Config state: Sessions
45
45
  */
46
46
  export interface ConfigStateSessions {
47
47
  messages: UIChatMessage[];
@@ -51,7 +51,7 @@ export interface ConfigStateSessions {
51
51
  }
52
52
 
53
53
  /**
54
- * 配置状态:单个会话
54
+ * Config state: Single session
55
55
  */
56
56
  export interface ConfigStateSingleSession {
57
57
  messages: UIChatMessage[];
@@ -60,7 +60,7 @@ export interface ConfigStateSingleSession {
60
60
  }
61
61
 
62
62
  /**
63
- * 配置状态:角色
63
+ * Config state: Agents
64
64
  */
65
65
  export interface ConfigStateAgents {
66
66
  sessionGroups: SessionGroupItem[];
@@ -68,21 +68,21 @@ export interface ConfigStateAgents {
68
68
  }
69
69
 
70
70
  /**
71
- * 配置状态:设置
71
+ * Config state: Settings
72
72
  */
73
73
  export interface ConfigStateSettings {
74
74
  settings: UserSettings;
75
75
  }
76
76
 
77
77
  /**
78
- * 配置状态:全部
78
+ * Config state: All
79
79
  */
80
80
  export interface ConfigStateAll extends ConfigStateSessions, ConfigStateSettings {}
81
81
 
82
- // ============= 配置文件类型 ============= //
82
+ // ============= Config File Types ============= //
83
83
 
84
84
  /**
85
- * 配置文件:设置
85
+ * Config file: Settings
86
86
  */
87
87
  export interface ConfigFileSettings {
88
88
  exportType: 'settings';
@@ -91,7 +91,7 @@ export interface ConfigFileSettings {
91
91
  }
92
92
 
93
93
  /**
94
- * 配置文件:会话
94
+ * Config file: Sessions
95
95
  */
96
96
  export interface ConfigFileSessions {
97
97
  exportType: 'sessions';
@@ -100,7 +100,7 @@ export interface ConfigFileSessions {
100
100
  }
101
101
 
102
102
  /**
103
- * 配置文件:单个会话
103
+ * Config file: Single session
104
104
  */
105
105
  export interface ConfigFileSingleSession {
106
106
  exportType: 'sessions';
@@ -109,7 +109,7 @@ export interface ConfigFileSingleSession {
109
109
  }
110
110
 
111
111
  /**
112
- * 配置文件:角色
112
+ * Config file: Agents
113
113
  */
114
114
  export interface ConfigFileAgents {
115
115
  exportType: 'agents';
@@ -118,7 +118,7 @@ export interface ConfigFileAgents {
118
118
  }
119
119
 
120
120
  /**
121
- * 配置文件:全部
121
+ * Config file: All
122
122
  */
123
123
  export interface ConfigFileAll {
124
124
  exportType: 'all';
@@ -127,6 +127,6 @@ export interface ConfigFileAll {
127
127
  }
128
128
 
129
129
  /**
130
- * 配置文件
130
+ * Config file
131
131
  */
132
132
  export type ConfigFile = ConfigFileSettings | ConfigFileSessions | ConfigFileAll | ConfigFileAgents;
@@ -14,23 +14,23 @@ export interface BaseGenerationAsset {
14
14
 
15
15
  export interface ImageGenerationAsset extends BaseGenerationAsset {
16
16
  /**
17
- * 图片/视频的高度
17
+ * Height of the image/video
18
18
  */
19
19
  height?: number;
20
20
  /**
21
- * api provider 家的 cdn url,一般很快就会失效
21
+ * CDN URL from the API provider, typically expires quickly
22
22
  */
23
23
  originalUrl?: string;
24
24
  /**
25
- * 缩略图,图片那就是尺寸裁剪过的,视频那就是封面的缩略图
25
+ * Thumbnail URL - for images it's a resized version, for videos it's a thumbnail of the cover
26
26
  */
27
27
  thumbnailUrl?: string;
28
28
  /**
29
- * 存到自己 oss url, 只存了 key 完整的 url 需要使用 FileService.getFullFileUrl 获取
29
+ * URL stored in own OSS, only the key is stored. The full URL needs to be obtained using FileService.getFullFileUrl
30
30
  */
31
31
  url?: string;
32
32
  /**
33
- * 图片/视频的宽度
33
+ * Width of the image/video
34
34
  */
35
35
  width?: number;
36
36
  }
@@ -38,8 +38,8 @@ export type UserMessageContentPart = UserMessageContentPartText | UserMessageCon
38
38
 
39
39
  export interface OpenAIChatMessage {
40
40
  /**
41
- * @title 内容
42
- * @description 消息内容
41
+ * @title Content
42
+ * @description Message content
43
43
  */
44
44
  content: string | UserMessageContentPart[];
45
45
 
@@ -49,8 +49,8 @@ export interface OpenAIChatMessage {
49
49
  function_call?: OpenAIFunctionCall;
50
50
  name?: string;
51
51
  /**
52
- * 角色
53
- * @description 消息发送者的角色
52
+ * Role
53
+ * @description Role of the message sender
54
54
  */
55
55
  role: LLMRoleType;
56
56
  tool_call_id?: string;
@@ -62,36 +62,36 @@ export interface OpenAIChatMessage {
62
62
  */
63
63
  export interface ChatStreamPayload {
64
64
  /**
65
- * 是否开启搜索
65
+ * Whether search is enabled
66
66
  */
67
67
  enabledSearch?: boolean;
68
68
  /**
69
- * @title 控制生成文本中的惩罚系数,用于减少重复性
69
+ * @title Penalty coefficient in generated text to reduce repetitiveness
70
70
  * @default 0
71
71
  */
72
72
  frequency_penalty?: number;
73
73
  /**
74
- * @title 生成文本的最大长度
74
+ * @title Maximum length of generated text
75
75
  */
76
76
  max_tokens?: number;
77
77
  /**
78
- * @title 聊天信息列表
78
+ * @title List of chat messages
79
79
  */
80
80
  messages: OpenAIChatMessage[];
81
81
  /**
82
- * @title 模型名称
82
+ * @title Model name
83
83
  */
84
84
  model: string;
85
85
  /**
86
- * @title 返回的文本数量
86
+ * @title Number of texts to return
87
87
  */
88
88
  n?: number;
89
89
  /**
90
- * 开启的插件列表
90
+ * List of enabled plugins
91
91
  */
92
92
  plugins?: string[];
93
93
  /**
94
- * @title 控制生成文本中的惩罚系数,用于减少主题的变化
94
+ * @title Penalty coefficient in generated text to reduce topic changes
95
95
  * @default 0
96
96
  */
97
97
  presence_penalty?: number;
@@ -102,19 +102,19 @@ export interface ChatStreamPayload {
102
102
  responseMode?: 'stream' | 'json';
103
103
  response_format?: ChatResponseFormat;
104
104
  /**
105
- * @title 是否开启流式请求
105
+ * @title Whether to enable streaming requests
106
106
  * @default true
107
107
  */
108
108
  stream?: boolean;
109
109
  /**
110
- * @title 生成文本的随机度量,用于控制文本的创造性和多样性
110
+ * @title Randomness measure for generated text, used to control creativity and diversity
111
111
  * @default 1
112
112
  */
113
113
  temperature: number;
114
114
  tool_choice?: string;
115
115
  tools?: ChatCompletionTool[];
116
116
  /**
117
- * @title 控制生成文本中最高概率的单个令牌
117
+ * @title Controls the single token with highest probability in generated text
118
118
  * @default 1
119
119
  */
120
120
  top_p?: number;