From aa7ba35b00ce1b34eae71e382facaf080afbf02f Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 11 Jun 2025 11:22:13 -0700 Subject: [PATCH 1/4] read url tool --- .continue/prompts/update-llm-info.prompt | 4 ++-- core/tools/builtIn.ts | 1 + core/tools/callTool.ts | 3 +++ core/tools/definitions/editFile.ts | 1 + core/tools/definitions/readURL.ts | 28 ++++++++++++++++++++++++ core/tools/implementations/readUrl.ts | 6 +++++ core/tools/index.ts | 2 ++ gui/src/pages/gui/ToolCallDiv/index.tsx | 1 + gui/src/redux/slices/uiSlice.ts | 1 + 9 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 core/tools/definitions/readURL.ts create mode 100644 core/tools/implementations/readUrl.ts diff --git a/.continue/prompts/update-llm-info.prompt b/.continue/prompts/update-llm-info.prompt index 7264ebf38..9c1cf1f8e 100644 --- a/.continue/prompts/update-llm-info.prompt +++ b/.continue/prompts/update-llm-info.prompt @@ -44,8 +44,8 @@ export const AllMediaTypes = [ 2. EXTRACT NEW INFORMATION -New information will be pulled from the internet. -If you do not see a web search tool, let me know. +Fetch information from the internet using the search web and read url tools. +If you do not see either of these tools, stop and let me know. Retrieve the following sites per these providers, and consider these notes on how to extract the information: - "gemini": https://ai.google.dev/gemini-api/docs/models - maxCompletionTokens is called "Output token limit", contextLength is called "Input token limit" diff --git a/core/tools/builtIn.ts b/core/tools/builtIn.ts index 892cc3ff8..42b194ace 100644 --- a/core/tools/builtIn.ts +++ b/core/tools/builtIn.ts @@ -11,6 +11,7 @@ export enum BuiltInToolNames { LSTool = "builtin_ls", CreateRuleBlock = "builtin_create_rule_block", RequestRule = "builtin_request_rule", + ReadUrl = "builtin_read_url", // excluded from allTools for now ViewRepoMap = "builtin_view_repo_map", diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 6ea95610b..fc2bff37d 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -10,6 +10,7 @@ import { grepSearchImpl } from "./implementations/grepSearch"; import { lsToolImpl } from "./implementations/lsTool"; import { readCurrentlyOpenFileImpl } from "./implementations/readCurrentlyOpenFile"; import { readFileImpl } from "./implementations/readFile"; +import { readUrlImpl } from "./implementations/readUrl"; import { requestRuleImpl } from "./implementations/requestRule"; import { runTerminalCommandImpl } from "./implementations/runTerminalCommand"; import { searchWebImpl } from "./implementations/searchWeb"; @@ -151,6 +152,8 @@ async function callBuiltInTool( return await runTerminalCommandImpl(args, extras); case BuiltInToolNames.SearchWeb: return await searchWebImpl(args, extras); + case BuiltInToolNames.ReadUrl: + return await readUrlImpl(args, extras); case BuiltInToolNames.ViewDiff: return await viewDiffImpl(args, extras); case BuiltInToolNames.LSTool: diff --git a/core/tools/definitions/editFile.ts b/core/tools/definitions/editFile.ts index 1653cb279..6c6ad6fd9 100644 --- a/core/tools/definitions/editFile.ts +++ b/core/tools/definitions/editFile.ts @@ -14,6 +14,7 @@ export const editFileTool: Tool = { hasAlready: "edited {{{ filepath }}}", group: BUILT_IN_GROUP_NAME, readonly: false, + isInstant: false, function: { name: BuiltInToolNames.EditExistingFile, description: diff --git a/core/tools/definitions/readURL.ts b/core/tools/definitions/readURL.ts new file mode 100644 index 000000000..58236ddf0 --- /dev/null +++ b/core/tools/definitions/readURL.ts @@ -0,0 +1,28 @@ +import { Tool } from "../.."; +import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; + +export const readUrlTool: Tool = { + type: "function", + displayTitle: "Read URL", + wouldLikeTo: "fetch {{{ url }}}", + isCurrently: "fetching {{{ url }}}", + hasAlready: "viewed {{{ url }}}", + readonly: true, + isInstant: true, + group: BUILT_IN_GROUP_NAME, + function: { + name: BuiltInToolNames.ReadUrl, + description: + "Can be used to view the contents of a website using a URL. Do NOT use this for files.", + parameters: { + type: "object", + required: ["url"], + properties: { + url: { + type: "string", + description: "The URL to read", + }, + }, + }, + }, +}; diff --git a/core/tools/implementations/readUrl.ts b/core/tools/implementations/readUrl.ts new file mode 100644 index 000000000..7f1b402b4 --- /dev/null +++ b/core/tools/implementations/readUrl.ts @@ -0,0 +1,6 @@ +import { ToolImpl } from "."; +import { getUrlContextItems } from "../../context/providers/URLContextProvider"; + +export const readUrlImpl: ToolImpl = async (args, extras) => { + return getUrlContextItems(args.url, extras.fetch); +}; diff --git a/core/tools/index.ts b/core/tools/index.ts index f7ed3be4b..0a9739ad8 100644 --- a/core/tools/index.ts +++ b/core/tools/index.ts @@ -7,6 +7,7 @@ import { grepSearchTool } from "./definitions/grepSearch"; import { lsTool } from "./definitions/lsTool"; import { readCurrentlyOpenFileTool } from "./definitions/readCurrentlyOpenFile"; import { readFileTool } from "./definitions/readFile"; +import { readUrlTool } from "./definitions/readURL"; import { requestRuleTool } from "./definitions/requestRule"; import { runTerminalCommandTool } from "./definitions/runTerminalCommand"; import { searchWebTool } from "./definitions/searchWeb"; @@ -24,6 +25,7 @@ export const baseToolDefinitions = [ readCurrentlyOpenFileTool, lsTool, createRuleBlock, + readUrlTool, // replacing with ls tool for now // viewSubdirectoryTool, // viewRepoMapTool, diff --git a/gui/src/pages/gui/ToolCallDiv/index.tsx b/gui/src/pages/gui/ToolCallDiv/index.tsx index c919c0ca1..31b8bb84d 100644 --- a/gui/src/pages/gui/ToolCallDiv/index.tsx +++ b/gui/src/pages/gui/ToolCallDiv/index.tsx @@ -41,6 +41,7 @@ const toolCallIcons: Record = { [BuiltInToolNames.LSTool]: FolderIcon, [BuiltInToolNames.ReadCurrentlyOpenFile]: DocumentTextIcon, [BuiltInToolNames.ReadFile]: DocumentIcon, + [BuiltInToolNames.ReadUrl]: GlobeAltIcon, [BuiltInToolNames.SearchWeb]: GlobeAltIcon, [BuiltInToolNames.ViewDiff]: CodeBracketIcon, [BuiltInToolNames.ViewRepoMap]: MapIcon, diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index b8961a0b1..40b748b03 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -53,6 +53,7 @@ export const uiSlice = createSlice({ [BuiltInToolNames.GrepSearch]: "allowedWithoutPermission", [BuiltInToolNames.FileGlobSearch]: "allowedWithoutPermission", [BuiltInToolNames.SearchWeb]: "allowedWithoutPermission", + [BuiltInToolNames.ReadUrl]: "disabled", [BuiltInToolNames.ViewDiff]: "allowedWithoutPermission", [BuiltInToolNames.LSTool]: "allowedWithoutPermission", [BuiltInToolNames.CreateRuleBlock]: "allowedWithPermission", From 425e6afb5b8dbce3e83cdcce730b892fe5e22d34 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 11 Jun 2025 11:35:46 -0700 Subject: [PATCH 2/4] show url contents in virtual file --- .../belowMainInput/ContextItemsPeek.tsx | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx b/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx index 7c67463a9..3c7ce9390 100644 --- a/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx @@ -33,27 +33,21 @@ export function ContextItemsPeekItem({ function openContextItem() { const { uri, name, content } = contextItem; - if (isUrl) { - if (uri?.value) { - ideMessenger.post("openUrl", uri.value); - } else { - console.error("Couldn't open url", uri); - } - } else if (uri) { + if (uri && uri?.type === "file") { const isRangeInFile = name.includes(" (") && name.endsWith(")"); if (isRangeInFile) { const rif = ctxItemToRifWithContents(contextItem, true); - ideMessenger.ide.showLines( + void ideMessenger.ide.showLines( rif.filepath, rif.range.start.line, rif.range.end.line, ); } else { - ideMessenger.ide.openFile(uri.value); + void ideMessenger.ide.openFile(uri.value); } } else { - ideMessenger.ide.showVirtualFile(name, content); + void ideMessenger.ide.showVirtualFile(name, content); } } @@ -136,6 +130,18 @@ export function ContextItemsPeekItem({
{ + if (contextItem.uri?.value) { + e.stopPropagation(); + ideMessenger.post("openUrl", contextItem.uri.value); + } else { + console.error("Couldn't open url", contextItem.uri); + } + } + : undefined + } > {contextItem.uri?.type === "file" ? getUriPathBasename(contextItem.description) From 405b7805e4003caafd158d66e8bf18149c3f7146 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 11 Jun 2025 16:46:53 -0700 Subject: [PATCH 3/4] change default readURL permissions --- gui/src/redux/slices/uiSlice.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index 40b748b03..9863b37d9 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -53,7 +53,7 @@ export const uiSlice = createSlice({ [BuiltInToolNames.GrepSearch]: "allowedWithoutPermission", [BuiltInToolNames.FileGlobSearch]: "allowedWithoutPermission", [BuiltInToolNames.SearchWeb]: "allowedWithoutPermission", - [BuiltInToolNames.ReadUrl]: "disabled", + [BuiltInToolNames.ReadUrl]: "allowedWithPermission", [BuiltInToolNames.ViewDiff]: "allowedWithoutPermission", [BuiltInToolNames.LSTool]: "allowedWithoutPermission", [BuiltInToolNames.CreateRuleBlock]: "allowedWithPermission", From bfca8a17addb36c5b00b9d3abec311f9ab941340 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 12 Jun 2025 10:40:24 -0700 Subject: [PATCH 4/4] Fetch URL Content tool --- core/tools/builtIn.ts | 2 +- core/tools/callTool.ts | 6 +++--- core/tools/definitions/{readURL.ts => fetchUrlContent.ts} | 4 ++-- .../implementations/{readUrl.ts => fetchUrlContent.ts} | 2 +- core/tools/index.ts | 4 ++-- gui/src/pages/gui/ToolCallDiv/index.tsx | 2 +- gui/src/redux/slices/uiSlice.ts | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) rename core/tools/definitions/{readURL.ts => fetchUrlContent.ts} (88%) rename core/tools/implementations/{readUrl.ts => fetchUrlContent.ts} (70%) diff --git a/core/tools/builtIn.ts b/core/tools/builtIn.ts index 42b194ace..5a2408a0c 100644 --- a/core/tools/builtIn.ts +++ b/core/tools/builtIn.ts @@ -11,7 +11,7 @@ export enum BuiltInToolNames { LSTool = "builtin_ls", CreateRuleBlock = "builtin_create_rule_block", RequestRule = "builtin_request_rule", - ReadUrl = "builtin_read_url", + FetchUrlContent = "builtin_fetch_url_content", // excluded from allTools for now ViewRepoMap = "builtin_view_repo_map", diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index fc2bff37d..40dd7abe2 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -5,12 +5,12 @@ import { BuiltInToolNames } from "./builtIn"; import { createNewFileImpl } from "./implementations/createNewFile"; import { createRuleBlockImpl } from "./implementations/createRuleBlock"; +import { fetchUrlContentImpl } from "./implementations/fetchUrlContent"; import { fileGlobSearchImpl } from "./implementations/globSearch"; import { grepSearchImpl } from "./implementations/grepSearch"; import { lsToolImpl } from "./implementations/lsTool"; import { readCurrentlyOpenFileImpl } from "./implementations/readCurrentlyOpenFile"; import { readFileImpl } from "./implementations/readFile"; -import { readUrlImpl } from "./implementations/readUrl"; import { requestRuleImpl } from "./implementations/requestRule"; import { runTerminalCommandImpl } from "./implementations/runTerminalCommand"; import { searchWebImpl } from "./implementations/searchWeb"; @@ -152,8 +152,8 @@ async function callBuiltInTool( return await runTerminalCommandImpl(args, extras); case BuiltInToolNames.SearchWeb: return await searchWebImpl(args, extras); - case BuiltInToolNames.ReadUrl: - return await readUrlImpl(args, extras); + case BuiltInToolNames.FetchUrlContent: + return await fetchUrlContentImpl(args, extras); case BuiltInToolNames.ViewDiff: return await viewDiffImpl(args, extras); case BuiltInToolNames.LSTool: diff --git a/core/tools/definitions/readURL.ts b/core/tools/definitions/fetchUrlContent.ts similarity index 88% rename from core/tools/definitions/readURL.ts rename to core/tools/definitions/fetchUrlContent.ts index 58236ddf0..e0122f55b 100644 --- a/core/tools/definitions/readURL.ts +++ b/core/tools/definitions/fetchUrlContent.ts @@ -1,7 +1,7 @@ import { Tool } from "../.."; import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; -export const readUrlTool: Tool = { +export const fetchUrlContentTool: Tool = { type: "function", displayTitle: "Read URL", wouldLikeTo: "fetch {{{ url }}}", @@ -11,7 +11,7 @@ export const readUrlTool: Tool = { isInstant: true, group: BUILT_IN_GROUP_NAME, function: { - name: BuiltInToolNames.ReadUrl, + name: BuiltInToolNames.FetchUrlContent, description: "Can be used to view the contents of a website using a URL. Do NOT use this for files.", parameters: { diff --git a/core/tools/implementations/readUrl.ts b/core/tools/implementations/fetchUrlContent.ts similarity index 70% rename from core/tools/implementations/readUrl.ts rename to core/tools/implementations/fetchUrlContent.ts index 7f1b402b4..d2c031d4e 100644 --- a/core/tools/implementations/readUrl.ts +++ b/core/tools/implementations/fetchUrlContent.ts @@ -1,6 +1,6 @@ import { ToolImpl } from "."; import { getUrlContextItems } from "../../context/providers/URLContextProvider"; -export const readUrlImpl: ToolImpl = async (args, extras) => { +export const fetchUrlContentImpl: ToolImpl = async (args, extras) => { return getUrlContextItems(args.url, extras.fetch); }; diff --git a/core/tools/index.ts b/core/tools/index.ts index 0a9739ad8..c4d1c658b 100644 --- a/core/tools/index.ts +++ b/core/tools/index.ts @@ -2,12 +2,12 @@ import { ConfigDependentToolParams, Tool } from ".."; import { createNewFileTool } from "./definitions/createNewFile"; import { createRuleBlock } from "./definitions/createRuleBlock"; import { editFileTool } from "./definitions/editFile"; +import { fetchUrlContentTool } from "./definitions/fetchUrlContent"; import { globSearchTool } from "./definitions/globSearch"; import { grepSearchTool } from "./definitions/grepSearch"; import { lsTool } from "./definitions/lsTool"; import { readCurrentlyOpenFileTool } from "./definitions/readCurrentlyOpenFile"; import { readFileTool } from "./definitions/readFile"; -import { readUrlTool } from "./definitions/readURL"; import { requestRuleTool } from "./definitions/requestRule"; import { runTerminalCommandTool } from "./definitions/runTerminalCommand"; import { searchWebTool } from "./definitions/searchWeb"; @@ -25,7 +25,7 @@ export const baseToolDefinitions = [ readCurrentlyOpenFileTool, lsTool, createRuleBlock, - readUrlTool, + fetchUrlContentTool, // replacing with ls tool for now // viewSubdirectoryTool, // viewRepoMapTool, diff --git a/gui/src/pages/gui/ToolCallDiv/index.tsx b/gui/src/pages/gui/ToolCallDiv/index.tsx index 31b8bb84d..d3f2edb09 100644 --- a/gui/src/pages/gui/ToolCallDiv/index.tsx +++ b/gui/src/pages/gui/ToolCallDiv/index.tsx @@ -41,7 +41,7 @@ const toolCallIcons: Record = { [BuiltInToolNames.LSTool]: FolderIcon, [BuiltInToolNames.ReadCurrentlyOpenFile]: DocumentTextIcon, [BuiltInToolNames.ReadFile]: DocumentIcon, - [BuiltInToolNames.ReadUrl]: GlobeAltIcon, + [BuiltInToolNames.FetchUrlContent]: GlobeAltIcon, [BuiltInToolNames.SearchWeb]: GlobeAltIcon, [BuiltInToolNames.ViewDiff]: CodeBracketIcon, [BuiltInToolNames.ViewRepoMap]: MapIcon, diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index 9863b37d9..dcdddafb1 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -53,7 +53,7 @@ export const uiSlice = createSlice({ [BuiltInToolNames.GrepSearch]: "allowedWithoutPermission", [BuiltInToolNames.FileGlobSearch]: "allowedWithoutPermission", [BuiltInToolNames.SearchWeb]: "allowedWithoutPermission", - [BuiltInToolNames.ReadUrl]: "allowedWithPermission", + [BuiltInToolNames.FetchUrlContent]: "allowedWithPermission", [BuiltInToolNames.ViewDiff]: "allowedWithoutPermission", [BuiltInToolNames.LSTool]: "allowedWithoutPermission", [BuiltInToolNames.CreateRuleBlock]: "allowedWithPermission",