Skip to content

Commit 2518d7e

Browse files
authored
🐛 fix: fix input cannot send markdown (lobehub#9674)
* fix claude json output * refactor to remove langchain in file-loaders * support deepseek tools calling * use peer * use peer * move files * fix test * add local-system placeholder * fix markdown editing * fix markdown editing * refactor doc parse
1 parent 0038a64 commit 2518d7e

File tree

42 files changed

+984
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+984
-225
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
"@lobehub/charts": "^2.1.2",
161161
"@lobehub/chat-plugin-sdk": "^1.32.4",
162162
"@lobehub/chat-plugins-gateway": "^1.9.0",
163-
"@lobehub/editor": "^1.16.0",
163+
"@lobehub/editor": "^1.16.1",
164164
"@lobehub/icons": "^2.42.0",
165165
"@lobehub/market-sdk": "^0.22.7",
166166
"@lobehub/tts": "^2.0.1",

packages/const/src/settings/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export * from './agent';
1212
export * from './common';
1313
export * from './group';
1414
export * from './hotkey';
15+
export * from './knowledge';
1516
export * from './llm';
1617
export * from './systemAgent';
1718
export * from './tool';

packages/database/package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@
1313
"test:server-db": "vitest run --config vitest.config.server.mts"
1414
},
1515
"dependencies": {
16-
"@electric-sql/pglite": "^0.2.17",
1716
"@lobechat/const": "workspace:*",
1817
"@lobechat/types": "workspace:*",
1918
"@lobechat/utils": "workspace:*",
20-
"dayjs": "^1.11.18",
21-
"drizzle-orm": "^0.44.5",
22-
"nanoid": "^5.1.5",
23-
"pg": "^8.16.3",
2419
"random-words": "^2.0.1",
2520
"ts-md5": "^2.0.1",
2621
"ws": "^8.18.3"
22+
},
23+
"peerDependencies": {
24+
"@electric-sql/pglite": "^0.2.17",
25+
"dayjs": ">=1.11.18",
26+
"drizzle-orm": ">=0.44.6",
27+
"nanoid": ">=5.1.5",
28+
"pg": ">=8.16.3"
2729
}
2830
}

