@lobehub/lobehub 2.0.0-next.306 → 2.0.0-next.308

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 (254) hide show
  1. package/.vscode/settings.json +18 -3
  2. package/CHANGELOG.md +61 -0
  3. package/changelog/v1.json +21 -0
  4. package/locales/ar/agentGroup.json +5 -0
  5. package/locales/ar/chat.json +26 -0
  6. package/locales/ar/models.json +43 -5
  7. package/locales/ar/plugin.json +4 -5
  8. package/locales/ar/setting.json +11 -0
  9. package/locales/ar/subscription.json +2 -0
  10. package/locales/ar/tool.json +2 -0
  11. package/locales/bg-BG/agentGroup.json +5 -0
  12. package/locales/bg-BG/chat.json +26 -0
  13. package/locales/bg-BG/models.json +49 -3
  14. package/locales/bg-BG/plugin.json +4 -5
  15. package/locales/bg-BG/setting.json +11 -0
  16. package/locales/bg-BG/subscription.json +2 -0
  17. package/locales/bg-BG/tool.json +2 -0
  18. package/locales/de-DE/agentGroup.json +5 -0
  19. package/locales/de-DE/chat.json +26 -0
  20. package/locales/de-DE/models.json +48 -5
  21. package/locales/de-DE/plugin.json +4 -5
  22. package/locales/de-DE/setting.json +11 -0
  23. package/locales/de-DE/subscription.json +2 -0
  24. package/locales/de-DE/tool.json +2 -0
  25. package/locales/en-US/models.json +8 -6
  26. package/locales/en-US/plugin.json +2 -4
  27. package/locales/en-US/setting.json +10 -11
  28. package/locales/en-US/tool.json +2 -0
  29. package/locales/es-ES/agentGroup.json +5 -0
  30. package/locales/es-ES/chat.json +26 -0
  31. package/locales/es-ES/models.json +43 -5
  32. package/locales/es-ES/plugin.json +4 -5
  33. package/locales/es-ES/setting.json +11 -0
  34. package/locales/es-ES/subscription.json +2 -0
  35. package/locales/es-ES/tool.json +2 -0
  36. package/locales/fa-IR/agentGroup.json +5 -0
  37. package/locales/fa-IR/chat.json +26 -0
  38. package/locales/fa-IR/models.json +42 -5
  39. package/locales/fa-IR/plugin.json +4 -5
  40. package/locales/fa-IR/setting.json +11 -0
  41. package/locales/fa-IR/subscription.json +2 -0
  42. package/locales/fa-IR/tool.json +2 -0
  43. package/locales/fr-FR/agentGroup.json +5 -0
  44. package/locales/fr-FR/chat.json +26 -0
  45. package/locales/fr-FR/models.json +5 -5
  46. package/locales/fr-FR/plugin.json +4 -5
  47. package/locales/fr-FR/setting.json +11 -0
  48. package/locales/fr-FR/subscription.json +2 -0
  49. package/locales/fr-FR/tool.json +2 -0
  50. package/locales/it-IT/agentGroup.json +5 -0
  51. package/locales/it-IT/chat.json +26 -0
  52. package/locales/it-IT/models.json +1 -3
  53. package/locales/it-IT/plugin.json +4 -5
  54. package/locales/it-IT/setting.json +11 -0
  55. package/locales/it-IT/subscription.json +2 -0
  56. package/locales/it-IT/tool.json +2 -0
  57. package/locales/ja-JP/agentGroup.json +5 -0
  58. package/locales/ja-JP/chat.json +26 -0
  59. package/locales/ja-JP/models.json +1 -5
  60. package/locales/ja-JP/plugin.json +4 -5
  61. package/locales/ja-JP/setting.json +11 -0
  62. package/locales/ja-JP/subscription.json +2 -0
  63. package/locales/ja-JP/tool.json +2 -0
  64. package/locales/ko-KR/agentGroup.json +5 -0
  65. package/locales/ko-KR/chat.json +26 -0
  66. package/locales/ko-KR/models.json +1 -3
  67. package/locales/ko-KR/plugin.json +4 -5
  68. package/locales/ko-KR/setting.json +11 -0
  69. package/locales/ko-KR/subscription.json +2 -0
  70. package/locales/ko-KR/tool.json +2 -0
  71. package/locales/nl-NL/agentGroup.json +5 -0
  72. package/locales/nl-NL/chat.json +26 -0
  73. package/locales/nl-NL/models.json +35 -3
  74. package/locales/nl-NL/plugin.json +4 -5
  75. package/locales/nl-NL/setting.json +11 -0
  76. package/locales/nl-NL/subscription.json +2 -0
  77. package/locales/nl-NL/tool.json +2 -0
  78. package/locales/pl-PL/agentGroup.json +5 -0
  79. package/locales/pl-PL/chat.json +26 -0
  80. package/locales/pl-PL/models.json +1 -3
  81. package/locales/pl-PL/plugin.json +4 -5
  82. package/locales/pl-PL/setting.json +11 -0
  83. package/locales/pl-PL/subscription.json +2 -0
  84. package/locales/pl-PL/tool.json +2 -0
  85. package/locales/pt-BR/agentGroup.json +5 -0
  86. package/locales/pt-BR/chat.json +26 -0
  87. package/locales/pt-BR/models.json +50 -5
  88. package/locales/pt-BR/plugin.json +4 -5
  89. package/locales/pt-BR/setting.json +11 -0
  90. package/locales/pt-BR/subscription.json +2 -0
  91. package/locales/pt-BR/tool.json +2 -0
  92. package/locales/ru-RU/agentGroup.json +5 -0
  93. package/locales/ru-RU/chat.json +26 -0
  94. package/locales/ru-RU/models.json +22 -3
  95. package/locales/ru-RU/plugin.json +4 -5
  96. package/locales/ru-RU/setting.json +11 -0
  97. package/locales/ru-RU/subscription.json +2 -0
  98. package/locales/ru-RU/tool.json +2 -0
  99. package/locales/tr-TR/agentGroup.json +5 -0
  100. package/locales/tr-TR/chat.json +26 -0
  101. package/locales/tr-TR/models.json +36 -3
  102. package/locales/tr-TR/plugin.json +4 -5
  103. package/locales/tr-TR/setting.json +11 -0
  104. package/locales/tr-TR/subscription.json +2 -0
  105. package/locales/tr-TR/tool.json +2 -0
  106. package/locales/vi-VN/agentGroup.json +5 -0
  107. package/locales/vi-VN/chat.json +26 -0
  108. package/locales/vi-VN/models.json +1 -1
  109. package/locales/vi-VN/plugin.json +4 -5
  110. package/locales/vi-VN/setting.json +11 -0
  111. package/locales/vi-VN/subscription.json +2 -0
  112. package/locales/vi-VN/tool.json +2 -0
  113. package/locales/zh-CN/models.json +52 -5
  114. package/locales/zh-CN/plugin.json +5 -7
  115. package/locales/zh-CN/setting.json +10 -11
  116. package/locales/zh-CN/tool.json +2 -2
  117. package/locales/zh-TW/agentGroup.json +5 -0
  118. package/locales/zh-TW/chat.json +26 -0
  119. package/locales/zh-TW/models.json +54 -5
  120. package/locales/zh-TW/plugin.json +4 -5
  121. package/locales/zh-TW/setting.json +11 -0
  122. package/locales/zh-TW/subscription.json +2 -0
  123. package/locales/zh-TW/tool.json +2 -0
  124. package/package.json +2 -2
  125. package/packages/builtin-agents/src/agents/group-supervisor/index.ts +1 -7
  126. package/packages/builtin-tool-group-agent-builder/src/ExecutionRuntime/index.ts +29 -0
  127. package/packages/builtin-tool-group-agent-builder/src/executor.ts +18 -0
  128. package/packages/builtin-tool-group-agent-builder/src/manifest.ts +17 -0
  129. package/packages/builtin-tool-group-agent-builder/src/types.ts +10 -0
  130. package/packages/builtin-tool-group-management/src/client/Inspector/ExecuteAgentTask/index.tsx +52 -8
  131. package/packages/builtin-tool-group-management/src/client/Render/ExecuteTask/index.tsx +2 -21
  132. package/packages/builtin-tool-group-management/src/executor.test.ts +6 -16
  133. package/packages/builtin-tool-group-management/src/executor.ts +8 -47
  134. package/packages/builtin-tool-group-management/src/manifest.ts +5 -18
  135. package/packages/builtin-tool-group-management/src/systemRole.ts +1 -8
  136. package/packages/builtin-tool-group-management/src/types.ts +2 -10
  137. package/packages/builtin-tool-local-system/src/ExecutionRuntime/index.ts +70 -31
  138. package/packages/builtin-tool-local-system/src/client/Render/WriteFile/index.tsx +48 -5
  139. package/packages/builtin-tool-local-system/src/client/Streaming/WriteFile/index.tsx +39 -0
  140. package/packages/builtin-tool-local-system/src/client/Streaming/index.ts +2 -0
  141. package/packages/builtin-tool-local-system/src/executor/index.ts +94 -60
  142. package/packages/database/src/repositories/agentGroup/index.ts +23 -0
  143. package/packages/model-bank/src/aiModels/qiniu.ts +24 -0
  144. package/packages/prompts/src/prompts/fileSystem/formatCommandOutput.test.ts +61 -0
  145. package/packages/prompts/src/prompts/fileSystem/formatCommandOutput.ts +21 -0
  146. package/packages/prompts/src/prompts/fileSystem/formatCommandResult.test.ts +87 -0
  147. package/packages/prompts/src/prompts/fileSystem/formatCommandResult.ts +35 -0
  148. package/packages/prompts/src/prompts/fileSystem/formatEditResult.test.ts +57 -0
  149. package/packages/prompts/src/prompts/fileSystem/formatEditResult.ts +17 -0
  150. package/packages/prompts/src/prompts/fileSystem/formatFileContent.test.ts +59 -0
  151. package/packages/prompts/src/prompts/fileSystem/formatFileContent.ts +14 -0
  152. package/packages/prompts/src/prompts/fileSystem/formatFileList.test.ts +62 -0
  153. package/packages/prompts/src/prompts/fileSystem/formatFileList.ts +13 -0
  154. package/packages/prompts/src/prompts/fileSystem/formatFileSearchResults.test.ts +34 -0
  155. package/packages/prompts/src/prompts/fileSystem/formatFileSearchResults.ts +12 -0
  156. package/packages/prompts/src/prompts/fileSystem/formatGlobResults.test.ts +64 -0
  157. package/packages/prompts/src/prompts/fileSystem/formatGlobResults.ts +23 -0
  158. package/packages/prompts/src/prompts/fileSystem/formatGrepResults.test.ts +85 -0
  159. package/packages/prompts/src/prompts/fileSystem/formatGrepResults.ts +24 -0
  160. package/packages/prompts/src/prompts/fileSystem/formatKillResult.test.ts +30 -0
  161. package/packages/prompts/src/prompts/fileSystem/formatKillResult.ts +9 -0
  162. package/packages/prompts/src/prompts/fileSystem/formatMoveResults.test.ts +37 -0
  163. package/packages/prompts/src/prompts/fileSystem/formatMoveResults.ts +20 -0
  164. package/packages/prompts/src/prompts/fileSystem/formatMultipleFiles.test.ts +54 -0
  165. package/packages/prompts/src/prompts/fileSystem/formatMultipleFiles.ts +9 -0
  166. package/packages/prompts/src/prompts/fileSystem/formatRenameResult.test.ts +35 -0
  167. package/packages/prompts/src/prompts/fileSystem/formatRenameResult.ts +17 -0
  168. package/packages/prompts/src/prompts/fileSystem/formatWriteResult.test.ts +30 -0
  169. package/packages/prompts/src/prompts/fileSystem/formatWriteResult.ts +11 -0
  170. package/packages/prompts/src/prompts/fileSystem/index.ts +13 -0
  171. package/packages/prompts/src/prompts/index.ts +1 -0
  172. package/src/app/[variants]/(auth)/_layout/index.tsx +0 -2
  173. package/src/app/[variants]/(auth)/layout.tsx +0 -2
  174. package/src/app/[variants]/(auth)/login/[[...login]]/page.tsx +1 -3
  175. package/src/app/[variants]/(auth)/signup/[[...signup]]/page.tsx +1 -3
  176. package/src/app/[variants]/(desktop)/desktop-onboarding/_layout/index.tsx +0 -2
  177. package/src/app/[variants]/(main)/_layout/index.tsx +0 -2
  178. package/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/Actions.tsx +4 -3
  179. package/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/useDropdownMenu.tsx +12 -2
  180. package/src/app/[variants]/(main)/agent/_layout/index.tsx +0 -2
  181. package/src/app/[variants]/(main)/agent/features/Portal/index.tsx +0 -2
  182. package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Sidebar/ActionButton/AddGroupAgent.tsx +69 -17
  183. package/src/app/[variants]/(main)/community/(list)/_layout/index.tsx +0 -2
  184. package/src/app/[variants]/(main)/community/(list)/assistant/_layout/index.tsx +0 -2
  185. package/src/app/[variants]/(main)/community/(list)/mcp/_layout/index.tsx +0 -2
  186. package/src/app/[variants]/(main)/community/(list)/model/_layout/index.tsx +0 -2
  187. package/src/app/[variants]/(main)/community/_layout/index.tsx +0 -2
  188. package/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/Actions.tsx +4 -3
  189. package/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/useDropdownMenu.tsx +12 -2
  190. package/src/app/[variants]/(main)/group/_layout/index.tsx +0 -2
  191. package/src/app/[variants]/(main)/group/features/Conversation/Header/index.tsx +4 -2
  192. package/src/app/[variants]/(main)/group/features/Portal/index.tsx +0 -2
  193. package/src/app/[variants]/(main)/home/_layout/index.tsx +0 -2
  194. package/src/app/[variants]/(main)/home/index.tsx +0 -2
  195. package/src/app/[variants]/(main)/image/_layout/Topics/TopicUrlSync.tsx +0 -2
  196. package/src/app/[variants]/(main)/image/_layout/index.tsx +0 -2
  197. package/src/app/[variants]/(main)/memory/_layout/index.tsx +0 -2
  198. package/src/app/[variants]/(main)/page/_layout/index.tsx +0 -2
  199. package/src/app/[variants]/(main)/resource/(home)/_layout/index.tsx +0 -2
  200. package/src/app/[variants]/(main)/resource/_layout/index.tsx +0 -2
  201. package/src/app/[variants]/(main)/resource/library/_layout/index.tsx +0 -2
  202. package/src/app/[variants]/(main)/resource/library/features/Container.tsx +0 -2
  203. package/src/app/[variants]/(main)/settings/_layout/index.tsx +0 -2
  204. package/src/app/[variants]/(main)/settings/about/index.tsx +0 -2
  205. package/src/app/[variants]/(main)/settings/agent/index.tsx +0 -2
  206. package/src/app/[variants]/(main)/settings/apikey/index.tsx +0 -2
  207. package/src/app/[variants]/(main)/settings/chat-appearance/index.tsx +0 -2
  208. package/src/app/[variants]/(main)/settings/common/index.tsx +0 -2
  209. package/src/app/[variants]/(main)/settings/hotkey/index.tsx +0 -2
  210. package/src/app/[variants]/(main)/settings/image/index.tsx +0 -2
  211. package/src/app/[variants]/(main)/settings/memory/index.tsx +0 -2
  212. package/src/app/[variants]/(main)/settings/provider/(list)/index.tsx +0 -2
  213. package/src/app/[variants]/(main)/settings/proxy/index.tsx +0 -2
  214. package/src/app/[variants]/(main)/settings/security/index.tsx +1 -3
  215. package/src/app/[variants]/(main)/settings/storage/index.tsx +0 -2
  216. package/src/app/[variants]/(main)/settings/tts/index.tsx +0 -2
  217. package/src/app/[variants]/(mobile)/(home)/_layout/index.tsx +0 -2
  218. package/src/app/[variants]/(mobile)/_layout/index.tsx +1 -3
  219. package/src/app/[variants]/(mobile)/chat/_layout/index.tsx +0 -2
  220. package/src/app/[variants]/(mobile)/chat/settings/_layout/index.tsx +0 -2
  221. package/src/app/[variants]/(mobile)/community/(detail)/_layout/index.tsx +0 -2
  222. package/src/app/[variants]/(mobile)/community/(list)/_layout/index.tsx +0 -2
  223. package/src/app/[variants]/(mobile)/community/_layout/index.tsx +0 -2
  224. package/src/app/[variants]/(mobile)/router/MobileClientRouter.tsx +0 -2
  225. package/src/app/[variants]/(mobile)/settings/index.tsx +0 -2
  226. package/src/app/[variants]/onboarding/_layout/index.tsx +0 -2
  227. package/src/app/[variants]/router/DesktopClientRouter.tsx +0 -2
  228. package/src/components/ModelSelect/index.tsx +6 -56
  229. package/src/components/server/MobileNavLayout.tsx +0 -2
  230. package/src/components/server/ServerLayout.tsx +0 -2
  231. package/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx +13 -3
  232. package/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx +26 -3
  233. package/src/features/ModelSwitchPanel/components/Footer.tsx +0 -2
  234. package/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx +0 -1
  235. package/src/features/ModelSwitchPanel/components/List/SingleProviderModelItem.tsx +0 -1
  236. package/src/features/ModelSwitchPanel/components/List/VirtualItemRenderer.tsx +0 -1
  237. package/src/features/ModelSwitchPanel/components/List/index.tsx +15 -13
  238. package/src/features/ModelSwitchPanel/components/PanelContent.tsx +0 -2
  239. package/src/features/ModelSwitchPanel/index.tsx +21 -23
  240. package/src/features/ResourceManager/components/Explorer/MasonryView/index.tsx +0 -2
  241. package/src/features/ResourceManager/components/Header/AddButton.tsx +20 -3
  242. package/src/features/User/UserAvatar.tsx +0 -2
  243. package/src/locales/default/plugin.ts +2 -1
  244. package/src/server/routers/lambda/__tests__/agentGroup.test.ts +1 -0
  245. package/src/server/routers/lambda/agentGroup.ts +22 -0
  246. package/src/services/chat/index.ts +1 -0
  247. package/src/services/chat/mecha/agentConfigResolver.test.ts +62 -45
  248. package/src/services/chat/mecha/agentConfigResolver.ts +29 -27
  249. package/src/services/chatGroup/index.ts +14 -0
  250. package/src/store/chat/agents/GroupOrchestration/__tests__/call-supervisor.test.ts +305 -0
  251. package/src/store/chat/agents/GroupOrchestration/createGroupOrchestrationExecutors.ts +2 -1
  252. package/src/store/chat/slices/aiChat/actions/streamingExecutor.ts +6 -2
  253. package/src/store/chat/slices/plugin/actions/exector.ts +92 -0
  254. package/src/store/chat/slices/plugin/actions/pluginTypes.ts +82 -177
