import type { Grader, GraderInput, GraderMetadata, GraderResult } from "../../index.js"; /** * A more deluxe matcher, which lets you match across arguments for the tool, like 'command'. */ export type ToolMatch = { /** * Regex matched against the tool name (e.g., bash, edit, view, web_search). The * pattern is unanchored — use `^name$` to require an exact match. */ name: string; /** * The command passed to tools like 'bash', or 'powershell' */ command?: string; /** * File path for tools like 'create'/'edit'/'view' */ path?: string; /** * When `true`, `pattern` is matched against the call's extracted **write-target * paths** instead of the full args. Requires `pattern`; mutually exclusive with * `read_only`. Unrecognized call shapes yield no targets and do not match. */ write_only?: boolean; /** * Like `write_only` but matches `pattern` against **read-target paths**. * Mutually exclusive with `write_only`. */ read_only?: boolean; /** Call must occur within the first `before_step` agent steps. `required` only. */ before_step?: number; /** Call must occur exactly in agent step `at_step`. `required` only. */ at_step?: number; /** * Regex patterns keyed by argument name (generalizes `command`/`path`). All listed * args must match. A missing arg means "no match" rather than a config error. */ args?: Record; /** * Escape-hatch regex matched against the serialized call arguments (normally * `JSON.stringify(arguments)`; a rare non-serializable value falls back to * `String()` or, failing that, never matches). Tool-agnostic, so it spans a * heterogeneous tool set whose content args have different names. Prefer `args` * for structured checks; use `pattern` only when no single arg key expresses it. */ pattern?: string; /** Regex matched against the (stringified) result. `required`/`disallowed` only. */ result?: string; /** Minimum number of matching calls required (default 1). `required` only. */ min_count?: number; /** Matching call must be the final tool call in the trajectory. `required` only. */ final?: boolean; }; /** * The same as ToolMatch, but with all the string fields replaced with RegExp's. * This just makes it clear when we're expecting precompiled regexes, vs strings. */ export type ToolMatchPrecompiled = { name: RegExp; command?: RegExp; path?: RegExp; write_only?: boolean; read_only?: boolean; args?: Map; pattern?: RegExp; result?: RegExp; before_step?: number; at_step?: number; min_count?: number; final?: boolean; }; export type Config = { /** * Tools that should be called. If any tool specified in here does not get called * this test will fail. */ required?: (ToolMatch | string)[]; /** * Tools that should NEVER be called. If any tool specified in here gets called * this test will fail. */ disallowed?: (ToolMatch | string)[]; /** Tools that must be called in this relative order. */ sequence?: (ToolMatch | string)[]; /** * Tools that must be dispatched together in the same model-response batch * (parallel tool use). */ parallel?: (ToolMatch | string)[]; }; export type Metadata = Config & { /** * All tools that were called during the session */ tools: string[]; }; export declare class ToolCallGrader implements Grader { metadata: GraderMetadata; /** * `tool-calls requires bash,edit forbids rm` — every configured constraint * contributes, because two instances often share one list and differ only in * a second (`required: [bash]` with different `disallowed`), which naming off * the first present key alone would render identical. Keys are visited in a * fixed order so the name never depends on object key order, and the overall * cap keeps a four-constraint config from running long. */ defaultName(config: Record): string; /** * A tool-calls instance asserts absence when it ONLY forbids calls: at least * one `disallowed` entry and no `required`/`sequence`/`parallel`. Such a config * is satisfied by an empty trajectory (nothing forbidden was called), so under * the oracle baseline it is expected to pass and is reported N/A. */ assertsAbsence(config: Record): boolean; grade(input: GraderInput): Promise; } /** * A problem with a tool-calls config that depends only on the config (not the * trajectory). Reported by {@link validateToolCallsConfig}. */ export interface ToolCallsConfigProblem { /** * Path to the offending value relative to the grader's `config` object */ path: string; message: string; } /** * Validate every trajectory-independent rule of a tool-calls config. */ export declare function validateToolCallsConfig(config: unknown): ToolCallsConfigProblem[]; export declare function matchesEntry(toolName: string, toolArgs: Map, toolMatch: ToolMatchPrecompiled, fullArgsJson: string | undefined, rawArgs?: unknown): boolean; export declare function isConfig(v: unknown): v is Config; //# sourceMappingURL=tool-call-grader.d.ts.map