@lobehub/lobehub 2.0.0-next.273 → 2.0.0-next.274
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 +34 -0
- package/changelog/v1.json +9 -0
- package/locales/ar/chat.json +7 -0
- package/locales/ar/models.json +2 -3
- package/locales/ar/plugin.json +22 -1
- package/locales/bg-BG/chat.json +7 -0
- package/locales/bg-BG/models.json +3 -3
- package/locales/bg-BG/plugin.json +22 -1
- package/locales/de-DE/chat.json +7 -0
- package/locales/de-DE/models.json +3 -4
- package/locales/de-DE/plugin.json +22 -1
- package/locales/en-US/chat.json +7 -0
- package/locales/en-US/models.json +5 -5
- package/locales/en-US/plugin.json +22 -1
- package/locales/es-ES/chat.json +7 -0
- package/locales/es-ES/models.json +3 -4
- package/locales/es-ES/plugin.json +22 -1
- package/locales/fa-IR/chat.json +7 -0
- package/locales/fa-IR/models.json +3 -4
- package/locales/fa-IR/plugin.json +22 -1
- package/locales/fr-FR/chat.json +7 -0
- package/locales/fr-FR/models.json +50 -3
- package/locales/fr-FR/plugin.json +22 -1
- package/locales/it-IT/chat.json +7 -0
- package/locales/it-IT/models.json +3 -3
- package/locales/it-IT/plugin.json +22 -1
- package/locales/ja-JP/chat.json +7 -0
- package/locales/ja-JP/models.json +43 -4
- package/locales/ja-JP/plugin.json +22 -1
- package/locales/ko-KR/chat.json +7 -0
- package/locales/ko-KR/models.json +3 -4
- package/locales/ko-KR/plugin.json +22 -1
- package/locales/nl-NL/chat.json +7 -0
- package/locales/nl-NL/models.json +51 -3
- package/locales/nl-NL/plugin.json +22 -1
- package/locales/pl-PL/chat.json +7 -0
- package/locales/pl-PL/models.json +3 -3
- package/locales/pl-PL/plugin.json +22 -1
- package/locales/pt-BR/chat.json +7 -0
- package/locales/pt-BR/models.json +3 -4
- package/locales/pt-BR/plugin.json +22 -1
- package/locales/ru-RU/chat.json +7 -0
- package/locales/ru-RU/models.json +3 -4
- package/locales/ru-RU/plugin.json +22 -1
- package/locales/tr-TR/chat.json +7 -0
- package/locales/tr-TR/models.json +3 -4
- package/locales/tr-TR/plugin.json +22 -1
- package/locales/vi-VN/chat.json +7 -0
- package/locales/vi-VN/models.json +3 -3
- package/locales/vi-VN/plugin.json +22 -1
- package/locales/zh-CN/chat.json +7 -0
- package/locales/zh-CN/models.json +54 -4
- package/locales/zh-CN/plugin.json +22 -1
- package/locales/zh-TW/chat.json +7 -0
- package/locales/zh-TW/models.json +43 -4
- package/locales/zh-TW/plugin.json +22 -1
- package/package.json +1 -1
- package/packages/builtin-tool-agent-builder/package.json +1 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/GetAvailableModels/index.tsx +66 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/InstallPlugin/index.tsx +63 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/SearchMarketTools/index.tsx +64 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/UpdateConfig/index.tsx +94 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/UpdatePrompt/index.tsx +96 -0
- package/packages/builtin-tool-agent-builder/src/client/Inspector/index.ts +29 -0
- package/packages/builtin-tool-agent-builder/src/client/index.ts +13 -0
- package/packages/builtin-tool-agent-builder/src/executor.ts +132 -0
- package/packages/builtin-tool-cloud-sandbox/src/client/Inspector/ExecuteCode/index.tsx +5 -14
- package/packages/builtin-tool-cloud-sandbox/src/client/Inspector/RunCommand/index.tsx +5 -13
- package/packages/builtin-tool-group-agent-builder/package.json +7 -1
- package/packages/builtin-tool-group-agent-builder/src/ExecutionRuntime/index.ts +331 -87
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/BatchCreateAgents/index.tsx +110 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/CreateAgent/index.tsx +72 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/InviteAgent/index.tsx +57 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/RemoveAgent/index.tsx +57 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/SearchAgent/index.tsx +66 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateAgentPrompt/index.tsx +120 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateGroup/index.tsx +87 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/UpdateGroupPrompt/index.tsx +99 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Inspector/index.ts +52 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Render/BatchCreateAgents.tsx +103 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Render/UpdateAgentPrompt/index.tsx +36 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Render/UpdateGroupPrompt/index.tsx +36 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Render/index.ts +16 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Streaming/BatchCreateAgents/index.tsx +88 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Streaming/UpdateAgentPrompt/index.tsx +37 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Streaming/UpdateGroupPrompt/index.tsx +35 -0
- package/packages/builtin-tool-group-agent-builder/src/client/Streaming/index.ts +22 -0
- package/packages/builtin-tool-group-agent-builder/src/client/index.ts +26 -0
- package/packages/builtin-tool-group-agent-builder/src/executor.ts +284 -0
- package/packages/builtin-tool-group-agent-builder/src/index.ts +1 -14
- package/packages/builtin-tool-group-agent-builder/src/manifest.ts +160 -15
- package/packages/builtin-tool-group-agent-builder/src/systemRole.ts +232 -46
- package/packages/builtin-tool-group-agent-builder/src/types.ts +191 -41
- package/packages/builtin-tool-group-management/src/client/Inspector/Broadcast/index.tsx +2 -2
- package/packages/builtin-tool-group-management/src/manifest.ts +1 -1
- package/packages/builtin-tool-gtd/src/client/Inspector/ClearTodos/index.tsx +5 -11
- package/packages/builtin-tool-gtd/src/client/Inspector/CompleteTodos/index.tsx +3 -9
- package/packages/builtin-tool-gtd/src/client/Inspector/CreatePlan/index.tsx +6 -15
- package/packages/builtin-tool-gtd/src/client/Inspector/CreateTodos/index.tsx +3 -9
- package/packages/builtin-tool-gtd/src/client/Inspector/ExecTask/index.tsx +6 -17
- package/packages/builtin-tool-gtd/src/client/Inspector/RemoveTodos/index.tsx +3 -9
- package/packages/builtin-tool-gtd/src/client/Inspector/UpdatePlan/index.tsx +3 -9
- package/packages/builtin-tool-gtd/src/client/Inspector/UpdateTodos/index.tsx +3 -9
- package/packages/builtin-tool-knowledge-base/src/client/Inspector/ReadKnowledge/index.tsx +4 -16
- package/packages/builtin-tool-knowledge-base/src/client/Inspector/SearchKnowledgeBase/index.tsx +5 -16
- package/packages/builtin-tool-local-system/src/client/Inspector/EditLocalFile/index.tsx +4 -12
- package/packages/builtin-tool-local-system/src/client/Inspector/GlobLocalFiles/index.tsx +5 -13
- package/packages/builtin-tool-local-system/src/client/Inspector/GrepContent/index.tsx +5 -16
- package/packages/builtin-tool-local-system/src/client/Inspector/ListLocalFiles/index.tsx +5 -16
- package/packages/builtin-tool-local-system/src/client/Inspector/ReadLocalFile/index.tsx +5 -16
- package/packages/builtin-tool-local-system/src/client/Inspector/RenameLocalFile/index.tsx +5 -11
- package/packages/builtin-tool-local-system/src/client/Inspector/RunCommand/index.tsx +5 -13
- package/packages/builtin-tool-local-system/src/client/Inspector/SearchLocalFiles/index.tsx +5 -16
- package/packages/builtin-tool-local-system/src/client/Inspector/WriteLocalFile/index.tsx +6 -15
- package/packages/builtin-tool-notebook/src/client/Inspector/CreateDocument/index.tsx +7 -15
- package/packages/builtin-tool-page-agent/src/client/Inspector/EditTitle/index.tsx +5 -14
- package/packages/builtin-tool-page-agent/src/client/Inspector/GetPageContent/index.tsx +7 -8
- package/packages/builtin-tool-page-agent/src/client/Inspector/InitPage/index.tsx +4 -10
- package/packages/builtin-tool-page-agent/src/client/Inspector/ModifyNodes/index.tsx +3 -9
- package/packages/builtin-tool-page-agent/src/client/Inspector/ReplaceText/index.tsx +5 -11
- package/packages/builtin-tool-web-browsing/src/client/Inspector/CrawlMultiPages/index.tsx +6 -15
- package/packages/builtin-tool-web-browsing/src/client/Inspector/CrawlSinglePage/index.tsx +6 -15
- package/packages/builtin-tool-web-browsing/src/client/Inspector/Search/index.tsx +4 -15
- package/packages/database/src/models/chatGroup.ts +1 -1
- package/packages/model-bank/src/aiModels/aihubmix.ts +2 -1
- package/packages/model-bank/src/aiModels/google.ts +2 -1
- package/packages/model-bank/src/aiModels/infiniai.ts +9 -6
- package/packages/model-bank/src/aiModels/minimax.ts +9 -5
- package/packages/model-bank/src/aiModels/ollamacloud.ts +4 -2
- package/packages/model-bank/src/aiModels/vertexai.ts +2 -1
- package/packages/types/src/agentGroup/index.ts +8 -0
- package/patches/@upstash__qstash.patch +13 -1
- package/src/app/[variants]/(main)/agent/_layout/Sidebar/Header/Nav.tsx +1 -1
- package/src/app/[variants]/(main)/agent/cron/[cronId]/index.tsx +4 -3
- package/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/index.tsx +1 -1
- package/src/app/[variants]/(main)/agent/profile/features/store/action.ts +18 -21
- package/src/app/[variants]/(main)/group/_layout/GroupIdSync.tsx +6 -1
- package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/AgentProfilePopup.tsx +29 -21
- package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/GroupMember.tsx +1 -0
- package/src/app/[variants]/(main)/group/_layout/Sidebar/GroupConfig/GroupMemberItem.tsx +35 -18
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/AddTopicButon.tsx +2 -10
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/Nav.tsx +10 -2
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Header/index.tsx +1 -2
- package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/AgentBuilderProvider.tsx +1 -0
- package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/TopicSelector.tsx +15 -9
- package/src/app/[variants]/(main)/group/profile/features/AgentBuilder/index.tsx +12 -6
- package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor/AgentHeader.tsx → GroupProfile/GroupHeader.tsx} +22 -29
- package/src/app/[variants]/(main)/group/profile/features/GroupProfile/index.tsx +96 -0
- package/src/app/[variants]/(main)/group/profile/features/Header/AgentBuilderToggle.tsx +3 -4
- package/src/app/[variants]/(main)/group/profile/features/Header/AutoSaveHint.tsx +11 -7
- package/src/app/[variants]/(main)/group/profile/features/Header/ChromeTabs/index.tsx +147 -0
- package/src/app/[variants]/(main)/group/profile/features/Header/index.tsx +104 -13
- package/src/app/[variants]/(main)/group/profile/features/MemberProfile/AgentHeader.tsx +222 -0
- package/src/app/[variants]/(main)/group/profile/features/MemberProfile/index.tsx +155 -0
- package/src/app/[variants]/(main)/group/profile/features/ProfileHydration.tsx +63 -5
- package/src/app/[variants]/(main)/group/profile/index.tsx +34 -37
- package/src/app/[variants]/(mobile)/(home)/_layout/SessionHydration.tsx +1 -1
- package/src/app/[variants]/(mobile)/(home)/features/SessionListContent/List/Item/index.tsx +1 -1
- package/src/features/AgentBuilder/index.tsx +16 -1
- package/src/features/Conversation/Messages/AssistantGroup/Tool/Inspector/StatusIndicator.tsx +3 -2
- package/src/features/EditorCanvas/EditorCanvas.test.tsx +206 -0
- package/src/features/EditorCanvas/EditorDataMode.tsx +53 -19
- package/src/features/EditorModal/index.tsx +2 -2
- package/src/features/NavPanel/components/SessionHydration.tsx +1 -1
- package/src/features/ShareModal/ShareImage/ChatList/index.tsx +1 -1
- package/src/features/ShareModal/SharePdf/index.tsx +1 -1
- package/src/hooks/useBidirectionalQuerySync.ts +112 -0
- package/src/locales/default/chat.ts +10 -0
- package/src/locales/default/plugin.ts +22 -1
- package/src/server/modules/AgentRuntime/RuntimeExecutors.ts +45 -45
- package/src/server/modules/KeyVaultsEncrypt/index.ts +6 -6
- package/src/server/modules/S3/index.ts +1 -1
- package/src/server/routers/lambda/agent.ts +24 -0
- package/src/server/routers/lambda/agentGroup.ts +39 -0
- package/src/services/agent.ts +22 -0
- package/src/services/chatGroup/index.ts +14 -0
- package/src/store/agent/selectors/selectors.ts +3 -0
- package/src/store/agentGroup/initialState.ts +6 -0
- package/src/store/agentGroup/selectors/byId.ts +3 -1
- package/src/store/agentGroup/selectors/current.ts +2 -2
- package/src/store/agentGroup/slices/lifecycle.ts +18 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/fixtures/mockStore.ts +1 -1
- package/src/store/chat/slices/aiAgent/actions/__tests__/agentGroup.test.ts +4 -1
- package/src/store/chat/slices/aiAgent/actions/agentGroup.ts +1 -1
- package/src/store/chat/slices/aiChat/actions/__tests__/conversationLifecycle.test.ts +65 -0
- package/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts +2 -1
- package/src/store/chat/slices/builtinTool/actions/__tests__/search.test.ts +1 -1
- package/src/store/chat/slices/builtinTool/actions/index.ts +1 -6
- package/src/store/chat/slices/message/action.test.ts +5 -5
- package/src/store/chat/slices/message/actions/publicApi.ts +5 -5
- package/src/store/chat/slices/message/initialState.ts +0 -5
- package/src/store/chat/slices/message/selectors/displayMessage.test.ts +4 -4
- package/src/store/chat/slices/plugin/action.test.ts +54 -19
- package/src/store/chat/slices/plugin/actions/pluginTypes.ts +15 -21
- package/src/store/chat/slices/topic/action.test.ts +74 -24
- package/src/store/chat/slices/topic/action.ts +21 -13
- package/src/store/chat/slices/topic/selectors.test.ts +1 -1
- package/src/store/global/initialState.ts +10 -0
- package/src/store/global/selectors/systemStatus.ts +5 -0
- package/src/store/groupProfile/action.ts +168 -0
- package/src/store/groupProfile/index.ts +16 -0
- package/src/{app/[variants]/(main)/group/profile/features/store → store/groupProfile}/initialState.ts +17 -0
- package/src/store/groupProfile/selectors.ts +13 -0
- package/src/store/tool/slices/builtin/executors/index.ts +4 -0
- package/src/styles/text.ts +16 -0
- package/src/tools/inspectors.ts +13 -0
- package/src/tools/renders.ts +3 -0
- package/src/tools/streamings.ts +8 -0
- package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/TypoBar.tsx +0 -129
- package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/index.tsx +0 -138
- package/src/app/[variants]/(main)/group/profile/features/EditorCanvas/useSlashItems.tsx +0 -139
- package/src/app/[variants]/(main)/group/profile/features/ProfileEditor/index.tsx +0 -82
- package/src/app/[variants]/(main)/group/profile/features/ProfileProvider.tsx +0 -20
- package/src/app/[variants]/(main)/group/profile/features/StoreUpdater.tsx +0 -24
- package/src/app/[variants]/(main)/group/profile/features/store/action.ts +0 -163
- package/src/app/[variants]/(main)/group/profile/features/store/index.ts +0 -23
- package/src/app/[variants]/(main)/group/profile/features/store/selectors.ts +0 -7
- package/src/features/EditorModal/EditorCanvas.tsx +0 -84
- package/src/features/EditorModal/Typobar.tsx +0 -139
- package/src/store/chat/slices/builtinTool/actions/agentBuilder.ts +0 -192
- package/src/store/chat/slices/builtinTool/actions/groupAgentBuilder.ts +0 -242
- package/src/tools/executionRuntimes.ts +0 -14
- /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/AgentTool.tsx +0 -0
- /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/MentionDropdown.tsx +0 -0
- /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/index.tsx +0 -0
- /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/types.ts +0 -0
- /package/src/app/[variants]/(main)/group/profile/features/{ProfileEditor → MemberProfile}/MentionList/useMentionItems.tsx +0 -0
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { type StoreApiWithSelector } from '@lobechat/types';
|
|
4
|
-
import { createContext } from 'zustand-utils';
|
|
5
|
-
import { subscribeWithSelector } from 'zustand/middleware';
|
|
6
|
-
import { shallow } from 'zustand/shallow';
|
|
7
|
-
import { createWithEqualityFn } from 'zustand/traditional';
|
|
8
|
-
|
|
9
|
-
import { type Store, store } from './action';
|
|
10
|
-
import { type State } from './initialState';
|
|
11
|
-
|
|
12
|
-
export type { PublicState, State } from './initialState';
|
|
13
|
-
|
|
14
|
-
export const createStore = (initState?: Partial<State>) =>
|
|
15
|
-
createWithEqualityFn(subscribeWithSelector(store(initState)), shallow);
|
|
16
|
-
|
|
17
|
-
export const {
|
|
18
|
-
useStore: useProfileStore,
|
|
19
|
-
useStoreApi,
|
|
20
|
-
Provider,
|
|
21
|
-
} = createContext<StoreApiWithSelector<Store>>();
|
|
22
|
-
|
|
23
|
-
export { selectors } from './selectors';
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IEditor,
|
|
3
|
-
ReactCodePlugin,
|
|
4
|
-
ReactCodemirrorPlugin,
|
|
5
|
-
ReactHRPlugin,
|
|
6
|
-
ReactLinkPlugin,
|
|
7
|
-
ReactListPlugin,
|
|
8
|
-
ReactMathPlugin,
|
|
9
|
-
ReactTablePlugin,
|
|
10
|
-
} from '@lobehub/editor';
|
|
11
|
-
import { Editor } from '@lobehub/editor/react';
|
|
12
|
-
import { Flexbox } from '@lobehub/ui';
|
|
13
|
-
import { FC, useMemo } from 'react';
|
|
14
|
-
|
|
15
|
-
import { useUserStore } from '@/store/user';
|
|
16
|
-
import { labPreferSelectors } from '@/store/user/selectors';
|
|
17
|
-
|
|
18
|
-
import TypoBar from './Typobar';
|
|
19
|
-
|
|
20
|
-
interface EditorCanvasProps {
|
|
21
|
-
defaultValue?: string;
|
|
22
|
-
editor?: IEditor;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const EditorCanvas: FC<EditorCanvasProps> = ({ defaultValue, editor }) => {
|
|
26
|
-
const enableRichRender = useUserStore(labPreferSelectors.enableInputMarkdown);
|
|
27
|
-
|
|
28
|
-
const richRenderProps = useMemo(
|
|
29
|
-
() =>
|
|
30
|
-
!enableRichRender
|
|
31
|
-
? {
|
|
32
|
-
enablePasteMarkdown: false,
|
|
33
|
-
markdownOption: false,
|
|
34
|
-
}
|
|
35
|
-
: {
|
|
36
|
-
plugins: [
|
|
37
|
-
ReactListPlugin,
|
|
38
|
-
ReactCodePlugin,
|
|
39
|
-
ReactCodemirrorPlugin,
|
|
40
|
-
ReactHRPlugin,
|
|
41
|
-
ReactLinkPlugin,
|
|
42
|
-
ReactTablePlugin,
|
|
43
|
-
ReactMathPlugin,
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
[enableRichRender],
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<>
|
|
51
|
-
{enableRichRender && <TypoBar editor={editor} />}
|
|
52
|
-
<Flexbox
|
|
53
|
-
padding={16}
|
|
54
|
-
style={{ cursor: 'text', maxHeight: '80vh', minHeight: '50vh', overflowY: 'auto' }}
|
|
55
|
-
>
|
|
56
|
-
<Editor
|
|
57
|
-
autoFocus
|
|
58
|
-
content={''}
|
|
59
|
-
editor={editor}
|
|
60
|
-
onInit={(editor) => {
|
|
61
|
-
if (!editor || !defaultValue) return;
|
|
62
|
-
try {
|
|
63
|
-
if (enableRichRender) {
|
|
64
|
-
editor?.setDocument('markdown', defaultValue);
|
|
65
|
-
} else {
|
|
66
|
-
editor?.setDocument('text', defaultValue);
|
|
67
|
-
}
|
|
68
|
-
} catch (e) {
|
|
69
|
-
console.error('setDocument error:', e);
|
|
70
|
-
}
|
|
71
|
-
}}
|
|
72
|
-
style={{
|
|
73
|
-
paddingBottom: 120,
|
|
74
|
-
}}
|
|
75
|
-
type={'text'}
|
|
76
|
-
variant={'chat'}
|
|
77
|
-
{...richRenderProps}
|
|
78
|
-
/>
|
|
79
|
-
</Flexbox>
|
|
80
|
-
</>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default EditorCanvas;
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { HotkeyEnum, type IEditor, getHotkeyById } from '@lobehub/editor';
|
|
2
|
-
import { useEditorState } from '@lobehub/editor/react';
|
|
3
|
-
import {
|
|
4
|
-
ChatInputActionBar,
|
|
5
|
-
ChatInputActions,
|
|
6
|
-
type ChatInputActionsProps,
|
|
7
|
-
} from '@lobehub/editor/react';
|
|
8
|
-
import { cssVar } from 'antd-style';
|
|
9
|
-
import {
|
|
10
|
-
BoldIcon,
|
|
11
|
-
CodeXmlIcon,
|
|
12
|
-
ItalicIcon,
|
|
13
|
-
ListIcon,
|
|
14
|
-
ListOrderedIcon,
|
|
15
|
-
ListTodoIcon,
|
|
16
|
-
MessageSquareQuote,
|
|
17
|
-
SigmaIcon,
|
|
18
|
-
SquareDashedBottomCodeIcon,
|
|
19
|
-
StrikethroughIcon,
|
|
20
|
-
UnderlineIcon,
|
|
21
|
-
} from 'lucide-react';
|
|
22
|
-
import { memo, useMemo } from 'react';
|
|
23
|
-
import { useTranslation } from 'react-i18next';
|
|
24
|
-
|
|
25
|
-
const TypoBar = memo<{ editor?: IEditor }>(({ editor }) => {
|
|
26
|
-
const { t } = useTranslation('editor');
|
|
27
|
-
const editorState = useEditorState(editor);
|
|
28
|
-
|
|
29
|
-
const items: ChatInputActionsProps['items'] = useMemo(
|
|
30
|
-
() =>
|
|
31
|
-
[
|
|
32
|
-
{
|
|
33
|
-
active: editorState.isBold,
|
|
34
|
-
icon: BoldIcon,
|
|
35
|
-
key: 'bold',
|
|
36
|
-
label: t('typobar.bold'),
|
|
37
|
-
onClick: editorState.bold,
|
|
38
|
-
tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.Bold).keys },
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
active: editorState.isItalic,
|
|
42
|
-
icon: ItalicIcon,
|
|
43
|
-
key: 'italic',
|
|
44
|
-
label: t('typobar.italic'),
|
|
45
|
-
onClick: editorState.italic,
|
|
46
|
-
tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.Italic).keys },
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
active: editorState.isUnderline,
|
|
50
|
-
icon: UnderlineIcon,
|
|
51
|
-
key: 'underline',
|
|
52
|
-
label: t('typobar.underline'),
|
|
53
|
-
onClick: editorState.underline,
|
|
54
|
-
tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.Underline).keys },
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
active: editorState.isStrikethrough,
|
|
58
|
-
icon: StrikethroughIcon,
|
|
59
|
-
key: 'strikethrough',
|
|
60
|
-
label: t('typobar.strikethrough'),
|
|
61
|
-
onClick: editorState.strikethrough,
|
|
62
|
-
tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.Strikethrough).keys },
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
type: 'divider',
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
icon: ListIcon,
|
|
70
|
-
key: 'bulletList',
|
|
71
|
-
label: t('typobar.bulletList'),
|
|
72
|
-
onClick: editorState.bulletList,
|
|
73
|
-
tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.BulletList).keys },
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
icon: ListOrderedIcon,
|
|
77
|
-
key: 'numberlist',
|
|
78
|
-
label: t('typobar.numberList'),
|
|
79
|
-
onClick: editorState.numberList,
|
|
80
|
-
tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.NumberList).keys },
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
icon: ListTodoIcon,
|
|
84
|
-
key: 'tasklist',
|
|
85
|
-
label: t('typobar.taskList'),
|
|
86
|
-
onClick: editorState.checkList,
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
type: 'divider',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
active: editorState.isBlockquote,
|
|
93
|
-
icon: MessageSquareQuote,
|
|
94
|
-
key: 'blockquote',
|
|
95
|
-
label: t('typobar.blockquote'),
|
|
96
|
-
onClick: editorState.blockquote,
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
type: 'divider',
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
icon: SigmaIcon,
|
|
103
|
-
key: 'math',
|
|
104
|
-
label: t('typobar.tex'),
|
|
105
|
-
onClick: editorState.insertMath,
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
active: editorState.isCode,
|
|
109
|
-
icon: CodeXmlIcon,
|
|
110
|
-
key: 'code',
|
|
111
|
-
label: t('typobar.code'),
|
|
112
|
-
onClick: editorState.code,
|
|
113
|
-
tooltipProps: { hotkey: getHotkeyById(HotkeyEnum.CodeInline).keys },
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
icon: SquareDashedBottomCodeIcon,
|
|
117
|
-
key: 'codeblock',
|
|
118
|
-
label: t('typobar.codeblock'),
|
|
119
|
-
onClick: editorState.codeblock,
|
|
120
|
-
},
|
|
121
|
-
].filter(Boolean) as ChatInputActionsProps['items'],
|
|
122
|
-
[editorState],
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
<ChatInputActionBar
|
|
127
|
-
left={<ChatInputActions items={items} />}
|
|
128
|
-
style={{
|
|
129
|
-
background: cssVar.colorFillQuaternary,
|
|
130
|
-
borderTopLeftRadius: 8,
|
|
131
|
-
borderTopRightRadius: 8,
|
|
132
|
-
}}
|
|
133
|
-
/>
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
TypoBar.displayName = 'TypoBar';
|
|
138
|
-
|
|
139
|
-
export default TypoBar;
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
GetAvailableModelsParams,
|
|
3
|
-
InstallPluginParams,
|
|
4
|
-
SearchMarketToolsParams,
|
|
5
|
-
UpdateAgentConfigParams,
|
|
6
|
-
UpdatePromptParams,
|
|
7
|
-
} from '@lobechat/builtin-tool-agent-builder';
|
|
8
|
-
import { AgentBuilderExecutionRuntime } from '@lobechat/builtin-tool-agent-builder/executionRuntime';
|
|
9
|
-
import debug from 'debug';
|
|
10
|
-
import { type StateCreator } from 'zustand/vanilla';
|
|
11
|
-
|
|
12
|
-
import { getAgentStoreState } from '@/store/agent';
|
|
13
|
-
import { type ChatStore } from '@/store/chat/store';
|
|
14
|
-
|
|
15
|
-
const log = debug('lobe-store:builtin-tool:agent-builder');
|
|
16
|
-
|
|
17
|
-
export interface AgentBuilderAction {
|
|
18
|
-
getAvailableModels: (id: string, params: GetAvailableModelsParams) => Promise<boolean>;
|
|
19
|
-
installPlugin: (id: string, params: InstallPluginParams) => Promise<boolean>;
|
|
20
|
-
internal_triggerAgentBuilderToolCalling: (
|
|
21
|
-
id: string,
|
|
22
|
-
apiName: string,
|
|
23
|
-
params: any,
|
|
24
|
-
) => Promise<boolean>;
|
|
25
|
-
searchMarketTools: (id: string, params: SearchMarketToolsParams) => Promise<boolean>;
|
|
26
|
-
updateConfig: (id: string, params: UpdateAgentConfigParams) => Promise<boolean>;
|
|
27
|
-
updatePrompt: (id: string, params: UpdatePromptParams) => Promise<boolean>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const runtime = new AgentBuilderExecutionRuntime();
|
|
31
|
-
|
|
32
|
-
export const agentBuilderSlice: StateCreator<
|
|
33
|
-
ChatStore,
|
|
34
|
-
[['zustand/devtools', never]],
|
|
35
|
-
[],
|
|
36
|
-
AgentBuilderAction
|
|
37
|
-
> = (set, get) => ({
|
|
38
|
-
// ==================== Read Operations ====================
|
|
39
|
-
|
|
40
|
-
getAvailableModels: async (id, params) => {
|
|
41
|
-
return get().internal_triggerAgentBuilderToolCalling(id, 'getAvailableModels', params);
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
installPlugin: async (id, params) => {
|
|
45
|
-
return get().internal_triggerAgentBuilderToolCalling(id, 'installPlugin', params);
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
// ==================== Internal Helper ====================
|
|
49
|
-
/**
|
|
50
|
-
* Internal helper to execute agent builder tool calling operations
|
|
51
|
-
* Handles operation tracking, error handling, and state updates
|
|
52
|
-
*/
|
|
53
|
-
internal_triggerAgentBuilderToolCalling: async (id, apiName, params) => {
|
|
54
|
-
// Get parent operationId from messageOperationMap (should be executeToolCall)
|
|
55
|
-
const parentOperationId = get().messageOperationMap[id];
|
|
56
|
-
|
|
57
|
-
// Create child operation for agent builder execution
|
|
58
|
-
// Auto-associates message with this operation via messageId in context
|
|
59
|
-
const { operationId, abortController } = get().startOperation({
|
|
60
|
-
context: {
|
|
61
|
-
messageId: id,
|
|
62
|
-
},
|
|
63
|
-
metadata: {
|
|
64
|
-
apiName,
|
|
65
|
-
params,
|
|
66
|
-
startTime: Date.now(),
|
|
67
|
-
},
|
|
68
|
-
parentOperationId,
|
|
69
|
-
type: 'builtinToolAgentBuilder',
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
log(
|
|
73
|
-
'[%s] messageId=%s, parentOpId=%s, opId=%s, aborted=%s',
|
|
74
|
-
apiName,
|
|
75
|
-
id,
|
|
76
|
-
parentOperationId,
|
|
77
|
-
operationId,
|
|
78
|
-
abortController.signal.aborted,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const context = { operationId };
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
// Get target agent ID from AgentStore, not ChatStore
|
|
85
|
-
// ChatStore's activeAgentId is for message scoping (might be AgentBuilder's own ID)
|
|
86
|
-
// AgentStore's activeAgentId is the actual target agent being configured
|
|
87
|
-
const agentId = getAgentStoreState().activeAgentId;
|
|
88
|
-
|
|
89
|
-
if (!agentId) {
|
|
90
|
-
throw new Error('No active agent found');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Execute the runtime method
|
|
94
|
-
let result;
|
|
95
|
-
switch (apiName) {
|
|
96
|
-
case 'updateAgentConfig':
|
|
97
|
-
case 'updateConfig': {
|
|
98
|
-
result = await runtime.updateAgentConfig(agentId, params as UpdateAgentConfigParams);
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
case 'getAvailableModels': {
|
|
102
|
-
result = await runtime.getAvailableModels(params as GetAvailableModelsParams);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
case 'searchMarketTools': {
|
|
106
|
-
result = await runtime.searchMarketTools(params as SearchMarketToolsParams);
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
case 'installPlugin': {
|
|
110
|
-
result = await runtime.installPlugin(agentId, params as InstallPluginParams);
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
case 'updatePrompt': {
|
|
114
|
-
result = await runtime.updatePrompt(agentId, {
|
|
115
|
-
streaming: true,
|
|
116
|
-
...params,
|
|
117
|
-
} as UpdatePromptParams);
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
default: {
|
|
121
|
-
throw new Error(`Unknown API name: ${apiName}`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const { content, success, error, state } = result;
|
|
126
|
-
|
|
127
|
-
// Complete operation
|
|
128
|
-
get().completeOperation(operationId);
|
|
129
|
-
|
|
130
|
-
// Update message content
|
|
131
|
-
await get().optimisticUpdateMessageContent(id, content, undefined, context);
|
|
132
|
-
|
|
133
|
-
if (success) {
|
|
134
|
-
// Update plugin state with the result
|
|
135
|
-
await get().optimisticUpdatePluginState(id, state, context);
|
|
136
|
-
} else {
|
|
137
|
-
// Update plugin error
|
|
138
|
-
await get().optimisticUpdatePluginError(id, error, context);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return true;
|
|
142
|
-
} catch (error) {
|
|
143
|
-
const err = error as Error;
|
|
144
|
-
|
|
145
|
-
log('[%s] Error: messageId=%s, error=%s', apiName, id, err.message);
|
|
146
|
-
|
|
147
|
-
// Check if it's an abort error
|
|
148
|
-
if (err.message.includes('The user aborted a request.') || err.name === 'AbortError') {
|
|
149
|
-
log('[%s] Request aborted: messageId=%s', apiName, id);
|
|
150
|
-
// Fail operation for abort
|
|
151
|
-
get().failOperation(operationId, {
|
|
152
|
-
message: 'User cancelled the request',
|
|
153
|
-
type: 'UserAborted',
|
|
154
|
-
});
|
|
155
|
-
// Don't update error message for user aborts
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Fail operation for other errors
|
|
160
|
-
get().failOperation(operationId, {
|
|
161
|
-
message: err.message,
|
|
162
|
-
type: 'PluginServerError',
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// For other errors, update message
|
|
166
|
-
await get().optimisticUpdateMessagePluginError(
|
|
167
|
-
id,
|
|
168
|
-
{
|
|
169
|
-
body: error,
|
|
170
|
-
message: err.message,
|
|
171
|
-
type: 'PluginServerError',
|
|
172
|
-
},
|
|
173
|
-
context,
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
searchMarketTools: async (id, params) => {
|
|
181
|
-
return get().internal_triggerAgentBuilderToolCalling(id, 'searchMarketTools', params);
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
// ==================== Write Operations ====================
|
|
185
|
-
updateConfig: async (id, params) => {
|
|
186
|
-
return get().internal_triggerAgentBuilderToolCalling(id, 'updateConfig', params);
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
updatePrompt: async (id, params) => {
|
|
190
|
-
return get().internal_triggerAgentBuilderToolCalling(id, 'updatePrompt', params);
|
|
191
|
-
},
|
|
192
|
-
});
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
GetAvailableModelsParams,
|
|
3
|
-
InstallPluginParams,
|
|
4
|
-
SearchMarketToolsParams,
|
|
5
|
-
UpdateAgentConfigParams,
|
|
6
|
-
} from '@lobechat/builtin-tool-agent-builder';
|
|
7
|
-
import { AgentBuilderExecutionRuntime } from '@lobechat/builtin-tool-agent-builder/executionRuntime';
|
|
8
|
-
import type {
|
|
9
|
-
InviteAgentParams,
|
|
10
|
-
RemoveAgentParams,
|
|
11
|
-
UpdateGroupConfigParams,
|
|
12
|
-
UpdateGroupPromptParams,
|
|
13
|
-
} from '@lobechat/builtin-tool-group-agent-builder';
|
|
14
|
-
import { GroupAgentBuilderExecutionRuntime } from '@lobechat/builtin-tool-group-agent-builder/executionRuntime';
|
|
15
|
-
import debug from 'debug';
|
|
16
|
-
import { type StateCreator } from 'zustand/vanilla';
|
|
17
|
-
|
|
18
|
-
import { getAgentStoreState } from '@/store/agent';
|
|
19
|
-
import { getChatGroupStoreState } from '@/store/agentGroup';
|
|
20
|
-
import { type ChatStore } from '@/store/chat/store';
|
|
21
|
-
|
|
22
|
-
const log = debug('lobe-store:builtin-tool:group-agent-builder');
|
|
23
|
-
|
|
24
|
-
export interface GroupAgentBuilderAction {
|
|
25
|
-
// Inherited operations from AgentBuilder (operate on supervisor agent)
|
|
26
|
-
groupAgentBuilder_getAvailableModels: (
|
|
27
|
-
id: string,
|
|
28
|
-
params: GetAvailableModelsParams,
|
|
29
|
-
) => Promise<boolean>;
|
|
30
|
-
groupAgentBuilder_installPlugin: (id: string, params: InstallPluginParams) => Promise<boolean>;
|
|
31
|
-
// Group-specific operations
|
|
32
|
-
groupAgentBuilder_inviteAgent: (id: string, params: InviteAgentParams) => Promise<boolean>;
|
|
33
|
-
groupAgentBuilder_removeAgent: (id: string, params: RemoveAgentParams) => Promise<boolean>;
|
|
34
|
-
groupAgentBuilder_searchMarketTools: (
|
|
35
|
-
id: string,
|
|
36
|
-
params: SearchMarketToolsParams,
|
|
37
|
-
) => Promise<boolean>;
|
|
38
|
-
groupAgentBuilder_updateConfig: (id: string, params: UpdateAgentConfigParams) => Promise<boolean>;
|
|
39
|
-
groupAgentBuilder_updateGroupConfig: (
|
|
40
|
-
id: string,
|
|
41
|
-
params: UpdateGroupConfigParams,
|
|
42
|
-
) => Promise<boolean>;
|
|
43
|
-
groupAgentBuilder_updatePrompt: (id: string, params: UpdateGroupPromptParams) => Promise<boolean>;
|
|
44
|
-
internal_triggerGroupAgentBuilderToolCalling: (
|
|
45
|
-
id: string,
|
|
46
|
-
apiName: string,
|
|
47
|
-
params: any,
|
|
48
|
-
) => Promise<boolean>;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const agentBuilderRuntime = new AgentBuilderExecutionRuntime();
|
|
52
|
-
const groupAgentBuilderRuntime = new GroupAgentBuilderExecutionRuntime();
|
|
53
|
-
|
|
54
|
-
export const groupAgentBuilderSlice: StateCreator<
|
|
55
|
-
ChatStore,
|
|
56
|
-
[['zustand/devtools', never]],
|
|
57
|
-
[],
|
|
58
|
-
GroupAgentBuilderAction
|
|
59
|
-
> = (set, get) => ({
|
|
60
|
-
// ==================== Inherited Operations (from AgentBuilder) ====================
|
|
61
|
-
groupAgentBuilder_getAvailableModels: async (id, params) => {
|
|
62
|
-
return get().internal_triggerGroupAgentBuilderToolCalling(id, 'getAvailableModels', params);
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
groupAgentBuilder_installPlugin: async (id, params) => {
|
|
66
|
-
return get().internal_triggerGroupAgentBuilderToolCalling(id, 'installPlugin', params);
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
// ==================== Group-specific Operations ====================
|
|
70
|
-
groupAgentBuilder_inviteAgent: async (id, params) => {
|
|
71
|
-
return get().internal_triggerGroupAgentBuilderToolCalling(id, 'inviteAgent', params);
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
groupAgentBuilder_removeAgent: async (id, params) => {
|
|
75
|
-
return get().internal_triggerGroupAgentBuilderToolCalling(id, 'removeAgent', params);
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
groupAgentBuilder_searchMarketTools: async (id, params) => {
|
|
79
|
-
return get().internal_triggerGroupAgentBuilderToolCalling(id, 'searchMarketTools', params);
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
groupAgentBuilder_updateConfig: async (id, params) => {
|
|
83
|
-
return get().internal_triggerGroupAgentBuilderToolCalling(id, 'updateConfig', params);
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
groupAgentBuilder_updateGroupConfig: async (id, params) => {
|
|
87
|
-
return get().internal_triggerGroupAgentBuilderToolCalling(id, 'updateGroupConfig', params);
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
groupAgentBuilder_updatePrompt: async (id, params) => {
|
|
91
|
-
return get().internal_triggerGroupAgentBuilderToolCalling(id, 'updatePrompt', params);
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
// ==================== Internal Helper ====================
|
|
95
|
-
|
|
96
|
-
internal_triggerGroupAgentBuilderToolCalling: async (id, apiName, params) => {
|
|
97
|
-
// Get parent operationId from messageOperationMap (should be executeToolCall)
|
|
98
|
-
const parentOperationId = get().messageOperationMap[id];
|
|
99
|
-
|
|
100
|
-
// Create child operation for group agent builder execution
|
|
101
|
-
const { operationId, abortController } = get().startOperation({
|
|
102
|
-
context: {
|
|
103
|
-
messageId: id,
|
|
104
|
-
},
|
|
105
|
-
metadata: {
|
|
106
|
-
apiName,
|
|
107
|
-
params,
|
|
108
|
-
startTime: Date.now(),
|
|
109
|
-
},
|
|
110
|
-
parentOperationId,
|
|
111
|
-
type: 'builtinToolGroupAgentBuilder',
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
log(
|
|
115
|
-
'[%s] messageId=%s, parentOpId=%s, opId=%s, aborted=%s',
|
|
116
|
-
apiName,
|
|
117
|
-
id,
|
|
118
|
-
parentOperationId,
|
|
119
|
-
operationId,
|
|
120
|
-
abortController.signal.aborted,
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
const context = { operationId };
|
|
124
|
-
|
|
125
|
-
try {
|
|
126
|
-
// Get the active group ID
|
|
127
|
-
const groupId = getChatGroupStoreState().activeGroupId;
|
|
128
|
-
if (!groupId) {
|
|
129
|
-
throw new Error('No active group found');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Get supervisor agent ID for config/model operations
|
|
133
|
-
const agentId = getAgentStoreState().activeAgentId;
|
|
134
|
-
|
|
135
|
-
// Execute the runtime method
|
|
136
|
-
let result;
|
|
137
|
-
switch (apiName) {
|
|
138
|
-
// Group-specific operations
|
|
139
|
-
case 'inviteAgent': {
|
|
140
|
-
result = await groupAgentBuilderRuntime.inviteAgent(groupId, params as InviteAgentParams);
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
case 'removeAgent': {
|
|
144
|
-
result = await groupAgentBuilderRuntime.removeAgent(groupId, params as RemoveAgentParams);
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case 'updatePrompt': {
|
|
148
|
-
result = await groupAgentBuilderRuntime.updatePrompt({
|
|
149
|
-
streaming: true,
|
|
150
|
-
...params,
|
|
151
|
-
} as UpdateGroupPromptParams);
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
case 'updateGroupConfig': {
|
|
155
|
-
result = await groupAgentBuilderRuntime.updateGroupConfig(
|
|
156
|
-
params as UpdateGroupConfigParams,
|
|
157
|
-
);
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
// Inherited operations (use AgentBuilder runtime for supervisor agent)
|
|
161
|
-
case 'updateAgentConfig':
|
|
162
|
-
case 'updateConfig': {
|
|
163
|
-
if (!agentId) throw new Error('No supervisor agent found');
|
|
164
|
-
result = await agentBuilderRuntime.updateAgentConfig(
|
|
165
|
-
agentId,
|
|
166
|
-
params as UpdateAgentConfigParams,
|
|
167
|
-
);
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
case 'getAvailableModels': {
|
|
171
|
-
result = await agentBuilderRuntime.getAvailableModels(params as GetAvailableModelsParams);
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
case 'searchMarketTools': {
|
|
175
|
-
result = await agentBuilderRuntime.searchMarketTools(params as SearchMarketToolsParams);
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
case 'installPlugin': {
|
|
179
|
-
if (!agentId) throw new Error('No supervisor agent found');
|
|
180
|
-
result = await agentBuilderRuntime.installPlugin(agentId, params as InstallPluginParams);
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
default: {
|
|
184
|
-
throw new Error(`Unknown API name: ${apiName}`);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const { content, success, error, state } = result;
|
|
189
|
-
|
|
190
|
-
// Complete operation
|
|
191
|
-
get().completeOperation(operationId);
|
|
192
|
-
|
|
193
|
-
// Update message content
|
|
194
|
-
await get().optimisticUpdateMessageContent(id, content, undefined, context);
|
|
195
|
-
|
|
196
|
-
if (success) {
|
|
197
|
-
// Update plugin state with the result
|
|
198
|
-
await get().optimisticUpdatePluginState(id, state, context);
|
|
199
|
-
} else {
|
|
200
|
-
// Update plugin error
|
|
201
|
-
await get().optimisticUpdatePluginError(id, error, context);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return true;
|
|
205
|
-
} catch (error) {
|
|
206
|
-
const err = error as Error;
|
|
207
|
-
|
|
208
|
-
log('[%s] Error: messageId=%s, error=%s', apiName, id, err.message);
|
|
209
|
-
|
|
210
|
-
// Check if it's an abort error
|
|
211
|
-
if (err.message.includes('The user aborted a request.') || err.name === 'AbortError') {
|
|
212
|
-
log('[%s] Request aborted: messageId=%s', apiName, id);
|
|
213
|
-
// Fail operation for abort
|
|
214
|
-
get().failOperation(operationId, {
|
|
215
|
-
message: 'User cancelled the request',
|
|
216
|
-
type: 'UserAborted',
|
|
217
|
-
});
|
|
218
|
-
// Don't update error message for user aborts
|
|
219
|
-
return true;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Fail operation for other errors
|
|
223
|
-
get().failOperation(operationId, {
|
|
224
|
-
message: err.message,
|
|
225
|
-
type: 'PluginServerError',
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
// For other errors, update message
|
|
229
|
-
await get().optimisticUpdateMessagePluginError(
|
|
230
|
-
id,
|
|
231
|
-
{
|
|
232
|
-
body: error,
|
|
233
|
-
message: err.message,
|
|
234
|
-
type: 'PluginServerError',
|
|
235
|
-
},
|
|
236
|
-
context,
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
return true;
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
});
|