@@ -1,22 +1,65 @@
1
1
  import { type WriteLocalFileParams } from '@lobechat/electron-client-ipc';
2
2
  import { type BuiltinRenderProps } from '@lobechat/types';
3
- import { Flexbox, Icon, Skeleton } from '@lobehub/ui';
3
+ import { Flexbox, Highlighter, Icon, Markdown, Skeleton } from '@lobehub/ui';
4
+ import { createStaticStyles } from 'antd-style';
4
5
  import { ChevronRight } from 'lucide-react';
5
6
  import path from 'path-browserify-esm';
6
7
  import { memo } from 'react';
7
8
 
8
9
  import { LocalFile, LocalFolder } from '@/features/LocalFile';
9
10
 
11
+ const styles = createStaticStyles(({ css, cssVar }) => ({
12
+ container: css`
13
+ padding: 8px;
14
+ border-radius: ${cssVar.borderRadiusLG};
15
+ background: ${cssVar.colorFillQuaternary};
16
+ `,
17
+ previewBox: css`
18
+ overflow: hidden;
19
+ border-radius: 8px;
20
+ background: ${cssVar.colorBgContainer};
21
+ `,
22
+ }));
23
+
10
24
  const WriteFile = memo<BuiltinRenderProps<WriteLocalFileParams>>(({ args }) => {
11
25
  if (!args) return <Skeleton active />;
12
26
 
13
27
  const { base, dir } = path.parse(args.path);
28
+ const ext = path.extname(args.path).slice(1).toLowerCase();
29
+
30
+ const renderContent = () => {
31
+ if (!args.content) return null;
32
+
33
+ if (ext === 'md' || ext === 'mdx') {
34
+ return (
35
+ <Markdown style={{ maxHeight: 240, overflow: 'auto', padding: '0 8px' }}>
36
+ {args.content}
37
+ </Markdown>
38
+ );
39
+ }
40
+
41
+ return (
42
+ <Highlighter
43
+ language={ext || 'text'}
44
+ showLanguage={false}
45
+ style={{ maxHeight: 240, overflow: 'auto' }}
46
+ variant={'borderless'}
47
+ wrap
48
+ >
49
+ {args.content}
50
+ </Highlighter>
51
+ );
52
+ };
14
53
 
15
54
  return (
16
- <Flexbox horizontal>
17
- <LocalFolder path={dir} />
18
- <Icon icon={ChevronRight} />
19
- <LocalFile name={base} path={args.path} />
55
+ <Flexbox className={styles.container} gap={12}>
56
+ <Flexbox align={'center'} horizontal>
57
+ <LocalFolder path={dir} />
58
+ <Icon icon={ChevronRight} />
59
+ <LocalFile name={base} path={args.path} />
60
+ </Flexbox>
61
+
62
+ {args.content && <Flexbox className={styles.previewBox}>{renderContent()}</Flexbox>}
20
63
  </Flexbox>
21
64
  );
22
65
  });
