toolValidationConfig.ts
utils/settings/toolValidationConfig.ts
104
Lines
3100
Bytes
5
Exports
0
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with tool-system. It contains 104 lines, 0 detected imports, and 5 detected exports.
Important relationships
Detected exports
ToolValidationConfigTOOL_VALIDATION_CONFIGisFilePatternToolisBashPrefixToolgetCustomValidation
Keywords
domaincontentwebfetchtoolnamevalidtoolspatternstoolvalidationprefix
Detected imports
- No import paths detected.
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
/**
* Tool validation configuration
*
* Most tools need NO configuration - basic validation works automatically.
* Only add your tool here if it has special pattern requirements.
*/
export type ToolValidationConfig = {
/** Tools that accept file glob patterns (e.g., *.ts, src/**) */
filePatternTools: string[]
/** Tools that accept bash wildcard patterns (* anywhere) and legacy :* prefix syntax */
bashPrefixTools: string[]
/** Custom validation rules for specific tools */
customValidation: {
[toolName: string]: (content: string) => {
valid: boolean
error?: string
suggestion?: string
examples?: string[]
}
}
}
export const TOOL_VALIDATION_CONFIG: ToolValidationConfig = {
// File pattern tools (accept *.ts, src/**, etc.)
filePatternTools: [
'Read',
'Write',
'Edit',
'Glob',
'NotebookRead',
'NotebookEdit',
],
// Bash wildcard tools (accept * anywhere, and legacy command:* syntax)
bashPrefixTools: ['Bash'],
// Custom validation (only if needed)
customValidation: {
// WebSearch doesn't support wildcards or complex patterns
WebSearch: content => {
if (content.includes('*') || content.includes('?')) {
return {
valid: false,
error: 'WebSearch does not support wildcards',
suggestion: 'Use exact search terms without * or ?',
examples: ['WebSearch(claude ai)', 'WebSearch(typescript tutorial)'],
}
}
return { valid: true }
},
// WebFetch uses domain: prefix for hostname-based permissions
WebFetch: content => {
// Check if it's trying to use a URL format
if (content.includes('://') || content.startsWith('http')) {
return {
valid: false,
error: 'WebFetch permissions use domain format, not URLs',
suggestion: 'Use "domain:hostname" format',
examples: [
'WebFetch(domain:example.com)',
'WebFetch(domain:github.com)',
],
}
}
// Must start with domain: prefix
if (!content.startsWith('domain:')) {
return {
valid: false,
error: 'WebFetch permissions must use "domain:" prefix',
suggestion: 'Use "domain:hostname" format',
examples: [
'WebFetch(domain:example.com)',
'WebFetch(domain:*.google.com)',
],
}
}
// Allow wildcards in domain patterns
// Valid: domain:*.example.com, domain:example.*, etc.
return { valid: true }
},
},
}
// Helper to check if a tool uses file patterns
export function isFilePatternTool(toolName: string): boolean {
return TOOL_VALIDATION_CONFIG.filePatternTools.includes(toolName)
}
// Helper to check if a tool uses bash prefix patterns
export function isBashPrefixTool(toolName: string): boolean {
return TOOL_VALIDATION_CONFIG.bashPrefixTools.includes(toolName)
}
// Helper to get custom validation for a tool
export function getCustomValidation(toolName: string) {
return TOOL_VALIDATION_CONFIG.customValidation[toolName]
}