Gemini CLI Core - Core functionality library for the open-source AI agent that brings the power of Gemini directly into your terminal.
Overall
score
87%
Evaluation — 87%
↑ 1.01xAgent success when using this tile
A utility that validates and evaluates policy rules for a CLI tool execution engine.
Build a policy rule validation system that can parse TOML-formatted policy rules and determine whether a given tool execution should be allowed, denied, or require user approval. The system should support priority-based matching, pattern matching on tool names and commands, and approval mode filtering.
@generates
/**
* Represents a policy rule for tool execution control
*/
export interface PolicyRule {
toolName: string;
commandRegex?: string;
decision: 'allow' | 'deny' | 'ask_user';
priority: number;
modes?: string[];
}
/**
* Parses TOML-formatted policy rules into PolicyRule objects
*
* @param tomlContent - TOML string containing rule definitions
* @returns Array of parsed PolicyRule objects
* @throws Error if TOML is invalid or missing required fields
*/
export function parseTomlRules(tomlContent: string): PolicyRule[];
/**
* Checks if a tool name matches a pattern (supports wildcards)
*
* @param toolName - The actual tool name to check
* @param pattern - Pattern to match against (supports * wildcard)
* @returns true if the tool name matches the pattern
*/
export function matchesToolPattern(toolName: string, pattern: string): boolean;
/**
* Evaluates which rule should apply for a given tool execution
* Returns the highest priority matching rule, or null if no rules match
*
* @param rules - Array of policy rules to evaluate
* @param toolName - Name of the tool being executed
* @param command - Optional command string (for shell tools)
* @param approvalMode - Current approval mode (e.g., "default", "autoEdit", "yolo")
* @returns The matching PolicyRule with highest priority, or null
*/
export function evaluatePolicy(
rules: PolicyRule[],
toolName: string,
command: string | null,
approvalMode: string
): PolicyRule | null;Provides TOML parsing functionality for reading policy rule files.
Install with Tessl CLI
npx tessl i tessl/npm-google--gemini-cli-coredocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10