@@ -0,0 +1,39 @@
1
+ 'use client';
2
+
3
+ import { type WriteLocalFileParams } from '@lobechat/electron-client-ipc';
4
+ import { type BuiltinStreamingProps } from '@lobechat/types';
5
+ import { Highlighter, Markdown } from '@lobehub/ui';
6
+ import path from 'path-browserify-esm';
7
+ import { memo } from 'react';
8
+
9
+ export const WriteFileStreaming = memo<BuiltinStreamingProps<WriteLocalFileParams>>(({ args }) => {
10
+ const { content, path: filePath } = args || {};
11
+
12
+ // Don't render if no content yet
13
+ if (!content) return null;
14
+
15
+ const ext = path
16
+ .extname(filePath || '')
17
+ .slice(1)
18
+ .toLowerCase();
19
+
20
+ // Use Markdown for .md files, Highlighter for others
21
+ if (ext === 'md' || ext === 'mdx') {
22
+ return <Markdown style={{ overflow: 'auto' }}>{content}</Markdown>;
23
+ }
24
+
25
+ return (
26
+ <Highlighter
27
+ animated
28
+ language={ext || 'text'}
29
+ showLanguage={false}
30
+ style={{ padding: '4px 8px' }}
31
+ variant={'outlined'}
32
+ wrap
33
+ >
34
+ {content}
35
+ </Highlighter>
36
+ );
37
+ });
38
+
39
+ WriteFileStreaming.displayName = 'WriteFileStreaming';
@@ -1,9 +1,11 @@
1
1
  import { LocalSystemApiName } from '../..';
