The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
Phase 3: Tool descriptions upgrade + mobile parity test (v2.4.0)
PurpleDoubleD23f88757eea8
diff --git a/src-tauri/src/commands/remote.rs b/src-tauri/src/commands/remote.rsindex ddac058c..94610d3d 100644--- a/src-tauri/src/commands/remote.rs+++ b/src-tauri/src/commands/remote.rs@@ -1154,46 +1154,48 @@ button{-webkit-appearance:none;appearance:none}var agentRunning = false;var agentAbort = false;- // ── Agent tools (parity with src/api/agents.ts AGENT_TOOLS) ──- // Full parity with desktop toolRegistry (src/api/mcp/builtin-tools.ts).- // Every tool the desktop agent has, the mobile agent has too.+ // ── Agent tools (parity with src/api/mcp/builtin-tools.ts) ──+ // Descriptions kept tight-matched with the desktop BUILTIN_TOOLS so the+ // same model behaviour follows us onto mobile. Tests in+ // src/api/__tests__/tool-description-parity.test.ts pin this parity.var AGENT_TOOLS = [- {name:'web_search', description:'Search the web. Returns a LIST of candidate results (title + URL + short snippet). The snippet is rarely enough — follow up with web_fetch on the best URL to read the page body.',- parameters:[{name:'query',type:'string',description:'Search query',required:true},- {name:'maxResults',type:'number',description:'Max results (default 5)',required:false}]},- {name:'web_fetch', description:'Fetch a URL and return its readable text (up to ~24 000 chars). HTML stripped, scripts/nav/footer removed. Use AFTER web_search for real page content.',- parameters:[{name:'url',type:'string',description:'Full URL (http:// or https://)',required:true}]},- {name:'file_read', description:'Read a file from the desktop filesystem. Relative paths resolve inside the agent workspace (~/agent-workspace); absolute paths work too.',- parameters:[{name:'path',type:'string',description:'File path',required:true}]},- {name:'file_write', description:'Write content to a file on the desktop. Creates or overwrites.',- parameters:[{name:'path',type:'string',description:'File path',required:true},- {name:'content',type:'string',description:'Content to write',required:true}]},- {name:'file_list', description:'List files in a directory on the desktop. Optional recursive + glob pattern.',- parameters:[{name:'path',type:'string',description:'Directory path',required:true},- {name:'recursive',type:'boolean',description:'Recurse into subdirs',required:false},- {name:'pattern',type:'string',description:'Glob pattern (e.g. "*.ts")',required:false}]},- {name:'file_search', description:'Grep-style content search across files matching a glob. Returns matching lines with file/line info.',- parameters:[{name:'path',type:'string',description:'Root directory',required:true},- {name:'query',type:'string',description:'Regex pattern',required:true},- {name:'pattern',type:'string',description:'Glob to filter files (e.g. "*.rs")',required:false}]},- {name:'shell_execute', description:'Run a shell command. Uses PowerShell on Windows, bash on Unix. Best for quick system queries like `date`, `dir`, `ls`, `git status`, `ping`, etc.',- parameters:[{name:'command',type:'string',description:'The command',required:true},- {name:'cwd',type:'string',description:'Working directory (optional)',required:false},- {name:'timeout',type:'number',description:'Timeout ms (default 120000)',required:false},- {name:'shell',type:'string',description:'"powershell" | "cmd" | "bash" (auto-detect if unset)',required:false}]},- {name:'code_execute', description:'Execute Python code in a sandboxed process. Use for calculations / data transforms / quick scripts.',- parameters:[{name:'code',type:'string',description:'Python code',required:true},- {name:'timeout',type:'number',description:'Timeout ms',required:false}]},- {name:'system_info', description:'OS, CPU, RAM, GPU, disk. Zero arguments.',+ {name:'web_search', description:'Search the web via the configured provider (Brave, Tavily, or auto). Returns a ranked list of {title, url, snippet}. PREFER web_fetch on promising URLs for full content — snippets are teasers, not answers. DO NOT call more than 3x per turn with similar queries; refine the query instead of re-searching. For current date/time, use get_current_time — do NOT web_search for it.',+ parameters:[{name:'query',type:'string',description:'The search query string',required:true},+ {name:'maxResults',type:'number',description:'Maximum results to return (default: 5, max: 20)',required:false}]},+ {name:'web_fetch', description:'Fetch a single URL and return its readable text (up to ~24 000 chars). Strips <script>, <style>, <nav>, <header>, <footer>, <aside>, <form> — returns main content only. PREFER this over web_search when you already know the target URL. NEVER call with localhost, private IPs (10.*, 192.168.*, 172.16-31.*), or file:// — they are refused. If response is empty or 4xx, try a different URL rather than retrying the same one.',+ parameters:[{name:'url',type:'string',description:'Full URL including protocol (http:// or https://)',required:true},+ {name:'maxLength',type:'number',description:'Max chars to return (default: 24000)',required:false}]},+ {name:'file_read', description:'Read the complete contents of a file. PREFER absolute paths; relative paths resolve against the agent workspace (~/agent-workspace). The entire file is returned — there is no pagination or range parameter. DO NOT re-read a file you just wrote with file_write; the write response already confirmed the save. For directory listings use file_list; for content search across many files use file_search.',+ parameters:[{name:'path',type:'string',description:'Path to the file (absolute preferred)',required:true}]},+ {name:'file_write', description:'Write a file. Creates parent directories if missing. OVERWRITES existing content — there is NO append mode. To preserve existing content and append, use file_read FIRST then file_write with the combined content. PREFER absolute paths. Writes to the same path within one turn are serialized automatically via the sideEffectKey scheduler.',+ parameters:[{name:'path',type:'string',description:'Path to the file (absolute preferred)',required:true},+ {name:'content',type:'string',description:'The complete new content of the file',required:true}]},+ {name:'file_list', description:'List directory contents. Returns entries with name, isDir, size, full path. Supports recursive=true for full tree and glob pattern ("*.ts", "**/*.py"). PREFER a specific pattern over recursive listing of large trees — recursing home / C:\\ is slow. For content search (grep), use file_search instead.',+ parameters:[{name:'path',type:'string',description:'Directory path to list',required:true},+ {name:'recursive',type:'boolean',description:'Recurse into subdirectories (default: false)',required:false},+ {name:'pattern',type:'string',description:'Glob pattern to filter results (e.g. "*.ts", "**/*.py")',required:false}]},+ {name:'file_search', description:'Grep-style regex content search across files in a directory. Returns matching lines with file + line number. PREFER over file_read + manual scan when hunting for a symbol across many files. Use file_list first if you do not know the layout. Default max 50 results — narrow the pattern or path if you flood. Pattern uses Rust regex syntax, not PCRE.',+ parameters:[{name:'path',type:'string',description:'Directory to search in (recursive by default)',required:true},+ {name:'pattern',type:'string',description:'Regex pattern to search for',required:true},+ {name:'maxResults',type:'number',description:'Maximum matching files (default: 50)',required:false}]},+ {name:'shell_execute', description:'Run a shell command. PowerShell on Windows, bash on Unix. Returns stdout, stderr, exit code. PREFER dedicated tools where available: file_read over `cat`, file_list over `ls`/`dir`, file_search over `grep`, get_current_time over `date`. Use shell_execute for git, npm, cargo, docker, package managers, or platform utilities without a dedicated tool. NEVER use to permanently delete without confirmation (rm -rf, Remove-Item -Recurse, git reset --hard). Default timeout 120 s; set higher only for known long-running builds.',+ parameters:[{name:'command',type:'string',description:'The full command to execute',required:true},+ {name:'cwd',type:'string',description:'Working directory (optional, absolute preferred)',required:false},+ {name:'timeout',type:'number',description:'Timeout in milliseconds (default: 120000)',required:false},+ {name:'shell',type:'string',description:'Override shell: "powershell" | "cmd" | "bash" (default: auto)',required:false}]},+ {name:'code_execute', description:'Execute Python code in a fresh subprocess. Returns stdout, stderr, exit code. Use for math, data transforms, JSON/CSV parsing, one-off scripts. NOT a REPL — state does not persist between calls; import everything you need each time. For system commands and shell utilities, PREFER shell_execute. Default timeout 30 s.',+ parameters:[{name:'code',type:'string',description:'The Python source to execute (UTF-8)',required:true},+ {name:'language',type:'string',description:'Programming language: "python" or "shell"',required:false}]},+ {name:'system_info', description:'Return desktop system info: OS, architecture, hostname, username, total RAM, CPU count. Zero arguments. Call once when output needs to be tailored to the user\'s platform; do not call repeatedly in a loop.',parameters:[]},- {name:'process_list', description:'List running processes with PID, name, CPU%, memory. Zero arguments.',+ {name:'process_list', description:'List the top 30 running processes sorted by memory: {name, pid, memory, cpu%}. Zero arguments. Use for task-manager-style queries ("is Chrome running?", "which process is eating RAM?"). There is NO process_kill tool — to kill a process use shell_execute with taskkill (Windows) or kill (Unix).',parameters:[]},- {name:'screenshot', description:'Take a desktop screenshot and return a base64-encoded PNG.',+ {name:'screenshot', description:'Capture the primary display as a base64 PNG. Zero arguments. USE for visual verification when the user asks "what\'s on my screen" or "look at X". Returns a short summary string (size + filename); the actual image is forwarded to the model via message content. NEVER call in a tight loop — screenshots are expensive and privacy-sensitive.',parameters:[]},- {name:'image_generate', description:'Generate an image from a text prompt via the desktop ComfyUI backend. Blocks up to 5 minutes.',- parameters:[{name:'prompt',type:'string',description:'What to generate',required:true},- {name:'negativePrompt',type:'string',description:'Things to avoid',required:false}]},- {name:'get_current_time', description:'Return the current local date, time and timezone on the desktop. Use this FIRST for any "what day / time / date is it" question — do NOT web_search for it.',+ {name:'image_generate', description:'Generate an image from a text prompt via the local ComfyUI pipeline. Blocks up to 5 minutes. USE for "draw me", "make an image of", "generate a picture". NOT for photo editing — this is text-to-image only; no inpainting via this tool. First installed image model is auto-selected. Rate-limit yourself to 1 call per turn — ComfyUI serializes generations internally so parallel calls will queue, not speed up.',+ parameters:[{name:'prompt',type:'string',description:'Positive text description of the desired image',required:true},+ {name:'negativePrompt',type:'string',description:'Things to avoid (blurry, deformed, etc.)',required:false}]},+ {name:'get_current_time', description:'Return the user\'s current local date, time, and timezone. Zero arguments. USE FIRST for any \'what day / time / date is it\' question — do NOT web_search or shell_execute `date`. The Rust backend probes the OS timezone on every call, so this is always authoritative.',parameters:[]}];diff --git a/src/api/__tests__/tool-description-parity.test.ts b/src/api/__tests__/tool-description-parity.test.tsnew file mode 100644index 00000000..546b8f81--- /dev/null+++ b/src/api/__tests__/tool-description-parity.test.ts@@ -0,0 +1,213 @@+/**+ * Phase 3 (v2.4.0) — Tool-description parity test.+ *+ * The mobile web UI (rendered from src-tauri/src/commands/remote.rs::mobile_landing)+ * re-declares the AGENT_TOOLS array inline so the ReAct prompt on mobile lists+ * exactly the same capabilities. This test pins:+ * - tool NAMES on both sides are the same set+ * - each tool description is Claude-Code-quality (length + contains at least+ * one of the recommended hint markers PREFER/NEVER/DO NOT/USE FIRST/Zero)+ * - required-parameter lists line up+ *+ * If this test fails after a description edit, update BOTH sides together.+ */+import { describe, it, expect } from 'vitest'+import { readFileSync } from 'node:fs'+import { resolve } from 'node:path'++type BuiltinTool = {+ name: string+ description: string+ inputSchema: { properties: Record<string, any>; required: string[] }+}++// Import the desktop source of truth. Kept as a `require` to avoid pulling the+// full Tauri backend-call chain through vitest's module graph.+const builtinTools: BuiltinTool[] = (() => {+ // Grep the TS source directly to avoid transitive imports during test import.+ const ts = readFileSync(+ resolve(__dirname, '..', 'mcp', 'builtin-tools.ts'),+ 'utf8'+ )+ return parseBuiltinToolsFromTs(ts)+})()++function parseBuiltinToolsFromTs(source: string): BuiltinTool[] {+ const tools: BuiltinTool[] = []+ // Match each entry inside BUILTIN_TOOLS: { name: '…', description: '…' + '…', … }+ const re =+ /\{\s*name:\s*'([^']+)'\s*,\s*description:\s*([\s\S]*?),\s*inputSchema:\s*(\{[\s\S]*?\}),\s*category/g+ let m: RegExpExecArray | null+ while ((m = re.exec(source)) !== null) {+ const name = m[1]+ const description = evaluateStringLiteralExpression(m[2])+ const required = extractRequiredArray(m[3])+ const propsList = extractPropertiesNames(m[3])+ tools.push({+ name,+ description,+ inputSchema: {+ properties: Object.fromEntries(propsList.map((p) => [p, {}])),+ required,+ },+ })+ }+ return tools+}++// Handles concatenated string-literal expressions: 'a' + 'b' + "c" etc.+function evaluateStringLiteralExpression(expr: string): string {+ const pieces: string[] = []+ const re = /(['"])((?:\\.|(?!\1).)*?)\1/g+ let m: RegExpExecArray | null+ while ((m = re.exec(expr)) !== null) {+ pieces.push(+ m[2]+ .replace(/\\\\/g, '\x00') // placeholder so we do not re-process escaped backslashes+ .replace(/\\'/g, "'")+ .replace(/\\"/g, '"')+ .replace(/\\n/g, '\n')+ .replace(/\x00/g, '\\')+ )+ }+ return pieces.join('')+}++function extractRequiredArray(schemaExpr: string): string[] {+ const m = schemaExpr.match(/required:\s*\[([^\]]*)\]/)+ if (!m) return []+ return [...m[1].matchAll(/'([^']+)'/g)].map((x) => x[1])+}++function extractPropertiesNames(schemaExpr: string): string[] {+ const propsBlock = schemaExpr.match(/properties:\s*\{([\s\S]*?)\}/)+ if (!propsBlock) return []+ return [...propsBlock[1].matchAll(/(\w+):\s*\{/g)].map((x) => x[1])+}++// ─── Mobile extraction ───+interface MobileTool {+ name: string+ description: string+ parameters: { name: string; required: boolean }[]+}++function parseMobileTools(): MobileTool[] {+ const rs = readFileSync(+ resolve(__dirname, '..', '..', '..', 'src-tauri', 'src', 'commands', 'remote.rs'),+ 'utf8'+ )+ // Grab the AGENT_TOOLS JS array contents.+ const arrMatch = rs.match(/var AGENT_TOOLS = \[([\s\S]*?)\];/)+ if (!arrMatch) throw new Error('Could not locate mobile AGENT_TOOLS array in remote.rs')+ const body = arrMatch[1]+ // Split into tool object blocks by looking for top-level "{name:" anchors.+ const tools: MobileTool[] = []+ const toolRe = /\{name:'([^']+)',\s*description:'((?:\\.|[^'\\])*)',\s*\n?\s*parameters:\[([^\]]*)\]\}/g+ let m: RegExpExecArray | null+ while ((m = toolRe.exec(body)) !== null) {+ const name = m[1]+ const description = m[2]+ .replace(/\\'/g, "'")+ .replace(/\\"/g, '"')+ .replace(/\\\\/g, '\\')+ const params = parseMobileParams(m[3])+ tools.push({ name, description, parameters: params })+ }+ return tools+}++function parseMobileParams(paramsExpr: string): { name: string; required: boolean }[] {+ const out: { name: string; required: boolean }[] = []+ const paramRe = /\{name:'([^']+)'[^}]*?required:\s*(true|false)[^}]*\}/g+ let m: RegExpExecArray | null+ while ((m = paramRe.exec(paramsExpr)) !== null) {+ out.push({ name: m[1], required: m[2] === 'true' })+ }+ return out+}++const mobileTools = parseMobileTools()++// ─── Tests ───++describe('tool-description-parity — extraction sanity', () => {+ it('parses the desktop BUILTIN_TOOLS list', () => {+ expect(builtinTools.length).toBeGreaterThanOrEqual(13)+ })+ it('parses the mobile AGENT_TOOLS list', () => {+ expect(mobileTools.length).toBeGreaterThanOrEqual(13)+ })+})++// Tools intentionally absent on mobile because their executor relies on+// desktop-only TypeScript code paths (WorkflowEngine for run_workflow).+// Expanding this set requires wiring the Rust /remote-api/agent-tool dispatcher.+const MOBILE_SKIP: ReadonlySet<string> = new Set<string>(['run_workflow'])++describe('tool-description-parity — name sets', () => {+ it('desktop and mobile expose the same set of tool names (modulo documented skips)', () => {+ const desktopNames = new Set(builtinTools.map((t) => t.name))+ const mobileNames = new Set(mobileTools.map((t) => t.name))+ const expectedOnMobile = [...desktopNames].filter((n) => !MOBILE_SKIP.has(n))+ const missingFromMobile = expectedOnMobile.filter((n) => !mobileNames.has(n))+ const extraOnMobile = [...mobileNames].filter((n) => !desktopNames.has(n))+ expect(missingFromMobile).toEqual([])+ expect(extraOnMobile).toEqual([])+ })+})++describe('tool-description-parity — description quality', () => {+ const HINT_MARKERS = ['PREFER', 'NEVER', 'DO NOT', 'USE FIRST', 'USE for', 'NOT a', 'NOT for']++ it.each(builtinTools.map((t) => [t.name, t]))(+ 'desktop %s has a substantive description',+ (_name, tool) => {+ const desc = (tool as BuiltinTool).description+ // Claude-Code-quality target: 80+ chars.+ expect(desc.length).toBeGreaterThanOrEqual(80)+ // Contains at least one hint marker OR is a zero-arg system tool where+ // "Zero arguments" is itself the hint.+ const hasMarker =+ HINT_MARKERS.some((h) => desc.includes(h)) || /Zero arguments/i.test(desc)+ expect(hasMarker, `expected ${(_name as string)} description to contain a hint marker`).toBe(true)+ }+ )++ it.each(mobileTools.map((t) => [t.name, t]))(+ 'mobile %s has a substantive description',+ (_name, tool) => {+ const desc = (tool as MobileTool).description+ expect(desc.length).toBeGreaterThanOrEqual(80)+ const hasMarker =+ HINT_MARKERS.some((h) => desc.includes(h)) || /Zero arguments/i.test(desc)+ expect(hasMarker).toBe(true)+ }+ )+})++describe('tool-description-parity — per-tool parity', () => {+ it('each desktop tool (excluding mobile skips) has a mobile counterpart with matching description', () => {+ const byName = new Map(mobileTools.map((t) => [t.name, t]))+ for (const d of builtinTools) {+ if (MOBILE_SKIP.has(d.name)) continue+ const m = byName.get(d.name)+ expect(m, `mobile AGENT_TOOLS missing ${d.name}`).toBeDefined()+ if (!m) continue+ const normalize = (s: string) => s.replace(/\s+/g, ' ').trim()+ expect(normalize(m.description)).toBe(normalize(d.description))+ }+ })++ it('required parameter names line up desktop ↔ mobile', () => {+ const byName = new Map(mobileTools.map((t) => [t.name, t]))+ for (const d of builtinTools) {+ if (MOBILE_SKIP.has(d.name)) continue+ const m = byName.get(d.name)+ if (!m) continue+ const mobileRequired = m.parameters.filter((p) => p.required).map((p) => p.name).sort()+ const desktopRequired = [...d.inputSchema.required].sort()+ expect(mobileRequired).toEqual(desktopRequired)+ }+ })+})diff --git a/src/api/mcp/builtin-tools.ts b/src/api/mcp/builtin-tools.tsindex 4d7fc576..2a3875f2 100644--- a/src/api/mcp/builtin-tools.ts+++ b/src/api/mcp/builtin-tools.ts@@ -13,12 +13,16 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [// Web{name: 'web_search',- description: 'Search the web for current information. Returns titles, URLs, and short snippets. Use web_fetch on promising URLs to read full content.',+ description:+ 'Search the web via the configured provider (Brave, Tavily, or auto). Returns a ranked list of {title, url, snippet}. '+ + 'PREFER web_fetch on promising URLs for full content — snippets are teasers, not answers. '+ + 'DO NOT call more than 3x per turn with similar queries; refine the query instead of re-searching. '+ + 'For current date/time, use get_current_time — do NOT web_search for it.',inputSchema: {type: 'object',properties: {query: { type: 'string', description: 'The search query string' },- maxResults: { type: 'number', description: 'Maximum results to return (default: 5)' },+ maxResults: { type: 'number', description: 'Maximum results to return (default: 5, max: 20)' },},required: ['query'],},@@ -27,12 +31,17 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [},{name: 'web_fetch',- description: 'Fetch a web page URL and return its text content. Use AFTER web_search to read the full content. Returns cleaned text, not HTML.',+ description:+ 'Fetch a single URL and return its readable text (up to ~24 000 chars). '+ + 'Strips <script>, <style>, <nav>, <header>, <footer>, <aside>, <form> — returns main content only. '+ + 'PREFER this over web_search when you already know the target URL. '+ + 'NEVER call with localhost, private IPs (10.*, 192.168.*, 172.16-31.*), or file:// — they are refused. '+ + 'If response is empty or 4xx, try a different URL rather than retrying the same one.',inputSchema: {type: 'object',properties: {- url: { type: 'string', description: 'The URL to fetch' },- maxLength: { type: 'number', description: 'Maximum characters to return (default: 4000)' },+ url: { type: 'string', description: 'Full URL including protocol (http:// or https://)' },+ maxLength: { type: 'number', description: 'Max chars to return (default: 24000)' },},required: ['url'],},@@ -43,11 +52,15 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [// Filesystem{name: 'file_read',- description: 'Read the contents of any file on the system. Supports absolute paths and relative paths (relative to agent workspace).',+ description:+ 'Read the complete contents of a file. PREFER absolute paths; relative paths resolve against the agent workspace (~/agent-workspace). '+ + 'The entire file is returned — there is no pagination or range parameter. '+ + 'DO NOT re-read a file you just wrote with file_write; the write response already confirmed the save. '+ + 'For directory listings use file_list; for content search across many files use file_search.',inputSchema: {type: 'object',properties: {- path: { type: 'string', description: 'Path to the file (absolute or relative)' },+ path: { type: 'string', description: 'Path to the file (absolute preferred)' },},required: ['path'],},@@ -56,12 +69,16 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [},{name: 'file_write',- description: 'Write content to any file. Creates the file if it does not exist, overwrites if it does. Creates parent directories automatically.',+ description:+ 'Write a file. Creates parent directories if missing. OVERWRITES existing content — there is NO append mode. '+ + 'To preserve existing content and append, use file_read FIRST then file_write with the combined content. '+ + 'PREFER absolute paths. '+ + 'Writes to the same path within one turn are serialized automatically via the sideEffectKey scheduler.',inputSchema: {type: 'object',properties: {- path: { type: 'string', description: 'Path to the file (absolute or relative)' },- content: { type: 'string', description: 'The content to write' },+ path: { type: 'string', description: 'Path to the file (absolute preferred)' },+ content: { type: 'string', description: 'The complete new content of the file' },},required: ['path', 'content'],},@@ -70,12 +87,16 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [},{name: 'file_list',- description: 'List files and directories at a path. Supports recursive listing and glob patterns.',+ description:+ 'List directory contents. Returns entries with name, isDir, size, full path. '+ + 'Supports recursive=true for full tree and glob pattern ("*.ts", "**/*.py"). '+ + 'PREFER a specific pattern over recursive listing of large trees — recursing home / C:\\ is slow. '+ + 'For content search (grep), use file_search instead.',inputSchema: {type: 'object',properties: {path: { type: 'string', description: 'Directory path to list' },- recursive: { type: 'boolean', description: 'Whether to list recursively (default: false)' },+ recursive: { type: 'boolean', description: 'Recurse into subdirectories (default: false)' },pattern: { type: 'string', description: 'Glob pattern to filter results (e.g. "*.ts", "**/*.py")' },},required: ['path'],@@ -85,13 +106,18 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [},{name: 'file_search',- description: 'Search file contents using regex patterns. Returns matching files with line numbers and context.',+ description:+ 'Grep-style regex content search across files in a directory. Returns matching lines with file + line number. '+ + 'PREFER over file_read + manual scan when hunting for a symbol across many files. '+ + 'Use file_list first if you do not know the layout. '+ + 'Default max 50 results — narrow the pattern or path if you flood. '+ + 'Pattern uses Rust regex syntax, not PCRE.',inputSchema: {type: 'object',properties: {- path: { type: 'string', description: 'Directory to search in' },+ path: { type: 'string', description: 'Directory to search in (recursive by default)' },pattern: { type: 'string', description: 'Regex pattern to search for' },- maxResults: { type: 'number', description: 'Maximum files to return (default: 50)' },+ maxResults: { type: 'number', description: 'Maximum matching files (default: 50)' },},required: ['path', 'pattern'],},@@ -102,14 +128,19 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [// Terminal{name: 'shell_execute',- description: 'Execute a shell command on the system. Supports PowerShell (Windows), bash (Linux/Mac). Returns stdout, stderr, and exit code.',+ description:+ 'Run a shell command. PowerShell on Windows, bash on Unix. Returns stdout, stderr, exit code. '+ + 'PREFER dedicated tools where available: file_read over `cat`, file_list over `ls`/`dir`, file_search over `grep`, get_current_time over `date`. '+ + 'Use shell_execute for git, npm, cargo, docker, package managers, or platform utilities without a dedicated tool. '+ + 'NEVER use to permanently delete without confirmation (rm -rf, Remove-Item -Recurse, git reset --hard). '+ + 'Default timeout 120 s; set higher only for known long-running builds.',inputSchema: {type: 'object',properties: {- command: { type: 'string', description: 'The command to execute' },- cwd: { type: 'string', description: 'Working directory (optional)' },+ command: { type: 'string', description: 'The full command to execute' },+ cwd: { type: 'string', description: 'Working directory (optional, absolute preferred)' },timeout: { type: 'number', description: 'Timeout in milliseconds (default: 120000)' },- shell: { type: 'string', description: 'Shell to use: "powershell", "cmd", "bash" (default: auto)' },+ shell: { type: 'string', description: 'Override shell: "powershell" | "cmd" | "bash" (default: auto)' },},required: ['command'],},@@ -118,11 +149,16 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [},{name: 'code_execute',- description: 'Execute Python code. Returns stdout, stderr, and exit code.',+ description:+ 'Execute Python code in a fresh subprocess. Returns stdout, stderr, exit code. '+ + 'Use for math, data transforms, JSON/CSV parsing, one-off scripts. '+ + 'NOT a REPL — state does not persist between calls; import everything you need each time. '+ + 'For system commands and shell utilities, PREFER shell_execute. '+ + 'Default timeout 30 s.',inputSchema: {type: 'object',properties: {- code: { type: 'string', description: 'The Python code to execute' },+ code: { type: 'string', description: 'The Python source to execute (UTF-8)' },language: { type: 'string', description: 'Programming language: "python" or "shell"', enum: ['python', 'shell'] },},required: ['code'],@@ -134,14 +170,19 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [// System{name: 'system_info',- description: 'Get system information: OS, architecture, hostname, username, RAM, CPU count.',+ description:+ 'Return desktop system info: OS, architecture, hostname, username, total RAM, CPU count. Zero arguments. '+ + 'Call once when output needs to be tailored to the user\'s platform; do not call repeatedly in a loop.',inputSchema: { type: 'object', properties: {}, required: [] },category: 'system',source: 'builtin',},{name: 'process_list',- description: 'List running processes sorted by memory usage. Returns top 50 processes with name, PID, memory, and CPU usage.',+ description:+ 'List the top 30 running processes sorted by memory: {name, pid, memory, cpu%}. Zero arguments. '+ + 'Use for task-manager-style queries ("is Chrome running?", "which process is eating RAM?"). '+ + 'There is NO process_kill tool — to kill a process use shell_execute with taskkill (Windows) or kill (Unix).',inputSchema: { type: 'object', properties: {}, required: [] },category: 'system',source: 'builtin',@@ -150,7 +191,11 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [// Desktop{name: 'screenshot',- description: 'Take a screenshot of the primary screen. Returns base64-encoded PNG image.',+ description:+ 'Capture the primary display as a base64 PNG. Zero arguments. '+ + 'USE for visual verification when the user asks "what\'s on my screen" or "look at X". '+ + 'Returns a short summary string (size + filename); the actual image is forwarded to the model via message content. '+ + 'NEVER call in a tight loop — screenshots are expensive and privacy-sensitive.',inputSchema: { type: 'object', properties: {}, required: [] },category: 'desktop',source: 'builtin',@@ -159,12 +204,17 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [// Image{name: 'image_generate',- description: 'Generate an image from a text description using the local ComfyUI image generation pipeline.',+ description:+ 'Generate an image from a text prompt via the local ComfyUI pipeline. Blocks up to 5 minutes. '+ + 'USE for "draw me", "make an image of", "generate a picture". '+ + 'NOT for photo editing — this is text-to-image only; no inpainting via this tool. '+ + 'First installed image model is auto-selected. '+ + 'Rate-limit yourself to 1 call per turn — ComfyUI serializes generations internally so parallel calls will queue, not speed up.',inputSchema: {type: 'object',properties: {- prompt: { type: 'string', description: 'Text description of the image to generate' },- negativePrompt: { type: 'string', description: 'Things to avoid in the generated image' },+ prompt: { type: 'string', description: 'Positive text description of the desired image' },+ negativePrompt: { type: 'string', description: 'Things to avoid (blurry, deformed, etc.)' },},required: ['prompt'],},@@ -175,12 +225,16 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [// Workflow{name: 'run_workflow',- description: 'Run a saved agent workflow by name. Available workflows: Research Topic, Summarize URL, Code Review, and any custom workflows.',+ description:+ 'Execute a saved agent workflow by name. Runs a nested ReAct with a pre-built step chain. '+ + 'USE for repeatable multi-step tasks: "Research Topic", "Summarize URL", "Code Review", plus any user-created workflows. '+ + 'DO NOT call from inside another workflow tool — depth capped at 5 to prevent recursion fork-bombs. '+ + 'Pass optional input as the starting variable. If the name is unknown, the error lists available names.',inputSchema: {type: 'object',properties: {- name: { type: 'string', description: 'Name of the workflow to run' },- input: { type: 'string', description: 'Initial input to provide to the workflow' },+ name: { type: 'string', description: 'Name of the workflow (case-insensitive match)' },+ input: { type: 'string', description: 'Initial input passed as user_input / last_output' },},required: ['name'],},@@ -191,7 +245,10 @@ const BUILTIN_TOOLS: MCPToolDefinition[] = [// Local clock — so the agent never googles "what day is it".{name: 'get_current_time',- description: 'Return the user\'s current local date, time and timezone. Use this FIRST for any "what day / time / date is it" question — do NOT web_search for it. Zero arguments.',+ description:+ "Return the user's current local date, time, and timezone. Zero arguments. "+ + "USE FIRST for any 'what day / time / date is it' question — do NOT web_search or shell_execute `date`. "+ + "The Rust backend probes the OS timezone on every call, so this is always authoritative.",inputSchema: {type: 'object',properties: {},