packages/electron-client-ipc/src/events/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LocalFilesDispatchEvents } from './localFile';
1+
import { LocalSystemDispatchEvents } from './localSystem';
22
import { MenuDispatchEvents } from './menu';
33
import { NotificationDispatchEvents } from './notification';
44
import { ProtocolBroadcastEvents, ProtocolDispatchEvents } from './protocol';
@@ -19,7 +19,7 @@ export interface ClientDispatchEvents
1919
extends WindowsDispatchEvents,
2020
SystemDispatchEvents,
2121
MenuDispatchEvents,
22-
LocalFilesDispatchEvents,
22+
LocalSystemDispatchEvents,
2323
AutoUpdateDispatchEvents,
2424
ShortcutDispatchEvents,
2525
RemoteServerDispatchEvents,
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
import {
2+
EditLocalFileParams,
3+
EditLocalFileResult,
4+
GetCommandOutputParams,
5+
GetCommandOutputResult,
6+
GlobFilesParams,
7+
GlobFilesResult,
8+
GrepContentParams,
9+
GrepContentResult,
10+
KillCommandParams,
11+
KillCommandResult,
212
ListLocalFileParams,
313
LocalFileItem,
414
LocalMoveFilesResultItem,
@@ -11,20 +21,29 @@ import {
1121
OpenLocalFolderParams,
1222
RenameLocalFileParams,
1323
RenameLocalFileResult,
24+
RunCommandParams,
25+
RunCommandResult,
1426
WriteLocalFileParams,
1527
} from '../types';
1628

17-
export interface LocalFilesDispatchEvents {
18-
// Local Files API Events
19-
listLocalFiles: (params: ListLocalFileParams) => LocalFileItem[];
29+
/* eslint-disable typescript-sort-keys/interface */
30+
export interface LocalSystemDispatchEvents {
31+
// File Operations
32+
editLocalFile: (params: EditLocalFileParams) => EditLocalFileResult;
2033
moveLocalFiles: (params: MoveLocalFilesParams) => LocalMoveFilesResultItem[];
21-
2234
openLocalFile: (params: OpenLocalFileParams) => void;
2335
openLocalFolder: (params: OpenLocalFolderParams) => void;
2436
readLocalFile: (params: LocalReadFileParams) => LocalReadFileResult;
2537
readLocalFiles: (params: LocalReadFilesParams) => LocalReadFileResult[];
26-
2738
renameLocalFile: (params: RenameLocalFileParams) => RenameLocalFileResult;
28-
searchLocalFiles: (params: LocalSearchFilesParams) => LocalFileItem[];
2939
writeLocalFile: (params: WriteLocalFileParams) => RenameLocalFileResult;
40+
// Shell Commands
41+
runCommand: (params: RunCommandParams) => RunCommandResult;
42+
getCommandOutput: (params: GetCommandOutputParams) => GetCommandOutputResult;
43+
killCommand: (params: KillCommandParams) => KillCommandResult;
44+
// Search & Find
45+
listLocalFiles: (params: ListLocalFileParams) => LocalFileItem[];
46+
grepContent: (params: GrepContentParams) => GrepContentResult;
47+
globLocalFiles: (params: GlobFilesParams) => GlobFilesResult;
48+
searchLocalFiles: (params: LocalSearchFilesParams) => LocalFileItem[];
3049
}

packages/electron-client-ipc/src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export * from './dataSync';
22
export * from './dispatch';
3-
export * from './localFile';
3+
export * from './localSystem';
44
export * from './mcpInstall';
55
export * from './notification';
66
export * from './proxy';

packages/electron-client-ipc/src/types/localFile.ts renamed to packages/electron-client-ipc/src/types/localSystem.ts

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ export interface WriteLocalFileParams {
6767
path: string;
6868
}
6969

70-
export interface RunCommandParams {
71-
command: string;
72-
}
73-
7470
export interface LocalReadFileResult {
7571
/**
7672
* Character count of the content within the specified `loc` range.
@@ -112,3 +108,92 @@ export interface OpenLocalFolderParams {
112108
isDirectory?: boolean;
113109
path: string;
114110
}
111+
112+
// Shell command types
113+
export interface RunCommandParams {
114+
command: string;
115+
description?: string;
116+
run_in_background?: boolean;
117+
timeout?: number;
118+
}
119+
120+
export interface RunCommandResult {
121+
error?: string;
122+
exit_code?: number;
123+
output?: string;
124+
shell_id?: string;
125+
stderr?: string;
126+
stdout?: string;
127+
success: boolean;
128+
}
129+
130+
export interface GetCommandOutputParams {
131+
filter?: string;
132+
shell_id: string;
133+
}
134+
135+
export interface GetCommandOutputResult {
136+
error?: string;
137+
output: string;
138+
running: boolean;
139+
stderr: string;
140+
stdout: string;
141+
success: boolean;
142+
}
143+
144+
export interface KillCommandParams {
145+
shell_id: string;
146+
}
147+
148+
export interface KillCommandResult {
149+
error?: string;
150+
success: boolean;
151+
}
152+
153+
// Grep types
154+
export interface GrepContentParams {
155+
'-A'?: number;
156+
'-B'?: number;
157+
'-C'?: number;
158+
'-i'?: boolean;
159+
'-n'?: boolean;
160+
'glob'?: string;
161+
'head_limit'?: number;
162+
'multiline'?: boolean;
163+
'output_mode'?: 'content' | 'files_with_matches' | 'count';
164+
'path'?: string;
165+
'pattern': string;
166+
'type'?: string;
167+
}
168+
169+
export interface GrepContentResult {
170+
matches: string[];
171+
success: boolean;
172+
total_matches: number;
173+
}
174+
175+
// Glob types
176+
export interface GlobFilesParams {
177+
path?: string;
178+
pattern: string;
179+
}
180+
181+
export interface GlobFilesResult {
182+
files: string[];
183+
success: boolean;
184+
total_files: number;
185+
}
186+
187+
// Edit types
188+
export interface EditLocalFileParams {
189+
file_path: string;
190+
new_string: string;
191+
old_string: string;
192+
replace_all?: boolean;
193+
}
194+
195+
export interface EditLocalFileResult {
196+
error?: string;
197+
replacements: number;
198+
success: boolean;
199+
}

packages/file-loaders/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
"test:coverage": "vitest --coverage --silent='passed-only'"
2626
},
2727
"dependencies": {
28-
"@langchain/community": "^0.3.41",
29-
"@langchain/core": "^0.3.45",
3028
"@napi-rs/canvas": "^0.1.70",
3129
"@xmldom/xmldom": "^0.9.8",
3230
"concat-stream": "^2.0.0",
3331
"mammoth": "^1.8.0",
3432
"officeparser": "5.1.1",
3533
"pdfjs-dist": "4.10.38",
34+
"word-extractor": "^1.0.4",
3635
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
3736
"yauzl": "^3.2.0"
3837
},

packages/file-loaders/src/loadFile.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ const getFileType = (filePath: string): SupportedFileType | undefined => {
3737
log('File type identified as pdf');
3838
return 'pdf';
3939
}
40-
case 'doc':
40+
case 'doc': {
41+
log('File type identified as doc');
42+
return 'doc';
43+
}
4144
case 'docx': {
4245
log('File type identified as docx');
4346
return 'docx';
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`DocLoader > should aggregate content correctly > aggregated_content 1`] = `
4+
"简单报告
5+
副标题
6+
轻点或点按此占位符文本并开始键入即可开始。你可以在 Mac、iPad、iPhone 或 iCloud.com 上查看和编辑此文稿。
7+
轻松编辑文本、更改字体以及添加精美的图形。使用段落样式来使整篇文稿保持一致的风格。例如,此段落使用"正文"样式。你可以在"格式"控制的"文本"标签页中更改样式。
8+
若要添加照片、图像画廊、音频片段、视频、图表或任意 700 多种可自定义形状,请在工具栏中轻点或点按其中一个插入按钮,或者将对象拖放到页面中。你可以分层放置对象、调整其大小以及将其放在页面中的任意位置。若要更改对象随文本移动的方式,请选择对象并随后轻点或点按"格式"控制中的"排列"标签页。
9+
小标题
10+
Pages 文稿可用于文字处理和页面布局。此"简单报告"模板为文字处理而设置,如此一来,文本便会随着你的键入而从某一页流向下一页,到达页面末尾时会自动创建新的页面。
11+
在页面布局文稿中,你可以手动重新排列页面并随意调整页面中的文本框、图像和其他对象的位置。若要创建页面布局文稿,请在模板选取器中选取一种页面布局模板。你也可以在 Mac、iPad 或 iPhone 上将此文稿改为页面布局,方法是在"文稿"控制中关闭"文稿正文"。
12+
"这是一个引用(报告中的关键短语)的例子。轻点或点按此文本添加你自己的内容。"
13+
14+
15+
16+
17+
这是第二页的内容
18+
"
19+
`;
20+
21+
exports[`DocLoader > should load pages correctly from a DOC file 1`] = `
22+
[
23+
{
24+
"charCount": 573,
25+
"lineCount": 15,
26+
"metadata": {
27+
"pageNumber": 1,
28+
},
29+
"pageContent": "简单报
30+
副标题
31+
轻点或点按此占位符文本并开始键入即可开始。你可以在 MaciPadiPhoneiCloud.com 上查看和编辑此文稿。
32+
轻松编辑文本、更改字体以及添加精美的图形。使用段落样式来使整篇文稿保持一致的风格。例如,此段落使用"正文"样式。你可以在"格式"控制的"文本"标签页中更改样式。
33+
若要添加照片、图像画廊、音频片段、视频、图表或任意 700 多种可自定义形状,请在工具栏中轻点或点按其中一个插入按钮,或者将对象拖放到页面中。你可以分层放置对象、调整其大小以及将其放在页面中的任意位置。若要更改对象随文本移动的方式,请选择对象并随后轻点或点按"格式"控制中的"排列"标签页。
34+
小标题
35+
Pages 文稿可用于文字处理和页面布局。此"简单报告"模板为文字处理而设置,如此一来,文本便会随着你的键入而从某一页流向下一页,到达页面末尾时会自动创建新的页面。
36+
在页面布局文稿中,你可以手动重新排列页面并随意调整页面中的文本框、图像和其他对象的位置。若要创建页面布局文稿,请在模板选取器中选取一种页面布局模板。你也可以在 MaciPadiPhone 上将此文稿改为页面布局,方法是在"文稿"控制中关闭"文稿正文"
37+
"这是一个引用(报告中的关键短语)的例子。轻点或点按此文本添加你自己的内容。"
38+
39+
40+
41+
42+
这是第二页的内容
43+
",
44+
},
45+
]
46+
`;

0 commit comments

Comments
 (0)