@lobehub/lobehub 2.0.0-next.62 → 2.0.0-next.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +18 -0
  3. package/locales/ar/plugin.json +2 -0
  4. package/locales/bg-BG/plugin.json +2 -0
  5. package/locales/de-DE/plugin.json +2 -0
  6. package/locales/en-US/plugin.json +8 -1
  7. package/locales/es-ES/plugin.json +2 -0
  8. package/locales/fa-IR/plugin.json +2 -0
  9. package/locales/fr-FR/plugin.json +2 -0
  10. package/locales/it-IT/plugin.json +2 -0
  11. package/locales/ja-JP/plugin.json +2 -0
  12. package/locales/ko-KR/plugin.json +2 -0
  13. package/locales/nl-NL/plugin.json +2 -0
  14. package/locales/pl-PL/plugin.json +2 -0
  15. package/locales/pt-BR/plugin.json +2 -0
  16. package/locales/ru-RU/plugin.json +2 -0
  17. package/locales/tr-TR/plugin.json +2 -0
  18. package/locales/vi-VN/plugin.json +2 -0
  19. package/locales/zh-CN/plugin.json +8 -1
  20. package/locales/zh-TW/plugin.json +2 -0
  21. package/package.json +1 -2
  22. package/packages/agent-runtime/src/types/event.ts +2 -1
  23. package/packages/conversation-flow/src/transformation/__tests__/MessageTransformer.test.ts +1 -2
  24. package/packages/database/src/client/db.test.ts +1 -2
  25. package/packages/database/src/client/db.ts +6 -6
  26. package/packages/database/src/core/electron.ts +1 -1
  27. package/packages/database/src/models/__tests__/asyncTask.test.ts +1 -2
  28. package/packages/database/src/models/__tests__/file.test.ts +1 -2
  29. package/packages/database/src/models/__tests__/generation.test.ts +1 -2
  30. package/packages/database/src/models/__tests__/generationBatch.test.ts +1 -2
  31. package/packages/database/src/models/aiProvider.ts +7 -7
  32. package/packages/database/src/repositories/aiInfra/index.test.ts +6 -6
  33. package/packages/database/src/repositories/aiInfra/index.ts +7 -7
  34. package/packages/database/src/repositories/dataImporter/__tests__/index.test.ts +1 -2
  35. package/packages/database/src/repositories/dataImporter/deprecated/__tests__/index.test.ts +1 -1
  36. package/packages/database/src/repositories/dataImporter/deprecated/index.ts +1 -1
  37. package/packages/database/src/repositories/dataImporter/index.ts +1 -2
  38. package/packages/database/src/repositories/tableViewer/index.ts +4 -5
  39. package/packages/database/src/schemas/agent.ts +1 -2
  40. package/packages/database/src/schemas/aiInfra.ts +1 -2
  41. package/packages/database/src/schemas/document.ts +1 -2
  42. package/packages/database/src/schemas/file.ts +1 -2
  43. package/packages/database/src/schemas/topic.ts +1 -2
  44. package/packages/database/src/schemas/user.ts +1 -1
  45. package/packages/database/src/server/models/__tests__/user.test.ts +1 -1
  46. package/packages/model-runtime/src/core/streams/vertex-ai.ts +1 -2
  47. package/packages/model-runtime/src/providers/comfyui/__tests__/index.test.ts +1 -2
  48. package/packages/model-runtime/src/providers/comfyui/auth/AuthManager.ts +1 -2
  49. package/packages/model-runtime/src/providers/comfyui/index.ts +2 -7
  50. package/packages/types/src/files/list.ts +1 -1
  51. package/packages/types/src/files/upload.ts +1 -1
  52. package/packages/types/src/importer.ts +2 -2
  53. package/packages/types/src/index.ts +4 -0
  54. package/packages/types/src/openai/image.ts +1 -1
  55. package/packages/types/src/topic/topic.ts +1 -1
  56. package/packages/types/src/user/settings/hotkey.ts +1 -1
  57. package/src/components/FileIcon/index.tsx +0 -2
  58. package/src/features/Conversation/Messages/Assistant/MessageContent.tsx +0 -18
  59. package/src/features/Conversation/Messages/Group/Tool/Inspector/index.tsx +26 -5
  60. package/src/features/Conversation/Messages/Group/Tool/index.tsx +1 -1
  61. package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Inspector/ToolTitle.tsx +1 -7
  62. package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Inspector/index.tsx +2 -15
  63. package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Render/CustomRender.tsx +1 -1
  64. package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Render/PluginSettings.tsx +2 -2
  65. package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Render/index.tsx +2 -31
  66. package/src/features/Conversation/Messages/Tool/ToolItem.tsx +51 -0
  67. package/src/features/Conversation/Messages/Tool/index.tsx +58 -0
  68. package/src/features/Conversation/Messages/index.tsx +5 -0
  69. package/src/features/DataImporter/index.tsx +2 -2
  70. package/src/features/ShareModal/ShareJSON/index.tsx +2 -2
  71. package/src/locales/default/plugin.ts +8 -0
  72. package/src/store/chat/slices/message/action.test.ts +8 -4
  73. package/src/store/chat/slices/message/actions/optimisticUpdate.ts +12 -0
  74. package/src/store/chat/slices/message/actions/publicApi.ts +19 -17
  75. package/src/tools/local-system/index.ts +27 -27
  76. package/src/tools/local-system/systemRole.ts +7 -7
  77. package/Dockerfile.lite +0 -272
  78. package/src/features/Conversation/Messages/Assistant/Tool/Render/LoadingPlaceholder/index.tsx +0 -29
  79. package/src/features/Conversation/Messages/Assistant/Tool/index.tsx +0 -76
  80. /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Inspector/BuiltinPluginTitle.tsx +0 -0
  81. /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Inspector/Debug.tsx +0 -0
  82. /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Inspector/PluginResult.tsx +0 -0
  83. /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Inspector/PluginState.tsx +0 -0
  84. /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Inspector/Settings.tsx +0 -0
  85. /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Render/Arguments/ObjectEntity.tsx +0 -0
  86. /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Render/Arguments/ValueCell.tsx +0 -0
  87. /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Render/Arguments/index.tsx +0 -0
  88. /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Render/ErrorResponse.tsx +0 -0
  89. /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Render/KeyValueEditor.tsx +0 -0
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix */
2
+ import type { CustomPluginParams } from '@lobechat/types';
2
3
  import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';
