diff --git a/src/core/assistant-message/index.ts b/src/core/assistant-message/index.ts index ef1f5685..29af030b 100644 --- a/src/core/assistant-message/index.ts +++ b/src/core/assistant-message/index.ts @@ -24,6 +24,7 @@ export const toolParamNames = [ "url", "coordinate", "text", + "prompt", "server_name", "tool_name", "arguments", diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-basic.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-basic.snap index 31e29d09..cc5bd39f 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-basic.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-basic.snap @@ -171,24 +171,6 @@ Usage: Text to type (optional) -## web_fetch -Description: Fetches content from a specified URL and processes into markdown -- Takes a URL as input -- Fetches the URL content, converts HTML to markdown -- Use this tool when you need to retrieve and analyze web content -- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. -- The URL must be a fully-formed valid URL -- HTTP URLs will be automatically upgraded to HTTPS -- This tool is read-only and does not modify any files -Parameters: -- url: (required) The URL to fetch content from -- task_progress: (optional) A checklist showing task progress after this tool use is completed. The task_progress parameter must be included as a separate parameter inside of the parent tool call, it must be separate from other parameters such as content, arguments, etc. (See 'UPDATING TASK PROGRESS' section for more details) -Usage: - -https://example.com/docs -Checklist here (optional) - - ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-browser.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-browser.snap index 3b55fa61..e0da901f 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-browser.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-browser.snap @@ -137,24 +137,6 @@ Usage: Checklist here (optional) -## web_fetch -Description: Fetches content from a specified URL and processes into markdown -- Takes a URL as input -- Fetches the URL content, converts HTML to markdown -- Use this tool when you need to retrieve and analyze web content -- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. -- The URL must be a fully-formed valid URL -- HTTP URLs will be automatically upgraded to HTTPS -- This tool is read-only and does not modify any files -Parameters: -- url: (required) The URL to fetch content from -- task_progress: (optional) A checklist showing task progress after this tool use is completed. The task_progress parameter must be included as a separate parameter inside of the parent tool call, it must be separate from other parameters such as content, arguments, etc. (See 'UPDATING TASK PROGRESS' section for more details) -Usage: - -https://example.com/docs -Checklist here (optional) - - ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-focus-chain.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-focus-chain.snap index d8f72ed9..ea92426b 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-focus-chain.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-focus-chain.snap @@ -156,22 +156,6 @@ Usage: Text to type (optional) -## web_fetch -Description: Fetches content from a specified URL and processes into markdown -- Takes a URL as input -- Fetches the URL content, converts HTML to markdown -- Use this tool when you need to retrieve and analyze web content -- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. -- The URL must be a fully-formed valid URL -- HTTP URLs will be automatically upgraded to HTTPS -- This tool is read-only and does not modify any files -Parameters: -- url: (required) The URL to fetch content from -Usage: - -https://example.com/docs - - ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-mcp.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-mcp.snap index b7f32d99..4e03b85e 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-mcp.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/anthropic_claude_sonnet_4-no-mcp.snap @@ -171,24 +171,6 @@ Usage: Text to type (optional) -## web_fetch -Description: Fetches content from a specified URL and processes into markdown -- Takes a URL as input -- Fetches the URL content, converts HTML to markdown -- Use this tool when you need to retrieve and analyze web content -- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. -- The URL must be a fully-formed valid URL -- HTTP URLs will be automatically upgraded to HTTPS -- This tool is read-only and does not modify any files -Parameters: -- url: (required) The URL to fetch content from -- task_progress: (optional) A checklist showing task progress after this tool use is completed. The task_progress parameter must be included as a separate parameter inside of the parent tool call, it must be separate from other parameters such as content, arguments, etc. (See 'UPDATING TASK PROGRESS' section for more details) -Usage: - -https://example.com/docs -Checklist here (optional) - - ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-basic.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-basic.snap index cb312a79..a3dc8892 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-basic.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-basic.snap @@ -177,6 +177,27 @@ Usage: Text to type (optional) +## web_fetch +Description: Fetches content from a specified URL and analyzes it using your prompt +- Takes a URL and analysis prompt as input +- Fetches the URL content and processes based on your prompt +- Use this tool when you need to retrieve and analyze web content +- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. +- The URL must be a fully-formed valid URL +- The prompt must be at least 2 characters +- HTTP URLs will be automatically upgraded to HTTPS +- This tool is read-only and does not modify any files +Parameters: +- url: (required) The URL to fetch content from +- prompt: (required) The prompt to use for analyzing the webpage content +- task_progress: (optional) A checklist showing task progress after this tool use is completed. The task_progress parameter must be included as a separate parameter inside of the parent tool call, it must be separate from other parameters such as content, arguments, etc. (See 'UPDATING TASK PROGRESS' section for more details) +Usage: + +https://example.com/docs +Summarize the main points and key takeaways +Checklist here (optional) + + ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-browser.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-browser.snap index 7f783247..721e98b0 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-browser.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-browser.snap @@ -143,6 +143,27 @@ Usage: Checklist here (optional) +## web_fetch +Description: Fetches content from a specified URL and analyzes it using your prompt +- Takes a URL and analysis prompt as input +- Fetches the URL content and processes based on your prompt +- Use this tool when you need to retrieve and analyze web content +- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. +- The URL must be a fully-formed valid URL +- The prompt must be at least 2 characters +- HTTP URLs will be automatically upgraded to HTTPS +- This tool is read-only and does not modify any files +Parameters: +- url: (required) The URL to fetch content from +- prompt: (required) The prompt to use for analyzing the webpage content +- task_progress: (optional) A checklist showing task progress after this tool use is completed. The task_progress parameter must be included as a separate parameter inside of the parent tool call, it must be separate from other parameters such as content, arguments, etc. (See 'UPDATING TASK PROGRESS' section for more details) +Usage: + +https://example.com/docs +Summarize the main points and key takeaways +Checklist here (optional) + + ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-focus-chain.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-focus-chain.snap index 846fac80..4307ff65 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-focus-chain.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-focus-chain.snap @@ -162,6 +162,25 @@ Usage: Text to type (optional) +## web_fetch +Description: Fetches content from a specified URL and analyzes it using your prompt +- Takes a URL and analysis prompt as input +- Fetches the URL content and processes based on your prompt +- Use this tool when you need to retrieve and analyze web content +- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. +- The URL must be a fully-formed valid URL +- The prompt must be at least 2 characters +- HTTP URLs will be automatically upgraded to HTTPS +- This tool is read-only and does not modify any files +Parameters: +- url: (required) The URL to fetch content from +- prompt: (required) The prompt to use for analyzing the webpage content +Usage: + +https://example.com/docs +Summarize the main points and key takeaways + + ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-mcp.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-mcp.snap index 1aefbf4e..7a367703 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-mcp.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/cline_microwave-no-mcp.snap @@ -177,6 +177,27 @@ Usage: Text to type (optional) +## web_fetch +Description: Fetches content from a specified URL and analyzes it using your prompt +- Takes a URL and analysis prompt as input +- Fetches the URL content and processes based on your prompt +- Use this tool when you need to retrieve and analyze web content +- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. +- The URL must be a fully-formed valid URL +- The prompt must be at least 2 characters +- HTTP URLs will be automatically upgraded to HTTPS +- This tool is read-only and does not modify any files +Parameters: +- url: (required) The URL to fetch content from +- prompt: (required) The prompt to use for analyzing the webpage content +- task_progress: (optional) A checklist showing task progress after this tool use is completed. The task_progress parameter must be included as a separate parameter inside of the parent tool call, it must be separate from other parameters such as content, arguments, etc. (See 'UPDATING TASK PROGRESS' section for more details) +Usage: + +https://example.com/docs +Summarize the main points and key takeaways +Checklist here (optional) + + ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-basic.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-basic.snap index 8deda5a9..0b2e4c05 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-basic.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-basic.snap @@ -171,24 +171,6 @@ Usage: Text to type (optional) -## web_fetch -Description: Fetches content from a specified URL and processes into markdown -- Takes a URL as input -- Fetches the URL content, converts HTML to markdown -- Use this tool when you need to retrieve and analyze web content -- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. -- The URL must be a fully-formed valid URL -- HTTP URLs will be automatically upgraded to HTTPS -- This tool is read-only and does not modify any files -Parameters: -- url: (required) The URL to fetch content from -- task_progress: (optional) A checklist showing task progress after this tool use is completed. The task_progress parameter must be included as a separate parameter inside of the parent tool call, it must be separate from other parameters such as content, arguments, etc. (See 'UPDATING TASK PROGRESS' section for more details) -Usage: - -https://example.com/docs -Checklist here (optional) - - ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-browser.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-browser.snap index af0a0ca9..fcb3aa16 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-browser.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-browser.snap @@ -137,24 +137,6 @@ Usage: Checklist here (optional) -## web_fetch -Description: Fetches content from a specified URL and processes into markdown -- Takes a URL as input -- Fetches the URL content, converts HTML to markdown -- Use this tool when you need to retrieve and analyze web content -- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. -- The URL must be a fully-formed valid URL -- HTTP URLs will be automatically upgraded to HTTPS -- This tool is read-only and does not modify any files -Parameters: -- url: (required) The URL to fetch content from -- task_progress: (optional) A checklist showing task progress after this tool use is completed. The task_progress parameter must be included as a separate parameter inside of the parent tool call, it must be separate from other parameters such as content, arguments, etc. (See 'UPDATING TASK PROGRESS' section for more details) -Usage: - -https://example.com/docs -Checklist here (optional) - - ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-focus-chain.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-focus-chain.snap index 5fc59c73..46e5f9c8 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-focus-chain.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-focus-chain.snap @@ -156,22 +156,6 @@ Usage: Text to type (optional) -## web_fetch -Description: Fetches content from a specified URL and processes into markdown -- Takes a URL as input -- Fetches the URL content, converts HTML to markdown -- Use this tool when you need to retrieve and analyze web content -- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. -- The URL must be a fully-formed valid URL -- HTTP URLs will be automatically upgraded to HTTPS -- This tool is read-only and does not modify any files -Parameters: -- url: (required) The URL to fetch content from -Usage: - -https://example.com/docs - - ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-mcp.snap b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-mcp.snap index 5947d29f..1881ebcf 100644 --- a/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-mcp.snap +++ b/src/core/prompts/system-prompt/__tests__/__snapshots__/openai_gpt_5-no-mcp.snap @@ -171,24 +171,6 @@ Usage: Text to type (optional) -## web_fetch -Description: Fetches content from a specified URL and processes into markdown -- Takes a URL as input -- Fetches the URL content, converts HTML to markdown -- Use this tool when you need to retrieve and analyze web content -- IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. -- The URL must be a fully-formed valid URL -- HTTP URLs will be automatically upgraded to HTTPS -- This tool is read-only and does not modify any files -Parameters: -- url: (required) The URL to fetch content from -- task_progress: (optional) A checklist showing task progress after this tool use is completed. The task_progress parameter must be included as a separate parameter inside of the parent tool call, it must be separate from other parameters such as content, arguments, etc. (See 'UPDATING TASK PROGRESS' section for more details) -Usage: - -https://example.com/docs -Checklist here (optional) - - ## use_mcp_tool Description: Request to use a tool provided by a connected MCP server. Each MCP server can provide multiple tools with different capabilities. Tools have defined input schemas that specify required and optional parameters. Parameters: diff --git a/src/core/prompts/system-prompt/__tests__/integration.test.ts b/src/core/prompts/system-prompt/__tests__/integration.test.ts index 75585af0..a31d0f19 100644 --- a/src/core/prompts/system-prompt/__tests__/integration.test.ts +++ b/src/core/prompts/system-prompt/__tests__/integration.test.ts @@ -132,6 +132,7 @@ const baseContext: SystemPromptContext = { cwd: "/test/project", ide: "TestIde", supportsBrowserUse: true, + clineWebToolsEnabled: true, mcpHub: { getServers: () => [ { diff --git a/src/core/prompts/system-prompt/tools/web_fetch.ts b/src/core/prompts/system-prompt/tools/web_fetch.ts index b99ae2aa..dc85b12c 100644 --- a/src/core/prompts/system-prompt/tools/web_fetch.ts +++ b/src/core/prompts/system-prompt/tools/web_fetch.ts @@ -3,18 +3,20 @@ import { ClineDefaultTool } from "@/shared/tools" import type { ClineToolSpec } from "../spec" import { TASK_PROGRESS_PARAMETER } from "../types" -const nextGen: ClineToolSpec = { - variant: ModelFamily.NEXT_GEN, +const GENERIC: ClineToolSpec = { + variant: ModelFamily.GENERIC, id: ClineDefaultTool.WEB_FETCH, name: "web_fetch", - description: `Fetches content from a specified URL and processes into markdown -- Takes a URL as input -- Fetches the URL content, converts HTML to markdown + description: `Fetches content from a specified URL and analyzes it using your prompt +- Takes a URL and analysis prompt as input +- Fetches the URL content and processes based on your prompt - Use this tool when you need to retrieve and analyze web content - IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions. - The URL must be a fully-formed valid URL +- The prompt must be at least 2 characters - HTTP URLs will be automatically upgraded to HTTPS - This tool is read-only and does not modify any files`, + contextRequirements: (context) => context.providerInfo.providerId === "cline" && context.clineWebToolsEnabled === true, parameters: [ { name: "url", @@ -22,6 +24,12 @@ const nextGen: ClineToolSpec = { instruction: "The URL to fetch content from", usage: "https://example.com/docs", }, + { + name: "prompt", + required: true, + instruction: "The prompt to use for analyzing the webpage content", + usage: "Summarize the main points and key takeaways", + }, TASK_PROGRESS_PARAMETER, ], } @@ -30,13 +38,19 @@ const NATIVE_NEXT_GEN: ClineToolSpec = { variant: ModelFamily.NATIVE_NEXT_GEN, id: ClineDefaultTool.WEB_FETCH, name: "web_fetch", - description: "Fetches content from a specified URL. Only used for gathering needed information relevant to the task.", + description: "Fetches and analyzes content from a specified URL.", + contextRequirements: (context) => context.providerInfo.providerId === "cline" && context.clineWebToolsEnabled === true, parameters: [ { name: "url", required: true, instruction: "The URL to fetch content from", }, + { + name: "prompt", + required: true, + instruction: "Prompt for analyzing the webpage content", + }, TASK_PROGRESS_PARAMETER, ], } @@ -46,4 +60,4 @@ const NATIVE_GPT_5: ClineToolSpec = { variant: ModelFamily.NATIVE_GPT_5, } -export const web_fetch_variants = [nextGen, NATIVE_GPT_5, NATIVE_NEXT_GEN] +export const web_fetch_variants = [GENERIC, NATIVE_GPT_5, NATIVE_NEXT_GEN] diff --git a/src/core/prompts/system-prompt/variants/microwave/config.ts b/src/core/prompts/system-prompt/variants/microwave/config.ts index 24f890dc..c040ebc5 100644 --- a/src/core/prompts/system-prompt/variants/microwave/config.ts +++ b/src/core/prompts/system-prompt/variants/microwave/config.ts @@ -42,6 +42,7 @@ export const config = createVariant(ModelFamily.MICROWAVE) ClineDefaultTool.LIST_FILES, ClineDefaultTool.LIST_CODE_DEF, ClineDefaultTool.BROWSER, + ClineDefaultTool.WEB_FETCH, ClineDefaultTool.MCP_USE, ClineDefaultTool.MCP_ACCESS, ClineDefaultTool.ASK, diff --git a/src/core/task/tools/handlers/WebFetchToolHandler.ts b/src/core/task/tools/handlers/WebFetchToolHandler.ts index 1b6993ac..a1f0d87e 100644 --- a/src/core/task/tools/handlers/WebFetchToolHandler.ts +++ b/src/core/task/tools/handlers/WebFetchToolHandler.ts @@ -1,7 +1,12 @@ -import { UrlContentFetcher } from "@services/browser/UrlContentFetcher" import { ClineAsk, ClineSayTool } from "@shared/ExtensionMessage" import { ClineDefaultTool } from "@shared/tools" +import axios from "axios" +import { ClineEnv } from "@/config" +import { AuthService } from "@/services/auth/AuthService" +import { buildClineExtraHeaders } from "@/services/EnvUtils" import { telemetryService } from "@/services/telemetry" +import { CLINE_ACCOUNT_AUTH_ERROR_MESSAGE } from "@/shared/ClineAccount" +import { getAxiosSettings } from "@/shared/net" import { ToolUse } from "../../../assistant-message" import { formatResponse } from "../../../prompts/responses" import { ToolResponse } from "../.." @@ -38,17 +43,28 @@ export class WebFetchToolHandler implements IFullyManagedTool { async execute(config: TaskConfig, block: ToolUse): Promise { try { const url: string | undefined = block.params.url + const prompt: string | undefined = block.params.prompt // Extract provider information for telemetry const apiConfig = config.services.stateManager.getApiConfiguration() const currentMode = config.services.stateManager.getGlobalSettingsKey("mode") const provider = (currentMode === "plan" ? apiConfig.planModeApiProvider : apiConfig.actModeApiProvider) as string - // Validate required parameter + // Check if Cline web tools are enabled + const clineWebToolsEnabled = config.services.stateManager.getGlobalSettingsKey("clineWebToolsEnabled") + if (provider !== "cline" || !clineWebToolsEnabled) { + return formatResponse.toolError("Cline web tools are currently disabled.") + } + + // Validate required parameters if (!url) { config.taskState.consecutiveMistakeCount++ return await config.callbacks.sayAndCreateMissingParamError(this.name, "url") } + if (!prompt) { + config.taskState.consecutiveMistakeCount++ + return await config.callbacks.sayAndCreateMissingParamError(this.name, "prompt") + } config.taskState.consecutiveMistakeCount = 0 // Create message for approval @@ -122,24 +138,36 @@ export class WebFetchToolHandler implements IFullyManagedTool { } // Execute the actual fetch - const urlContentFetcher = config.services?.urlContentFetcher as UrlContentFetcher + const baseUrl = ClineEnv.config().apiBaseUrl + const authToken = await AuthService.getInstance().getAuthToken() - await urlContentFetcher.launchBrowser() - try { - // Fetch Markdown content - const markdownContent = await urlContentFetcher.urlToMarkdown(url) - - // TODO: Implement secondary AI call to process markdownContent with prompt - // For now, returning markdown directly. - // This will be a significant sub-task. - // Placeholder for processed summary: - const processedSummary = `Fetched Markdown for ${url}:\n\n${markdownContent}` - - return formatResponse.toolResult(processedSummary) - } finally { - // Ensure browser is closed even on error - await urlContentFetcher.closeBrowser() + if (!authToken) { + throw new Error(CLINE_ACCOUNT_AUTH_ERROR_MESSAGE) } + + const response = await axios.post( + `${baseUrl}/api/v1/search/webfetch`, + { + Url: url, + Prompt: prompt, + }, + { + headers: { + Authorization: `Bearer ${authToken}`, + "Content-Type": "application/json", + "X-Task-ID": config.ulid || "", + ...(await buildClineExtraHeaders()), + }, + timeout: 15000, + ...getAxiosSettings(), + }, + ) + + // Parse response + // Axios will throw on non-200 status, so no need to check fetchStatus + const result = response.data.data.result + + return formatResponse.toolResult(result) } catch (error) { return `Error fetching web content: ${(error as Error).message}` }