Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat: show orphaned tool message and support delete tool message (#10232)

Arvin Xu38cfd266f432
diff --git a/locales/ar/plugin.json b/locales/ar/plugin.json
index 46e81d03ff8..7d68229fe18 100644
--- a/locales/ar/plugin.json
+++ b/locales/ar/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "عرض قائمة المعلمات",
+ "delete": "حذف استدعاء الأداة",
+ "orphanedToolCall": "قد تكون رسالة استدعاء الأداة هذه معزولة بسبب ظروف غير طبيعية، مما قد يؤثر على تنفيذ الوكيل بشكل صحيح. يُرجى إزالتها.",
"pluginRender": "عرض واجهة الإضافة"
},
"list": {
diff --git a/locales/bg-BG/plugin.json b/locales/bg-BG/plugin.json
index 761331d88af..1ce0d17c00d 100644
--- a/locales/bg-BG/plugin.json
+++ b/locales/bg-BG/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "Преглед на списъка с параметри",
+ "delete": "Изтриване на извикване на инструмент",
+ "orphanedToolCall": "Това извикване на инструмент може да е станало изолирано поради необичайни причини, което може да повлияе на нормалното изпълнение на агента. Моля, премахнете го.",
"pluginRender": "Преглед на интерфейса на плъгина"
},
"list": {
diff --git a/locales/de-DE/plugin.json b/locales/de-DE/plugin.json
index d3cc9845bd4..1867251e65f 100644
--- a/locales/de-DE/plugin.json
+++ b/locales/de-DE/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "Parameterliste anzeigen",
+ "delete": "Werkzeugaufruf löschen",
+ "orphanedToolCall": "Dieser Werkzeugaufruf könnte aufgrund eines Fehlers verwaist sein, was den normalen Ablauf des Agenten beeinträchtigen kann. Bitte entfernen Sie ihn.",
"pluginRender": "Plugin-Oberfläche anzeigen"
},
"list": {
diff --git a/locales/en-US/plugin.json b/locales/en-US/plugin.json
index 00c6225930e..a8fd88eacdc 100644
--- a/locales/en-US/plugin.json
+++ b/locales/en-US/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "View Argument List",
+ "delete": "Delete Tool Call",
+ "orphanedToolCall": "This tool call message may have become orphaned due to an unexpected issue, which could affect the Agent's normal operation. Please remove it.",
"pluginRender": "View Plugin Interface"
},
"list": {
@@ -251,13 +253,18 @@
},
"localSystem": {
"apiName": {
+ "getCommandOutput": "Get Code Output",
+ "globLocalFiles": "Match Files",
+ "grepContent": "Search Content",
+ "killCommand": "Kill Code Execution",
"listLocalFiles": "View File List",
"moveLocalFiles": "Move Files",
"readLocalFile": "Read File Content",
"renameLocalFile": "Rename",
"runCommand": "Run Code",
"searchLocalFiles": "Search Files",
- "writeLocalFile": "Write File"
+ "writeLocalFile": "Write File",
+ "editLocalFile": "Edit File"
},
"title": "Local System"
},
diff --git a/locales/es-ES/plugin.json b/locales/es-ES/plugin.json
index 689a434d96d..36b011d83ef 100644
--- a/locales/es-ES/plugin.json
+++ b/locales/es-ES/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "Ver lista de parámetros",
+ "delete": "Eliminar llamada a la herramienta",
+ "orphanedToolCall": "Este mensaje de llamada a la herramienta podría haberse quedado huérfano debido a circunstancias excepcionales, lo que puede afectar el funcionamiento normal del agente. Por favor, elimínelo.",
"pluginRender": "Ver interfaz del plugin"
},
"list": {
diff --git a/locales/fa-IR/plugin.json b/locales/fa-IR/plugin.json
index 82305dd81c1..07c02f14b60 100644
--- a/locales/fa-IR/plugin.json
+++ b/locales/fa-IR/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "مشاهده لیست پارامترها",
+ "delete": "حذف فراخوانی ابزار",
+ "orphanedToolCall": "این پیام فراخوانی ابزار ممکن است به دلایل غیرعادی به یک پیام یتیم تبدیل شده باشد که می‌تواند عملکرد عادی عامل را مختل کند. لطفاً آن را حذف کنید.",
"pluginRender": "مشاهده رابط افزونه"
},
"list": {
diff --git a/locales/fr-FR/plugin.json b/locales/fr-FR/plugin.json
index dd4aa6945dd..b24f4ac95b7 100644
--- a/locales/fr-FR/plugin.json
+++ b/locales/fr-FR/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "Voir la liste des paramètres",
+ "delete": "Supprimer l'appel d'outil",
+ "orphanedToolCall": "Cet appel d'outil est peut-être devenu orphelin en raison d'une erreur, ce qui pourrait perturber le bon fonctionnement de l'agent. Veuillez le supprimer.",
"pluginRender": "Voir l'interface du plugin"
},
"list": {
diff --git a/locales/it-IT/plugin.json b/locales/it-IT/plugin.json
index 5b10422f3e6..c5f33e777e0 100644
--- a/locales/it-IT/plugin.json
+++ b/locales/it-IT/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "Visualizza lista parametri",
+ "delete": "Elimina chiamata allo strumento",
+ "orphanedToolCall": "Questo messaggio di chiamata allo strumento potrebbe essere diventato orfano a causa di un'anomalia, il che potrebbe compromettere il corretto funzionamento dell'agente. Si consiglia di rimuoverlo.",
"pluginRender": "Visualizza interfaccia plugin"
},
"list": {
diff --git a/locales/ja-JP/plugin.json b/locales/ja-JP/plugin.json
index 4375ba920b6..0a35f1435f6 100644
--- a/locales/ja-JP/plugin.json
+++ b/locales/ja-JP/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "パラメータリストを表示",
+ "delete": "ツール呼び出しを削除",
+ "orphanedToolCall": "このツール呼び出しメッセージは、異常な理由により孤立している可能性があり、エージェントの正常な実行に影響を与えることがあります。削除してください。",
"pluginRender": "プラグイン画面を表示"
},
"list": {
diff --git a/locales/ko-KR/plugin.json b/locales/ko-KR/plugin.json
index a030a0b6a04..8653db797f3 100644
--- a/locales/ko-KR/plugin.json
+++ b/locales/ko-KR/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "인자 목록 보기",
+ "delete": "도구 호출 삭제",
+ "orphanedToolCall": "이 도구 호출 메시지는 예기치 않은 이유로 고립되었을 수 있으며, 이는 에이전트의 정상적인 실행에 영향을 줄 수 있습니다. 제거해 주세요.",
"pluginRender": "플러그인 인터페이스 보기"
},
"list": {
diff --git a/locales/nl-NL/plugin.json b/locales/nl-NL/plugin.json
index 4d185437468..77b7eb4c98d 100644
--- a/locales/nl-NL/plugin.json
+++ b/locales/nl-NL/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "Bekijk parameterlijst",
+ "delete": "Hulpoproep verwijderen",
+ "orphanedToolCall": "Dit hulpoproepbericht is mogelijk geïsoleerd geraakt door een onverwachte fout, wat de normale werking van de agent kan beïnvloeden. Verwijder het alstublieft.",
"pluginRender": "Bekijk plugin-interface"
},
"list": {
diff --git a/locales/pl-PL/plugin.json b/locales/pl-PL/plugin.json
index 1835bb2be4b..d6543d7b74e 100644
--- a/locales/pl-PL/plugin.json
+++ b/locales/pl-PL/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "Zobacz listę argumentów",
+ "delete": "Usuń wywołanie narzędzia",
+ "orphanedToolCall": "To wywołanie narzędzia mogło zostać osierocone z powodu nieoczekiwanych okoliczności, co może zakłócić prawidłowe działanie Agenta. Proszę je usunąć.",
"pluginRender": "Zobacz interfejs wtyczki"
},
"list": {
diff --git a/locales/pt-BR/plugin.json b/locales/pt-BR/plugin.json
index 6826e63e4fe..1d6f1b0d1ba 100644
--- a/locales/pt-BR/plugin.json
+++ b/locales/pt-BR/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "Ver lista de parâmetros",
+ "delete": "Excluir chamada de ferramenta",
+ "orphanedToolCall": "Esta chamada de ferramenta pode ter se tornado uma mensagem órfã devido a um erro, o que pode afetar a execução normal do Agente. Por favor, remova-a.",
"pluginRender": "Ver interface do plugin"
},
"list": {
diff --git a/locales/ru-RU/plugin.json b/locales/ru-RU/plugin.json
index 40d8df30006..533b7be47e0 100644
--- a/locales/ru-RU/plugin.json
+++ b/locales/ru-RU/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "Просмотр списка параметров",
+ "delete": "Удалить вызов инструмента",
+ "orphanedToolCall": "Этот вызов инструмента, возможно, стал изолированным из-за непредвиденных обстоятельств, что может повлиять на корректную работу агента. Пожалуйста, удалите его.",
"pluginRender": "Просмотр интерфейса плагина"
},
"list": {
diff --git a/locales/tr-TR/plugin.json b/locales/tr-TR/plugin.json
index abc9c943842..bac44985b54 100644
--- a/locales/tr-TR/plugin.json
+++ b/locales/tr-TR/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "Parametre listesini görüntüle",
+ "delete": "Araç çağrısını sil",
+ "orphanedToolCall": "Bu araç çağrısı mesajı, beklenmeyen bir nedenle yetim kalmış olabilir ve bu durum Ajansın düzgün çalışmasını etkileyebilir. Lütfen bunu kaldırın.",
"pluginRender": "Eklenti arayüzünü görüntüle"
},
"list": {
diff --git a/locales/vi-VN/plugin.json b/locales/vi-VN/plugin.json
index 16dfe59a4e2..0398ef3e454 100644
--- a/locales/vi-VN/plugin.json
+++ b/locales/vi-VN/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "Xem danh sách tham số",
+ "delete": "Xoá lệnh gọi công cụ",
+ "orphanedToolCall": "Lệnh gọi công cụ này có thể đã trở thành một tin nhắn bị cô lập do sự cố bất thường, điều này có thể ảnh hưởng đến quá trình thực thi bình thường của Tác nhân. Vui lòng xoá nó.",
"pluginRender": "Xem giao diện plugin"
},
"list": {
diff --git a/locales/zh-CN/plugin.json b/locales/zh-CN/plugin.json
index 494ee02108a..536cab4edd1 100644
--- a/locales/zh-CN/plugin.json
+++ b/locales/zh-CN/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "查看参数列表",
+ "delete": "删除工具调用",
+ "orphanedToolCall": "该工具调用消息可能因异常原因成为孤立消息,这会影响 Agent 的正常执行,请将其移除",
"pluginRender": "查看插件界面"
},
"list": {
@@ -251,13 +253,18 @@
},
"localSystem": {
"apiName": {
+ "getCommandOutput": "获取代码输出",
+ "globLocalFiles": "匹配搜索文件",
+ "grepContent": "搜索内容",
+ "killCommand": "终止代码执行",
"listLocalFiles": "查看文件列表",
"moveLocalFiles": "移动文件",
"readLocalFile": "读取文件内容",
"renameLocalFile": "重命名",
"runCommand": "执行代码",
"searchLocalFiles": "搜索文件",
- "writeLocalFile": "写入文件"
+ "writeLocalFile": "写入文件",
+ "editLocalFile": "编辑文件"
},
"title": "本地系统"
},
diff --git a/locales/zh-TW/plugin.json b/locales/zh-TW/plugin.json
index a54036a7629..a662e48c5b0 100644
--- a/locales/zh-TW/plugin.json
+++ b/locales/zh-TW/plugin.json
@@ -236,6 +236,8 @@
},
"inspector": {
"args": "查看參數列表",
+ "delete": "刪除工具調用",
+ "orphanedToolCall": "該工具調用訊息可能因異常原因成為孤立訊息,這可能會影響 Agent 的正常執行,請將其移除",
"pluginRender": "查看插件介面"
},
"list": {
diff --git a/src/components/FileIcon/index.tsx b/src/components/FileIcon/index.tsx
index 5afe49c9807..d987243fe88 100644
--- a/src/components/FileIcon/index.tsx
+++ b/src/components/FileIcon/index.tsx
@@ -28,8 +28,6 @@ const FileIcon = memo<FileListProps>(({ fileName, size, variant = 'raw', isDirec
);
}
- console.log('FileIcon', fileName);
-
return <MaterialFileTypeIcon filename={fileName} size={size} type={'file'} variant={variant} />;
});
diff --git a/src/features/Conversation/Messages/Assistant/MessageContent.tsx b/src/features/Conversation/Messages/Assistant/MessageContent.tsx
index 3d59a9586f1..224d4b458de 100644
--- a/src/features/Conversation/Messages/Assistant/MessageContent.tsx
+++ b/src/features/Conversation/Messages/Assistant/MessageContent.tsx
@@ -12,7 +12,6 @@ import FileChunks from './FileChunks';
import IntentUnderstanding from './IntentUnderstanding';
import Reasoning from './Reasoning';
import SearchGrounding from './SearchGrounding';
-import Tool from './Tool';
export const AssistantMessageContent = memo<
UIChatMessage & {
@@ -67,23 +66,6 @@ export const AssistantMessageContent = memo<
/>
)}
{showImageItems && <ImageFileListViewer items={imageList} />}
- {tools && (
- <Flexbox gap={8}>
- {tools.map((toolCall, index) => (
- <Tool
- apiName={toolCall.apiName}
- arguments={toolCall.arguments}
- id={toolCall.id}
- identifier={toolCall.identifier}
- index={index}
- key={toolCall.id}
- messageId={id}
- payload={toolCall}
- type={toolCall.type}
- />
- ))}
- </Flexbox>
- )}
</Flexbox>
);
});
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Render/LoadingPlaceholder/index.tsx b/src/features/Conversation/Messages/Assistant/Tool/Render/LoadingPlaceholder/index.tsx
deleted file mode 100644
index b23b8a6775a..00000000000
--- a/src/features/Conversation/Messages/Assistant/Tool/Render/LoadingPlaceholder/index.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { safeParseJSON } from '@lobechat/utils';
-import { memo } from 'react';
-
-import { getBuiltinPlaceholder } from '@/tools/placeholders';
-
-import Arguments from '../Arguments';
-
-interface LoadingPlaceholderProps {
- apiName: string;
- identifier: string;
- loading?: boolean;
- requestArgs?: string;
-}
-
-const LoadingPlaceholder = memo<LoadingPlaceholderProps>(
- ({ identifier, requestArgs, apiName, loading }) => {
- const Render = getBuiltinPlaceholder(identifier, apiName);
-
- if (Render) {
- return (
- <Render apiName={apiName} args={safeParseJSON(requestArgs) || {}} identifier={identifier} />
- );
- }
-
- return <Arguments arguments={requestArgs} shine={loading} />;
- },
-);
-
-export default LoadingPlaceholder;
diff --git a/src/features/Conversation/Messages/Assistant/Tool/index.tsx b/src/features/Conversation/Messages/Assistant/Tool/index.tsx
deleted file mode 100644
index a4c21d0ffc7..00000000000
--- a/src/features/Conversation/Messages/Assistant/Tool/index.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { CSSProperties, memo, useEffect, useState } from 'react';
-import { Flexbox } from 'react-layout-kit';
-
-import AnimatedCollapsed from '@/components/AnimatedCollapsed';
-import { useChatStore } from '@/store/chat';
-import { messageStateSelectors } from '@/store/chat/selectors';
-
-import Inspectors from './Inspector';
-import Render from './Render';
-
-export interface InspectorProps {
- apiName: string;
- arguments?: string;
- id: string;
- identifier: string;
- index: number;
- messageId: string;
- payload: object;
- style?: CSSProperties;
- type?: string;
-}
-
-const Tool = memo<InspectorProps>(
- ({ arguments: requestArgs, apiName, messageId, id, index, identifier, style, payload, type }) => {
- const [showDetail, setShowDetail] = useState(type !== 'mcp');
- const [showPluginRender, setShowPluginRender] = useState(false);
- const isLoading = useChatStore(messageStateSelectors.isInToolsCalling(messageId, index));
-
- useEffect(() => {
- if (type !== 'mcp') return;
-
- setTimeout(
- () => {
- setShowDetail(isLoading);
- },
- isLoading ? 1 : 1500,
- );
- }, [isLoading]);
-
- return (
- <Flexbox gap={8} style={style}>
- <Inspectors
- apiName={apiName}
- arguments={requestArgs}
- // mcp don't have ui render
- hidePluginUI={type === 'mcp'}
- id={id}
- identifier={identifier}
- index={index}
- messageId={messageId}
- payload={payload}
- setShowPluginRender={setShowPluginRender}
- setShowRender={setShowDetail}
- showPluginRender={showPluginRender}
- showRender={showDetail}
- />
- <AnimatedCollapsed open={showDetail}>
- <Render
- apiName={apiName}
- identifier={identifier}
- messageId={messageId}
- requestArgs={requestArgs}
- setShowPluginRender={setShowPluginRender}
- showPluginRender={showPluginRender}
- toolCallId={id}
- toolIndex={index}
- />
- </AnimatedCollapsed>
- </Flexbox>
- );
- },
-);
-
-Tool.displayName = 'AssistantTool';
-
-export default Tool;
diff --git a/src/features/Conversation/Messages/Group/Tool/Inspector/index.tsx b/src/features/Conversation/Messages/Group/Tool/Inspector/index.tsx
index adef4be66c9..e377949340c 100644
--- a/src/features/Conversation/Messages/Group/Tool/Inspector/index.tsx
+++ b/src/features/Conversation/Messages/Group/Tool/Inspector/index.tsx
@@ -1,13 +1,23 @@
+import { ToolIntervention } from '@lobechat/types';
import { ActionIcon, Icon, Tooltip } from '@lobehub/ui';
import { createStyles } from 'antd-style';
-import { Ban, Check, LayoutPanelTop, LogsIcon, LucideBug, LucideBugOff, X } from 'lucide-react';
+import {
+ Ban,
+ Check,
+ LayoutPanelTop,
+ LogsIcon,
+ LucideBug,
+ LucideBugOff,
+ Trash2,
+ X,
+} from 'lucide-react';
import { CSSProperties, memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';
import { LOADING_FLAT } from '@/const/message';
+import { useChatStore } from '@/store/chat';
import { shinyTextStylish } from '@/styles/loading';
-import { ToolIntervention } from '@/types/message';
import Debug from './Debug';
import Settings from './Settings';
@@ -63,12 +73,12 @@ export const useStyles = createStyles(({ css, token, cx }) => ({
interface InspectorProps {
apiName: string;
arguments?: string;
+ assistantMessageId: string;
hidePluginUI?: boolean;
id: string;
identifier: string;
index: number;
intervention?: ToolIntervention;
- messageId: string;
result?: { content: string | null; error?: any; state?: any };
setShowPluginRender: (show: boolean) => void;
setShowRender: (show: boolean) => void;
@@ -81,7 +91,7 @@ interface InspectorProps {
const Inspectors = memo<InspectorProps>(
({
- messageId,
+ assistantMessageId,
index,
identifier,
apiName,
@@ -100,6 +110,8 @@ const Inspectors = memo<InspectorProps>(
const [showDebug, setShowDebug] = useState(false);
+ const [deleteAssistantMessage] = useChatStore((s) => [s.deleteAssistantMessage]);
+
const hasError = !!result?.error;
const hasSuccessResult = !!result?.content && result.content !== LOADING_FLAT;
@@ -128,7 +140,7 @@ const Inspectors = memo<InspectorProps>(
identifier={identifier}
index={index}
isLoading={isTitleLoading}
- messageId={messageId}
+ messageId={assistantMessageId}
toolCallId={id}
/>
</Flexbox>
@@ -152,6 +164,15 @@ const Inspectors = memo<InspectorProps>(
size={'small'}
title={t(showDebug ? 'debug.off' : 'debug.on')}
/>
+ <ActionIcon
+ icon={Trash2}
+ onClick={() => {
+ deleteAssistantMessage(assistantMessageId);
+ }}
+ size={'small'}
+ title={t('inspector.delete')}
+ />
+
<Settings id={identifier} />
</Flexbox>
{hasResult && (
diff --git a/src/features/Conversation/Messages/Group/Tool/index.tsx b/src/features/Conversation/Messages/Group/Tool/index.tsx
index edf3a24c815..7c7acd07c01 100644
--- a/src/features/Conversation/Messages/Group/Tool/index.tsx
+++ b/src/features/Conversation/Messages/Group/Tool/index.tsx
@@ -60,11 +60,11 @@ const Tool = memo<GroupToolProps>(
<Inspectors
apiName={apiName}
arguments={requestArgs}
+ assistantMessageId={assistantMessageId}
id={id}
identifier={identifier}
index={index}
intervention={intervention}
- messageId={assistantMessageId}
result={result}
setShowPluginRender={setShowCustomPluginUI}
setShowRender={setShowToolDetail}
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Inspector/BuiltinPluginTitle.tsx b/src/features/Conversation/Messages/Tool/Inspector/BuiltinPluginTitle.tsx
similarity index 100%
rename from src/features/Conversation/Messages/Assistant/Tool/Inspector/BuiltinPluginTitle.tsx
rename to src/features/Conversation/Messages/Tool/Inspector/BuiltinPluginTitle.tsx
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Inspector/Debug.tsx b/src/features/Conversation/Messages/Tool/Inspector/Debug.tsx
similarity index 100%
rename from src/features/Conversation/Messages/Assistant/Tool/Inspector/Debug.tsx
rename to src/features/Conversation/Messages/Tool/Inspector/Debug.tsx
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Inspector/PluginResult.tsx b/src/features/Conversation/Messages/Tool/Inspector/PluginResult.tsx
similarity index 100%
rename from src/features/Conversation/Messages/Assistant/Tool/Inspector/PluginResult.tsx
rename to src/features/Conversation/Messages/Tool/Inspector/PluginResult.tsx
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Inspector/PluginState.tsx b/src/features/Conversation/Messages/Tool/Inspector/PluginState.tsx
similarity index 100%
rename from src/features/Conversation/Messages/Assistant/Tool/Inspector/PluginState.tsx
rename to src/features/Conversation/Messages/Tool/Inspector/PluginState.tsx
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Inspector/Settings.tsx b/src/features/Conversation/Messages/Tool/Inspector/Settings.tsx
similarity index 100%
rename from src/features/Conversation/Messages/Assistant/Tool/Inspector/Settings.tsx
rename to src/features/Conversation/Messages/Tool/Inspector/Settings.tsx
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Inspector/ToolTitle.tsx b/src/features/Conversation/Messages/Tool/Inspector/ToolTitle.tsx
similarity index 88%
rename from src/features/Conversation/Messages/Assistant/Tool/Inspector/ToolTitle.tsx
rename to src/features/Conversation/Messages/Tool/Inspector/ToolTitle.tsx
index 11e48885d8d..b3dee1358f4 100644
--- a/src/features/Conversation/Messages/Assistant/Tool/Inspector/ToolTitle.tsx
+++ b/src/features/Conversation/Messages/Tool/Inspector/ToolTitle.tsx
@@ -6,8 +6,6 @@ import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';
-import { useChatStore } from '@/store/chat';
-import { messageStateSelectors } from '@/store/chat/selectors';
import { pluginHelpers, useToolStore } from '@/store/tool';
import { toolSelectors } from '@/store/tool/selectors';
import { shinyTextStylish } from '@/styles/loading';
@@ -43,10 +41,6 @@ const ToolTitle = memo<ToolTitleProps>(({ identifier, messageId, index, apiName,
const { t } = useTranslation('plugin');
const { styles } = useStyles();
- const isLoading = useChatStore(
- messageStateSelectors.isToolApiNameShining(messageId, index, toolCallId),
- );
-
const pluginMeta = useToolStore(toolSelectors.getMetaById(identifier), isEqual);
const plugins = useMemo(
@@ -84,7 +78,7 @@ const ToolTitle = memo<ToolTitleProps>(({ identifier, messageId, index, apiName,
const pluginTitle = pluginHelpers.getPluginTitle(pluginMeta) ?? t('unknownPlugin');
return (
- <Flexbox align={'center'} className={isLoading ? styles.shinyText : ''} gap={6} horizontal>
+ <Flexbox align={'center'} gap={6} horizontal>
<div>{pluginTitle}</div> <Icon icon={ChevronRight} />
<span className={styles.apiName}>{apiName}</span>
</Flexbox>
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Inspector/index.tsx b/src/features/Conversation/Messages/Tool/Inspector/index.tsx
similarity index 89%
rename from src/features/Conversation/Messages/Assistant/Tool/Inspector/index.tsx
rename to src/features/Conversation/Messages/Tool/Inspector/index.tsx
index 580a5465252..068400c1195 100644
--- a/src/features/Conversation/Messages/Assistant/Tool/Inspector/index.tsx
+++ b/src/features/Conversation/Messages/Tool/Inspector/index.tsx
@@ -68,10 +68,8 @@ interface InspectorProps {
messageId: string;
payload: object;
setShowPluginRender: (show: boolean) => void;
- setShowRender: (show: boolean) => void;
showPluginRender: boolean;
showPortal?: boolean;
- showRender: boolean;
style?: CSSProperties;
}
@@ -83,9 +81,7 @@ const Inspectors = memo<InspectorProps>(
apiName,
id,
arguments: requestArgs,
- showRender,
payload,
- setShowRender,
showPluginRender,
setShowPluginRender,
hidePluginUI = false,
@@ -98,16 +94,7 @@ const Inspectors = memo<InspectorProps>(
return (
<Flexbox className={styles.container} gap={4}>
<Flexbox align={'center'} distribution={'space-between'} gap={8} horizontal>
- <Flexbox
- align={'center'}
- className={styles.tool}
- gap={8}
- horizontal
- onClick={() => {
- setShowRender(!showRender);
- }}
- paddingInline={4}
- >
+ <Flexbox align={'center'} className={styles.tool} gap={8} horizontal paddingInline={4}>
<ToolTitle
apiName={apiName}
identifier={identifier}
@@ -117,7 +104,7 @@ const Inspectors = memo<InspectorProps>(
/>
</Flexbox>
<Flexbox className={styles.actions} horizontal>
- {showRender && !hidePluginUI && (
+ {!hidePluginUI && (
<ActionIcon
icon={showPluginRender ? LogsIcon : LayoutPanelTop}
onClick={() => {
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Render/Arguments/ObjectEntity.tsx b/src/features/Conversation/Messages/Tool/Render/Arguments/ObjectEntity.tsx
similarity index 100%
rename from src/features/Conversation/Messages/Assistant/Tool/Render/Arguments/ObjectEntity.tsx
rename to src/features/Conversation/Messages/Tool/Render/Arguments/ObjectEntity.tsx
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Render/Arguments/ValueCell.tsx b/src/features/Conversation/Messages/Tool/Render/Arguments/ValueCell.tsx
similarity index 100%
rename from src/features/Conversation/Messages/Assistant/Tool/Render/Arguments/ValueCell.tsx
rename to src/features/Conversation/Messages/Tool/Render/Arguments/ValueCell.tsx
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Render/Arguments/index.tsx b/src/features/Conversation/Messages/Tool/Render/Arguments/index.tsx
similarity index 100%
rename from src/features/Conversation/Messages/Assistant/Tool/Render/Arguments/index.tsx
rename to src/features/Conversation/Messages/Tool/Render/Arguments/index.tsx
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Render/CustomRender.tsx b/src/features/Conversation/Messages/Tool/Render/CustomRender.tsx
similarity index 97%
rename from src/features/Conversation/Messages/Assistant/Tool/Render/CustomRender.tsx
rename to src/features/Conversation/Messages/Tool/Render/CustomRender.tsx
index b8797aecc85..0fe4a163ef6 100644
--- a/src/features/Conversation/Messages/Assistant/Tool/Render/CustomRender.tsx
+++ b/src/features/Conversation/Messages/Tool/Render/CustomRender.tsx
@@ -7,11 +7,11 @@ import { memo, useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';
-import PluginResult from '@/features/Conversation/Messages/Assistant/Tool/Inspector/PluginResult';
import PluginRender from '@/features/PluginsUI/Render';
import { useChatStore } from '@/store/chat';
import { messageStateSelectors } from '@/store/chat/selectors';
+import PluginResult from '../Inspector/PluginResult';
import Arguments from './Arguments';
import KeyValueEditor from './KeyValueEditor';
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Render/ErrorResponse.tsx b/src/features/Conversation/Messages/Tool/Render/ErrorResponse.tsx
similarity index 100%
rename from src/features/Conversation/Messages/Assistant/Tool/Render/ErrorResponse.tsx
rename to src/features/Conversation/Messages/Tool/Render/ErrorResponse.tsx
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Render/KeyValueEditor.tsx b/src/features/Conversation/Messages/Tool/Render/KeyValueEditor.tsx
similarity index 100%
rename from src/features/Conversation/Messages/Assistant/Tool/Render/KeyValueEditor.tsx
rename to src/features/Conversation/Messages/Tool/Render/KeyValueEditor.tsx
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Render/PluginSettings.tsx b/src/features/Conversation/Messages/Tool/Render/PluginSettings.tsx
similarity index 94%
rename from src/features/Conversation/Messages/Assistant/Tool/Render/PluginSettings.tsx
rename to src/features/Conversation/Messages/Tool/Render/PluginSettings.tsx
index 879ffe9be53..750d936efda 100644
--- a/src/features/Conversation/Messages/Assistant/Tool/Render/PluginSettings.tsx
+++ b/src/features/Conversation/Messages/Tool/Render/PluginSettings.tsx
@@ -1,4 +1,3 @@
-import { ChatPluginPayload } from '@lobechat/types';
import { Avatar, Button } from '@lobehub/ui';
import { Divider } from 'antd';
import { useTheme } from 'antd-style';
@@ -11,8 +10,9 @@ import PluginSettingsConfig from '@/features/PluginSettings';
import { useChatStore } from '@/store/chat';
import { pluginHelpers, useToolStore } from '@/store/tool';
import { pluginSelectors } from '@/store/tool/selectors';
+import { ChatPluginPayload } from '@/types/index';
-import { ErrorActionContainer, useStyles } from '../../../../Error/style';
+import { ErrorActionContainer, useStyles } from '../../../Error/style';
interface PluginSettingsProps {
id: string;
diff --git a/src/features/Conversation/Messages/Assistant/Tool/Render/index.tsx b/src/features/Conversation/Messages/Tool/Render/index.tsx
similarity index 59%
rename from src/features/Conversation/Messages/Assistant/Tool/Render/index.tsx
rename to src/features/Conversation/Messages/Tool/Render/index.tsx
index 53adf65efe5..5fff506fe38 100644
--- a/src/features/Conversation/Messages/Assistant/Tool/Render/index.tsx
+++ b/src/features/Conversation/Messages/Tool/Render/index.tsx
@@ -1,4 +1,3 @@
-import { LOADING_FLAT } from '@lobechat/const';
import { Suspense, memo } from 'react';
import { useChatStore } from '@/store/chat';
@@ -6,11 +5,8 @@ import { dbMessageSelectors, messageStateSelectors } from '@/store/chat/selector
import CustomRender from './CustomRender';
import ErrorResponse from './ErrorResponse';
-import LoadingPlaceholder from './LoadingPlaceholder';
interface RenderProps {
- apiName: string;
- identifier: string;
messageId: string;
requestArgs?: string;
setShowPluginRender: (show: boolean) => void;
@@ -20,16 +16,7 @@ interface RenderProps {
}
const Render = memo<RenderProps>(
- ({
- toolCallId,
- toolIndex,
- messageId,
- requestArgs,
- showPluginRender,
- setShowPluginRender,
- identifier,
- apiName,
- }) => {
+ ({ toolCallId, toolIndex, messageId, requestArgs, showPluginRender, setShowPluginRender }) => {
const loading = useChatStore(messageStateSelectors.isToolCallStreaming(messageId, toolIndex));
const toolMessage = useChatStore(dbMessageSelectors.getDbMessageByToolCallId(toolCallId));
@@ -40,24 +27,8 @@ const Render = memo<RenderProps>(
return <ErrorResponse {...toolMessage.error} id={messageId} plugin={toolMessage.plugin} />;
}
- const placeholder = (
- <LoadingPlaceholder
- apiName={apiName}
- identifier={identifier}
- loading
- requestArgs={requestArgs}
- />
- );
-
- // 如果是 LOADING_FLAT 则说明还在加载中
- // 而 standalone 模式的插件 content 应该始终是 LOADING_FLAT
- const inPlaceholder =
- toolMessage.content === LOADING_FLAT && toolMessage.plugin?.type !== 'standalone';
-
- if (inPlaceholder) return placeholder;
-
return (
- <Suspense fallback={placeholder}>
+ <Suspense>
<CustomRender
{...toolMessage}
requestArgs={requestArgs}
diff --git a/src/features/Conversation/Messages/Tool/ToolItem.tsx b/src/features/Conversation/Messages/Tool/ToolItem.tsx
new file mode 100644
index 00000000000..24b5d5f9cd4
--- /dev/null
+++ b/src/features/Conversation/Messages/Tool/ToolItem.tsx
@@ -0,0 +1,51 @@
+import { CSSProperties, memo, useState } from 'react';
+import { Flexbox } from 'react-layout-kit';
+
+import Inspectors from './Inspector';
+import Render from './Render';
+
+export interface InspectorProps {
+ apiName: string;
+ arguments?: string;
+ identifier: string;
+ index: number;
+ messageId: string;
+ payload: object;
+ style?: CSSProperties;
+ toolCallId: string;
+ type?: string;
+}
+
+const Tool = memo<InspectorProps>(
+ ({ arguments: requestArgs, apiName, messageId, toolCallId, index, identifier, payload }) => {
+ const [showPluginRender, setShowPluginRender] = useState(false);
+
+ return (
+ <Flexbox gap={8} style={{ paddingBottom: 12 }}>
+ <Inspectors
+ apiName={apiName}
+ arguments={requestArgs}
+ id={toolCallId}
+ identifier={identifier}
+ index={index}
+ messageId={messageId}
+ payload={payload}
+ setShowPluginRender={setShowPluginRender}
+ showPluginRender={showPluginRender}
+ />
+ <Render
+ messageId={messageId}
+ requestArgs={requestArgs}
+ setShowPluginRender={setShowPluginRender}
+ showPluginRender={showPluginRender}
+ toolCallId={toolCallId}
+ toolIndex={index}
+ />
+ </Flexbox>
+ );
+ },
+);
+
+Tool.displayName = 'AssistantTool';
+
+export default Tool;
diff --git a/src/features/Conversation/Messages/Tool/index.tsx b/src/features/Conversation/Messages/Tool/index.tsx
new file mode 100644
index 00000000000..af28aeb29d5
--- /dev/null
+++ b/src/features/Conversation/Messages/Tool/index.tsx
@@ -0,0 +1,58 @@
+import { Alert } from '@lobehub/ui';
+import { Button } from 'antd';
+import isEqual from 'fast-deep-equal';
+import { memo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { Flexbox } from 'react-layout-kit';
+
+import { useChatStore } from '@/store/chat';
+import { dbMessageSelectors } from '@/store/chat/selectors';
+import { UIChatMessage } from '@/types/message';
+
+import ToolItem from './ToolItem';
+
+interface ToolMessageProps {
+ id: string;
+ index: number;
+}
+
+const Tool = memo<ToolMessageProps>(({ id, index }) => {
+ const { t } = useTranslation('plugin');
+ const item = useChatStore(dbMessageSelectors.getDbMessageById(id), isEqual) as UIChatMessage;
+ const deleteToolMessage = useChatStore((s) => s.deleteToolMessage);
+ const [loading, setLoading] = useState(false);
+
+ const handleDelete = async () => {
+ setLoading(true);
+ try {
+ await deleteToolMessage(id);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ return (
+ <Flexbox gap={4} paddingBlock={12} paddingInline={12}>
+ <Alert
+ action={
+ <Button loading={loading} onClick={handleDelete} size={'small'} type={'primary'}>
+ {t('inspector.delete')}
+ </Button>
+ }
+ message={t('inspector.orphanedToolCall')}
+ type={'warning'}
+ variant={'borderless'}
+ />
+ {item.plugin && (
+ <ToolItem
+ {...item.plugin}
+ index={index}
+ messageId={id}
+ payload={item.plugin || {}}
+ toolCallId={item.tool_call_id!}
+ />
+ )}
+ </Flexbox>
+ );
+});
+export default Tool;
diff --git a/src/features/Conversation/Messages/index.tsx b/src/features/Conversation/Messages/index.tsx
index bd7b4ebbabc..a2f80cd8da1 100644
--- a/src/features/Conversation/Messages/index.tsx
+++ b/src/features/Conversation/Messages/index.tsx
@@ -18,6 +18,7 @@ import { InPortalThreadContext } from '../context/InPortalThreadContext';
import AssistantMessage from './Assistant';
import GroupMessage from './Group';
import SupervisorMessage from './Supervisor';
+import ToolMessage from './Tool';
import UserMessage from './User';
const useStyles = createStyles(({ css, prefixCls }) => ({
@@ -133,6 +134,10 @@ const Item = memo<ChatListItemProps>(
return <GroupMessage disableEditing={disableEditing} id={id} index={index} />;
}
+ case 'tool': {
+ return <ToolMessage id={id} index={index} />;
+ }
+
case 'supervisor': {
return <SupervisorMessage disableEditing={disableEditing} id={id} index={index} />;
}
diff --git a/src/features/ShareModal/ShareJSON/index.tsx b/src/features/ShareModal/ShareJSON/index.tsx
index fa3bca3cd51..e957d68d344 100644
--- a/src/features/ShareModal/ShareJSON/index.tsx
+++ b/src/features/ShareModal/ShareJSON/index.tsx
@@ -12,7 +12,7 @@ import { useIsMobile } from '@/hooks/useIsMobile';
import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/selectors';
import { useChatStore } from '@/store/chat';
-import { chatSelectors, topicSelectors } from '@/store/chat/selectors';
+import { dbMessageSelectors, topicSelectors } from '@/store/chat/selectors';
import { useStyles } from '../style';
import Preview from './Preview';
@@ -50,7 +50,7 @@ const ShareImage = memo(() => {
];
const systemRole = useAgentStore(agentSelectors.currentAgentSystemRole);
- const messages = useChatStore(chatSelectors.activeBaseChats, isEqual);
+ const messages = useChatStore(dbMessageSelectors.activeDbMessages, isEqual);
const data = generateMessages({ ...fieldValue, messages, systemRole });
const content = JSON.stringify(data, null, 2);
diff --git a/src/locales/default/plugin.ts b/src/locales/default/plugin.ts
index 46d8cce6848..ee3cd92e611 100644
--- a/src/locales/default/plugin.ts
+++ b/src/locales/default/plugin.ts
@@ -237,6 +237,9 @@ export default {
},
inspector: {
args: '查看参数列表',
+ delete: '删除工具调用',
+ orphanedToolCall:
+ '该工具调用消息可能因异常原因成为孤立消息,这会影响 Agent 的正常执行,请将其移除',
pluginRender: '查看插件界面',
},
list: {
@@ -252,6 +255,11 @@ export default {
},
localSystem: {
apiName: {
+ editLocalFile: '编辑文件',
+ getCommandOutput: '获取代码输出',
+ globLocalFiles: '匹配搜索文件',
+ grepContent: '搜索内容',
+ killCommand: '终止代码执行',
listLocalFiles: '查看文件列表',
moveLocalFiles: '移动文件',
readLocalFile: '读取文件内容',
diff --git a/src/store/chat/slices/message/action.test.ts b/src/store/chat/slices/message/action.test.ts
index 480975034fd..b91dea1850e 100644
--- a/src/store/chat/slices/message/action.test.ts
+++ b/src/store/chat/slices/message/action.test.ts
@@ -227,13 +227,16 @@ describe('chatMessage actions', () => {
expect(replaceMessagesSpy).toHaveBeenCalledWith(mockMessages);
});
- it('deleteMessage should remove messages with tools', async () => {
+ it('deleteMessage should remove the message only', async () => {
const { result } = renderHook(() => useChatStore());
const messageId = 'message-id';
const removeMessagesSpy = vi.spyOn(messageService, 'removeMessages');
- const mockMessages = [{ id: 'remaining-message' }] as any;
+ const mockMessages = [
+ { id: '2', tool_call_id: 'tool1', role: 'tool' },
+ { id: '3', tool_call_id: 'tool2', role: 'tool' },
+ ] as any;
- // Mock the service to return messages
+ // Mock the service to return remaining messages (orphaned tool messages)
(messageService.removeMessages as Mock).mockResolvedValue({
success: true,
messages: mockMessages,
@@ -258,7 +261,8 @@ describe('chatMessage actions', () => {
await result.current.deleteMessage(messageId);
});
- expect(removeMessagesSpy).toHaveBeenCalledWith([messageId, '2', '3'], {
+ // Only the message itself should be deleted, tool messages remain as orphaned
+ expect(removeMessagesSpy).toHaveBeenCalledWith([messageId], {
sessionId: 'session-id',
topicId: undefined,
});
diff --git a/src/store/chat/slices/message/actions/optimisticUpdate.ts b/src/store/chat/slices/message/actions/optimisticUpdate.ts
index 95a2a7e9b76..b13c1462065 100644
--- a/src/store/chat/slices/message/actions/optimisticUpdate.ts
+++ b/src/store/chat/slices/message/actions/optimisticUpdate.ts
@@ -41,6 +41,7 @@ export interface MessageOptimisticUpdateAction {
* delete the message content with optimistic update
*/
optimisticDeleteMessage: (id: string) => Promise<void>;
+ optimisticDeleteMessages: (ids: string[]) => Promise<void>;
/**
* update the message content with optimistic update
@@ -154,6 +155,17 @@ export const messageOptimisticUpdate: StateCreator<
}
},
+ optimisticDeleteMessages: async (ids) => {
+ get().internal_dispatchMessage({ ids, type: 'deleteMessages' });
+ const result = await messageService.removeMessages(ids, {
+ sessionId: get().activeId,
+ topicId: get().activeTopicId,
+ });
+ if (result?.success && result.messages) {
+ get().replaceMessages(result.messages);
+ }
+ },
+
optimisticUpdateMessageContent: async (id, content, extra) => {
const {
internal_dispatchMessage,
diff --git a/src/store/chat/slices/message/actions/publicApi.ts b/src/store/chat/slices/message/actions/publicApi.ts
index 63e70dcaebc..cafe0fb949d 100644
--- a/src/store/chat/slices/message/actions/publicApi.ts
+++ b/src/store/chat/slices/message/actions/publicApi.ts
@@ -31,6 +31,7 @@ export interface MessagePublicApiAction {
*/
clearMessage: () => Promise<void>;
deleteMessage: (id: string) => Promise<void>;
+ deleteAssistantMessage: (id: string) => Promise<void>;
deleteDBMessage: (id: string) => Promise<void>;
deleteToolMessage: (id: string) => Promise<void>;
clearAllMessages: () => Promise<void>;
@@ -97,12 +98,28 @@ export const messagePublicApi: StateCreator<
}
},
+ deleteAssistantMessage: async (id) => {
+ const message = dbMessageSelectors.getDbMessageById(id)(get());
+ if (!message) return;
+
+ let ids = [message.id];
+ if (message.tools) {
+ const allMessages = dbMessageSelectors.activeDbMessages(get());
+
+ const toolMessageIds = message.tools.flatMap((tool) => {
+ const messages = allMessages.filter((m) => m.tool_call_id === tool.id);
+ return messages.map((m) => m.id);
+ });
+ ids = ids.concat(toolMessageIds);
+ }
+
+ await get().optimisticDeleteMessages(ids);
+ },
deleteMessage: async (id) => {
const message = displayMessageSelectors.getDisplayMessageById(id)(get());
if (!message) return;
let ids = [message.id];
- const allMessages = displayMessageSelectors.activeDisplayMessages(get());
// Handle assistantGroup messages: delete all child blocks and tool results
if (message.role === 'assistantGroup' && message.children) {
@@ -117,23 +134,8 @@ export const messagePublicApi: StateCreator<
});
ids = ids.concat(toolResultIds);
}
- // Handle regular messages with tools: find and delete related tool messages
- else if (message.tools) {
- const toolMessageIds = message.tools.flatMap((tool) => {
- const messages = allMessages.filter((m) => m.tool_call_id === tool.id);
- return messages.map((m) => m.id);
- });
- ids = ids.concat(toolMessageIds);
- }
- get().internal_dispatchMessage({ type: 'deleteMessages', ids });
- const result = await messageService.removeMessages(ids, {
- sessionId: get().activeId,
- topicId: get().activeTopicId,
- });
- if (result?.success && result.messages) {
- get().replaceMessages(result.messages);
- }
+ await get().optimisticDeleteMessages(ids);
},
deleteDBMessage: async (id) => {
diff --git a/src/tools/local-system/index.ts b/src/tools/local-system/index.ts
index 9b1f72595ea..d53c664e4cc 100644
--- a/src/tools/local-system/index.ts
+++ b/src/tools/local-system/index.ts
@@ -203,6 +203,33 @@ export const LocalSystemManifest: BuiltinToolManifest = {
type: 'object',
},
},
+ {
+ description:
+ 'Perform exact string replacements in files. Must read the file first before editing.',
+ name: LocalSystemApiName.editLocalFile,
+ parameters: {
+ properties: {
+ file_path: {
+ description: 'The absolute path to the file to modify',
+ type: 'string',
+ },
+ new_string: {
+ description: 'The text to replace with (must differ from old_string)',
+ type: 'string',
+ },
+ old_string: {
+ description: 'The exact text to replace',
+ type: 'string',
+ },
+ replace_all: {
+ description: 'Replace all occurrences of old_string (default: false)',
+ type: 'boolean',
+ },
+ },
+ required: ['file_path', 'old_string', 'new_string'],
+ type: 'object',
+ },
+ },
{
description:
'Execute a shell command and return its output. Supports both synchronous and background execution with timeout control.',
@@ -349,33 +376,6 @@ export const LocalSystemManifest: BuiltinToolManifest = {
type: 'object',
},
},
- {
- description:
- 'Perform exact string replacements in files. Must read the file first before editing.',
- name: LocalSystemApiName.editLocalFile,
- parameters: {
- properties: {
- file_path: {
- description: 'The absolute path to the file to modify',
- type: 'string',
- },
- new_string: {
- description: 'The text to replace with (must differ from old_string)',
- type: 'string',
- },
- old_string: {
- description: 'The exact text to replace',
- type: 'string',
- },
- replace_all: {
- description: 'Replace all occurrences of old_string (default: false)',
- type: 'boolean',
- },
- },
- required: ['file_path', 'old_string', 'new_string'],
- type: 'object',
- },
- },
],
identifier: 'lobe-local-system',
meta: {
diff --git a/src/tools/local-system/systemRole.ts b/src/tools/local-system/systemRole.ts
index 8569cb1e1cd..457bee776b1 100644
--- a/src/tools/local-system/systemRole.ts
+++ b/src/tools/local-system/systemRole.ts
@@ -19,17 +19,17 @@ You have access to a set of tools to interact with the user's local file system:
1. **listLocalFiles**: Lists files and directories in a specified path.
2. **readLocalFile**: Reads the content of a specified file, optionally within a line range. You can read file types such as Word, Excel, PowerPoint, PDF, and plain text files.
3. **writeLocalFile**: Write content to a specific file, only support plain text file like \`.text\` or \`.md\`
-4. **searchLocalFiles**: Searches for files based on keywords and other criteria using Spotlight (macOS) or native search. Use this tool to find files if the user is unsure about the exact path.
+4. **editLocalFile**: Performs exact string replacements in files. Must read the file first before editing.
5. **renameLocalFile**: Renames a single file or directory in its current location.
6. **moveLocalFiles**: Moves multiple files or directories. Can be used for renaming during the move.
-7. **editLocalFile**: Performs exact string replacements in files. Must read the file first before editing.
**Shell Commands:**
-8. **runCommand**: Execute shell commands with timeout control. Supports both synchronous and background execution. When providing a description, always use the same language as the user's input.
-9. **getCommandOutput**: Retrieve output from running background commands. Returns only new output since last check.
-10. **killCommand**: Terminate a running background shell command by its ID.
+7. **runCommand**: Execute shell commands with timeout control. Supports both synchronous and background execution. When providing a description, always use the same language as the user's input.
+8. **getCommandOutput**: Retrieve output from running background commands. Returns only new output since last check.
+9. **killCommand**: Terminate a running background shell command by its ID.
**Search & Find:**
+10. **searchLocalFiles**: Searches for files based on keywords and other criteria using Spotlight (macOS) or native search. Use this tool to find files if the user is unsure about the exact path.
11. **grepContent**: Search for content within files using regex patterns. Supports various output modes, filtering, and context lines.
12. **globLocalFiles**: Find files matching glob patterns (e.g., "**/*.js", "*.{ts,tsx}").
</core_capabilities>
@@ -37,9 +37,9 @@ You have access to a set of tools to interact with the user's local file system:
<workflow>
1. Understand the user's request regarding local operations (files, commands, searches).
2. Select the appropriate tool:
- - File operations: listLocalFiles, readLocalFile, writeLocalFile, editLocalFile, searchLocalFiles, renameLocalFile, moveLocalFiles
+ - File operations: listLocalFiles, readLocalFile, writeLocalFile, editLocalFile, renameLocalFile, moveLocalFiles
- Shell commands: runCommand, getCommandOutput, killCommand
- - Search/Find: grepContent, globLocalFiles
+ - Search/Find: searchLocalFiles, grepContent, globLocalFiles
3. Execute the operation. **If the user mentions a common location (like Desktop, Documents, Downloads, etc.) without providing a full path, use the corresponding path from the <user_context> section.**
4. Present the results or confirmation.
</workflow>