Roo-Code/src/core/mode-validator.ts
2025-01-24 12:46:10 -05:00

17 lines
580 B
TypeScript

import { Mode, isToolAllowedForMode, getModeConfig, ModeConfig, FileRestrictionError } from "../shared/modes"
import { ToolName } from "../shared/tool-groups"
export { isToolAllowedForMode }
export type { ToolName }
export function validateToolUse(
toolName: ToolName,
mode: Mode,
customModes?: ModeConfig[],
toolRequirements?: Record<string, boolean>,
toolParams?: Record<string, unknown>,
): void {
if (!isToolAllowedForMode(toolName, mode, customModes ?? [], toolRequirements, toolParams)) {
throw new Error(`Tool "${toolName}" is not allowed in ${mode} mode.`)
}
}