/** * dsh-auto-approval-llm ยท declarative rules (B1). * * A pure Claude-Code-style declarative rule layer (supersedes the removed * legacy `riskRules` regex routes). Line grammar (one rule per line, blank/#-comments ignored): * * Tool(pattern) | allow|deny|human [| reason|toolName|arguments] * pattern | allow|deny|human [| reason|toolName|arguments] * * - `Tool(a)` with a comma list (bash,pwsh) scopes the rule to those tools * (names may contain `*`). Without parentheses the pattern applies to every * tool. * - `field` defaults to `arguments` for the new syntax (the `arguments` object * being matched depends on the tool; command tools match their command text). * - First matching rule wins; only one policy is returned. * * Kept pure (no imports) so host enforcement and the browser settings-card * live validation share the exact same interpretation. */ export type RulePolicy = 'allow' | 'deny' | 'human'; export type RuleField = 'reason' | 'toolName' | 'arguments'; export interface DeclaredRule { tools?: string[]; pattern: RegExp; source: string; policy: RulePolicy; field: RuleField; } export interface RuleParseError { line: number; message: string; } export interface RuleSet { rules: DeclaredRule[]; errors: RuleParseError[]; } export declare function parseRulesText(text: string): RuleSet; export interface RuleSubject { toolName: string; reason?: string; arguments?: unknown; } /** * Field projection for rule matching: command-like tools expose their actual * command text under command/script/code/prompt/text/content keys. Matching * against the raw argument JSON envelope would defeat anchored patterns like * `^git push`. Extract the command/code text first; fall back to the full * serialized arguments when no text field exists. */ export declare function extractRuleTarget(args: unknown): string; /** * First matching rule wins. `tools` undefined matches every tool; otherwise the * rule only applies when the tool name matches one of the entries (glob `*` * supported). Returns the policy and the rule for audit, or undefined. */ export declare function evaluateRules(rules: DeclaredRule[], subject: RuleSubject): { policy: RulePolicy; rule: DeclaredRule; } | undefined;