2
2
  import { RunCommandStreaming } from './RunCommand';
3
+ import { WriteFileStreaming } from './WriteFile';
3
4
 
4
5
  /**
5
6
  * Local System Streaming Components Registry
6
7
  */
7
8
  export const LocalSystemStreamings = {
8
9
  [LocalSystemApiName.runCommand]: RunCommandStreaming,
10
+ [LocalSystemApiName.writeLocalFile]: WriteFileStreaming,
9
11
  };
@@ -23,6 +23,21 @@ import type {
23
23
  RunCommandResult,
24
24
  WriteLocalFileParams,
25
25
  } from '@lobechat/electron-client-ipc';
26
+ import {
27
+ formatCommandOutput,
28
+ formatCommandResult,
29
+ formatEditResult,
30
+ formatFileContent,
31
+ formatFileList,
32
+ formatFileSearchResults,
33
+ formatGlobResults,
34
+ formatGrepResults,
35
+ formatKillResult,
36
+ formatMoveResults,
37
+ formatMultipleFiles,
38
+ formatRenameResult,
39
+ formatWriteResult,
40
+ } from '@lobechat/prompts';
26
41
  import { BaseExecutor, type BuiltinToolResult } from '@lobechat/types';
27
42
 
28
43
  import { localFileService } from '@/services/electron/localFileService';
