@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.
- package/.vscode/settings.json +18 -3
- package/CHANGELOG.md +61 -0
- package/changelog/v1.json +21 -0
- package/locales/ar/agentGroup.json +5 -0
- package/locales/ar/chat.json +26 -0
- package/locales/ar/models.json +43 -5
- package/locales/ar/plugin.json +4 -5
- package/locales/ar/setting.json +11 -0
- package/locales/ar/subscription.json +2 -0
- package/locales/ar/tool.json +2 -0
- package/locales/bg-BG/agentGroup.json +5 -0
- package/locales/bg-BG/chat.json +26 -0
- package/locales/bg-BG/models.json +49 -3
- package/locales/bg-BG/plugin.json +4 -5
- package/locales/bg-BG/setting.json +11 -0
- package/locales/bg-BG/subscription.json +2 -0
- package/locales/bg-BG/tool.json +2 -0
- package/locales/de-DE/agentGroup.json +5 -0
- package/locales/de-DE/chat.json +26 -0
- package/locales/de-DE/models.json +48 -5
- package/locales/de-DE/plugin.json +4 -5
- package/locales/de-DE/setting.json +11 -0
- package/locales/de-DE/subscription.json +2 -0
- package/locales/de-DE/tool.json +2 -0
- package/locales/en-US/models.json +8 -6
- package/locales/en-US/plugin.json +2 -4
- package/locales/en-US/setting.json +10 -11
- package/locales/en-US/tool.json +2 -0
- package/locales/es-ES/agentGroup.json +5 -0
- package/locales/es-ES/chat.json +26 -0
- package/locales/es-ES/models.json +43 -5
- package/locales/es-ES/plugin.json +4 -5
- package/locales/es-ES/setting.json +11 -0
- package/locales/es-ES/subscription.json +2 -0
- package/locales/es-ES/tool.json +2 -0
- package/locales/fa-IR/agentGroup.json +5 -0
- package/locales/fa-IR/chat.json +26 -0
- package/locales/fa-IR/models.json +42 -5
- package/locales/fa-IR/plugin.json +4 -5
- package/locales/fa-IR/setting.json +11 -0
- package/locales/fa-IR/subscription.json +2 -0
- package/locales/fa-IR/tool.json +2 -0
- package/locales/fr-FR/agentGroup.json +5 -0
- package/locales/fr-FR/chat.json +26 -0
- package/locales/fr-FR/models.json +5 -5
- package/locales/fr-FR/plugin.json +4 -5
- package/locales/fr-FR/setting.json +11 -0
- package/locales/fr-FR/subscription.json +2 -0
- package/locales/fr-FR/tool.json +2 -0
- package/locales/it-IT/agentGroup.json +5 -0
- package/locales/it-IT/chat.json +26 -0
- package/locales/it-IT/models.json +1 -3
- package/locales/it-IT/plugin.json +4 -5
- package/locales/it-IT/setting.json +11 -0
- package/locales/it-IT/subscription.json +2 -0
- package/locales/it-IT/tool.json +2 -0
- package/locales/ja-JP/agentGroup.json +5 -0
- package/locales/ja-JP/chat.json +26 -0
- package/locales/ja-JP/models.json +1 -5
- package/locales/ja-JP/plugin.json +4 -5
- package/locales/ja-JP/setting.json +11 -0
- package/locales/ja-JP/subscription.json +2 -0
- package/locales/ja-JP/tool.json +2 -0
- package/locales/ko-KR/agentGroup.json +5 -0
- package/locales/ko-KR/chat.json +26 -0
- package/locales/ko-KR/models.json +1 -3
- package/locales/ko-KR/plugin.json +4 -5
- package/locales/ko-KR/setting.json +11 -0
- package/locales/ko-KR/subscription.json +2 -0
- package/locales/ko-KR/tool.json +2 -0
- package/locales/nl-NL/agentGroup.json +5 -0
- package/locales/nl-NL/chat.json +26 -0
- package/locales/nl-NL/models.json +35 -3
- package/locales/nl-NL/plugin.json +4 -5
- package/locales/nl-NL/setting.json +11 -0
- package/locales/nl-NL/subscription.json +2 -0
- package/locales/nl-NL/tool.json +2 -0
- package/locales/pl-PL/agentGroup.json +5 -0
- package/locales/pl-PL/chat.json +26 -0
- package/locales/pl-PL/models.json +1 -3
- package/locales/pl-PL/plugin.json +4 -5
- package/locales/pl-PL/setting.json +11 -0
- package/locales/pl-PL/subscription.json +2 -0
- package/locales/pl-PL/tool.json +2 -0
- package/locales/pt-BR/agentGroup.json +5 -0
- package/locales/pt-BR/chat.json +26 -0
- package/locales/pt-BR/models.json +50 -5
- package/locales/pt-BR/plugin.json +4 -5
- package/locales/pt-BR/setting.json +11 -0
- package/locales/pt-BR/subscription.json +2 -0
- package/locales/pt-BR/tool.json +2 -0
- package/locales/ru-RU/agentGroup.json +5 -0
- package/locales/ru-RU/chat.json +26 -0
- package/locales/ru-RU/models.json +22 -3
- package/locales/ru-RU/plugin.json +4 -5
- package/locales/ru-RU/setting.json +11 -0
- package/locales/ru-RU/subscription.json +2 -0
- package/locales/ru-RU/tool.json +2 -0
- package/locales/tr-TR/agentGroup.json +5 -0
- package/locales/tr-TR/chat.json +26 -0
- package/locales/tr-TR/models.json +36 -3
- package/locales/tr-TR/plugin.json +4 -5
- package/locales/tr-TR/setting.json +11 -0
- package/locales/tr-TR/subscription.json +2 -0
- package/locales/tr-TR/tool.json +2 -0
- package/locales/vi-VN/agentGroup.json +5 -0
- package/locales/vi-VN/chat.json +26 -0
- package/locales/vi-VN/models.json +1 -1
- package/locales/vi-VN/plugin.json +4 -5
- package/locales/vi-VN/setting.json +11 -0
- package/locales/vi-VN/subscription.json +2 -0
- package/locales/vi-VN/tool.json +2 -0
- package/locales/zh-CN/models.json +52 -5
- package/locales/zh-CN/plugin.json +5 -7
- package/locales/zh-CN/setting.json +10 -11
- package/locales/zh-CN/tool.json +2 -2
- package/locales/zh-TW/agentGroup.json +5 -0
- package/locales/zh-TW/chat.json +26 -0
- package/locales/zh-TW/models.json +54 -5
- package/locales/zh-TW/plugin.json +4 -5
- package/locales/zh-TW/setting.json +11 -0
- package/locales/zh-TW/subscription.json +2 -0
- package/locales/zh-TW/tool.json +2 -0
- package/package.json +2 -2
- package/packages/builtin-agents/src/agents/group-supervisor/index.ts +1 -7
- package/packages/builtin-tool-group-agent-builder/src/ExecutionRuntime/index.ts +29 -0
- package/packages/builtin-tool-group-agent-builder/src/executor.ts +18 -0
- package/packages/builtin-tool-group-agent-builder/src/manifest.ts +17 -0
- package/packages/builtin-tool-group-agent-builder/src/types.ts +10 -0
- package/packages/builtin-tool-group-management/src/client/Inspector/ExecuteAgentTask/index.tsx +52 -8
- package/packages/builtin-tool-group-management/src/client/Render/ExecuteTask/index.tsx +2 -21
- package/packages/builtin-tool-group-management/src/executor.test.ts +6 -16
- package/packages/builtin-tool-group-management/src/executor.ts +8 -47
- package/packages/builtin-tool-group-management/src/manifest.ts +5 -18
- package/packages/builtin-tool-group-management/src/systemRole.ts +1 -8
- package/packages/builtin-tool-group-management/src/types.ts +2 -10
- package/packages/builtin-tool-local-system/src/ExecutionRuntime/index.ts +70 -31
- package/packages/builtin-tool-local-system/src/client/Render/WriteFile/index.tsx +48 -5
- package/packages/builtin-tool-local-system/src/client/Streaming/WriteFile/index.tsx +39 -0
- package/packages/builtin-tool-local-system/src/client/Streaming/index.ts +2 -0
- package/packages/builtin-tool-local-system/src/executor/index.ts +94 -60
- package/packages/database/src/repositories/agentGroup/index.ts +23 -0
- package/packages/model-bank/src/aiModels/qiniu.ts +24 -0
- package/packages/prompts/src/prompts/fileSystem/formatCommandOutput.test.ts +61 -0
- package/packages/prompts/src/prompts/fileSystem/formatCommandOutput.ts +21 -0
- package/packages/prompts/src/prompts/fileSystem/formatCommandResult.test.ts +87 -0
- package/packages/prompts/src/prompts/fileSystem/formatCommandResult.ts +35 -0
- package/packages/prompts/src/prompts/fileSystem/formatEditResult.test.ts +57 -0
- package/packages/prompts/src/prompts/fileSystem/formatEditResult.ts +17 -0
- package/packages/prompts/src/prompts/fileSystem/formatFileContent.test.ts +59 -0
- package/packages/prompts/src/prompts/fileSystem/formatFileContent.ts +14 -0
- package/packages/prompts/src/prompts/fileSystem/formatFileList.test.ts +62 -0
- package/packages/prompts/src/prompts/fileSystem/formatFileList.ts +13 -0
- package/packages/prompts/src/prompts/fileSystem/formatFileSearchResults.test.ts +34 -0
- package/packages/prompts/src/prompts/fileSystem/formatFileSearchResults.ts +12 -0
- package/packages/prompts/src/prompts/fileSystem/formatGlobResults.test.ts +64 -0
- package/packages/prompts/src/prompts/fileSystem/formatGlobResults.ts +23 -0
- package/packages/prompts/src/prompts/fileSystem/formatGrepResults.test.ts +85 -0
- package/packages/prompts/src/prompts/fileSystem/formatGrepResults.ts +24 -0
- package/packages/prompts/src/prompts/fileSystem/formatKillResult.test.ts +30 -0
- package/packages/prompts/src/prompts/fileSystem/formatKillResult.ts +9 -0
- package/packages/prompts/src/prompts/fileSystem/formatMoveResults.test.ts +37 -0
- package/packages/prompts/src/prompts/fileSystem/formatMoveResults.ts +20 -0
- package/packages/prompts/src/prompts/fileSystem/formatMultipleFiles.test.ts +54 -0
- package/packages/prompts/src/prompts/fileSystem/formatMultipleFiles.ts +9 -0
- package/packages/prompts/src/prompts/fileSystem/formatRenameResult.test.ts +35 -0
- package/packages/prompts/src/prompts/fileSystem/formatRenameResult.ts +17 -0
- package/packages/prompts/src/prompts/fileSystem/formatWriteResult.test.ts +30 -0
- package/packages/prompts/src/prompts/fileSystem/formatWriteResult.ts +11 -0
- package/packages/prompts/src/prompts/fileSystem/index.ts +13 -0
- package/packages/prompts/src/prompts/index.ts +1 -0
- package/src/app/[variants]/(auth)/_layout/index.tsx +0 -2
- package/src/app/[variants]/(auth)/layout.tsx +0 -2
- package/src/app/[variants]/(auth)/login/[[...login]]/page.tsx +1 -3
- package/src/app/[variants]/(auth)/signup/[[...signup]]/page.tsx +1 -3
- package/src/app/[variants]/(desktop)/desktop-onboarding/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/Actions.tsx +4 -3
- package/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/useDropdownMenu.tsx +12 -2
- package/src/app/[variants]/(main)/agent/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/agent/features/Portal/index.tsx +0 -2
- package/src/app/[variants]/(main)/community/(detail)/group_agent/features/Sidebar/ActionButton/AddGroupAgent.tsx +69 -17
- package/src/app/[variants]/(main)/community/(list)/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/community/(list)/assistant/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/community/(list)/mcp/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/community/(list)/model/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/community/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/Actions.tsx +4 -3
- package/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/useDropdownMenu.tsx +12 -2
- package/src/app/[variants]/(main)/group/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/group/features/Conversation/Header/index.tsx +4 -2
- package/src/app/[variants]/(main)/group/features/Portal/index.tsx +0 -2
- package/src/app/[variants]/(main)/home/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/home/index.tsx +0 -2
- package/src/app/[variants]/(main)/image/_layout/Topics/TopicUrlSync.tsx +0 -2
- package/src/app/[variants]/(main)/image/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/memory/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/page/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/resource/(home)/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/resource/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/resource/library/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/resource/library/features/Container.tsx +0 -2
- package/src/app/[variants]/(main)/settings/_layout/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/about/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/agent/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/apikey/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/chat-appearance/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/common/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/hotkey/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/image/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/memory/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/provider/(list)/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/proxy/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/security/index.tsx +1 -3
- package/src/app/[variants]/(main)/settings/storage/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/tts/index.tsx +0 -2
- package/src/app/[variants]/(mobile)/(home)/_layout/index.tsx +0 -2
- package/src/app/[variants]/(mobile)/_layout/index.tsx +1 -3
- package/src/app/[variants]/(mobile)/chat/_layout/index.tsx +0 -2
- package/src/app/[variants]/(mobile)/chat/settings/_layout/index.tsx +0 -2
- package/src/app/[variants]/(mobile)/community/(detail)/_layout/index.tsx +0 -2
- package/src/app/[variants]/(mobile)/community/(list)/_layout/index.tsx +0 -2
- package/src/app/[variants]/(mobile)/community/_layout/index.tsx +0 -2
- package/src/app/[variants]/(mobile)/router/MobileClientRouter.tsx +0 -2
- package/src/app/[variants]/(mobile)/settings/index.tsx +0 -2
- package/src/app/[variants]/onboarding/_layout/index.tsx +0 -2
- package/src/app/[variants]/router/DesktopClientRouter.tsx +0 -2
- package/src/components/ModelSelect/index.tsx +6 -56
- package/src/components/server/MobileNavLayout.tsx +0 -2
- package/src/components/server/ServerLayout.tsx +0 -2
- package/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx +13 -3
- package/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx +26 -3
- package/src/features/ModelSwitchPanel/components/Footer.tsx +0 -2
- package/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx +0 -1
- package/src/features/ModelSwitchPanel/components/List/SingleProviderModelItem.tsx +0 -1
- package/src/features/ModelSwitchPanel/components/List/VirtualItemRenderer.tsx +0 -1
- package/src/features/ModelSwitchPanel/components/List/index.tsx +15 -13
- package/src/features/ModelSwitchPanel/components/PanelContent.tsx +0 -2
- package/src/features/ModelSwitchPanel/index.tsx +21 -23
- package/src/features/ResourceManager/components/Explorer/MasonryView/index.tsx +0 -2
- package/src/features/ResourceManager/components/Header/AddButton.tsx +20 -3
- package/src/features/User/UserAvatar.tsx +0 -2
- package/src/locales/default/plugin.ts +2 -1
- package/src/server/routers/lambda/__tests__/agentGroup.test.ts +1 -0
- package/src/server/routers/lambda/agentGroup.ts +22 -0
- package/src/services/chat/index.ts +1 -0
- package/src/services/chat/mecha/agentConfigResolver.test.ts +62 -45
- package/src/services/chat/mecha/agentConfigResolver.ts +29 -27
- package/src/services/chatGroup/index.ts +14 -0
- package/src/store/chat/agents/GroupOrchestration/__tests__/call-supervisor.test.ts +305 -0
- package/src/store/chat/agents/GroupOrchestration/createGroupOrchestrationExecutors.ts +2 -1
- package/src/store/chat/slices/aiChat/actions/streamingExecutor.ts +6 -2
- package/src/store/chat/slices/plugin/actions/exector.ts +92 -0
- package/src/store/chat/slices/plugin/actions/pluginTypes.ts +82 -177
|
@@ -19,6 +19,7 @@ import { userProfileSelectors } from '@/store/user/slices/auth/selectors';
|
|
|
19
19
|
import { safeParseJSON } from '@/utils/safeParseJSON';
|
|
20
20
|
|
|
21
21
|
import { dbMessageSelectors } from '../../message/selectors';
|
|
22
|
+
import { RemoteToolExecutor, klavisExecutor, lobehubSkillExecutor } from './exector';
|
|
22
23
|
|
|
23
24
|
const log = debug('lobe-store:plugin-types');
|
|
24
25
|
|
|
@@ -86,6 +87,16 @@ export interface PluginTypesAction {
|
|
|
86
87
|
* Internal method to call plugin API
|
|
87
88
|
*/
|
|
88
89
|
internal_callPluginApi: (id: string, payload: ChatToolPayload) => Promise<string | undefined>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Internal unified method to invoke remote tool plugins (Klavis, LobeHub Skill, etc.)
|
|
93
|
+
*/
|
|
94
|
+
internal_invokeRemoteToolPlugin: (
|
|
95
|
+
id: string,
|
|
96
|
+
payload: ChatToolPayload,
|
|
97
|
+
executor: RemoteToolExecutor,
|
|
98
|
+
logPrefix: string,
|
|
99
|
+
) => Promise<string | undefined>;
|
|
89
100
|
}
|
|
90
101
|
|
|
91
102
|
export const pluginTypes: StateCreator<
|
|
@@ -360,106 +371,66 @@ export const pluginTypes: StateCreator<
|
|
|
360
371
|
},
|
|
361
372
|
|
|
362
373
|
invokeKlavisTypePlugin: async (id, payload) => {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
// Get message to extract sessionId/topicId
|
|
366
|
-
const message = dbMessageSelectors.getDbMessageById(id)(get());
|
|
367
|
-
|
|
368
|
-
// Get abort controller from operation
|
|
369
|
-
const operationId = get().messageOperationMap[id];
|
|
370
|
-
const operation = operationId ? get().operations[operationId] : undefined;
|
|
371
|
-
const abortController = operation?.abortController;
|
|
372
|
-
|
|
373
|
-
log(
|
|
374
|
-
'[invokeKlavisTypePlugin] messageId=%s, tool=%s, operationId=%s, aborted=%s',
|
|
374
|
+
return get().internal_invokeRemoteToolPlugin(
|
|
375
375
|
id,
|
|
376
|
-
payload
|
|
377
|
-
|
|
378
|
-
|
|
376
|
+
payload,
|
|
377
|
+
klavisExecutor,
|
|
378
|
+
'invokeKlavisTypePlugin',
|
|
379
379
|
);
|
|
380
|
+
},
|
|
380
381
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// Parse arguments
|
|
392
|
-
const args = safeParseJSON(payload.arguments) || {};
|
|
382
|
+
invokeLobehubSkillTypePlugin: async (id, payload) => {
|
|
383
|
+
return get().internal_invokeRemoteToolPlugin(
|
|
384
|
+
id,
|
|
385
|
+
payload,
|
|
386
|
+
lobehubSkillExecutor,
|
|
387
|
+
'invokeLobehubSkillTypePlugin',
|
|
388
|
+
);
|
|
389
|
+
},
|
|
393
390
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
serverUrl: server.serverUrl,
|
|
397
|
-
toolArgs: args,
|
|
398
|
-
toolName: payload.apiName,
|
|
399
|
-
});
|
|
391
|
+
invokeMarkdownTypePlugin: async (id, payload) => {
|
|
392
|
+
const { internal_callPluginApi } = get();
|
|
400
393
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
394
|
+
await internal_callPluginApi(id, payload);
|
|
395
|
+
},
|
|
404
396
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (toolResult) {
|
|
409
|
-
data = {
|
|
410
|
-
content: toolResult.content,
|
|
411
|
-
error: toolResult.state?.isError ? toolResult.state : undefined,
|
|
412
|
-
state: toolResult.state,
|
|
413
|
-
success: toolResult.success,
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
} catch (error) {
|
|
417
|
-
console.error('[invokeKlavisTypePlugin] Error:', error);
|
|
397
|
+
invokeStandaloneTypePlugin: async (id, payload) => {
|
|
398
|
+
const result = await useToolStore.getState().validatePluginSettings(payload.identifier);
|
|
399
|
+
if (!result) return;
|
|
418
400
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
401
|
+
// if the plugin settings is not valid, then set the message with error type
|
|
402
|
+
if (!result.valid) {
|
|
403
|
+
// Get message to extract agentId/topicId
|
|
404
|
+
const message = dbMessageSelectors.getDbMessageById(id)(get());
|
|
405
|
+
const updateResult = await messageService.updateMessageError(
|
|
406
|
+
id,
|
|
407
|
+
{
|
|
408
|
+
body: {
|
|
409
|
+
error: result.errors,
|
|
410
|
+
message: '[plugin] your settings is invalid with plugin manifest setting schema',
|
|
411
|
+
},
|
|
412
|
+
message: t('response.PluginSettingsInvalid', { ns: 'error' }),
|
|
413
|
+
type: PluginErrorType.PluginSettingsInvalid as any,
|
|
414
|
+
},
|
|
415
|
+
{
|
|
425
416
|
agentId: message?.agentId,
|
|
426
417
|
topicId: message?.topicId,
|
|
418
|
+
},
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
if (updateResult?.success && updateResult.messages) {
|
|
422
|
+
get().replaceMessages(updateResult.messages, {
|
|
423
|
+
context: { agentId: message?.agentId || '', topicId: message?.topicId },
|
|
427
424
|
});
|
|
428
|
-
if (result?.success && result.messages) {
|
|
429
|
-
get().replaceMessages(result.messages, {
|
|
430
|
-
context: {
|
|
431
|
-
agentId: message?.agentId,
|
|
432
|
-
topicId: message?.topicId,
|
|
433
|
-
},
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
425
|
}
|
|
426
|
+
return;
|
|
437
427
|
}
|
|
438
|
-
|
|
439
|
-
// 如果报错则结束了
|
|
440
|
-
if (!data) return;
|
|
441
|
-
|
|
442
|
-
// operationId already declared above, reuse it
|
|
443
|
-
const context = operationId ? { operationId } : undefined;
|
|
444
|
-
|
|
445
|
-
// Use optimisticUpdateToolMessage to update content and state/error in a single call
|
|
446
|
-
await get().optimisticUpdateToolMessage(
|
|
447
|
-
id,
|
|
448
|
-
{
|
|
449
|
-
content: data.content,
|
|
450
|
-
pluginError: data.success ? undefined : data.error,
|
|
451
|
-
pluginState: data.success ? data.state : undefined,
|
|
452
|
-
},
|
|
453
|
-
context,
|
|
454
|
-
);
|
|
455
|
-
|
|
456
|
-
return data.content;
|
|
457
428
|
},
|
|
458
429
|
|
|
459
|
-
|
|
430
|
+
invokeMCPTypePlugin: async (id, payload) => {
|
|
460
431
|
let data: MCPToolCallResult | undefined;
|
|
461
432
|
|
|
462
|
-
// Get message to extract
|
|
433
|
+
// Get message to extract agentId/topicId
|
|
463
434
|
const message = dbMessageSelectors.getDbMessageById(id)(get());
|
|
464
435
|
|
|
465
436
|
// Get abort controller from operation
|
|
@@ -468,7 +439,7 @@ export const pluginTypes: StateCreator<
|
|
|
468
439
|
const abortController = operation?.abortController;
|
|
469
440
|
|
|
470
441
|
log(
|
|
471
|
-
'[
|
|
442
|
+
'[invokeMCPTypePlugin] messageId=%s, tool=%s, operationId=%s, aborted=%s',
|
|
472
443
|
id,
|
|
473
444
|
payload.apiName,
|
|
474
445
|
operationId,
|
|
@@ -476,42 +447,19 @@ export const pluginTypes: StateCreator<
|
|
|
476
447
|
);
|
|
477
448
|
|
|
478
449
|
try {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
// Parse arguments
|
|
483
|
-
const args = safeParseJSON(payload.arguments) || {};
|
|
484
|
-
|
|
485
|
-
// Call LobeHub Skill tool via store action
|
|
486
|
-
const result = await useToolStore.getState().callLobehubSkillTool({
|
|
487
|
-
args,
|
|
488
|
-
provider,
|
|
489
|
-
toolName: payload.apiName,
|
|
450
|
+
const result = await mcpService.invokeMcpToolCall(payload, {
|
|
451
|
+
signal: abortController?.signal,
|
|
452
|
+
topicId: message?.topicId,
|
|
490
453
|
});
|
|
491
454
|
|
|
492
|
-
if (
|
|
493
|
-
throw new Error(result.error || 'LobeHub Skill tool execution failed');
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
// Convert to MCPToolCallResult format
|
|
497
|
-
const content = typeof result.data === 'string' ? result.data : JSON.stringify(result.data);
|
|
498
|
-
data = {
|
|
499
|
-
content,
|
|
500
|
-
error: undefined,
|
|
501
|
-
state: { content: [{ text: content, type: 'text' }] },
|
|
502
|
-
success: true,
|
|
503
|
-
};
|
|
455
|
+
if (!!result) data = result;
|
|
504
456
|
} catch (error) {
|
|
505
|
-
console.
|
|
457
|
+
console.log(error);
|
|
458
|
+
const err = error as Error;
|
|
506
459
|
|
|
507
460
|
// ignore the aborted request error
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
log(
|
|
511
|
-
'[invokeLobehubSkillTypePlugin] Request aborted: messageId=%s, tool=%s',
|
|
512
|
-
id,
|
|
513
|
-
payload.apiName,
|
|
514
|
-
);
|
|
461
|
+
if (err.message.includes('The user aborted a request.')) {
|
|
462
|
+
log('[invokeMCPTypePlugin] Request aborted: messageId=%s, tool=%s', id, payload.apiName);
|
|
515
463
|
} else {
|
|
516
464
|
const result = await messageService.updateMessageError(id, error as any, {
|
|
517
465
|
agentId: message?.agentId,
|
|
@@ -519,18 +467,17 @@ export const pluginTypes: StateCreator<
|
|
|
519
467
|
});
|
|
520
468
|
if (result?.success && result.messages) {
|
|
521
469
|
get().replaceMessages(result.messages, {
|
|
522
|
-
context: {
|
|
523
|
-
agentId: message?.agentId,
|
|
524
|
-
topicId: message?.topicId,
|
|
525
|
-
},
|
|
470
|
+
context: { agentId: message?.agentId || '', topicId: message?.topicId },
|
|
526
471
|
});
|
|
527
472
|
}
|
|
528
473
|
}
|
|
529
474
|
}
|
|
530
475
|
|
|
531
|
-
//
|
|
476
|
+
// 如果报错则结束了
|
|
477
|
+
|
|
532
478
|
if (!data) return;
|
|
533
479
|
|
|
480
|
+
// operationId already declared above, reuse it
|
|
534
481
|
const context = operationId ? { operationId } : undefined;
|
|
535
482
|
|
|
536
483
|
// Use optimisticUpdateToolMessage to update content and state/error in a single call
|
|
@@ -547,49 +494,10 @@ export const pluginTypes: StateCreator<
|
|
|
547
494
|
return data.content;
|
|
548
495
|
},
|
|
549
496
|
|
|
550
|
-
|
|
551
|
-
const { internal_callPluginApi } = get();
|
|
552
|
-
|
|
553
|
-
await internal_callPluginApi(id, payload);
|
|
554
|
-
},
|
|
555
|
-
|
|
556
|
-
invokeStandaloneTypePlugin: async (id, payload) => {
|
|
557
|
-
const result = await useToolStore.getState().validatePluginSettings(payload.identifier);
|
|
558
|
-
if (!result) return;
|
|
559
|
-
|
|
560
|
-
// if the plugin settings is not valid, then set the message with error type
|
|
561
|
-
if (!result.valid) {
|
|
562
|
-
// Get message to extract agentId/topicId
|
|
563
|
-
const message = dbMessageSelectors.getDbMessageById(id)(get());
|
|
564
|
-
const updateResult = await messageService.updateMessageError(
|
|
565
|
-
id,
|
|
566
|
-
{
|
|
567
|
-
body: {
|
|
568
|
-
error: result.errors,
|
|
569
|
-
message: '[plugin] your settings is invalid with plugin manifest setting schema',
|
|
570
|
-
},
|
|
571
|
-
message: t('response.PluginSettingsInvalid', { ns: 'error' }),
|
|
572
|
-
type: PluginErrorType.PluginSettingsInvalid as any,
|
|
573
|
-
},
|
|
574
|
-
{
|
|
575
|
-
agentId: message?.agentId,
|
|
576
|
-
topicId: message?.topicId,
|
|
577
|
-
},
|
|
578
|
-
);
|
|
579
|
-
|
|
580
|
-
if (updateResult?.success && updateResult.messages) {
|
|
581
|
-
get().replaceMessages(updateResult.messages, {
|
|
582
|
-
context: { agentId: message?.agentId || '', topicId: message?.topicId },
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
|
|
589
|
-
invokeMCPTypePlugin: async (id, payload) => {
|
|
497
|
+
internal_invokeRemoteToolPlugin: async (id, payload, executor, logPrefix) => {
|
|
590
498
|
let data: MCPToolCallResult | undefined;
|
|
591
499
|
|
|
592
|
-
// Get message to extract
|
|
500
|
+
// Get message to extract sessionId/topicId
|
|
593
501
|
const message = dbMessageSelectors.getDbMessageById(id)(get());
|
|
594
502
|
|
|
595
503
|
// Get abort controller from operation
|
|
@@ -598,7 +506,8 @@ export const pluginTypes: StateCreator<
|
|
|
598
506
|
const abortController = operation?.abortController;
|
|
599
507
|
|
|
600
508
|
log(
|
|
601
|
-
'[
|
|
509
|
+
'[%s] messageId=%s, tool=%s, operationId=%s, aborted=%s',
|
|
510
|
+
logPrefix,
|
|
602
511
|
id,
|
|
603
512
|
payload.apiName,
|
|
604
513
|
operationId,
|
|
@@ -606,19 +515,14 @@ export const pluginTypes: StateCreator<
|
|
|
606
515
|
);
|
|
607
516
|
|
|
608
517
|
try {
|
|
609
|
-
|
|
610
|
-
signal: abortController?.signal,
|
|
611
|
-
topicId: message?.topicId,
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
if (!!result) data = result;
|
|
518
|
+
data = await executor(payload);
|
|
615
519
|
} catch (error) {
|
|
616
|
-
console.
|
|
617
|
-
const err = error as Error;
|
|
520
|
+
console.error(`[${logPrefix}] Error:`, error);
|
|
618
521
|
|
|
619
522
|
// ignore the aborted request error
|
|
620
|
-
|
|
621
|
-
|
|
523
|
+
const err = error as Error;
|
|
524
|
+
if (err.message.includes('aborted')) {
|
|
525
|
+
log('[%s] Request aborted: messageId=%s, tool=%s', logPrefix, id, payload.apiName);
|
|
622
526
|
} else {
|
|
623
527
|
const result = await messageService.updateMessageError(id, error as any, {
|
|
624
528
|
agentId: message?.agentId,
|
|
@@ -626,17 +530,18 @@ export const pluginTypes: StateCreator<
|
|
|
626
530
|
});
|
|
627
531
|
if (result?.success && result.messages) {
|
|
628
532
|
get().replaceMessages(result.messages, {
|
|
629
|
-
context: {
|
|
533
|
+
context: {
|
|
534
|
+
agentId: message?.agentId,
|
|
535
|
+
topicId: message?.topicId,
|
|
536
|
+
},
|
|
630
537
|
});
|
|
631
538
|
}
|
|
632
539
|
}
|
|
633
540
|
}
|
|
634
541
|
|
|
635
|
-
//
|
|
636
|
-
|
|
542
|
+
// If error occurred, exit
|
|
637
543
|
if (!data) return;
|
|
638
544
|
|
|
639
|
-
// operationId already declared above, reuse it
|
|
640
545
|
const context = operationId ? { operationId } : undefined;
|
|
641
546
|
|
|
642
547
|
// Use optimisticUpdateToolMessage to update content and state/error in a single call
|