3
4
  import { boolean, jsonb, pgTable, primaryKey, text } from 'drizzle-orm/pg-core';
4
5
 
5
6
  import { DEFAULT_PREFERENCE } from '@/const/user';
6
- import { CustomPluginParams } from '@/types/tool/plugin';
7
7
 
8
8
  import { timestamps, timestamptz } from './_helpers';
9
9
 
@@ -1,3 +1,4 @@
1
+ import type { UserGuide, UserPreference } from '@lobechat/types';
1
2
  import { TRPCError } from '@trpc/server';
2
3
  import dayjs from 'dayjs';
3
4
  import { count, eq } from 'drizzle-orm';
@@ -5,7 +6,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
5
6
 
6
7
  import { INBOX_SESSION_ID } from '@/const/session';
7
8
  import { KeyVaultsGateKeeper } from '@/server/modules/KeyVaultsEncrypt';
8
- import { UserGuide, UserPreference } from '@/types/user';
9
9
 
10
10
  import { getTestDBInstance } from '../../../core/dbForTest';
11
11
  import { SessionModel } from '../../../models/session';
@@ -1,6 +1,5 @@
1
1
  import { GenerateContentResponse } from '@google/genai';
2
-
3
- import { GroundingSearch } from '@/types/search';
2
+ import { GroundingSearch } from '@lobechat/types';
4
3
 
5
4
  import { nanoid } from '../../utils/uuid';
6
5
  import { convertGoogleAIUsage } from '../usageConverters/google-ai';
@@ -1,9 +1,8 @@
1
1
  // @vitest-environment node
2
+ import type { ComfyUIKeyVault } from '@lobechat/types';
2
3
  import { createBasicAuthCredentials } from '@lobechat/utils';
3
4
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
4
5
 
5
- import type { ComfyUIKeyVault } from '@/types/index';
6
-
7
6
  import type { CreateImagePayload } from '../../../types/image';
8
7
  import { LobeComfyUI } from '../index';
9
8
 
@@ -1,7 +1,6 @@
1
+ import type { ComfyUIKeyVault } from '@lobechat/types';
1
2
  import { createBasicAuthCredentials } from '@lobechat/utils';
