continue-custom/core/tools/index.ts
Shawn Smith a4c4f79fd0
fix: 🔒 Simpler fix to exclude search_web tool to signed in users (#7165)
* fix: 🔒 Simpler fix to exclude search_web tool to signed in users

* fix: 💡 Revise comment to clarify only sign in is required
2025-08-18 16:22:20 -07:00

43 lines
1.6 KiB
TypeScript

import { ConfigDependentToolParams, IDE, Tool } from "..";
import * as toolDefinitions from "./definitions";
// I'm writing these as functions because we've messed up 3 TIMES by pushing to const, causing duplicate tool definitions on subsequent config loads.
// missing support for remote os calls: https://github.com/microsoft/vscode/issues/252269
const getLocalOnlyToolDefinitions = () => [toolDefinitions.grepSearchTool];
const getBaseToolDefinitions = () => [
toolDefinitions.readFileTool,
toolDefinitions.createNewFileTool,
toolDefinitions.runTerminalCommandTool,
toolDefinitions.globSearchTool,
toolDefinitions.viewDiffTool,
toolDefinitions.readCurrentlyOpenFileTool,
toolDefinitions.lsTool,
toolDefinitions.createRuleBlock,
toolDefinitions.fetchUrlContentTool,
];
export const getConfigDependentToolDefinitions = (
params: ConfigDependentToolParams,
): Tool[] => [
toolDefinitions.requestRuleTool(params),
// Search and replace is now generally available
toolDefinitions.searchAndReplaceInFileTool,
// Keep edit file tool available for models that need it
toolDefinitions.editFileTool,
// Web search is only available for signed-in users
...(params.isSignedIn ? [toolDefinitions.searchWebTool] : []),
...(params.enableExperimentalTools
? [
toolDefinitions.viewRepoMapTool,
toolDefinitions.viewSubdirectoryTool,
toolDefinitions.codebaseTool,
]
: []),
];
export const getToolsForIde = async (ide: IDE): Promise<Tool[]> =>
(await ide.isWorkspaceRemote())
? getBaseToolDefinitions()
: [...getBaseToolDefinitions(), ...getLocalOnlyToolDefinitions()];