updating webfetch and integrating new handler (#7509)
* updating system prompt for webfetch and integrating new handler * updating tests to match new webfetch tool
This commit is contained in:
1 parent
0e3cdab82b
commit
4005df6eae
17 files changed
+152
-165
No files matched your search
@@ -24,6 +24,7 @@ export const toolParamNames = [
|
||||
"url",
|
||||
"coordinate",
|
||||
"text",
|
||||
"prompt",
|
||||
"server_name",
|
||||
"tool_name",
|
||||
"arguments",
|
||||
|
||||
-18
@@ -171,24 +171,6 @@ Usage:
|
||||
<text>Text to type (optional)</text>
|
||||
</browser_action>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
-18
@@ -137,24 +137,6 @@ Usage:
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</list_code_definition_names>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
-16
@@ -156,22 +156,6 @@ Usage:
|
||||
<text>Text to type (optional)</text>
|
||||
</browser_action>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
-18
@@ -171,24 +171,6 @@ Usage:
|
||||
<text>Text to type (optional)</text>
|
||||
</browser_action>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
@@ -177,6 +177,27 @@ Usage:
|
||||
<text>Text to type (optional)</text>
|
||||
</browser_action>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
<prompt>Summarize the main points and key takeaways</prompt>
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
+21
@@ -143,6 +143,27 @@ Usage:
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</list_code_definition_names>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
<prompt>Summarize the main points and key takeaways</prompt>
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
+19
@@ -162,6 +162,25 @@ Usage:
|
||||
<text>Text to type (optional)</text>
|
||||
</browser_action>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
<prompt>Summarize the main points and key takeaways</prompt>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
@@ -177,6 +177,27 @@ Usage:
|
||||
<text>Text to type (optional)</text>
|
||||
</browser_action>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
<prompt>Summarize the main points and key takeaways</prompt>
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
@@ -171,24 +171,6 @@ Usage:
|
||||
<text>Text to type (optional)</text>
|
||||
</browser_action>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
@@ -137,24 +137,6 @@ Usage:
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</list_code_definition_names>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
-16
@@ -156,22 +156,6 @@ Usage:
|
||||
<text>Text to type (optional)</text>
|
||||
</browser_action>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
@@ -171,24 +171,6 @@ Usage:
|
||||
<text>Text to type (optional)</text>
|
||||
</browser_action>
|
||||
|
||||
## 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:
|
||||
<web_fetch>
|
||||
<url>https://example.com/docs</url>
|
||||
<task_progress>Checklist here (optional)</task_progress>
|
||||
</web_fetch>
|
||||
|
||||
## 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:
|
||||
|
||||
@@ -132,6 +132,7 @@ const baseContext: SystemPromptContext = {
|
||||
cwd: "/test/project",
|
||||
ide: "TestIde",
|
||||
supportsBrowserUse: true,
|
||||
clineWebToolsEnabled: true,
|
||||
mcpHub: {
|
||||
getServers: () => [
|
||||
{
|
||||
|
||||
@@ -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]
|
||||
@@ -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,
|
||||
|
||||
@@ -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<ToolResponse> {
|
||||
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}`
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user