@@ -76,8 +91,10 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
76
91
 
77
92
  const state: LocalFileListState = { listResults: result };
78
93
 
94
+ const content = formatFileList(result, params.path);
95
+
79
96
  return {
80
- content: JSON.stringify(result),
97
+ content,
81
98
  state,
82
99
  success: true,
83
100
  };
@@ -96,8 +113,14 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
96
113
 
97
114
  const state: LocalReadFileState = { fileContent: result };
98
115
 
116
+ const content = formatFileContent({
117
+ content: result.content,
118
+ lineRange: params.loc,
119
+ path: params.path,
120
+ });
121
+
99
122
  return {
100
- content: JSON.stringify(result),
123
+ content,
101
124
  state,
102
125
  success: true,
103
126
  };
@@ -116,8 +139,10 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
116
139
 
117
140
  const state: LocalReadFilesState = { filesContent: results };
118
141
 
142
+ const content = formatMultipleFiles(results);
143
+
119
144
  return {
120
- content: JSON.stringify(results),
145
+ content,
121
146
  state,
122
147
  success: true,
123
148
  };
@@ -136,8 +161,10 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
136
161
 
137
162
  const state: LocalFileSearchState = { searchResults: result };
138
163
 
164
+ const content = formatFileSearchResults(result);
165
+
139
166
  return {
140
- content: JSON.stringify(result),
167
+ content,
141
168
  state,
142
169
  success: true,
143
170
  };