2
3
 
3
- import type { ComfyUIKeyVault } from '@/types/index';
4
-
5
4
  export interface BasicCredentials {
6
5
  password: string;
7
6
  type: 'basic';
@@ -1,14 +1,9 @@
1
+ import type { ComfyUIKeyVault } from '@lobechat/types';
1
2
  import { createBasicAuthCredentials } from '@lobechat/utils';
2
3
  import debug from 'debug';
3
4
 
4
- import type { ComfyUIKeyVault } from '@/types/index';
5
-
6
5
  import { LobeRuntimeAI } from '../../core/BaseAI';
7
- import {
8
- AuthenticatedImageRuntime,
9
- CreateImagePayload,
10
- CreateImageResponse,
11
- } from '../../types/image';
6
+ import { AuthenticatedImageRuntime, CreateImagePayload, CreateImageResponse } from '../../types';
12
7
  import { parseComfyUIErrorMessage } from '../../utils/comfyuiErrorParser';
13
8
  import { AgentRuntimeError } from '../../utils/createError';
14
9
 
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
 
3
- import { AsyncTaskStatus } from '@/types/asyncTask';
3
+ import type { AsyncTaskStatus } from '../asyncTask';
4
4
 
5
5
  export interface FileListItem {
6
6
  chunkCount: number | null;
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
 
3
- import { FileParsingTask } from '@/types/asyncTask';
3
+ import type { FileParsingTask } from '../asyncTask';
4
4
 
5
5
  export interface FileUploadState {
6
6
  progress: number;
@@ -116,7 +116,7 @@ export enum ImportStage {
116
116
  Finished,
117
117
  }
118
118
 
119
- export interface FileUploadState {
119
+ export interface ImportFileUploadState {
120
120
  progress: number;
121
121
  /**
122
122
  * rest time in ms
@@ -137,7 +137,7 @@ export interface ErrorShape {
137
137
 
138
138
  export interface OnImportCallbacks {
139
139
  onError?: (error: ErrorShape) => void;
140
- onFileUploading?: (state: FileUploadState) => void;
140
+ onFileUploading?: (state: ImportFileUploadState) => void;
141
141
  onStageChange?: (stage: ImportStage) => void;
142
142
  /**
143
143
  *
@@ -8,11 +8,14 @@ export * from './chatGroup';
8
8
  export * from './chunk';
9
9
  export * from './clientDB';
10
10
  export * from './discover';
11
+ export * from './document';
11
12
  export * from './eval';
13
+ export * from './export';
12
14
  export * from './fetch';
13
15
  export * from './files';
14
16
  export * from './generation';
15
17
  export * from './hotkey';
18
+ export * from './importer';
16
19
  export * from './knowledgeBase';
17
20
  export * from './llm';
18
21
  export * from './message';
@@ -23,6 +26,7 @@ export * from './search';
23
26
  export * from './serverConfig';
24
27
  export * from './service';
25
28
  export * from './session';
29
+ export * from './tableViewer';
26
30
  export * from './tool';
27
31
  export * from './topic';
28
32
  export * from './user';
@@ -1,4 +1,4 @@
1
- import { DallEImageQuality, DallEImageSize, DallEImageStyle } from '@/types/tool/dalle';
1
+ import type { DallEImageQuality, DallEImageSize, DallEImageStyle } from '../tool/dalle';
2
2
 
3
3
  export interface OpenAIImagePayload {
4
4
  model: 'dall-e-2' | 'dall-e-3';
@@ -1,4 +1,4 @@
1
- import { BaseDataModel } from '@/types/meta';
1
+ import type { BaseDataModel } from '../meta';
2
2
 
3
3
  // 类型定义
4
4
  export type TimeGroupId =
@@ -1,3 +1,3 @@
1
- import { HotkeyId } from '@/types/hotkey';
1
+ import type { HotkeyId } from '../../hotkey';
2
2
 
3
3
  export type UserHotkeyConfig = Record<HotkeyId, string>;
@@ -28,8 +28,6 @@ const FileIcon = memo<FileListProps>(({ fileName, size, variant = 'raw', isDirec
28
28
  );
29
29
  }
30
30
 
31
- console.log('FileIcon', fileName);
32
-
33
31
  return <MaterialFileTypeIcon filename={fileName} size={size} type={'file'} variant={variant} />;
34
32
  });
35
33
 
@@ -12,7 +12,6 @@ import FileChunks from './FileChunks';
12
12
  import IntentUnderstanding from './IntentUnderstanding';
13
13
  import Reasoning from './Reasoning';
14
14
  import SearchGrounding from './SearchGrounding';
15
- import Tool from './Tool';
16
15
 
17
16
  export const AssistantMessageContent = memo<
18
17
  UIChatMessage & {
@@ -67,23 +66,6 @@ export const AssistantMessageContent = memo<
67
66
  />
68
67
  )}
69
68
  {showImageItems && <ImageFileListViewer items={imageList} />}
70
- {tools && (
71
- <Flexbox gap={8}>
72
- {tools.map((toolCall, index) => (
73
- <Tool
74
- apiName={toolCall.apiName}
75
- arguments={toolCall.arguments}
76
- id={toolCall.id}
77
- identifier={toolCall.identifier}
78
- index={index}
79
- key={toolCall.id}
80
- messageId={id}
81
- payload={toolCall}
82
- type={toolCall.type}
83
- />
84
- ))}
85
- </Flexbox>
86
- )}
87
69
  </Flexbox>
88
70
  );
89
71
  });
@@ -1,13 +1,23 @@
1
+ import { ToolIntervention } from '@lobechat/types';
1
2
  import { ActionIcon, Icon, Tooltip } from '@lobehub/ui';
2
3
  import { createStyles } from 'antd-style';
3
- import { Ban, Check, LayoutPanelTop, LogsIcon, LucideBug, LucideBugOff, X } from 'lucide-react';
4
+ import {
5
+ Ban,
6
+ Check,
7
+ LayoutPanelTop,
8
+ LogsIcon,
9
+ LucideBug,
10
+ LucideBugOff,
11
+ Trash2,
12
+ X,
13
+ } from 'lucide-react';
4
14
  import { CSSProperties, memo, useState } from 'react';
5
15
  import { useTranslation } from 'react-i18next';
6
16
  import { Flexbox } from 'react-layout-kit';
7
17
 
8
18
  import { LOADING_FLAT } from '@/const/message';
19
+ import { useChatStore } from '@/store/chat';
9
20
  import { shinyTextStylish } from '@/styles/loading';
10
- import { ToolIntervention } from '@/types/message';
11
21
 
12
22
  import Debug from './Debug';
13
23
  import Settings from './Settings';
@@ -63,12 +73,12 @@ export const useStyles = createStyles(({ css, token, cx }) => ({
63
73
  interface InspectorProps {
64
74
  apiName: string;
65
75
  arguments?: string;
76
+ assistantMessageId: string;
66
77
  hidePluginUI?: boolean;
67
78
  id: string;
68
79
  identifier: string;
69
80
  index: number;
70
81
  intervention?: ToolIntervention;
71
- messageId: string;
72
82
  result?: { content: string | null; error?: any; state?: any };
73
83
  setShowPluginRender: (show: boolean) => void;
74
84
  setShowRender: (show: boolean) => void;
@@ -81,7 +91,7 @@ interface InspectorProps {
81
91
 
82
92
  const Inspectors = memo<InspectorProps>(
83
93
  ({
84
- messageId,
94
+ assistantMessageId,
85
95
  index,
86
96
  identifier,
87
97
  apiName,
@@ -100,6 +110,8 @@ const Inspectors = memo<InspectorProps>(
100
110
 
101
111
  const [showDebug, setShowDebug] = useState(false);
102
112
 
113
+ const [deleteAssistantMessage] = useChatStore((s) => [s.deleteAssistantMessage]);
114
+
103
115
  const hasError = !!result?.error;
104
116
  const hasSuccessResult = !!result?.content && result.content !== LOADING_FLAT;
105
117
 
@@ -128,7 +140,7 @@ const Inspectors = memo<InspectorProps>(
128
140
  identifier={identifier}
129
141
  index={index}
130
142
  isLoading={isTitleLoading}
131
- messageId={messageId}
143
+ messageId={assistantMessageId}
132
144
  toolCallId={id}
133
145
  />
134
146
  </Flexbox>
@@ -152,6 +164,15 @@ const Inspectors = memo<InspectorProps>(
152
164
  size={'small'}
153
165
  title={t(showDebug ? 'debug.off' : 'debug.on')}
154
166
  />
167
+ <ActionIcon
168
+ icon={Trash2}
169
+ onClick={() => {
170
+ deleteAssistantMessage(assistantMessageId);
171
+ }}
172
+ size={'small'}
173
+ title={t('inspector.delete')}
174
+ />
175
+
155
176
  <Settings id={identifier} />
156
177
  </Flexbox>
157
178
  {hasResult && (
@@ -60,11 +60,11 @@ const Tool = memo<GroupToolProps>(
60
60
  <Inspectors
61
61
  apiName={apiName}
62
62
  arguments={requestArgs}
63
+ assistantMessageId={assistantMessageId}
63
64
  id={id}
64
65
  identifier={identifier}
65
66
  index={index}
66
67
  intervention={intervention}
67
- messageId={assistantMessageId}
68
68
  result={result}
69
69
  setShowPluginRender={setShowCustomPluginUI}
70
70
  setShowRender={setShowToolDetail}
@@ -6,8 +6,6 @@ import { memo, useMemo } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { Flexbox } from 'react-layout-kit';
8
8
 
9
- import { useChatStore } from '@/store/chat';
10
- import { messageStateSelectors } from '@/store/chat/selectors';
11
9
  import { pluginHelpers, useToolStore } from '@/store/tool';
12
10
  import { toolSelectors } from '@/store/tool/selectors';
13
11
  import { shinyTextStylish } from '@/styles/loading';
@@ -43,10 +41,6 @@ const ToolTitle = memo<ToolTitleProps>(({ identifier, messageId, index, apiName,
43
41
  const { t } = useTranslation('plugin');
44
42
  const { styles } = useStyles();
45
43
 
46
- const isLoading = useChatStore(
47
- messageStateSelectors.isToolApiNameShining(messageId, index, toolCallId),
48
- );
49
-
50
44
  const pluginMeta = useToolStore(toolSelectors.getMetaById(identifier), isEqual);
51
45
 
52
46
  const plugins = useMemo(
@@ -84,7 +78,7 @@ const ToolTitle = memo<ToolTitleProps>(({ identifier, messageId, index, apiName,
84
78
  const pluginTitle = pluginHelpers.getPluginTitle(pluginMeta) ?? t('unknownPlugin');
85
79
 
86
80
  return (
87
- <Flexbox align={'center'} className={isLoading ? styles.shinyText : ''} gap={6} horizontal>
81
+ <Flexbox align={'center'} gap={6} horizontal>
88
82
  <div>{pluginTitle}</div> <Icon icon={ChevronRight} />
89
83
  <span className={styles.apiName}>{apiName}</span>
90
84
  </Flexbox>
@@ -68,10 +68,8 @@ interface InspectorProps {
68
68
  messageId: string;
69
69
  payload: object;
70
70
  setShowPluginRender: (show: boolean) => void;
71
- setShowRender: (show: boolean) => void;
72
71
  showPluginRender: boolean;
73
72
  showPortal?: boolean;
74
- showRender: boolean;
75
73
  style?: CSSProperties;
76
74
  }
77
75
 
@@ -83,9 +81,7 @@ const Inspectors = memo<InspectorProps>(
83
81
  apiName,
84
82
  id,
85
83
  arguments: requestArgs,
86
- showRender,
87
84
  payload,
88
- setShowRender,
89
85
  showPluginRender,
90
86
  setShowPluginRender,
91
87
  hidePluginUI = false,
@@ -98,16 +94,7 @@ const Inspectors = memo<InspectorProps>(
98
94
  return (
99
95
  <Flexbox className={styles.container} gap={4}>
100
96
  <Flexbox align={'center'} distribution={'space-between'} gap={8} horizontal>
101
- <Flexbox
102
- align={'center'}
103
- className={styles.tool}
104
- gap={8}
105
- horizontal
106
- onClick={() => {
107
- setShowRender(!showRender);
108
- }}
109
- paddingInline={4}
110
- >
97
+ <Flexbox align={'center'} className={styles.tool} gap={8} horizontal paddingInline={4}>
111
98
  <ToolTitle
112
99
  apiName={apiName}
113
100
  identifier={identifier}
@@ -117,7 +104,7 @@ const Inspectors = memo<InspectorProps>(
117
104
  />
118
105
  </Flexbox>
119
106
  <Flexbox className={styles.actions} horizontal>
120
- {showRender && !hidePluginUI && (
107
+ {!hidePluginUI && (
121
108
  <ActionIcon
122
109
  icon={showPluginRender ? LogsIcon : LayoutPanelTop}
123
110
  onClick={() => {
@@ -7,11 +7,11 @@ import { memo, useCallback, useEffect, useState } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { Flexbox } from 'react-layout-kit';
9
9
 
10
- import PluginResult from '@/features/Conversation/Messages/Assistant/Tool/Inspector/PluginResult';
11
10
  import PluginRender from '@/features/PluginsUI/Render';
12
11
  import { useChatStore } from '@/store/chat';
13
12
  import { messageStateSelectors } from '@/store/chat/selectors';
14
13
 
14
+ import PluginResult from '../Inspector/PluginResult';
15
15
  import Arguments from './Arguments';
16
16
  import KeyValueEditor from './KeyValueEditor';
17
17
 
@@ -1,4 +1,3 @@
1
- import { ChatPluginPayload } from '@lobechat/types';
2
1
  import { Avatar, Button } from '@lobehub/ui';
3
2
  import { Divider } from 'antd';
4
3
  import { useTheme } from 'antd-style';
@@ -11,8 +10,9 @@ import PluginSettingsConfig from '@/features/PluginSettings';
11
10
  import { useChatStore } from '@/store/chat';
12
11
  import { pluginHelpers, useToolStore } from '@/store/tool';
13
12
  import { pluginSelectors } from '@/store/tool/selectors';
13
+ import { ChatPluginPayload } from '@/types/index';
14
14
 
15
- import { ErrorActionContainer, useStyles } from '../../../../Error/style';
15
+ import { ErrorActionContainer, useStyles } from '../../../Error/style';
16
16
 
17
17
  interface PluginSettingsProps {
18
18
  id: string;
@@ -1,4 +1,3 @@
1
- import { LOADING_FLAT } from '@lobechat/const';
2
1
  import { Suspense, memo } from 'react';
3
2
 
4
3
  import { useChatStore } from '@/store/chat';
@@ -6,11 +5,8 @@ import { dbMessageSelectors, messageStateSelectors } from '@/store/chat/selector
6
5
 
7
6
  import CustomRender from './CustomRender';
8
7
  import ErrorResponse from './ErrorResponse';
9
- import LoadingPlaceholder from './LoadingPlaceholder';
10
8
 
11
9
  interface RenderProps {
12
- apiName: string;
13
- identifier: string;
14
10
  messageId: string;
15
11
  requestArgs?: string;
16
12
  setShowPluginRender: (show: boolean) => void;
@@ -20,16 +16,7 @@ interface RenderProps {
20
16
  }
21
17
 
22
18
  const Render = memo<RenderProps>(
23
- ({
24
- toolCallId,
25
- toolIndex,
26
- messageId,
27
- requestArgs,
28
- showPluginRender,
29
- setShowPluginRender,
30
- identifier,
31
- apiName,
32
- }) => {
19
+ ({ toolCallId, toolIndex, messageId, requestArgs, showPluginRender, setShowPluginRender }) => {
33
20
  const loading = useChatStore(messageStateSelectors.isToolCallStreaming(messageId, toolIndex));
34
21
  const toolMessage = useChatStore(dbMessageSelectors.getDbMessageByToolCallId(toolCallId));
35
22
 
@@ -40,24 +27,8 @@ const Render = memo<RenderProps>(
40
27
  return <ErrorResponse {...toolMessage.error} id={messageId} plugin={toolMessage.plugin} />;
41
28
  }
42
29
 
43
- const placeholder = (
44
- <LoadingPlaceholder
45
- apiName={apiName}
46
- identifier={identifier}
47
- loading
48
- requestArgs={requestArgs}
49
- />
50
- );
51
-
52
- // 如果是 LOADING_FLAT 则说明还在加载中
53
- // 而 standalone 模式的插件 content 应该始终是 LOADING_FLAT
54
- const inPlaceholder =
55
- toolMessage.content === LOADING_FLAT && toolMessage.plugin?.type !== 'standalone';
56
-
57
- if (inPlaceholder) return placeholder;
58
-
59
30
  return (
60
- <Suspense fallback={placeholder}>
31
+ <Suspense>
61
32
  <CustomRender
62
33
  {...toolMessage}
63
34
  requestArgs={requestArgs}
@@ -0,0 +1,51 @@
1
+ import { CSSProperties, memo, useState } from 'react';
2
+ import { Flexbox } from 'react-layout-kit';
3
+
4
+ import Inspectors from './Inspector';
5
+ import Render from './Render';
6
+
7
+ export interface InspectorProps {
8
+ apiName: string;
9
+ arguments?: string;
10
+ identifier: string;
11
+ index: number;
12
+ messageId: string;
13
+ payload: object;
14
+ style?: CSSProperties;
15
+ toolCallId: string;
16
+ type?: string;
17
+ }
18
+
19
+ const Tool = memo<InspectorProps>(
20
+ ({ arguments: requestArgs, apiName, messageId, toolCallId, index, identifier, payload }) => {
21
+ const [showPluginRender, setShowPluginRender] = useState(false);
22
+
23
+ return (
24
+ <Flexbox gap={8} style={{ paddingBottom: 12 }}>
25
+ <Inspectors
26
+ apiName={apiName}
27
+ arguments={requestArgs}
28
+ id={toolCallId}
29
+ identifier={identifier}
30
+ index={index}
31
+ messageId={messageId}
32
+ payload={payload}
33
+ setShowPluginRender={setShowPluginRender}
34
+ showPluginRender={showPluginRender}
35
+ />
36
+ <Render
37
+ messageId={messageId}
38
+ requestArgs={requestArgs}
39
+ setShowPluginRender={setShowPluginRender}
40
+ showPluginRender={showPluginRender}
41
+ toolCallId={toolCallId}
42
+ toolIndex={index}
43
+ />
44
+ </Flexbox>
45
+ );
46
+ },
47
+ );
48
+
49
+ Tool.displayName = 'AssistantTool';
50
+
51
+ export default Tool;
@@ -0,0 +1,58 @@
1
+ import { Alert } from '@lobehub/ui';
2
+ import { Button } from 'antd';
3
+ import isEqual from 'fast-deep-equal';
4
+ import { memo, useState } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import { Flexbox } from 'react-layout-kit';
7
+
8
+ import { useChatStore } from '@/store/chat';
9
+ import { dbMessageSelectors } from '@/store/chat/selectors';
10
+ import { UIChatMessage } from '@/types/message';
11
+
12
+ import ToolItem from './ToolItem';
13
+
14
+ interface ToolMessageProps {
15
+ id: string;
16
+ index: number;
17
+ }
18
+
19
+ const Tool = memo<ToolMessageProps>(({ id, index }) => {
20
+ const { t } = useTranslation('plugin');
21
+ const item = useChatStore(dbMessageSelectors.getDbMessageById(id), isEqual) as UIChatMessage;
22
+ const deleteToolMessage = useChatStore((s) => s.deleteToolMessage);
23
+ const [loading, setLoading] = useState(false);
24
+
25
+ const handleDelete = async () => {
26
+ setLoading(true);
27
+ try {
28
+ await deleteToolMessage(id);
29
+ } finally {
30
+ setLoading(false);
31
+ }
32
+ };
33
+
34
+ return (
35
+ <Flexbox gap={4} paddingBlock={12} paddingInline={12}>
36
+ <Alert
37
+ action={
38
+ <Button loading={loading} onClick={handleDelete} size={'small'} type={'primary'}>
39
+ {t('inspector.delete')}
40
+ </Button>
41
+ }
42
+ message={t('inspector.orphanedToolCall')}
43
+ type={'warning'}
44
+ variant={'borderless'}
45
+ />
46
+ {item.plugin && (
47
+ <ToolItem
48
+ {...item.plugin}
49
+ index={index}
50
+ messageId={id}
51
+ payload={item.plugin || {}}
52
+ toolCallId={item.tool_call_id!}
53
+ />
54
+ )}
55
+ </Flexbox>
56
+ );
57
+ });
58
+ export default Tool;
@@ -18,6 +18,7 @@ import { InPortalThreadContext } from '../context/InPortalThreadContext';
18
18
  import AssistantMessage from './Assistant';
19
19
  import GroupMessage from './Group';
20
20
  import SupervisorMessage from './Supervisor';
21
+ import ToolMessage from './Tool';
21
22
  import UserMessage from './User';
22
23
 
23
24
  const useStyles = createStyles(({ css, prefixCls }) => ({
@@ -133,6 +134,10 @@ const Item = memo<ChatListItemProps>(
133
134
  return <GroupMessage disableEditing={disableEditing} id={id} index={index} />;
134
135
  }
135
136
 
137
+ case 'tool': {
138
+ return <ToolMessage id={id} index={index} />;
139
+ }
140
+
136
141
  case 'supervisor': {
137
142
  return <SupervisorMessage disableEditing={disableEditing} id={id} index={index} />;
138
143
  }
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
 
3
+ import { ErrorShape, ImportFileUploadState, ImportStage } from '@lobechat/types';
3
4
  import { Upload } from 'antd';
4
5
  import { createStyles } from 'antd-style';
5
6
  import { ImportIcon } from 'lucide-react';
@@ -12,7 +13,6 @@ import { importService } from '@/services/import';
12
13
  import { useChatStore } from '@/store/chat';
13
14
  import { useSessionStore } from '@/store/session';
14
15
  import { ImportPgDataStructure } from '@/types/export';
15
- import { ErrorShape, FileUploadState, ImportStage } from '@/types/importer';
16
16
 
17
17
  import ImportError from './Error';
18
18
  import { FileUploading } from './FileUploading';
@@ -64,7 +64,7 @@ const DataImporter = memo<DataImporterProps>(({ children, onFinishImport }) => {
64
64
  const [duration, setDuration] = useState(0);
65
65
  const [importState, setImportState] = useState(ImportStage.Start);
66
66
 
67
- const [fileUploadingState, setUploadingState] = useState<FileUploadState | undefined>();
67
+ const [fileUploadingState, setUploadingState] = useState<ImportFileUploadState | undefined>();
68
68
  const [importError, setImportError] = useState<ErrorShape | undefined>();
69
69
  const [importResults, setImportResults] = useState<ImportResults | undefined>();
70
70
  const [showImportModal, setShowImportModal] = useState(false);
@@ -12,7 +12,7 @@ import { useIsMobile } from '@/hooks/useIsMobile';
12
12
  import { useAgentStore } from '@/store/agent';
13
13
  import { agentSelectors } from '@/store/agent/selectors';
14
14
  import { useChatStore } from '@/store/chat';
15
- import { chatSelectors, topicSelectors } from '@/store/chat/selectors';
15
+ import { dbMessageSelectors, topicSelectors } from '@/store/chat/selectors';
16
16
 
17
17
  import { useStyles } from '../style';
18
18
  import Preview from './Preview';
@@ -50,7 +50,7 @@ const ShareImage = memo(() => {
50
50
  ];
51
51
 
52
52
  const systemRole = useAgentStore(agentSelectors.currentAgentSystemRole);
53
- const messages = useChatStore(chatSelectors.activeBaseChats, isEqual);
53
+ const messages = useChatStore(dbMessageSelectors.activeDbMessages, isEqual);
54
54
  const data = generateMessages({ ...fieldValue, messages, systemRole });
55
55
  const content = JSON.stringify(data, null, 2);
56
56
 
@@ -237,6 +237,9 @@ export default {
237
237
  },
238
238
  inspector: {
239
239
  args: '查看参数列表',
240
+ delete: '删除工具调用',
241
+ orphanedToolCall:
242
+ '该工具调用消息可能因异常原因成为孤立消息,这会影响 Agent 的正常执行,请将其移除',
240
243
  pluginRender: '查看插件界面',
241
244
  },
242
245
  list: {
@@ -252,6 +255,11 @@ export default {
252
255
  },
253
256
  localSystem: {
254
257
  apiName: {
258
+ editLocalFile: '编辑文件',
259
+ getCommandOutput: '获取代码输出',
260
+ globLocalFiles: '匹配搜索文件',
261
+ grepContent: '搜索内容',
262
+ killCommand: '终止代码执行',
255
263
  listLocalFiles: '查看文件列表',
256
264
  moveLocalFiles: '移动文件',
257
265
  readLocalFile: '读取文件内容',