import { ValidationRule, ValidationContext, ValidationSeverity } from '../interfaces'; /** * Options for StaticCallTargetRule */ export interface StaticCallTargetOptions { /** * List of function names to validate * Default: ['callTool', '__safe_callTool'] */ targetFunctions?: string[]; /** * Optional whitelist of allowed tool names * Supports exact strings or RegExp patterns * If provided, only these tool names are allowed */ allowedToolNames?: (string | RegExp)[]; /** * Which argument position to validate (0-indexed) * Default: 0 (first argument) */ argumentPosition?: number; } /** * Rule that enforces static string literals for call targets * * This rule ensures that certain functions (like `callTool`) are called * with static string literals as their first argument. This prevents * dynamic tool name injection and enables static analysis of tool usage. * * @example * ```typescript * // These will FAIL validation: * callTool(toolName, args); // Variable reference * callTool("tool" + suffix, args); // Concatenation * callTool(`tool_${id}`, args); // Template with expressions * callTool(cond ? "a" : "b", args); // Ternary expression * * // These will PASS validation: * callTool("users:list", args); // Static string literal * callTool('billing:invoice', args); // Static string literal * ``` */ export declare class StaticCallTargetRule implements ValidationRule { private options; readonly name = "static-call-target"; readonly description = "Enforces static string literals for call targets"; readonly defaultSeverity = ValidationSeverity.ERROR; readonly enabledByDefault = true; private readonly targetFunctions; private readonly allowedToolNames; private readonly argumentPosition; constructor(options?: StaticCallTargetOptions); validate(context: ValidationContext): void; /** * Extract a static string value from an AST node * Returns null if the node is not a static string */ private extractStaticString; /** * Describe why a node type is considered dynamic (for error messages) */ private describeDynamicType; }