From aa7ba35b00ce1b34eae71e382facaf080afbf02f Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 11 Jun 2025 11:22:13 -0700 Subject: [PATCH] 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",