/** * AGT-03 Pre-execution command gate — runtime evaluator. * * Mirrors `edge-client/src/session/cmd_gate.rs::evaluate`. Pure decision * logic; no I/O, no env reads at runtime (the env is read once via * `CmdGateConfig.resolve` at boot, then the resulting config is passed * in to every `evaluate()` call). * * FIX (2026-07-14, F-12): previously the TS client exported a `CmdGateConfig` * schema but had NO `evaluate()` runtime. The `cmd_gate.mode = 'block'` * setting in `config.toml` was silently ignored — every tool invocation * ran uninspected. Operators got a false sense of security. * * The decision matrix matches Rust 1:1: * 1. `mode === 'off'` → Allow * 2. Allowlist match (case-insensitive) → Allow (read-only introspection) * 3. Denylist substring scan → Deny (Block) / RequireApproval (Warn) * 4. `always_approve` match → RequireApproval (mutating tool) * 5. Default → Allow * * The integration point is `pi-rpc.ts::handleToolExecutionStart()` — it * calls `evaluate()` on each `tool_execution_start` event and routes the * decision to one of: forward as-is, emit synthetic `extension_ui_request` * + await approval, or emit error + abort pi. */ import type { CmdGateConfig } from '../config/cmd-gate.js'; /** What the gate decided. */ export type GateDecision = { readonly kind: 'Allow'; } | { readonly kind: 'RequireApproval'; readonly preview: string; readonly reason: string; } | { readonly kind: 'Deny'; readonly reason: string; }; /** * Pure decision function. Case-insensitive matching on tool name + denylist. * * @param cfg Resolved CmdGateConfig (env + file merged at boot). * @param toolName The pi tool's name (NOT lowercased here — we lowercase internally). * @param args The raw JSON the tool was invoked with. */ export declare function evaluate(cfg: CmdGateConfig, toolName: string, args: unknown): GateDecision; /** * Recursively walk `value` and concatenate every string value into the * returned string, newline-separated. Mirrors `fail_fast::collect_strings`. * * FIX 2026-07-14, G-11: bounded depth + truncated size to prevent DoS via * deeply-nested or huge tool args (relay trust is the only barrier). * - `MAX_DEPTH = 32` prevents stack overflow from `{a:{a:{a:...}}}` chains * - `MAX_BYTES = 1 MiB` prevents memory doubling in `evaluate()` * Returns empty string if `value` is not an object/array. */ export declare function collectStringArgs(value: unknown): string;