@lobehub/lobehub 2.0.0-next.186 → 2.0.0-next.188
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.
- package/CHANGELOG.md +50 -0
- package/changelog/v1.json +18 -0
- package/locales/ar/models.json +89 -5
- package/locales/ar/plugin.json +5 -0
- package/locales/ar/providers.json +1 -0
- package/locales/bg-BG/models.json +68 -0
- package/locales/bg-BG/plugin.json +5 -0
- package/locales/bg-BG/providers.json +1 -0
- package/locales/de-DE/models.json +85 -0
- package/locales/de-DE/plugin.json +5 -0
- package/locales/de-DE/providers.json +1 -0
- package/locales/en-US/models.json +11 -10
- package/locales/en-US/plugin.json +5 -0
- package/locales/en-US/providers.json +1 -0
- package/locales/es-ES/models.json +72 -0
- package/locales/es-ES/plugin.json +5 -0
- package/locales/es-ES/providers.json +1 -0
- package/locales/fa-IR/models.json +86 -0
- package/locales/fa-IR/plugin.json +5 -0
- package/locales/fa-IR/providers.json +1 -0
- package/locales/fr-FR/models.json +49 -0
- package/locales/fr-FR/plugin.json +5 -0
- package/locales/fr-FR/providers.json +1 -0
- package/locales/it-IT/models.json +82 -0
- package/locales/it-IT/plugin.json +5 -0
- package/locales/it-IT/providers.json +1 -0
- package/locales/ja-JP/models.json +42 -5
- package/locales/ja-JP/plugin.json +5 -0
- package/locales/ja-JP/providers.json +1 -0
- package/locales/ko-KR/models.json +54 -0
- package/locales/ko-KR/plugin.json +5 -0
- package/locales/ko-KR/providers.json +1 -0
- package/locales/nl-NL/models.json +12 -1
- package/locales/nl-NL/plugin.json +5 -0
- package/locales/nl-NL/providers.json +1 -0
- package/locales/pl-PL/models.json +46 -0
- package/locales/pl-PL/plugin.json +5 -0
- package/locales/pl-PL/providers.json +1 -0
- package/locales/pt-BR/models.json +59 -0
- package/locales/pt-BR/plugin.json +5 -0
- package/locales/pt-BR/providers.json +1 -0
- package/locales/ru-RU/models.json +85 -0
- package/locales/ru-RU/plugin.json +5 -0
- package/locales/ru-RU/providers.json +1 -0
- package/locales/tr-TR/models.json +81 -0
- package/locales/tr-TR/plugin.json +5 -0
- package/locales/tr-TR/providers.json +1 -0
- package/locales/vi-VN/models.json +54 -0
- package/locales/vi-VN/plugin.json +5 -0
- package/locales/vi-VN/providers.json +1 -0
- package/locales/zh-CN/models.json +42 -5
- package/locales/zh-CN/plugin.json +5 -0
- package/locales/zh-CN/providers.json +1 -0
- package/locales/zh-TW/models.json +85 -0
- package/locales/zh-TW/plugin.json +5 -0
- package/locales/zh-TW/providers.json +1 -0
- package/package.json +1 -1
- package/packages/builtin-tool-gtd/src/manifest.ts +13 -8
- package/packages/builtin-tool-gtd/src/systemRole.ts +54 -19
- package/packages/builtin-tool-knowledge-base/package.json +1 -0
- package/packages/builtin-tool-knowledge-base/src/client/Inspector/ReadKnowledge/index.tsx +97 -0
- package/packages/builtin-tool-knowledge-base/src/client/Inspector/SearchKnowledgeBase/index.tsx +75 -0
- package/packages/builtin-tool-knowledge-base/src/client/Inspector/index.ts +11 -0
- package/packages/builtin-tool-knowledge-base/src/client/Render/ReadKnowledge/FileCard.tsx +12 -12
- package/packages/builtin-tool-knowledge-base/src/client/Render/ReadKnowledge/index.tsx +16 -25
- package/packages/builtin-tool-knowledge-base/src/client/Render/SearchKnowledgeBase/Item/index.tsx +21 -47
- package/packages/builtin-tool-knowledge-base/src/client/Render/SearchKnowledgeBase/index.tsx +19 -31
- package/packages/builtin-tool-knowledge-base/src/client/Render/index.ts +0 -5
- package/packages/builtin-tool-knowledge-base/src/client/index.ts +5 -1
- package/packages/builtin-tool-knowledge-base/src/executor/index.ts +119 -0
- package/packages/builtin-tool-local-system/package.json +1 -0
- package/packages/builtin-tool-local-system/src/client/Inspector/EditLocalFile/index.tsx +44 -29
- package/packages/builtin-tool-local-system/src/client/Inspector/GrepContent/index.tsx +20 -18
- package/packages/builtin-tool-local-system/src/client/Inspector/ListLocalFiles/index.tsx +76 -0
- package/packages/builtin-tool-local-system/src/client/Inspector/ReadLocalFile/index.tsx +8 -32
- package/packages/builtin-tool-local-system/src/client/Inspector/RenameLocalFile/index.tsx +62 -0
- package/packages/builtin-tool-local-system/src/client/Inspector/SearchLocalFiles/index.tsx +17 -11
- package/packages/builtin-tool-local-system/src/client/Inspector/WriteLocalFile/index.tsx +61 -0
- package/packages/builtin-tool-local-system/src/client/Inspector/index.ts +6 -0
- package/packages/builtin-tool-local-system/src/client/Render/EditLocalFile/index.tsx +6 -1
- package/packages/builtin-tool-local-system/src/client/Render/SearchFiles/SearchQuery/SearchView.tsx +19 -31
- package/packages/builtin-tool-local-system/src/client/Render/SearchFiles/SearchQuery/index.tsx +2 -42
- package/packages/builtin-tool-local-system/src/client/Render/index.ts +0 -2
- package/packages/builtin-tool-local-system/src/client/components/FilePathDisplay.tsx +56 -0
- package/packages/builtin-tool-local-system/src/client/components/index.ts +2 -0
- package/packages/builtin-tool-local-system/src/executor/index.ts +435 -0
- package/packages/builtin-tool-web-browsing/src/client/Inspector/Search/index.tsx +32 -5
- package/packages/fetch-sse/src/__tests__/request.test.ts +608 -0
- package/packages/model-bank/src/aiModels/aihubmix.ts +44 -8
- package/packages/model-bank/src/aiModels/google.ts +49 -17
- package/packages/model-bank/src/aiModels/hunyuan.ts +20 -0
- package/packages/model-bank/src/aiModels/infiniai.ts +48 -7
- package/packages/model-bank/src/aiModels/lobehub.ts +13 -11
- package/packages/model-bank/src/aiModels/minimax.ts +46 -2
- package/packages/model-bank/src/aiModels/ollamacloud.ts +40 -5
- package/packages/model-bank/src/aiModels/openai.ts +6 -3
- package/packages/model-bank/src/aiModels/qwen.ts +1 -1
- package/packages/model-bank/src/aiModels/siliconcloud.ts +60 -0
- package/packages/model-bank/src/aiModels/vertexai.ts +77 -44
- package/packages/model-bank/src/aiModels/volcengine.ts +111 -2
- package/packages/model-bank/src/aiModels/zenmux.ts +19 -13
- package/packages/model-bank/src/aiModels/zhipu.ts +64 -2
- package/packages/model-bank/src/types/aiModel.ts +3 -0
- package/packages/model-runtime/src/core/contextBuilders/google.test.ts +84 -0
- package/packages/model-runtime/src/core/contextBuilders/google.ts +37 -1
- package/packages/model-runtime/src/providers/volcengine/index.ts +2 -1
- package/packages/model-runtime/src/providers/zhipu/index.test.ts +0 -27
- package/packages/model-runtime/src/providers/zhipu/index.ts +1 -1
- package/packages/model-runtime/src/utils/modelParse.ts +26 -21
- package/packages/types/src/agent/chatConfig.ts +6 -2
- package/src/features/ChatInput/ActionBar/Model/ControlsForm.tsx +40 -1
- package/src/features/ChatInput/ActionBar/Model/GPT52ProReasoningEffortSlider.tsx +59 -0
- package/src/features/ChatInput/ActionBar/Model/GPT52ReasoningEffortSlider.tsx +61 -0
- package/src/features/ChatInput/ActionBar/Model/TextVerbositySlider.tsx +1 -1
- package/src/features/ChatInput/ActionBar/Model/ThinkingLevel2Slider.tsx +58 -0
- package/src/features/ChatInput/ActionBar/Model/ThinkingLevelSlider.tsx +10 -8
- package/src/helpers/toolEngineering/index.ts +1 -1
- package/src/locales/default/plugin.ts +6 -0
- package/src/server/modules/Mecha/AgentToolsEngine/__tests__/index.test.ts +1 -1
- package/src/server/modules/Mecha/AgentToolsEngine/index.ts +1 -1
- package/src/services/chat/mecha/modelParamsResolver.ts +11 -0
- package/src/store/chat/slices/builtinTool/actions/index.ts +1 -11
- package/src/store/tool/slices/builtin/executors/index.ts +4 -0
- package/src/styles/text.ts +1 -1
- package/src/tools/executionRuntimes.ts +3 -8
- package/src/tools/identifiers.ts +1 -1
- package/src/tools/index.ts +1 -1
- package/src/tools/inspectors.ts +5 -0
- package/src/tools/renders.ts +6 -12
- package/packages/builtin-tool-local-system/src/client/Render/RenameLocalFile/index.tsx +0 -37
- package/src/store/chat/slices/builtinTool/actions/__tests__/localSystem.test.ts +0 -201
- package/src/store/chat/slices/builtinTool/actions/knowledgeBase.ts +0 -163
- package/src/store/chat/slices/builtinTool/actions/localSystem.ts +0 -241
- package/src/tools/knowledge-base/ExecutionRuntime/index.ts +0 -25
- package/src/tools/knowledge-base/Render/ReadKnowledge/index.tsx +0 -29
- package/src/tools/knowledge-base/Render/SearchKnowledgeBase/index.tsx +0 -29
- package/src/tools/knowledge-base/Render/index.ts +0 -7
- package/src/tools/knowledge-base/index.ts +0 -12
- package/src/tools/local-system/ExecutionRuntime/index.ts +0 -9
- package/src/tools/local-system/systemRole.ts +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @vitest-environment node
|
|
2
|
+
import { KnowledgeBaseManifest } from '@lobechat/builtin-tool-knowledge-base';
|
|
2
3
|
import { LocalSystemManifest } from '@lobechat/builtin-tool-local-system';
|
|
3
4
|
import { WebBrowsingManifest } from '@lobechat/builtin-tool-web-browsing';
|
|
4
5
|
import { ToolsEngine } from '@lobechat/context-engine';
|
|
5
6
|
import { describe, expect, it } from 'vitest';
|
|
6
7
|
|
|
7
8
|
import { builtinTools } from '@/tools';
|
|
8
|
-
import { KnowledgeBaseManifest } from '@/tools/knowledge-base';
|
|
9
9
|
|
|
10
10
|
import { createServerAgentToolsEngine, createServerToolsEngine } from '../index';
|
|
11
11
|
import type { InstalledPlugin, ServerAgentToolsContext } from '../types';
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* - Gets model capabilities from provided function
|
|
10
10
|
* - No dependency on frontend stores (useToolStore, useAgentStore, etc.)
|
|
11
11
|
*/
|
|
12
|
+
import { KnowledgeBaseManifest } from '@lobechat/builtin-tool-knowledge-base';
|
|
12
13
|
import { LocalSystemManifest } from '@lobechat/builtin-tool-local-system';
|
|
13
14
|
import { WebBrowsingManifest } from '@lobechat/builtin-tool-web-browsing';
|
|
14
15
|
import { ToolsEngine } from '@lobechat/context-engine';
|
|
@@ -16,7 +17,6 @@ import type { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';
|
|
|
16
17
|
import debug from 'debug';
|
|
17
18
|
|
|
18
19
|
import { builtinTools } from '@/tools';
|
|
19
|
-
import { KnowledgeBaseManifest } from '@/tools/knowledge-base';
|
|
20
20
|
|
|
21
21
|
import type {
|
|
22
22
|
ServerAgentToolsContext,
|
|
@@ -95,6 +95,17 @@ export const resolveModelExtendParams = (ctx: ModelParamsContext): ModelExtendPa
|
|
|
95
95
|
extendParams.reasoning_effort = chatConfig.gpt5_1ReasoningEffort;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
if (modelExtendParams.includes('gpt5_2ReasoningEffort') && chatConfig.gpt5_2ReasoningEffort) {
|
|
99
|
+
extendParams.reasoning_effort = chatConfig.gpt5_2ReasoningEffort;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (
|
|
103
|
+
modelExtendParams.includes('gpt5_2ProReasoningEffort') &&
|
|
104
|
+
chatConfig.gpt5_2ProReasoningEffort
|
|
105
|
+
) {
|
|
106
|
+
extendParams.reasoning_effort = chatConfig.gpt5_2ProReasoningEffort;
|
|
107
|
+
}
|
|
108
|
+
|
|
98
109
|
// Text verbosity
|
|
99
110
|
if (modelExtendParams.includes('textVerbosity') && chatConfig.textVerbosity) {
|
|
100
111
|
extendParams.verbosity = chatConfig.textVerbosity;
|
|
@@ -5,18 +5,10 @@ import { type ChatStore } from '@/store/chat/store';
|
|
|
5
5
|
import { type AgentBuilderAction, agentBuilderSlice } from './agentBuilder';
|
|
6
6
|
import { type GroupAgentBuilderAction, groupAgentBuilderSlice } from './groupAgentBuilder';
|
|
7
7
|
import { type ChatCodeInterpreterAction, codeInterpreterSlice } from './interpreter';
|
|
8
|
-
import { type KnowledgeBaseAction, knowledgeBaseSlice } from './knowledgeBase';
|
|
9
|
-
import { type LocalFileAction, localSystemSlice } from './localSystem';
|
|
10
8
|
import { type SearchAction, searchSlice } from './search';
|
|
11
9
|
|
|
12
10
|
export interface ChatBuiltinToolAction
|
|
13
|
-
extends
|
|
14
|
-
SearchAction,
|
|
15
|
-
LocalFileAction,
|
|
16
|
-
ChatCodeInterpreterAction,
|
|
17
|
-
KnowledgeBaseAction,
|
|
18
|
-
AgentBuilderAction,
|
|
19
|
-
GroupAgentBuilderAction {}
|
|
11
|
+
extends SearchAction, ChatCodeInterpreterAction, AgentBuilderAction, GroupAgentBuilderAction {}
|
|
20
12
|
|
|
21
13
|
export const chatToolSlice: StateCreator<
|
|
22
14
|
ChatStore,
|
|
@@ -25,9 +17,7 @@ export const chatToolSlice: StateCreator<
|
|
|
25
17
|
ChatBuiltinToolAction
|
|
26
18
|
> = (...params) => ({
|
|
27
19
|
...searchSlice(...params),
|
|
28
|
-
...localSystemSlice(...params),
|
|
29
20
|
...codeInterpreterSlice(...params),
|
|
30
|
-
...knowledgeBaseSlice(...params),
|
|
31
21
|
...agentBuilderSlice(...params),
|
|
32
22
|
...groupAgentBuilderSlice(...params),
|
|
33
23
|
});
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { groupManagementExecutor } from '@lobechat/builtin-tool-group-management/executor';
|
|
8
8
|
import { gtdExecutor } from '@lobechat/builtin-tool-gtd/executor';
|
|
9
|
+
import { knowledgeBaseExecutor } from '@lobechat/builtin-tool-knowledge-base/executor';
|
|
10
|
+
import { localSystemExecutor } from '@lobechat/builtin-tool-local-system/executor';
|
|
9
11
|
import { memoryExecutor } from '@lobechat/builtin-tool-memory/executor';
|
|
10
12
|
import { notebookExecutor } from '@lobechat/builtin-tool-notebook/executor';
|
|
11
13
|
|
|
@@ -117,6 +119,8 @@ const registerExecutors = (executors: IBuiltinToolExecutor[]): void => {
|
|
|
117
119
|
registerExecutors([
|
|
118
120
|
groupManagementExecutor,
|
|
119
121
|
gtdExecutor,
|
|
122
|
+
knowledgeBaseExecutor,
|
|
123
|
+
localSystemExecutor,
|
|
120
124
|
memoryExecutor,
|
|
121
125
|
notebookExecutor,
|
|
122
126
|
pageAgentExecutor,
|
package/src/styles/text.ts
CHANGED
|
@@ -33,7 +33,7 @@ export const highlightTextStyles = createStaticStyles(({ css, cssVar }) => ({
|
|
|
33
33
|
primary: css`
|
|
34
34
|
padding-block-end: 1px;
|
|
35
35
|
color: ${cssVar.colorText};
|
|
36
|
-
background: linear-gradient(to top, ${cssVar.
|
|
36
|
+
background: linear-gradient(to top, ${cssVar.colorPrimaryBgHover} 40%, transparent 40%);
|
|
37
37
|
`,
|
|
38
38
|
warning: css`
|
|
39
39
|
padding-block-end: 1px;
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { AgentBuilderManifest } from '@lobechat/builtin-tool-agent-builder';
|
|
2
2
|
import { AgentBuilderExecutionRuntime } from '@lobechat/builtin-tool-agent-builder/executionRuntime';
|
|
3
|
-
import {
|
|
3
|
+
import { GroupAgentBuilderManifest } from '@lobechat/builtin-tool-group-agent-builder';
|
|
4
4
|
import { GroupAgentBuilderExecutionRuntime } from '@lobechat/builtin-tool-group-agent-builder/executionRuntime';
|
|
5
|
-
import { LocalSystemManifest } from '@lobechat/builtin-tool-local-system';
|
|
6
5
|
import { WebBrowsingManifest } from '@lobechat/builtin-tool-web-browsing';
|
|
7
6
|
import { WebBrowsingExecutionRuntime } from '@lobechat/builtin-tool-web-browsing/executionRuntime';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
import { KnowledgeBaseExecutionRuntime } from './knowledge-base/ExecutionRuntime';
|
|
11
|
-
import { LocalSystemExecutionRuntime } from './local-system/ExecutionRuntime';
|
|
8
|
+
// Note: KnowledgeBase and LocalSystem now use executor pattern via toolStore/builtin/executors
|
|
12
9
|
|
|
13
10
|
export const BuiltinToolServerRuntimes: Record<string, any> = {
|
|
14
11
|
[AgentBuilderManifest.identifier]: AgentBuilderExecutionRuntime,
|
|
15
|
-
[
|
|
16
|
-
[KnowledgeBaseManifest.identifier]: KnowledgeBaseExecutionRuntime,
|
|
17
|
-
[LocalSystemManifest.identifier]: LocalSystemExecutionRuntime,
|
|
12
|
+
[GroupAgentBuilderManifest.identifier]: GroupAgentBuilderExecutionRuntime,
|
|
18
13
|
[WebBrowsingManifest.identifier]: WebBrowsingExecutionRuntime,
|
|
19
14
|
};
|
package/src/tools/identifiers.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { CloudSandboxManifest } from '@lobechat/builtin-tool-cloud-sandbox';
|
|
|
3
3
|
import { GroupAgentBuilderManifest } from '@lobechat/builtin-tool-group-agent-builder';
|
|
4
4
|
import { GroupManagementManifest } from '@lobechat/builtin-tool-group-management';
|
|
5
5
|
import { GTDManifest } from '@lobechat/builtin-tool-gtd';
|
|
6
|
+
import { KnowledgeBaseManifest } from '@lobechat/builtin-tool-knowledge-base';
|
|
6
7
|
import { LocalSystemManifest } from '@lobechat/builtin-tool-local-system';
|
|
7
8
|
import { MemoryManifest } from '@lobechat/builtin-tool-memory';
|
|
8
9
|
import { NotebookManifest } from '@lobechat/builtin-tool-notebook';
|
|
@@ -10,7 +11,6 @@ import { PageAgentManifest } from '@lobechat/builtin-tool-page-agent';
|
|
|
10
11
|
import { WebBrowsingManifest } from '@lobechat/builtin-tool-web-browsing';
|
|
11
12
|
|
|
12
13
|
import { ArtifactsManifest } from './artifacts';
|
|
13
|
-
import { KnowledgeBaseManifest } from './knowledge-base';
|
|
14
14
|
|
|
15
15
|
export const builtinToolIdentifiers: string[] = [
|
|
16
16
|
AgentBuilderManifest.identifier,
|
package/src/tools/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { CloudSandboxManifest } from '@lobechat/builtin-tool-cloud-sandbox';
|
|
|
3
3
|
import { GroupAgentBuilderManifest } from '@lobechat/builtin-tool-group-agent-builder';
|
|
4
4
|
import { GroupManagementManifest } from '@lobechat/builtin-tool-group-management';
|
|
5
5
|
import { GTDManifest } from '@lobechat/builtin-tool-gtd';
|
|
6
|
+
import { KnowledgeBaseManifest } from '@lobechat/builtin-tool-knowledge-base';
|
|
6
7
|
import { LocalSystemManifest } from '@lobechat/builtin-tool-local-system';
|
|
7
8
|
import { MemoryManifest } from '@lobechat/builtin-tool-memory';
|
|
8
9
|
import { NotebookManifest } from '@lobechat/builtin-tool-notebook';
|
|
@@ -12,7 +13,6 @@ import { isDesktop } from '@lobechat/const';
|
|
|
12
13
|
import { type LobeBuiltinTool } from '@lobechat/types';
|
|
13
14
|
|
|
14
15
|
import { ArtifactsManifest } from './artifacts';
|
|
15
|
-
import { KnowledgeBaseManifest } from './knowledge-base';
|
|
16
16
|
|
|
17
17
|
export const builtinTools: LobeBuiltinTool[] = [
|
|
18
18
|
{
|
package/src/tools/inspectors.ts
CHANGED
|
@@ -7,6 +7,10 @@ import {
|
|
|
7
7
|
GroupManagementManifest,
|
|
8
8
|
} from '@lobechat/builtin-tool-group-management/client';
|
|
9
9
|
import { GTDInspectors, GTDManifest } from '@lobechat/builtin-tool-gtd/client';
|
|
10
|
+
import {
|
|
11
|
+
KnowledgeBaseInspectors,
|
|
12
|
+
KnowledgeBaseManifest,
|
|
13
|
+
} from '@lobechat/builtin-tool-knowledge-base/client';
|
|
10
14
|
import {
|
|
11
15
|
LocalSystemInspectors,
|
|
12
16
|
LocalSystemManifest,
|
|
@@ -32,6 +36,7 @@ const BuiltinToolInspectors: Record<string, Record<string, BuiltinInspector>> =
|
|
|
32
36
|
BuiltinInspector
|
|
33
37
|
>,
|
|
34
38
|
[GTDManifest.identifier]: GTDInspectors as Record<string, BuiltinInspector>,
|
|
39
|
+
[KnowledgeBaseManifest.identifier]: KnowledgeBaseInspectors as Record<string, BuiltinInspector>,
|
|
35
40
|
[LocalSystemManifest.identifier]: LocalSystemInspectors as Record<string, BuiltinInspector>,
|
|
36
41
|
[PageAgentManifest.identifier]: PageAgentInspectors as Record<string, BuiltinInspector>,
|
|
37
42
|
[WebBrowsingManifest.identifier]: WebBrowsingInspectors as Record<string, BuiltinInspector>,
|
package/src/tools/renders.ts
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
// agent-builder
|
|
2
1
|
import { AgentBuilderManifest } from '@lobechat/builtin-tool-agent-builder';
|
|
3
2
|
import { AgentBuilderRenders } from '@lobechat/builtin-tool-agent-builder/client';
|
|
4
|
-
// cloud-sandbox
|
|
5
3
|
import { CloudSandboxManifest } from '@lobechat/builtin-tool-cloud-sandbox';
|
|
6
4
|
import { CloudSandboxRenders } from '@lobechat/builtin-tool-cloud-sandbox/client';
|
|
7
|
-
// group-management
|
|
8
5
|
import { GroupManagementManifest } from '@lobechat/builtin-tool-group-management';
|
|
9
6
|
import { GroupManagementRenders } from '@lobechat/builtin-tool-group-management/client';
|
|
10
|
-
// gtd
|
|
11
7
|
import { GTDManifest, GTDRenders } from '@lobechat/builtin-tool-gtd/client';
|
|
12
|
-
// local-system
|
|
13
8
|
import {
|
|
14
|
-
|
|
9
|
+
KnowledgeBaseManifest,
|
|
10
|
+
KnowledgeBaseRenders,
|
|
11
|
+
} from '@lobechat/builtin-tool-knowledge-base/client';
|
|
12
|
+
import {
|
|
13
|
+
LocalSystemManifest,
|
|
15
14
|
LocalSystemRenders,
|
|
16
15
|
} from '@lobechat/builtin-tool-local-system/client';
|
|
17
16
|
import { NotebookManifest, NotebookRenders } from '@lobechat/builtin-tool-notebook/client';
|
|
18
|
-
// web-browsing
|
|
19
17
|
import {
|
|
20
18
|
WebBrowsingManifest,
|
|
21
19
|
WebBrowsingRenders,
|
|
22
20
|
} from '@lobechat/builtin-tool-web-browsing/client';
|
|
23
21
|
import { type BuiltinRender } from '@lobechat/types';
|
|
24
22
|
|
|
25
|
-
// knowledge-base
|
|
26
|
-
import { KnowledgeBaseManifest } from './knowledge-base';
|
|
27
|
-
import { KnowledgeBaseRenders } from './knowledge-base/Render';
|
|
28
|
-
|
|
29
23
|
/**
|
|
30
24
|
* Builtin tools renders registry
|
|
31
25
|
* Organized by toolset (identifier) -> API name
|
|
@@ -37,7 +31,7 @@ const BuiltinToolsRenders: Record<string, Record<string, BuiltinRender>> = {
|
|
|
37
31
|
[GTDManifest.identifier]: GTDRenders as Record<string, BuiltinRender>,
|
|
38
32
|
[NotebookManifest.identifier]: NotebookRenders as Record<string, BuiltinRender>,
|
|
39
33
|
[KnowledgeBaseManifest.identifier]: KnowledgeBaseRenders as Record<string, BuiltinRender>,
|
|
40
|
-
[
|
|
34
|
+
[LocalSystemManifest.identifier]: LocalSystemRenders as Record<string, BuiltinRender>,
|
|
41
35
|
[WebBrowsingManifest.identifier]: WebBrowsingRenders as Record<string, BuiltinRender>,
|
|
42
36
|
};
|
|
43
37
|
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { LocalReadFileState } from '@lobechat/builtin-tool-local-system';
|
|
2
|
-
import { type RenameLocalFileParams } from '@lobechat/electron-client-ipc';
|
|
3
|
-
import { type BuiltinRenderProps } from '@lobechat/types';
|
|
4
|
-
import { Flexbox, Icon } from '@lobehub/ui';
|
|
5
|
-
import { createStaticStyles } from 'antd-style';
|
|
6
|
-
import { ArrowRightIcon } from 'lucide-react';
|
|
7
|
-
import path from 'path-browserify-esm';
|
|
8
|
-
import React, { memo } from 'react';
|
|
9
|
-
|
|
10
|
-
import { LocalFile } from '@/features/LocalFile';
|
|
11
|
-
|
|
12
|
-
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
13
|
-
container: css`
|
|
14
|
-
color: ${cssVar.colorTextQuaternary};
|
|
15
|
-
`,
|
|
16
|
-
new: css`
|
|
17
|
-
color: ${cssVar.colorTextSecondary};
|
|
18
|
-
`,
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
const RenameLocalFile = memo<BuiltinRenderProps<RenameLocalFileParams, LocalReadFileState>>(
|
|
22
|
-
({ args }) => {
|
|
23
|
-
const { base: oldFileName, dir } = path.parse(args.path);
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<Flexbox align={'center'} className={styles.container} gap={8} horizontal paddingInline={12}>
|
|
27
|
-
<Flexbox>{oldFileName}</Flexbox>
|
|
28
|
-
<Flexbox>
|
|
29
|
-
<Icon icon={ArrowRightIcon} />
|
|
30
|
-
</Flexbox>
|
|
31
|
-
<LocalFile name={args.newName} path={path.join(dir, args.newName)} />
|
|
32
|
-
</Flexbox>
|
|
33
|
-
);
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
export default RenameLocalFile;
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { LocalFileItem, LocalMoveFilesResultItem } from '@lobechat/electron-client-ipc';
|
|
2
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
-
|
|
4
|
-
import { localFileService } from '@/services/electron/localFileService';
|
|
5
|
-
import { ChatStore } from '@/store/chat';
|
|
6
|
-
|
|
7
|
-
import { localSystemSlice } from '../localSystem';
|
|
8
|
-
|
|
9
|
-
vi.mock('@/services/electron/localFileService', () => ({
|
|
10
|
-
localFileService: {
|
|
11
|
-
listLocalFiles: vi.fn(),
|
|
12
|
-
moveLocalFiles: vi.fn(),
|
|
13
|
-
readLocalFile: vi.fn(),
|
|
14
|
-
readLocalFiles: vi.fn(),
|
|
15
|
-
renameLocalFile: vi.fn(),
|
|
16
|
-
searchLocalFiles: vi.fn(),
|
|
17
|
-
writeFile: vi.fn(),
|
|
18
|
-
},
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
const mockSet = vi.fn();
|
|
22
|
-
|
|
23
|
-
const mockStore = {
|
|
24
|
-
completeOperation: vi.fn(),
|
|
25
|
-
failOperation: vi.fn(),
|
|
26
|
-
internal_triggerLocalFileToolCalling: vi.fn(),
|
|
27
|
-
messageOperationMap: {},
|
|
28
|
-
optimisticUpdateMessageContent: vi.fn(),
|
|
29
|
-
optimisticUpdateMessagePluginError: vi.fn(),
|
|
30
|
-
optimisticUpdatePluginArguments: vi.fn(),
|
|
31
|
-
optimisticUpdatePluginState: vi.fn(),
|
|
32
|
-
set: mockSet,
|
|
33
|
-
startOperation: vi.fn().mockReturnValue({
|
|
34
|
-
abortController: new AbortController(),
|
|
35
|
-
operationId: 'test-op-id',
|
|
36
|
-
}),
|
|
37
|
-
} as unknown as ChatStore;
|
|
38
|
-
|
|
39
|
-
const createStore = () => {
|
|
40
|
-
return localSystemSlice(
|
|
41
|
-
(set) => ({
|
|
42
|
-
...mockStore,
|
|
43
|
-
set,
|
|
44
|
-
}),
|
|
45
|
-
() => mockStore,
|
|
46
|
-
{} as any,
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
describe('localFileSlice', () => {
|
|
51
|
-
const store = createStore();
|
|
52
|
-
|
|
53
|
-
beforeEach(() => {
|
|
54
|
-
vi.clearAllMocks();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('internal_triggerLocalFileToolCalling', () => {
|
|
58
|
-
it('should handle successful calling', async () => {
|
|
59
|
-
const mockContent = 'result content';
|
|
60
|
-
const mockState = { state: 'test' };
|
|
61
|
-
const mockService = vi
|
|
62
|
-
.fn()
|
|
63
|
-
.mockResolvedValue({ content: mockContent, state: mockState, success: true });
|
|
64
|
-
|
|
65
|
-
await store.internal_triggerLocalFileToolCalling('test-id', mockService);
|
|
66
|
-
|
|
67
|
-
expect(mockStore.startOperation).toBeCalled();
|
|
68
|
-
expect(mockStore.completeOperation).toBeCalled();
|
|
69
|
-
expect(mockStore.optimisticUpdatePluginState).toBeCalled();
|
|
70
|
-
expect(mockStore.optimisticUpdateMessageContent).toBeCalled();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('should handle error', async () => {
|
|
74
|
-
const mockError = new Error('test error');
|
|
75
|
-
const mockService = vi.fn().mockRejectedValue(mockError);
|
|
76
|
-
|
|
77
|
-
await store.internal_triggerLocalFileToolCalling('test-id', mockService);
|
|
78
|
-
|
|
79
|
-
expect(mockStore.optimisticUpdateMessagePluginError).toBeCalledWith(
|
|
80
|
-
'test-id',
|
|
81
|
-
{
|
|
82
|
-
body: mockError,
|
|
83
|
-
message: 'test error',
|
|
84
|
-
type: 'PluginServerError',
|
|
85
|
-
},
|
|
86
|
-
{ operationId: 'test-op-id' },
|
|
87
|
-
);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe('listLocalFiles', () => {
|
|
92
|
-
it('should call listLocalFiles service and update state', async () => {
|
|
93
|
-
const mockResult: LocalFileItem[] = [
|
|
94
|
-
{
|
|
95
|
-
name: 'test.txt',
|
|
96
|
-
path: '/test.txt',
|
|
97
|
-
isDirectory: false,
|
|
98
|
-
createdTime: new Date(),
|
|
99
|
-
lastAccessTime: new Date(),
|
|
100
|
-
modifiedTime: new Date(),
|
|
101
|
-
size: 100,
|
|
102
|
-
type: 'file',
|
|
103
|
-
},
|
|
104
|
-
];
|
|
105
|
-
vi.mocked(localFileService.listLocalFiles).mockResolvedValue(mockResult);
|
|
106
|
-
|
|
107
|
-
await store.listLocalFiles('test-id', { path: '/test' });
|
|
108
|
-
|
|
109
|
-
expect(mockStore.internal_triggerLocalFileToolCalling).toBeCalled();
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe('moveLocalFiles', () => {
|
|
114
|
-
it('should handle successful move', async () => {
|
|
115
|
-
const mockResults = [
|
|
116
|
-
{
|
|
117
|
-
sourcePath: '/test.txt',
|
|
118
|
-
destinationPath: '/target/test.txt',
|
|
119
|
-
success: true,
|
|
120
|
-
},
|
|
121
|
-
] as unknown as LocalMoveFilesResultItem[];
|
|
122
|
-
|
|
123
|
-
vi.mocked(localFileService.moveLocalFiles).mockResolvedValue(mockResults);
|
|
124
|
-
|
|
125
|
-
await store.moveLocalFiles('test-id', {
|
|
126
|
-
sourcePaths: ['/test.txt'],
|
|
127
|
-
destinationDir: '/target',
|
|
128
|
-
} as any);
|
|
129
|
-
|
|
130
|
-
expect(mockStore.internal_triggerLocalFileToolCalling).toBeCalled();
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
describe('writeLocalFile', () => {
|
|
135
|
-
it('should handle successful write', async () => {
|
|
136
|
-
vi.mocked(localFileService.writeFile).mockResolvedValue({
|
|
137
|
-
success: true,
|
|
138
|
-
newPath: '/test.txt',
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
await store.writeLocalFile('test-id', { path: '/test.txt', content: 'test' });
|
|
142
|
-
|
|
143
|
-
expect(mockStore.internal_triggerLocalFileToolCalling).toBeCalled();
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('should handle write error', async () => {
|
|
147
|
-
vi.mocked(localFileService.writeFile).mockResolvedValue({
|
|
148
|
-
success: false,
|
|
149
|
-
error: 'Write failed',
|
|
150
|
-
newPath: '/test.txt',
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
await store.writeLocalFile('test-id', { path: '/test.txt', content: 'test' });
|
|
154
|
-
|
|
155
|
-
expect(mockStore.internal_triggerLocalFileToolCalling).toBeCalled();
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
describe('renameLocalFile', () => {
|
|
160
|
-
it('should handle successful rename', async () => {
|
|
161
|
-
vi.mocked(localFileService.renameLocalFile).mockResolvedValue({
|
|
162
|
-
success: true,
|
|
163
|
-
newPath: '/new.txt',
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
await store.renameLocalFile('test-id', { path: '/test.txt', newName: 'new.txt' });
|
|
167
|
-
|
|
168
|
-
expect(mockStore.internal_triggerLocalFileToolCalling).toBeCalled();
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('should handle rename error', async () => {
|
|
172
|
-
vi.mocked(localFileService.renameLocalFile).mockResolvedValue({
|
|
173
|
-
success: false,
|
|
174
|
-
error: 'Rename failed',
|
|
175
|
-
newPath: '/test.txt',
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
await store.renameLocalFile('test-id', { path: '/test.txt', newName: 'new.txt' });
|
|
179
|
-
|
|
180
|
-
expect(mockStore.internal_triggerLocalFileToolCalling).toBeCalled();
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it('should validate new filename', async () => {
|
|
184
|
-
vi.mocked(localFileService.renameLocalFile).mockRejectedValue(
|
|
185
|
-
new Error('Invalid new name provided'),
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
await store.renameLocalFile('test-id', {
|
|
189
|
-
path: '/test.txt',
|
|
190
|
-
newName: '../invalid.txt',
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
expect(mockStore.internal_triggerLocalFileToolCalling).toBeCalledWith(
|
|
194
|
-
'test-id',
|
|
195
|
-
expect.any(Function),
|
|
196
|
-
);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// toggleLocalFileLoading is no longer needed as we use operation-based state management
|
|
201
|
-
});
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import debug from 'debug';
|
|
2
|
-
import { type StateCreator } from 'zustand/vanilla';
|
|
3
|
-
|
|
4
|
-
import { agentSelectors } from '@/store/agent/selectors';
|
|
5
|
-
import { getAgentStoreState } from '@/store/agent/store';
|
|
6
|
-
import { type ChatStore } from '@/store/chat/store';
|
|
7
|
-
import { KnowledgeBaseExecutionRuntime } from '@/tools/knowledge-base/ExecutionRuntime';
|
|
8
|
-
|
|
9
|
-
const log = debug('lobe-store:builtin-tool:knowledge-base');
|
|
10
|
-
|
|
11
|
-
export interface KnowledgeBaseAction {
|
|
12
|
-
internal_triggerKnowledgeBaseToolCalling: (
|
|
13
|
-
id: string,
|
|
14
|
-
callingService: () => Promise<{ content: string; error?: any; state?: any; success: boolean }>,
|
|
15
|
-
) => Promise<boolean>;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Read full content of specific files from knowledge base
|
|
19
|
-
*/
|
|
20
|
-
readKnowledge: (
|
|
21
|
-
id: string,
|
|
22
|
-
params: {
|
|
23
|
-
fileIds: string[];
|
|
24
|
-
},
|
|
25
|
-
) => Promise<boolean>;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Search knowledge base for relevant files and chunks
|
|
29
|
-
*/
|
|
30
|
-
searchKnowledgeBase: (
|
|
31
|
-
id: string,
|
|
32
|
-
params: {
|
|
33
|
-
query: string;
|
|
34
|
-
topK?: number;
|
|
35
|
-
},
|
|
36
|
-
) => Promise<boolean>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const runtime = new KnowledgeBaseExecutionRuntime();
|
|
40
|
-
|
|
41
|
-
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
42
|
-
export const knowledgeBaseSlice: StateCreator<
|
|
43
|
-
ChatStore,
|
|
44
|
-
[['zustand/devtools', never]],
|
|
45
|
-
[],
|
|
46
|
-
KnowledgeBaseAction
|
|
47
|
-
> = (set, get) => ({
|
|
48
|
-
readKnowledge: async (id, params) => {
|
|
49
|
-
return get().internal_triggerKnowledgeBaseToolCalling(id, async () => {
|
|
50
|
-
return await runtime.readKnowledge(params);
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
searchKnowledgeBase: async (id, params) => {
|
|
55
|
-
// Get knowledge base IDs from agent store
|
|
56
|
-
const agentState = getAgentStoreState();
|
|
57
|
-
const knowledgeIds = agentSelectors.currentKnowledgeIds(agentState);
|
|
58
|
-
|
|
59
|
-
// Only search in knowledge bases, not agent files
|
|
60
|
-
// Agent files will be injected as full content in context-engine
|
|
61
|
-
const knowledgeBaseIds = knowledgeIds.knowledgeBaseIds;
|
|
62
|
-
|
|
63
|
-
return get().internal_triggerKnowledgeBaseToolCalling(id, async () => {
|
|
64
|
-
return await runtime.searchKnowledgeBase(params, {
|
|
65
|
-
knowledgeBaseIds,
|
|
66
|
-
messageId: id,
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
// ==================== utils ====================
|
|
72
|
-
|
|
73
|
-
internal_triggerKnowledgeBaseToolCalling: async (id, callingService) => {
|
|
74
|
-
// Get parent operationId from messageOperationMap (should be executeToolCall)
|
|
75
|
-
const parentOperationId = get().messageOperationMap[id];
|
|
76
|
-
|
|
77
|
-
// Create child operation for knowledge base execution
|
|
78
|
-
// Auto-associates message with this operation via messageId in context
|
|
79
|
-
const { operationId: knowledgeBaseOpId, abortController } = get().startOperation({
|
|
80
|
-
context: {
|
|
81
|
-
messageId: id,
|
|
82
|
-
},
|
|
83
|
-
metadata: {
|
|
84
|
-
startTime: Date.now(),
|
|
85
|
-
},
|
|
86
|
-
parentOperationId,
|
|
87
|
-
type: 'builtinToolKnowledgeBase',
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
log(
|
|
91
|
-
'[knowledgeBase] messageId=%s, parentOpId=%s, knowledgeBaseOpId=%s, aborted=%s',
|
|
92
|
-
id,
|
|
93
|
-
parentOperationId,
|
|
94
|
-
knowledgeBaseOpId,
|
|
95
|
-
abortController.signal.aborted,
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
const context = { operationId: knowledgeBaseOpId };
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
const { state, content, success, error } = await callingService();
|
|
102
|
-
|
|
103
|
-
// Complete knowledge base operation
|
|
104
|
-
get().completeOperation(knowledgeBaseOpId);
|
|
105
|
-
|
|
106
|
-
if (success) {
|
|
107
|
-
if (state) {
|
|
108
|
-
await get().optimisticUpdatePluginState(id, state, context);
|
|
109
|
-
}
|
|
110
|
-
await get().optimisticUpdateMessageContent(id, content, undefined, context);
|
|
111
|
-
} else {
|
|
112
|
-
await get().optimisticUpdateMessagePluginError(
|
|
113
|
-
id,
|
|
114
|
-
{
|
|
115
|
-
body: error,
|
|
116
|
-
message: error?.message || 'Operation failed',
|
|
117
|
-
type: 'PluginServerError',
|
|
118
|
-
},
|
|
119
|
-
context,
|
|
120
|
-
);
|
|
121
|
-
// Still update content even if failed, to show error message
|
|
122
|
-
await get().optimisticUpdateMessageContent(id, content, undefined, context);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return true;
|
|
126
|
-
} catch (error) {
|
|
127
|
-
const err = error as Error;
|
|
128
|
-
|
|
129
|
-
log('[knowledgeBase] Error: messageId=%s, error=%s', id, err.message);
|
|
130
|
-
|
|
131
|
-
// Check if it's an abort error
|
|
132
|
-
if (err.message.includes('The user aborted a request.') || err.name === 'AbortError') {
|
|
133
|
-
log('[knowledgeBase] Request aborted: messageId=%s', id);
|
|
134
|
-
// Fail knowledge base operation for abort
|
|
135
|
-
get().failOperation(knowledgeBaseOpId, {
|
|
136
|
-
message: 'User cancelled the request',
|
|
137
|
-
type: 'UserAborted',
|
|
138
|
-
});
|
|
139
|
-
// Don't update error message for user aborts
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Fail knowledge base operation for other errors
|
|
144
|
-
get().failOperation(knowledgeBaseOpId, {
|
|
145
|
-
message: err.message,
|
|
146
|
-
type: 'PluginServerError',
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// For other errors, update message
|
|
150
|
-
await get().optimisticUpdateMessagePluginError(
|
|
151
|
-
id,
|
|
152
|
-
{
|
|
153
|
-
body: error,
|
|
154
|
-
message: err.message,
|
|
155
|
-
type: 'PluginServerError',
|
|
156
|
-
},
|
|
157
|
-
context,
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
});
|