@@ -154,20 +181,9 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
154
181
  try {
155
182
  const results: LocalMoveFilesResultItem[] = await localFileService.moveLocalFiles(params);
156
183
 
157
- const allSucceeded = results.every((r) => r.success);
158
- const someFailed = results.some((r) => !r.success);
159
184
  const successCount = results.filter((r) => r.success).length;
160
- const failedCount = results.length - successCount;
161
185
 
162
- let message = '';
163
-
164
- if (allSucceeded) {
165
- message = `Successfully moved ${results.length} item(s).`;
166
- } else if (someFailed) {
167
- message = `Moved ${successCount} item(s) successfully. Failed to move ${failedCount} item(s).`;
168
- } else {
169
- message = `Failed to move all ${results.length} item(s).`;
170
- }
186
+ const content = formatMoveResults(results);
171
187
 
172
188
  const state: LocalMoveFilesState = {
173
189
  results,
@@ -176,7 +192,7 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
176
192
  };
177
193
 
178
194
  return {
179
- content: JSON.stringify({ message, results }),
195
+ content,
180
196
  state,
181
197
  success: true,
182
198
  };
@@ -202,7 +218,12 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
202
218
  };
203
219
 
204
220
  return {
205
- content: JSON.stringify({ message: result.error, success: false }),
221
+ content: formatRenameResult({
222
+ error: result.error,
223
+ newName: params.newName,
224
+ oldPath: params.path,
225
+ success: false,
226
+ }),
206
227
  state,
207
228
  success: false,
208
229
  };
@@ -215,8 +236,9 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
215
236
  };
216
237
 
