From 8a5018ef0fd429c75bcff3b1f7c9050a0c1f84ec Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 14 May 2025 10:32:02 -0700 Subject: [PATCH 1/3] fix spacing for mode toggle keyboard shortcut and agent not supported copy --- gui/src/components/modelSelection/ModeSelect.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gui/src/components/modelSelection/ModeSelect.tsx b/gui/src/components/modelSelection/ModeSelect.tsx index c1f1552ef..23caef356 100644 --- a/gui/src/components/modelSelection/ModeSelect.tsx +++ b/gui/src/components/modelSelection/ModeSelect.tsx @@ -173,17 +173,24 @@ function ModeSelect() { {mode === "chat" && } - +
Agent
- {mode === "agent" && } - {!agentModeSupported && (Not supported)} + {agentModeSupported ? ( + mode === "agent" && + ) : ( + (Not supported) + )}
- {metaKeyLabel}. for next mode + {`${metaKeyLabel} . for next mode`}
From d40fc9634607420f130c5a646cb1a832a6ee5214 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 14 May 2025 10:59:34 -0700 Subject: [PATCH 2/3] better URI tool errors and no hanging for nonexistent tool --- core/tools/callTool.ts | 80 ++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index d8eaf4ffd..263dfcdb7 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -29,11 +29,12 @@ async function callHttpTool( }), }); + const data = await response.json(); + if (!response.ok) { - throw new Error(`Failed to call tool: ${url}`); + throw new Error(`Failed to call tool at ${url}:\n${JSON.stringify(data)}`); } - const data = await response.json(); return data.output; } @@ -84,7 +85,7 @@ async function callToolFromUri( }); if (response.isError === true) { - throw new Error(`Failed to call tool: ${toolName}`); + throw new Error(JSON.stringify(response.content)); } const contextItems: ContextItem[] = []; @@ -141,43 +142,46 @@ export async function callTool( contextItems: ContextItem[]; errorMessage: string | undefined; }> { - const args = JSON.parse(callArgs || "{}"); - const uri = tool.uri ?? tool.function.name; try { + const args = JSON.parse(callArgs || "{}"); let contextItems: ContextItem[] = []; - switch (uri) { - case BuiltInToolNames.ReadFile: - contextItems = await readFileImpl(args, extras); - break; - case BuiltInToolNames.CreateNewFile: - contextItems = await createNewFileImpl(args, extras); - break; - case BuiltInToolNames.GrepSearch: - contextItems = await grepSearchImpl(args, extras); - break; - case BuiltInToolNames.FileGlobSearch: - contextItems = await fileGlobSearchImpl(args, extras); - break; - case BuiltInToolNames.RunTerminalCommand: - contextItems = await runTerminalCommandImpl(args, extras); - break; - case BuiltInToolNames.SearchWeb: - contextItems = await searchWebImpl(args, extras); - break; - case BuiltInToolNames.ViewDiff: - contextItems = await viewDiffImpl(args, extras); - break; - case BuiltInToolNames.LSTool: - contextItems = await lsToolImpl(args, extras); - break; - case BuiltInToolNames.ReadCurrentlyOpenFile: - contextItems = await readCurrentlyOpenFileImpl(args, extras); - break; - case BuiltInToolNames.CreateRuleBlock: - contextItems = await createRuleBlockImpl(args, extras); - break; - default: - contextItems = await callToolFromUri(uri, args, extras); + if (tool.uri) { + contextItems = await callToolFromUri(tool.uri, args, extras); + } else { + switch (tool.function.name) { + case BuiltInToolNames.ReadFile: + contextItems = await readFileImpl(args, extras); + break; + case BuiltInToolNames.CreateNewFile: + contextItems = await createNewFileImpl(args, extras); + break; + case BuiltInToolNames.GrepSearch: + contextItems = await grepSearchImpl(args, extras); + break; + case BuiltInToolNames.FileGlobSearch: + contextItems = await fileGlobSearchImpl(args, extras); + break; + case BuiltInToolNames.RunTerminalCommand: + contextItems = await runTerminalCommandImpl(args, extras); + break; + case BuiltInToolNames.SearchWeb: + contextItems = await searchWebImpl(args, extras); + break; + case BuiltInToolNames.ViewDiff: + contextItems = await viewDiffImpl(args, extras); + break; + case BuiltInToolNames.LSTool: + contextItems = await lsToolImpl(args, extras); + break; + case BuiltInToolNames.ReadCurrentlyOpenFile: + contextItems = await readCurrentlyOpenFileImpl(args, extras); + break; + case BuiltInToolNames.CreateRuleBlock: + contextItems = await createRuleBlockImpl(args, extras); + break; + default: + throw new Error(`Tool "${tool.function.name}" not found`); + } } if (tool.faviconUrl) { contextItems.forEach((item) => { From c62180f721479653efed61092b1ac9f2ca05b3be Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 16 May 2025 12:29:31 -0700 Subject: [PATCH 3/3] remove let --- core/tools/callTool.ts | 73 ++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 263dfcdb7..34501550b 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -131,6 +131,37 @@ async function callToolFromUri( } } +async function callBuiltInTool( + functionName: string, + args: any, + extras: ToolExtras, +): Promise { + switch (functionName) { + case BuiltInToolNames.ReadFile: + return await readFileImpl(args, extras); + case BuiltInToolNames.CreateNewFile: + return await createNewFileImpl(args, extras); + case BuiltInToolNames.GrepSearch: + return await grepSearchImpl(args, extras); + case BuiltInToolNames.FileGlobSearch: + return await fileGlobSearchImpl(args, extras); + case BuiltInToolNames.RunTerminalCommand: + return await runTerminalCommandImpl(args, extras); + case BuiltInToolNames.SearchWeb: + return await searchWebImpl(args, extras); + case BuiltInToolNames.ViewDiff: + return await viewDiffImpl(args, extras); + case BuiltInToolNames.LSTool: + return await lsToolImpl(args, extras); + case BuiltInToolNames.ReadCurrentlyOpenFile: + return await readCurrentlyOpenFileImpl(args, extras); + case BuiltInToolNames.CreateRuleBlock: + return await createRuleBlockImpl(args, extras); + default: + throw new Error(`Tool "${functionName}" not found`); + } +} + // Handles calls for core/non-client tools // Returns an error context item if the tool call fails // Note: Edit tool is handled on client @@ -144,45 +175,9 @@ export async function callTool( }> { try { const args = JSON.parse(callArgs || "{}"); - let contextItems: ContextItem[] = []; - if (tool.uri) { - contextItems = await callToolFromUri(tool.uri, args, extras); - } else { - switch (tool.function.name) { - case BuiltInToolNames.ReadFile: - contextItems = await readFileImpl(args, extras); - break; - case BuiltInToolNames.CreateNewFile: - contextItems = await createNewFileImpl(args, extras); - break; - case BuiltInToolNames.GrepSearch: - contextItems = await grepSearchImpl(args, extras); - break; - case BuiltInToolNames.FileGlobSearch: - contextItems = await fileGlobSearchImpl(args, extras); - break; - case BuiltInToolNames.RunTerminalCommand: - contextItems = await runTerminalCommandImpl(args, extras); - break; - case BuiltInToolNames.SearchWeb: - contextItems = await searchWebImpl(args, extras); - break; - case BuiltInToolNames.ViewDiff: - contextItems = await viewDiffImpl(args, extras); - break; - case BuiltInToolNames.LSTool: - contextItems = await lsToolImpl(args, extras); - break; - case BuiltInToolNames.ReadCurrentlyOpenFile: - contextItems = await readCurrentlyOpenFileImpl(args, extras); - break; - case BuiltInToolNames.CreateRuleBlock: - contextItems = await createRuleBlockImpl(args, extras); - break; - default: - throw new Error(`Tool "${tool.function.name}" not found`); - } - } + const contextItems = tool.uri + ? await callToolFromUri(tool.uri, args, extras) + : await callBuiltInTool(tool.function.name, args, extras); if (tool.faviconUrl) { contextItems.forEach((item) => { item.icon = tool.faviconUrl;