Elffuss BraidHub

kikocis/continue public

Merge pull request #6081 from continuedev/dallin/url-tool

Fetch URL Content Tool
Changesetea675877d1a2bf781872ba4a7ffa7bf38c7b8c0d3fcfee9a2de0c27cde889d33
AuthorDallin Romney <dallinromney@gmail.com> · 2025-06-12 10:51 -07:00
CommitterGitHub <noreply@github.com> · 2025-06-12 10:51 -07:00
Parents0795258f043e, 32d59361d5be

Browse the files at this changeset

10 files changed

modified .continue/prompts/update-llm-info.prompt +2 −2
@@ -44,8 +44,8 @@
4444
4545 2. EXTRACT NEW INFORMATION
4646
47-New information will be pulled from the internet.
48-If you do not see a web search tool, let me know.
47+Fetch information from the internet using the search web and read url tools.
48+If you do not see either of these tools, stop and let me know.
4949
5050 Retrieve the following sites per these providers, and consider these notes on how to extract the information:
5151 - "gemini": https://ai.google.dev/gemini-api/docs/models - maxCompletionTokens is called "Output token limit", contextLength is called "Input token limit"
modified core/tools/builtIn.ts +1 −0
@@ -11,6 +11,7 @@
1111 LSTool = "builtin_ls",
1212 CreateRuleBlock = "builtin_create_rule_block",
1313 RequestRule = "builtin_request_rule",
14+ FetchUrlContent = "builtin_fetch_url_content",
1415
1516 // excluded from allTools for now
1617 ViewRepoMap = "builtin_view_repo_map",
modified core/tools/callTool.ts +3 −0
@@ -5,6 +5,7 @@
55
66 import { createNewFileImpl } from "./implementations/createNewFile";
77 import { createRuleBlockImpl } from "./implementations/createRuleBlock";
8+import { fetchUrlContentImpl } from "./implementations/fetchUrlContent";
89 import { fileGlobSearchImpl } from "./implementations/globSearch";
910 import { grepSearchImpl } from "./implementations/grepSearch";
1011 import { lsToolImpl } from "./implementations/lsTool";
@@ -151,6 +152,8 @@
151152 return await runTerminalCommandImpl(args, extras);
152153 case BuiltInToolNames.SearchWeb:
153154 return await searchWebImpl(args, extras);
155+ case BuiltInToolNames.FetchUrlContent:
156+ return await fetchUrlContentImpl(args, extras);
154157 case BuiltInToolNames.ViewDiff:
155158 return await viewDiffImpl(args, extras);
156159 case BuiltInToolNames.LSTool:
modified core/tools/definitions/editFile.ts +1 −0
@@ -14,6 +14,7 @@
1414 hasAlready: "edited {{{ filepath }}}",
1515 group: BUILT_IN_GROUP_NAME,
1616 readonly: false,
17+ isInstant: false,
1718 function: {
1819 name: BuiltInToolNames.EditExistingFile,
1920 description:
added core/tools/definitions/fetchUrlContent.ts +28 −0
@@ -0,0 +1,28 @@
1+import { Tool } from "../..";
2+import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
3+
4+export const fetchUrlContentTool: Tool = {
5+ type: "function",
6+ displayTitle: "Read URL",
7+ wouldLikeTo: "fetch {{{ url }}}",
8+ isCurrently: "fetching {{{ url }}}",
9+ hasAlready: "viewed {{{ url }}}",
10+ readonly: true,
11+ isInstant: true,
12+ group: BUILT_IN_GROUP_NAME,
13+ function: {
14+ name: BuiltInToolNames.FetchUrlContent,
15+ description:
16+ "Can be used to view the contents of a website using a URL. Do NOT use this for files.",
17+ parameters: {
18+ type: "object",
19+ required: ["url"],
20+ properties: {
21+ url: {
22+ type: "string",
23+ description: "The URL to read",
24+ },
25+ },
26+ },
27+ },
28+};
added core/tools/implementations/fetchUrlContent.ts +6 −0
@@ -0,0 +1,6 @@
1+import { ToolImpl } from ".";
2+import { getUrlContextItems } from "../../context/providers/URLContextProvider";
3+
4+export const fetchUrlContentImpl: ToolImpl = async (args, extras) => {
5+ return getUrlContextItems(args.url, extras.fetch);
6+};
modified core/tools/index.ts +2 −0
@@ -2,6 +2,7 @@
22 import { createNewFileTool } from "./definitions/createNewFile";
33 import { createRuleBlock } from "./definitions/createRuleBlock";
44 import { editFileTool } from "./definitions/editFile";
5+import { fetchUrlContentTool } from "./definitions/fetchUrlContent";
56 import { globSearchTool } from "./definitions/globSearch";
67 import { grepSearchTool } from "./definitions/grepSearch";
78 import { lsTool } from "./definitions/lsTool";
@@ -24,6 +25,7 @@
2425 readCurrentlyOpenFileTool,
2526 lsTool,
2627 createRuleBlock,
28+ fetchUrlContentTool,
2729 // replacing with ls tool for now
2830 // viewSubdirectoryTool,
2931 // viewRepoMapTool,
modified gui/src/components/mainInput/belowMainInput/ContextItemsPeek.tsx +16 −10
@@ -33,27 +33,21 @@
3333 function openContextItem() {
3434 const { uri, name, content } = contextItem;
3535
36- if (isUrl) {
37- if (uri?.value) {
38- ideMessenger.post("openUrl", uri.value);
39- } else {
40- console.error("Couldn't open url", uri);
41- }
42- } else if (uri) {
36+ if (uri && uri?.type === "file") {
4337 const isRangeInFile = name.includes(" (") && name.endsWith(")");
4438
4539 if (isRangeInFile) {
4640 const rif = ctxItemToRifWithContents(contextItem, true);
47- ideMessenger.ide.showLines(
41+ void ideMessenger.ide.showLines(
4842 rif.filepath,
4943 rif.range.start.line,
5044 rif.range.end.line,
5145 );
5246 } else {
53- ideMessenger.ide.openFile(uri.value);
47+ void ideMessenger.ide.openFile(uri.value);
5448 }
5549 } else {
56- ideMessenger.ide.showVirtualFile(name, content);
50+ void ideMessenger.ide.showVirtualFile(name, content);
5751 }
5852 }
5953
@@ -136,6 +130,18 @@
136130 </div>
137131 <div
138132 className={`min-w-0 flex-1 overflow-hidden truncate whitespace-nowrap text-xs text-gray-400 ${isUrl ? "hover:underline" : ""}`}
133+ onClick={
134+ isUrl
135+ ? (e) => {
136+ if (contextItem.uri?.value) {
137+ e.stopPropagation();
138+ ideMessenger.post("openUrl", contextItem.uri.value);
139+ } else {
140+ console.error("Couldn't open url", contextItem.uri);
141+ }
142+ }
143+ : undefined
144+ }
139145 >
140146 {contextItem.uri?.type === "file"
141147 ? getUriPathBasename(contextItem.description)
modified gui/src/pages/gui/ToolCallDiv/index.tsx +1 −0
@@ -41,6 +41,7 @@
4141 [BuiltInToolNames.LSTool]: FolderIcon,
4242 [BuiltInToolNames.ReadCurrentlyOpenFile]: DocumentTextIcon,
4343 [BuiltInToolNames.ReadFile]: DocumentIcon,
44+ [BuiltInToolNames.FetchUrlContent]: GlobeAltIcon,
4445 [BuiltInToolNames.SearchWeb]: GlobeAltIcon,
4546 [BuiltInToolNames.ViewDiff]: CodeBracketIcon,
4647 [BuiltInToolNames.ViewRepoMap]: MapIcon,
modified gui/src/redux/slices/uiSlice.ts +1 −0
@@ -53,6 +53,7 @@
5353 [BuiltInToolNames.GrepSearch]: "allowedWithoutPermission",
5454 [BuiltInToolNames.FileGlobSearch]: "allowedWithoutPermission",
5555 [BuiltInToolNames.SearchWeb]: "allowedWithoutPermission",
56+ [BuiltInToolNames.FetchUrlContent]: "allowedWithPermission",
5657 [BuiltInToolNames.ViewDiff]: "allowedWithoutPermission",
5758 [BuiltInToolNames.LSTool]: "allowedWithoutPermission",
5859 [BuiltInToolNames.CreateRuleBlock]: "allowedWithPermission",