217
238
  return {
218
- content: JSON.stringify({
219
- message: `Successfully renamed file ${params.path} to ${params.newName}.`,
239
+ content: formatRenameResult({
240
+ newName: params.newName,
241
+ oldPath: params.path,
220
242
  success: true,
221
243
  }),
222
244
  state,
@@ -237,8 +259,9 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
237
259
 
238
260
  if (!result.success) {
239
261
  return {
240
- content: JSON.stringify({
241
- message: result.error || 'Failed to write file',
262
+ content: formatWriteResult({
263
+ error: result.error,
264
+ path: params.path,
242
265
  success: false,
243
266
  }),
244
267
  error: { message: result.error || 'Failed to write file', type: 'PluginServerError' },
@@ -247,8 +270,8 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
247
270
  }
248
271
 
249
272
  return {
250
- content: JSON.stringify({
251
- message: `Successfully wrote file ${params.path}`,
273
+ content: formatWriteResult({
274
+ path: params.path,
252
275
  success: true,
253
276
  }),
254
277
  success: true,
@@ -273,11 +296,12 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
273
296
  };
274
297
  }
275
298
 
276
- const statsText =
277
- result.linesAdded || result.linesDeleted
278
- ? ` (+${result.linesAdded || 0} -${result.linesDeleted || 0})`
279
- : '';
280
- const message = `Successfully replaced ${result.replacements} occurrence(s) in ${params.file_path}${statsText}`;
299
+ const content = formatEditResult({
300
+ filePath: params.file_path,
301
+ linesAdded: result.linesAdded,
302
+ linesDeleted: result.linesDeleted,
303
+ replacements: result.replacements,
304
+ });
281
305
 
282
306
  const state: EditLocalFileState = {
283
307
  diffText: result.diffText,
@@ -287,7 +311,7 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
287
311
  };
288
312
 
289
313
  return {
290
- content: message,
314
+ content,
291
315
  state,
292
316
  success: true,
293
317
  };
@@ -306,22 +330,19 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
306
330
  try {
307
331
  const result: RunCommandResult = await localFileService.runCommand(params);
308
332
 
309
- let message: string;
310
-
311
- if (result.success) {
312
- if (result.shell_id) {
313
- message = `Command started in background with shell_id: ${result.shell_id}`;
314
- } else {
315
- message = `Command completed successfully.`;
316
- }
317
- } else {
318
- message = `Command failed: ${result.error}`;
319
- }
333
+ const content = formatCommandResult({
334
+ error: result.error,
335
+ exitCode: result.exit_code,
336
+ shellId: result.shell_id,
337
+ stderr: result.stderr,
338
+ stdout: result.stdout,
339
+ success: result.success,
340
+ });
320
341
 
321
- const state: RunCommandState = { message, result };
342
+ const state: RunCommandState = { message: content.split('\n\n')[0], result };
322
343
 
323
344
  return {
324
- content: JSON.stringify(result),
345
+ content,
325
346
  state,
326
347
  success: result.success,
327
348
  };
@@ -338,14 +359,17 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
338
359
  try {
339
360
  const result: GetCommandOutputResult = await localFileService.getCommandOutput(params);
340
361
 
341
- const message = result.success
342
- ? `Output retrieved. Running: ${result.running}`
343
- : `Failed: ${result.error}`;
362
+ const content = formatCommandOutput({
363
+ error: result.error,
364
+ output: result.output,
365
+ running: result.running,
366
+ success: result.success,
367
+ });
344
368
 
345
- const state: GetCommandOutputState = { message, result };
369
+ const state: GetCommandOutputState = { message: content.split('\n\n')[0], result };
346
370
 
347
371
  return {
348
- content: JSON.stringify(result),
372
+ content,
349
373
  state,
350
374
  success: result.success,
351
375
  };
@@ -362,14 +386,16 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
362
386
  try {
363
387
  const result: KillCommandResult = await localFileService.killCommand(params);
364
388
 
365
- const message = result.success
366
- ? `Successfully killed shell: ${params.shell_id}`
367
- : `Failed to kill shell: ${result.error}`;
389
+ const content = formatKillResult({
390
+ error: result.error,
391
+ shellId: params.shell_id,
392
+ success: result.success,
393
+ });
368
394
 
369
- const state: KillCommandState = { message, result };
395
+ const state: KillCommandState = { message: content, result };
370
396
 
371
397
  return {
372
- content: JSON.stringify(result),
398
+ content,
373
399
  state,
374
400
  success: result.success,
375
401
  };
@@ -388,14 +414,17 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
388
414
  try {
389
415
  const result: GrepContentResult = await localFileService.grepContent(params);
390
416
 
391
- const message = result.success
392
- ? `Found ${result.total_matches} matches in ${result.matches.length} locations`
417
+ const content = result.success
418
+ ? formatGrepResults({
419
+ matches: result.matches,
420
+ totalMatches: result.total_matches,
421
+ })
393
422
  : 'Search failed';
394
423
 
395
- const state: GrepContentState = { message, result };
424
+ const state: GrepContentState = { message: content.split('\n')[0], result };
396
425
 
397
426
  return {
398
- content: JSON.stringify(result),
427
+ content,
399
428
  state,
400
429
  success: result.success,
401
430
  };
@@ -412,12 +441,17 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
412
441
  try {
413
442
  const result: GlobFilesResult = await localFileService.globFiles(params);
414
443
 
415
- const message = result.success ? `Found ${result.total_files} files` : 'Glob search failed';
444
+ const content = result.success
445
+ ? formatGlobResults({
446
+ files: result.files,
447
+ totalFiles: result.total_files,
448
+ })
449
+ : 'Glob search failed';
416
450
 
417
- const state: GlobFilesState = { message, result };
451
+ const state: GlobFilesState = { message: content.split('\n')[0], result };
418
452
 
419
453
  return {
420
- content: JSON.stringify(result),
454
+ content,
421
455
  state,
422
456
  success: result.success,
423
457
  };
@@ -15,8 +15,14 @@ import {
15
15
  import { LobeChatDatabase } from '../../type';
16
16
 
17
17
  export interface SupervisorAgentConfig {
18
+ avatar?: string;
19
+ backgroundColor?: string;
20
+ description?: string;
18
21
  model?: string;
22
+ params?: any;
19
23
  provider?: string;
24
+ systemRole?: string;
25
+ tags?: string[];
20
26
  title?: string;
21
27
  }
22
28
 
@@ -164,8 +170,14 @@ export class AgentGroupRepository {
164
170
  const [supervisorAgent] = await this.db
165
171
  .insert(agents)
166
172
  .values({
173
+ avatar: supervisorConfig?.avatar,
174
+ backgroundColor: supervisorConfig?.backgroundColor,
175
+ description: supervisorConfig?.description,
167
176
  model: supervisorConfig?.model,
177
+ params: supervisorConfig?.params,
168
178
  provider: supervisorConfig?.provider,
179
+ systemRole: supervisorConfig?.systemRole,
180
+ tags: supervisorConfig?.tags,
169
181
  title: supervisorConfig?.title ?? 'Supervisor',
170
182
  userId: this.userId,
171
183
  virtual: true,
@@ -356,7 +368,12 @@ export class AgentGroupRepository {
356
368
  const [newGroup] = await trx
357
369
  .insert(chatGroups)
358
370
  .values({
371
+ avatar: sourceGroup.avatar,
372
+ backgroundColor: sourceGroup.backgroundColor,
359
373
  config: sourceGroup.config,
374
+ content: sourceGroup.content,
375
+ description: sourceGroup.description,
376
+ editorData: sourceGroup.editorData,
360
377
  pinned: sourceGroup.pinned,
361
378
  title: newTitle || (sourceGroup.title ? `${sourceGroup.title} (Copy)` : 'Copy'),
362
379
  userId: this.userId,
@@ -368,8 +385,14 @@ export class AgentGroupRepository {
368
385
  const [newSupervisor] = await trx
369
386
  .insert(agents)
370
387
  .values({
388
+ avatar: supervisorAgent?.avatar,
389
+ backgroundColor: supervisorAgent?.backgroundColor,
390
+ description: supervisorAgent?.description,
371
391
  model: supervisorAgent?.model,
392
+ params: supervisorAgent?.params,
372
393
  provider: supervisorAgent?.provider,
394
+ systemRole: supervisorAgent?.systemRole,
395
+ tags: supervisorAgent?.tags,
373
396
  title: supervisorAgent?.title || 'Supervisor',
374
397
  userId: this.userId,
375
398
  virtual: true,
@@ -78,6 +78,30 @@ const qiniuChatModels: AIChatModelCard[] = [
78
78
  },
79
79
  type: 'chat',
80
80
  },
81
+ {
82
+ abilities: {
83
+ reasoning: true,
84
+ },
85
+ contextWindowTokens: 163_840,
86
+ description:
87
+ 'DeepSeek Math V2 is a model that has made significant breakthroughs in mathematical reasoning capabilities. Its core innovation lies in the "self-verification" training mechanism, and it has achieved gold medal levels in several top mathematics competitions.',
88
+ displayName: 'DeepSeek Math V2',
89
+ enabled: true,
90
+ id: 'deepseek/deepseek-math-v2',
91
+ maxOutput: 131_072,
92
+ pricing: {
93
+ currency: 'CNY',
94
+ units: [
95
+ { name: 'textInput', rate: 4.0, strategy: 'fixed', unit: 'millionTokens' },
96
+ { name: 'textOutput', rate: 16.0, strategy: 'fixed', unit: 'millionTokens' },
97
+ ],
98
+ },
99
+ releasedAt: '2025-11-27',
100
+ settings: {
101
+ searchImpl: 'params',
102
+ },
103
+ type: 'chat',
104
+ },
81
105
  {
82
106
  abilities: {
83
107
  functionCall: true,
@@ -0,0 +1,61 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { formatCommandOutput } from './formatCommandOutput';
4
+
5
+ describe('formatCommandOutput', () => {
6
+ it('should format successful output while running', () => {
7
+ const result = formatCommandOutput({
8
+ running: true,
9
+ success: true,
10
+ });
11
+ expect(result).toMatchInlineSnapshot(`"Output retrieved. Running: true"`);
12
+ });
13
+
14
+ it('should format successful output when not running', () => {
15
+ const result = formatCommandOutput({
16
+ running: false,
17
+ success: true,
18
+ });
19
+ expect(result).toMatchInlineSnapshot(`"Output retrieved. Running: false"`);
20
+ });
21
+
22
+ it('should format successful output with content', () => {
23
+ const result = formatCommandOutput({
24
+ output: 'Process output here',
25
+ running: true,
26
+ success: true,
27
+ });
28
+ expect(result).toMatchInlineSnapshot(`
29
+ "Output retrieved. Running: true
30
+
31
+ Output:
32
+ Process output here"
33
+ `);
34
+ });
35
+
36
+ it('should format failed output', () => {
37
+ const result = formatCommandOutput({
38
+ error: 'Process not found',
39
+ running: false,
40
+ success: false,
41
+ });
42
+ expect(result).toMatchInlineSnapshot(`"Failed: Process not found"`);
43
+ });
44
+
45
+ it('should format successful output with error info', () => {
46
+ const result = formatCommandOutput({
47
+ error: 'Warning message',
48
+ output: 'Some output',
49
+ running: false,
50
+ success: true,
51
+ });
52
+ expect(result).toMatchInlineSnapshot(`
53
+ "Output retrieved. Running: false
54
+
55
+ Output:
56
+ Some output
57
+
58
+ Error: Warning message"
59
+ `);
60
+ });
61
+ });
@@ -0,0 +1,21 @@
1
+ export interface FormatCommandOutputParams {
2
+ error?: string;
3
+ output?: string;
4
+ running: boolean;
5
+ success: boolean;
6
+ }
7
+
8
+ export const formatCommandOutput = ({
9
+ success,
10
+ running,
11
+ output,
12
+ error,
13
+ }: FormatCommandOutputParams): string => {
14
+ const message = success ? `Output retrieved. Running: ${running}` : `Failed: ${error}`;
15
+
16
+ const parts: string[] = [message];
17
+ if (output) parts.push(`Output:\n${output}`);
18
+ if (error && success) parts.push(`Error: ${error}`);
19
+
20
+ return parts.join('\n\n');
21
+ };
@@ -0,0 +1,87 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { formatCommandResult } from './formatCommandResult';
4
+
5
+ describe('formatCommandResult', () => {
6
+ it('should format successful command without output', () => {
7
+ const result = formatCommandResult({ success: true });
8
+ expect(result).toMatchInlineSnapshot(`"Command completed successfully."`);
9
+ });
10
+
11
+ it('should format successful background command', () => {
12
+ const result = formatCommandResult({
13
+ shellId: 'shell-123',
14
+ success: true,
15
+ });
16
+ expect(result).toMatchInlineSnapshot(
17
+ `"Command started in background with shell_id: shell-123"`,
18
+ );
19
+ });
20
+
21
+ it('should format successful command with stdout', () => {
22
+ const result = formatCommandResult({
23
+ stdout: 'Hello World',
24
+ success: true,
25
+ });
26
+ expect(result).toMatchInlineSnapshot(`
27
+ "Command completed successfully.
28
+
29
+ Output:
30
+ Hello World"
31
+ `);
32
+ });
33
+
34
+ it('should format successful command with stderr', () => {
35
+ const result = formatCommandResult({
36
+ stderr: 'Warning: deprecated',
37
+ success: true,
38
+ });
39
+ expect(result).toMatchInlineSnapshot(`
40
+ "Command completed successfully.
41
+
42
+ Stderr:
43
+ Warning: deprecated"
44
+ `);
45
+ });
46
+
47
+ it('should format successful command with exit code', () => {
48
+ const result = formatCommandResult({
49
+ exitCode: 0,
50
+ success: true,
51
+ });
52
+ expect(result).toMatchInlineSnapshot(`
53
+ "Command completed successfully.
54
+
55
+ Exit code: 0"
56
+ `);
57
+ });
58
+
59
+ it('should format failed command', () => {
60
+ const result = formatCommandResult({
61
+ error: 'Permission denied',
62
+ success: false,
63
+ });
64
+ expect(result).toMatchInlineSnapshot(`"Command failed: Permission denied"`);
65
+ });
66
+
67
+ it('should format command with all fields', () => {
68
+ const result = formatCommandResult({
69
+ error: 'Command error',
70
+ exitCode: 1,
71
+ stderr: 'Error occurred',
72
+ stdout: 'Some output',
73
+ success: false,
74
+ });
75
+ expect(result).toMatchInlineSnapshot(`
76
+ "Command failed: Command error
77
+
78
+ Output:
79
+ Some output
80
+
81
+ Stderr:
82
+ Error occurred
83
+
84
+ Exit code: 1"
85
+ `);
86
+ });
87
+ });