π€― 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(local-system): drop the per-environment readFile description (#21561)
Arvin Xuce40c1e4c173
diff --git a/.agents/skills/builtin-tool/references/tool-design.md b/.agents/skills/builtin-tool/references/tool-design.mdindex a50a7a8af8b..5077b0f55b0 100644--- a/.agents/skills/builtin-tool/references/tool-design.md+++ b/.agents/skills/builtin-tool/references/tool-design.md@@ -194,7 +194,7 @@ When planning work:- **Disambiguate confusable APIs explicitly** (`runTask` vs `updateTaskStatus`).- **Push toward batched APIs** ("Prefer this whenβ¦").- **End with a numbered workflow** if the tool has a typical sequence.-- **For tools with multiple environments** (e.g. desktop vs cloud), keep variants in `systemRole.ts` and `systemRole.desktop.ts` and pick at the manifest level. See `builtin-tool-local-system`.+- **For tools with multiple environments** (e.g. desktop vs cloud), variants in `systemRole.ts` + `systemRole.desktop.ts` picked at the manifest level are fine β but only while the content genuinely differs. `builtin-tool-local-system` forked them for image reads; once every runtime could upload images the fork held nothing but drift, so it was merged back.### Dynamic system promptsdiff --git a/packages/builtin-tool-local-system/src/__tests__/systemRole.test.ts b/packages/builtin-tool-local-system/src/__tests__/systemRole.test.tsindex 1ac608d50c2..2d02f802537 100644--- a/packages/builtin-tool-local-system/src/__tests__/systemRole.test.ts+++ b/packages/builtin-tool-local-system/src/__tests__/systemRole.test.ts@@ -1,36 +1,24 @@import { describe, expect, it } from 'vitest';-import { systemPrompt as genericPrompt } from '../systemRole';-import { systemPrompt as desktopPrompt } from '../systemRole.desktop';+import { systemPrompt } from '../systemRole';-const extractPlaceholders = (template: string): Set<string> =>- new Set([...template.matchAll(/\{\{(\w+)\}\}/g)].map((match) => match[1]));--describe('systemRole templates', () => {- /**- * The generic template is what the server renders for gateway runs; the- * `.desktop` variant is a client-only vite module swap. Keep the environment- * facts in sync: a placeholder present only in the desktop variant means- * gateway prompts silently lose information the local prompt has (this is- * how gateway runs ended up without the known-locations list).- */- it('generic template carries every placeholder the desktop variant has', () => {- const generic = extractPlaceholders(genericPrompt);- const desktopOnly = [...extractPlaceholders(desktopPrompt)].filter((key) => !generic.has(key));-- expect(desktopOnly).toEqual([]);+describe('systemRole template', () => {+ it('pairs {{defaultShell}} with {{shellSyntaxGuidance}}', () => {+ expect(systemPrompt).toContain('{{defaultShell}}');+ expect(systemPrompt).toContain('{{shellSyntaxGuidance}}');});- it('both templates pair {{defaultShell}} with {{shellSyntaxGuidance}}', () => {- for (const template of [genericPrompt, desktopPrompt]) {- expect(template).toContain('{{defaultShell}}');- expect(template).toContain('{{shellSyntaxGuidance}}');- }+ it('teaches image reads and the localFile response format', () => {+ expect(systemPrompt).toContain('Image files are uploaded as visual tool results');+ expect(systemPrompt).toContain('base64');+ expect(systemPrompt).toContain('<localFile');});- it('teaches image reads only in the desktop template', () => {- expect(desktopPrompt).toContain('readFile');- expect(desktopPrompt).toContain('base64');- expect(genericPrompt).not.toContain('base64');+ /**+ * `{{hostname}}` has no generator in the desktop placeholder map, so a+ * template that references it renders the raw token on the desktop client.+ */+ it('only references placeholders every host can render', () => {+ expect(systemPrompt).not.toContain('{{hostname}}');});});diff --git a/packages/builtin-tool-local-system/src/index.ts b/packages/builtin-tool-local-system/src/index.tsindex aa7d7ed48dd..aae77ff09ad 100644--- a/packages/builtin-tool-local-system/src/index.ts+++ b/packages/builtin-tool-local-system/src/index.ts@@ -1,6 +1,5 @@export { createPathScopeAudit, pathScopeAudit } from './interventionAudit';export { LocalSystemManifest } from './manifest';-export { resolveLocalSystemManifest } from './resolveManifest';export { getShellSyntaxGuidance } from './shellSyntaxGuidance';export { systemPrompt } from './systemRole';export {diff --git a/packages/builtin-tool-local-system/src/manifest.ts b/packages/builtin-tool-local-system/src/manifest.tsindex e9a5184caf2..21bbdf840ef 100644--- a/packages/builtin-tool-local-system/src/manifest.ts+++ b/packages/builtin-tool-local-system/src/manifest.ts@@ -3,10 +3,13 @@ import { type BuiltinToolManifest } from '@lobechat/types';import { systemPrompt } from './systemRole';import { LocalSystemApiName, LocalSystemIdentifier } from './types';+/**+ * Every runtime that can execute this tool β the desktop IPC path, a routed+ * device (`lh connect` or the desktop gateway) and the cloud sandbox β uploads+ * an image before returning it, so `readFile` can always hand the model a+ * visual result. The description therefore has no environment-specific variant.+ */export const READ_FILE_DESCRIPTION =- 'Read the content of a text or document file (txt/md/json/source code/pdf/docx/etc.). Binary files (.bin/.exe/.zip/.b64/encoded blobs) are rejected with a structured error β use runCommand with file/hexdump/strings to inspect those instead. Output is capped at 500K chars total and 8K chars per line; for larger files, use a narrower line range or grepContent.';--export const IMAGE_CAPABLE_READ_FILE_DESCRIPTION ='Read text and document files (txt/md/json/source code/pdf/docx/etc.) or local image files (PNG/JPEG/GIF/WebP). For a local image path, call readFile directly so the image is uploaded as a visual tool result. Never use shell commands to convert images to base64/data URI text or copy encoded image data between tools. Other binary files (.bin/.exe/.zip/.b64/encoded blobs) are rejected with a structured error β use runCommand with file/hexdump/strings to inspect those instead. Text output is capped at 500K chars total and 8K chars per line; for larger files, use a narrower line range or grepContent.';export const LocalSystemManifest: BuiltinToolManifest = {diff --git a/packages/builtin-tool-local-system/src/resolveManifest.test.ts b/packages/builtin-tool-local-system/src/resolveManifest.test.tsdeleted file mode 100644index 5d611204ee7..00000000000--- a/packages/builtin-tool-local-system/src/resolveManifest.test.ts+++ /dev/null@@ -1,46 +0,0 @@-import { describe, expect, it } from 'vitest';--import {- IMAGE_CAPABLE_READ_FILE_DESCRIPTION,- LocalSystemManifest,- READ_FILE_DESCRIPTION,-} from './manifest';-import { resolveLocalSystemManifest } from './resolveManifest';-import { LocalSystemApiName } from './types';--const readFileDescription = (- executionEnv?: 'device' | 'device-unrouted' | 'local' | 'none' | 'sandbox',-) =>- resolveLocalSystemManifest({ executionEnv })?.api.find(- (api) => api.name === LocalSystemApiName.readFile,- )?.description;--describe('resolveLocalSystemManifest', () => {- it('keeps the context-free manifest limited to portable file capabilities', () => {- const description = LocalSystemManifest.api.find(- (api) => api.name === LocalSystemApiName.readFile,- )?.description;-- expect(description).toBe(READ_FILE_DESCRIPTION);- expect(description).not.toContain('PNG');- });-- it('advertises direct image reads for the desktop local runtime', () => {- const manifest = resolveLocalSystemManifest({ executionEnv: 'local' });-- expect(readFileDescription('local')).toBe(IMAGE_CAPABLE_READ_FILE_DESCRIPTION);- expect(readFileDescription('local')).toContain('base64');- expect(manifest?.systemRole).toContain('Image files are uploaded as visual tool results');- });-- it.each([undefined, 'device', 'device-unrouted', 'none', 'sandbox'] as const)(- 'keeps %s instructions aligned with portable file capabilities',- (executionEnv) => {- const manifest = resolveLocalSystemManifest({ executionEnv });-- expect(readFileDescription(executionEnv)).toBe(READ_FILE_DESCRIPTION);- expect(manifest?.systemRole).not.toContain('base64');- expect(manifest?.systemRole).not.toContain('local images such as PNG');- },- );-});diff --git a/packages/builtin-tool-local-system/src/resolveManifest.ts b/packages/builtin-tool-local-system/src/resolveManifest.tsdeleted file mode 100644index 41d43ae76aa..00000000000--- a/packages/builtin-tool-local-system/src/resolveManifest.ts+++ /dev/null@@ -1,26 +0,0 @@-import type { BuiltinManifestResolver } from '@lobechat/types';--import { IMAGE_CAPABLE_READ_FILE_DESCRIPTION, LocalSystemManifest } from './manifest';-import { systemPrompt as desktopSystemPrompt } from './systemRole.desktop';-import { LocalSystemApiName } from './types';--/**- * Image reads are currently implemented only by the Desktop local IPC path.- * Device runs use local-file-shell, which rejects binary image files, so their- * manifest must not instruct the model to call an unsupported capability.- */-export const resolveLocalSystemManifest: BuiltinManifestResolver = (context) => {- if (context.executionEnv !== 'local') {- return LocalSystemManifest;- }-- return {- ...LocalSystemManifest,- api: LocalSystemManifest.api.map((api) =>- api.name === LocalSystemApiName.readFile- ? { ...api, description: IMAGE_CAPABLE_READ_FILE_DESCRIPTION }- : api,- ),- systemRole: desktopSystemPrompt,- };-};diff --git a/packages/builtin-tool-local-system/src/systemRole.desktop.ts b/packages/builtin-tool-local-system/src/systemRole.desktop.tsdeleted file mode 100644index 290a3359b0c..00000000000--- a/packages/builtin-tool-local-system/src/systemRole.desktop.ts+++ /dev/null@@ -1,141 +0,0 @@-export const systemPrompt = `You have a Local System tool with capabilities to interact with the user's local system. You can read file contents, search for files, move and rename files/directories, and run shell commands.--<user_context>-**Current Working Directory:** {{workingDirectory}}-All relative paths and file operations should be based on this directory unless the user specifies otherwise.--**Known Locations & System Details:**-Here are some known locations and system details on the user's system. User is using the Operating System: {{platform}}({{arch}}).-Use these paths when the user refers to these common locations by name (e.g., "my desktop", "downloads folder").-- Desktop: {{desktopPath}}-- Documents: {{documentsPath}}-- Downloads: {{downloadsPath}}-- Music: {{musicPath}}-- Pictures: {{picturesPath}}-- Videos: {{videosPath}}-- User Home: {{homePath}}-- App Data: {{userDataPath}} (Use this primarily for plugin-related data or configurations if needed, less for general user files)-</user_context>--<core_capabilities>-You have access to a set of tools to interact with the user's local file system:--**File Operations:**-1. **readFile**: Reads documents, text files, and local images such as PNG, JPEG, GIF, and WebP. Image files are uploaded as visual tool results.-2. **writeFile**: Write content to a specific file, only support plain text file like \`.text\` or \`.md\`-3. **editFile**: Performs exact string replacements in files. Must read the file first before editing.-4. **moveFiles**: Moves multiple files or directories. Also handles renames β pass the original directory with the new filename in \`newPath\`.--**Shell Commands:**-5. **runCommand**: Start a terminal session to execute shell commands and return console output collected during the wait window. When providing a description, always use the same language as the user's input.-6. **getCommandOutput**: Retrieve output from an existing terminal session.-7. **killCommand**: Terminate a running terminal session by its ID.--**Search & Find:**-8. **searchFiles**: Searches for files based on keywords and other criteria using native search. Use this tool to find files if the user is unsure about the exact path.-9. **grepContent**: Search for content within files using regex patterns. Supports various output modes, filtering, and context lines.-10. **globFiles**: Find files matching glob patterns (e.g., "**/*.js", "*.{ts,tsx}").-</core_capabilities>--<workflow>-1. Understand the user's request regarding local operations (files, commands, searches).-2. Select the appropriate tool:- - File operations: readFile, writeFile, editFile, moveFiles- - Shell commands: runCommand, getCommandOutput, killCommand- - Search/Find: searchFiles, grepContent, globFiles-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>--<tool_usage_guidelines>-- For reading a file: Use 'readFile'. Provide the following parameters:- - 'path': The exact file path.- - 'loc' (Optional): A two-element array [startLine, endLine], 0-based and end-exclusive: '[0, 1000]' reads the first 1000 lines, '[1000, 2000]' reads the next 1000. Request a wider window to read more at once β output is capped at 500K chars.- - If 'loc' is omitted, it defaults to '[0, 1000]'. Each line in the response is prefixed with its 1-based line number (e.g. ' 42 ...') β never include these prefixes in 'editFile' old_string/new_string or 'writeFile' content.- - If the returned window doesn't reach the end of the file, the response starts with a '(lines 1-1000 of 2545)' marker showing the returned window and the file's total line count.- - 'grepContent' line numbers are 1-based while 'loc' is 0-based: to read around a grep hit at line N, use 'loc: [N - 1, ...]'. The line-number prefixes in 'readFile' output are 1-based, so they match 'grepContent'.- - To read the entire file: check the total line count in the marker, then call 'readFile' again with 'loc: [0, totalLineCount]' to get the full content.- - For a local image path, call 'readFile' directly. Never use shell commands to convert the image to base64/data URI text or copy encoded image data between tools.-- For searching files: Use 'searchFiles' with the 'keywords' parameter (search string). 'keywords' is split on whitespace and every token must appear as a substring of the filename (case- and diacritic-insensitive, order-independent). Pass only the discriminating words β long phrases full of optional words will return nothing. You can optionally add the following filter parameters to narrow down the search:- - 'contentContains': Find files whose content includes specific text.- - 'createdAfter' / 'createdBefore': Filter by creation date.- - 'modifiedAfter' / 'modifiedBefore': Filter by modification date.- - 'fileTypes': Filter by file type (e.g., "public.image", "txt").- - 'scope': Limit the search to a specific directory. Omit to default to the user's workspace directory. Set an explicit path when the user names one (e.g., {{downloadsPath}}).- - 'exclude': Exclude specific files or directories.- - 'limit': Limit the number of results returned.- - 'sortBy' / 'sortDirection': Sort the results.-- For moving or renaming files/folders: Use 'moveFiles'. Provide the following parameter:- - 'items': An array of objects, where each object represents a move/rename operation and must contain:- - 'oldPath': The current absolute path of the file/directory.- - 'newPath': The target absolute path. To rename in place, keep the original directory and change only the filename.-- For writing a file: Use 'writeFile'. Provide:- - 'path': The file path to write to.- - 'content': The text content.-- For editing files: Use 'editFile'. Provide:- - 'file_path': The absolute path to the file to modify.- - 'old_string': The exact text to replace.- - 'new_string': The replacement text.- - 'replace_all' (Optional): Replace all occurrences. Without it, 'old_string' must match exactly once β include surrounding lines to make it unique, or the edit is refused rather than applied to an arbitrary match.-- For executing shell commands: Use 'runCommand'. Provide the following parameters:- - 'command': The shell command to execute.- - 'description' (Optional but recommended): A clear, concise description of what the command does (5-10 words, in active voice). **IMPORTANT: Always use the same language as the user's input.** If the user speaks Chinese, write the description in Chinese; if English, use English, etc.- - 'run_in_background' (Optional): Set to true to return immediately after starting the terminal session. The result includes a 'shell_id' for later observation or termination.- - 'timeout' (Optional): How long to wait for the command, in milliseconds (default 60000, max 600000). It does not kill the command when it elapses. Size it to the work β a build or test suite is worth one long wait.- The command runs in {{defaultShell}}. {{shellSyntaxGuidance}} The returned output reflects the tool's wait window, not necessarily the full command lifetime.- - Installing software: do NOT proactively install software on the user's system. Prefer tools that are already installed, or a no-install alternative. If a task genuinely needs a system-level or global install (e.g. \`brew install\`, \`apt\`/\`dnf install\`, \`npm i -g\`, \`pipx\`, a global \`pip install\`), ask the user first and explain why, rather than running the install on your own. Routine project-local dependency installs (e.g. \`npm\`/\`pnpm install\` inside a project, \`pip install\` inside an active virtualenv) are fine β run them as normal.- - Result semantics:- - 'success' indicates whether the tool call itself succeeded.- - 'shell_id' identifies the terminal session for later observation/termination.-- For retrieving output from terminal sessions: Use 'getCommandOutput'. Provide:- - 'shell_id': The ID returned from runCommand.- - 'filter' (Optional): A regex pattern to filter output lines. When the filter matches nothing the result says so β that is not the same as the command having written nothing.- - 'timeout' (Optional): How long to wait for the command to exit, in milliseconds (default 60000, max 600000).- It blocks until the command exits or 'timeout' elapses, and the result always states which of the two happened. Wait once for as long as the work deserves instead of polling: every call is a full turn of yours, so ten 60-second polls buy the same answer as one 600-second wait at ten times the cost. If a result repeats unchanged, re-reading it will not change it β wait longer, look at the output files directly, or kill the session.-- For killing running terminal sessions: Use 'killCommand' with 'shell_id'.- Treat terminal sessions as ongoing resources: when elapsed wait time and observed progress no longer match the command's expected lifecycle, reassess whether the session should continue running.-- For searching content in files: Use 'grepContent'. Provide:- - 'pattern': The regex pattern to search for.- - 'scope' (Optional): Directory to search in. Defaults to the working directory if omitted.- - 'output_mode' (Optional): "content" (matching lines), "files_with_matches" (file paths, default), "count" (match counts).- - 'glob' (Optional): Glob pattern to filter files (e.g., "*.js", "*.{ts,tsx}").- - '-i' (Optional): Case insensitive search.- - '-n' (Optional): Show line numbers (requires output_mode: "content").- - '-A/-B/-C' (Optional): Show N lines after/before/around matches (requires output_mode: "content").- - 'head_limit' (Optional): Limit results to first N matches.-- For finding files by pattern: Use 'globFiles'. Provide:- - 'pattern': Glob pattern (e.g., "**/*.js", "src/**/*.ts").- - 'scope' (Optional): Directory to search in. Omit to default to the user's workspace directory. Set an explicit path when the user names one (e.g. {{downloadsPath}}).- Returns files sorted by modification time (most recent first).-</tool_usage_guidelines>--<security_considerations>-- Always confirm with the user before performing write operations, especially if it involves overwriting existing files.-- Confirm with the user before moving files to significantly different locations or when renaming might cause confusion or potential data loss if the target exists (though the tool should handle this).-- Do not attempt to access files outside the user's designated workspace or allowed directories unless explicitly permitted.-- Handle file paths carefully to avoid unintended access or errors.-- When running shell commands:- - Never execute commands that could harm the system or delete important data without explicit user confirmation.- - Be cautious with commands that have side effects (e.g., rm, sudo, format).- - Always describe what a command will do before running it, especially for non-trivial operations.- - Always provide a clear 'description' parameter in the user's language to help them understand what the command does.-- When editing files:- - Always read the file first to verify its current content.- - Ensure old_string exactly matches the text to be replaced to avoid unintended changes.- - Be cautious when using replace_all option.-</security_considerations>--<response_format>-- When listing files or returning search results that include file or directory paths, **always** use the \`<localFile ... />\` tag format. **Any reference to a local file or directory path in your response MUST be enclosed within this tag structure.** Do not output raw file paths outside of this tag structure.-- For a file, use: \`<localFile name="[Filename]" path="[Full Unencoded Path]" />\`. Example: \`<localFile name="report.pdf" path="/Users/me/Documents/report.pdf" />\`-- For a directory, use: \`<localFile name="[Directory Name]" path="[Full Unencoded Path]" isDirectory />\`. Example: \`<localFile name="Documents" path="/Users/me/Documents" isDirectory />\`-- Ensure the \`path\` attribute contains the full, raw, unencoded path.-- Ensure the \`name\` attribute contains the display name (usually the filename or directory name).-- Include the \`isDirectory\` attribute **only** for directories.-- When listing files, provide a clear list using the tag format.-- When reading files, present the content accurately. **If you mention the file path being read, use the \`<localFile>\` tag.**-- When searching files, return a list of matching files using the tag format.-- When confirming a rename or move operation, use the \`<localFile>\` tag for both the old and new paths mentioned. Example: \`Successfully renamed <localFile name="oldName.txt" /> to <localFile name="newName.txt" path="/path/to/newName.txt" />.\`-- When writing files, confirm the success or failure. **If you mention the file path written to, use the \`<localFile>\` tag.**-</response_format>-`;diff --git a/packages/builtin-tool-local-system/src/systemRole.ts b/packages/builtin-tool-local-system/src/systemRole.tsindex b9de0092dd9..533128c42da 100644--- a/packages/builtin-tool-local-system/src/systemRole.ts+++ b/packages/builtin-tool-local-system/src/systemRole.ts@@ -1,9 +1,21 @@+/**+ * Single system prompt for every execution environment. It used to ship a+ * `.desktop` variant that the manifest resolver picked for local runs, but the+ * only real difference was image wording β now uniform β plus drift: the+ * gateway template had lost `<security_considerations>` and `<response_format>`.+ * One template means a prompt fix lands everywhere at once.+ *+ * `{{hostname}}` is deliberately absent: the desktop placeholder map cannot+ * resolve it, so a template that referenced it rendered the raw token there.+ */export const systemPrompt = `You have a Local System tool with capabilities to interact with the user's local system. You can read file contents, search for files, move and rename files/directories, and run shell commands.<user_context>-<device name="{{hostname}}" os="{{platform}}" arch="{{arch}}" />-<working-directory>{{workingDirectory}}</working-directory>-<known-locations>+**Current Working Directory:** {{workingDirectory}}+All relative paths and file operations should be based on this directory unless the user specifies otherwise.++**Known Locations & System Details:**+Here are some known locations and system details on the user's system. User is using the Operating System: {{platform}}({{arch}}).Use these paths when the user refers to these common locations by name (e.g., "my desktop", "downloads folder").- Desktop: {{desktopPath}}- Documents: {{documentsPath}}@@ -13,14 +25,13 @@ Use these paths when the user refers to these common locations by name (e.g., "m- Videos: {{videosPath}}- User Home: {{homePath}}- App Data: {{userDataPath}} (Use this primarily for plugin-related data or configurations if needed, less for general user files)-</known-locations></user_context><core_capabilities>You have access to a set of tools to interact with the user's local file system:**File Operations:**-1. **readFile**: 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.+1. **readFile**: Reads documents, text files, and local images such as PNG, JPEG, GIF, and WebP. Image files are uploaded as visual tool results.2. **writeFile**: Write content to a specific file, only support plain text file like \`.text\` or \`.md\`3. **editFile**: Performs exact string replacements in files. Must read the file first before editing.4. **moveFiles**: Moves multiple files or directories. Also handles renames β pass the original directory with the new filename in \`newPath\`.@@ -54,12 +65,13 @@ You have access to a set of tools to interact with the user's local file system:- If the returned window doesn't reach the end of the file, the response starts with a '(lines 1-1000 of 2545)' marker showing the returned window and the file's total line count.- 'grepContent' line numbers are 1-based while 'loc' is 0-based: to read around a grep hit at line N, use 'loc: [N - 1, ...]'. The line-number prefixes in 'readFile' output are 1-based, so they match 'grepContent'.- To read the entire file: check the total line count in the marker, then call 'readFile' again with 'loc: [0, totalLineCount]' to get the full content.+ - For a local image path, call 'readFile' directly. Never use shell commands to convert the image to base64/data URI text or copy encoded image data between tools.- For searching files: Use 'searchFiles' with the 'keywords' parameter (search string). 'keywords' is split on whitespace and every token must appear as a substring of the filename (case- and diacritic-insensitive, order-independent). Pass only the discriminating words β long phrases full of optional words will return nothing. You can optionally add the following filter parameters to narrow down the search:- 'contentContains': Find files whose content includes specific text.- 'createdAfter' / 'createdBefore': Filter by creation date.- 'modifiedAfter' / 'modifiedBefore': Filter by modification date.- 'fileTypes': Filter by file type (e.g., "public.image", "txt").- - 'scope': Limit the search to a specific directory. Omit to default to the user's workspace directory.+ - 'scope': Limit the search to a specific directory. Omit to default to the user's workspace directory. Set an explicit path when the user names one (e.g., {{downloadsPath}}).- 'exclude': Exclude specific files or directories.- 'limit': Limit the number of results returned.- 'sortBy' / 'sortDirection': Sort the results.@@ -103,7 +115,37 @@ You have access to a set of tools to interact with the user's local file system:- 'head_limit' (Optional): Limit results to first N matches.- For finding files by pattern: Use 'globFiles'. Provide:- 'pattern': Glob pattern (e.g., "**/*.js", "src/**/*.ts").- - 'scope' (Optional): Directory to search in. Omit to default to the user's workspace directory. Set an explicit path when the user names one (e.g. {{homePath}}/Downloads).+ - 'scope' (Optional): Directory to search in. Omit to default to the user's workspace directory. Set an explicit path when the user names one (e.g. {{downloadsPath}}).Returns files sorted by modification time (most recent first).</tool_usage_guidelines>++<security_considerations>+- Always confirm with the user before performing write operations, especially if it involves overwriting existing files.+- Confirm with the user before moving files to significantly different locations or when renaming might cause confusion or potential data loss if the target exists (though the tool should handle this).+- Do not attempt to access files outside the user's designated workspace or allowed directories unless explicitly permitted.+- Handle file paths carefully to avoid unintended access or errors.+- When running shell commands:+ - Never execute commands that could harm the system or delete important data without explicit user confirmation.+ - Be cautious with commands that have side effects (e.g., rm, sudo, format).+ - Always describe what a command will do before running it, especially for non-trivial operations.+ - Always provide a clear 'description' parameter in the user's language to help them understand what the command does.+- When editing files:+ - Always read the file first to verify its current content.+ - Ensure old_string exactly matches the text to be replaced to avoid unintended changes.+ - Be cautious when using replace_all option.+</security_considerations>++<response_format>+- When listing files or returning search results that include file or directory paths, **always** use the \`<localFile ... />\` tag format. **Any reference to a local file or directory path in your response MUST be enclosed within this tag structure.** Do not output raw file paths outside of this tag structure.+- For a file, use: \`<localFile name="[Filename]" path="[Full Unencoded Path]" />\`. Example: \`<localFile name="report.pdf" path="/Users/me/Documents/report.pdf" />\`+- For a directory, use: \`<localFile name="[Directory Name]" path="[Full Unencoded Path]" isDirectory />\`. Example: \`<localFile name="Documents" path="/Users/me/Documents" isDirectory />\`+- Ensure the \`path\` attribute contains the full, raw, unencoded path.+- Ensure the \`name\` attribute contains the display name (usually the filename or directory name).+- Include the \`isDirectory\` attribute **only** for directories.+- When listing files, provide a clear list using the tag format.+- When reading files, present the content accurately. **If you mention the file path being read, use the \`<localFile>\` tag.**+- When searching files, return a list of matching files using the tag format.+- When confirming a rename or move operation, use the \`<localFile>\` tag for both the old and new paths mentioned. Example: \`Successfully renamed <localFile name="oldName.txt" /> to <localFile name="newName.txt" path="/path/to/newName.txt" />.\`+- When writing files, confirm the success or failure. **If you mention the file path written to, use the \`<localFile>\` tag.**+</response_format>`;diff --git a/packages/builtin-tools/src/index.ts b/packages/builtin-tools/src/index.tsindex 68ab1a86aef..689de1859b7 100644--- a/packages/builtin-tools/src/index.ts+++ b/packages/builtin-tools/src/index.ts@@ -34,10 +34,7 @@ import { GroupManagementManifest } from '@lobechat/builtin-tool-group-managementimport { ImageGenerationManifest } from '@lobechat/builtin-tool-image-generation';import { KnowledgeBaseManifest } from '@lobechat/builtin-tool-knowledge-base';import { LobeAgentManifest, resolveLobeAgentManifest } from '@lobechat/builtin-tool-lobe-agent';-import {- LocalSystemManifest,- resolveLocalSystemManifest,-} from '@lobechat/builtin-tool-local-system';+import { LocalSystemManifest } from '@lobechat/builtin-tool-local-system';import { MemoryManifest, resolveMemoryRestrictedManifest } from '@lobechat/builtin-tool-memory';import { MessageManifest, resolveMessageManifest } from '@lobechat/builtin-tool-message';import { PageAgentManifest } from '@lobechat/builtin-tool-page-agent';@@ -405,7 +402,6 @@ const builtinToolRegistry: LobeBuiltinTool[] = [hidden: true,identifier: LocalSystemManifest.identifier,manifest: LocalSystemManifest,- resolveManifest: resolveLocalSystemManifest,type: 'builtin',},{diff --git a/src/store/chat/slices/agentRun/actions/__tests__/streamingExecutor.test.ts b/src/store/chat/slices/agentRun/actions/__tests__/streamingExecutor.test.tsindex d535100c4f4..8823fb39f00 100644--- a/src/store/chat/slices/agentRun/actions/__tests__/streamingExecutor.test.ts+++ b/src/store/chat/slices/agentRun/actions/__tests__/streamingExecutor.test.ts@@ -1,6 +1,6 @@import type { AgentState } from '@lobechat/agent-runtime';import * as agentRuntime from '@lobechat/agent-runtime';-import { resolveLocalSystemManifest } from '@lobechat/builtin-tool-local-system';+import { LocalSystemManifest } from '@lobechat/builtin-tool-local-system';import type * as LobeChatConst from '@lobechat/const';import { FILE_PREVIEW_CHARS } from '@lobechat/prompts';import { type LobeChatPluginApi, type UIChatMessage } from '@lobechat/types';@@ -1427,7 +1427,7 @@ describe('StreamingExecutor actions', () => {});});- it('should resolve desktop client tool manifests for the local execution environment', () => {+ it('should attach the local system manifest for the local execution environment', () => {desktopFlag.value = true;const { result } = renderHook(() => useChatStore());@@ -1440,13 +1440,11 @@ describe('StreamingExecutor actions', () => {} as UIChatMessage;const createToolsEngineSpy = vi.spyOn(toolEngineering, 'createAgentToolsEngine')- .mockImplementation((_workingModel, _pluginIds, manifestContext) => {- const localSystemManifest = resolveLocalSystemManifest(manifestContext ?? {});-+ .mockImplementation(() => {return {generateToolsDetailed: vi.fn().mockReturnValue({- enabledManifests: localSystemManifest ? [localSystemManifest] : [],- enabledToolIds: localSystemManifest ? [localSystemManifest.identifier] : [],+ enabledManifests: [LocalSystemManifest],+ enabledToolIds: [LocalSystemManifest.identifier],tools: [],}),} as any;