/** * Fluent Assertion Builder — Chainable API for building complex agent assertions. * * @example * ```typescript * const assertion = new AssertionBuilder() * .that("response") * .contains("Paris") * .and().hasToolCall("search_flights") * .and().costLessThan(0.10) * .and().completedWithin(5000) * .build(); * * const result = assertion.evaluate(trace); * ``` */ import type { AgentTrace } from './types'; export type AssertionTarget = 'response' | 'trace' | 'tools' | 'cost' | 'steps'; export interface AssertionCheck { type: string; target: AssertionTarget; params: Record; negate: boolean; } export interface AssertionResult { passed: boolean; checks: AssertionCheckResult[]; summary: string; } export interface AssertionCheckResult { type: string; passed: boolean; message: string; expected?: any; actual?: any; } export interface BuiltAssertion { checks: AssertionCheck[]; evaluate(trace: AgentTrace): AssertionResult; toString(): string; } export declare class AssertionBuilder { private checks; private currentTarget; private negated; /** * Set the target for subsequent assertions. */ that(target: AssertionTarget): AssertionBuilder; /** * Negate the next assertion. */ not(): AssertionBuilder; /** * Chain another assertion. */ and(): AssertionBuilder; /** * Response contains a substring. */ contains(text: string): AssertionBuilder; /** * Response matches a regex. */ matches(pattern: string | RegExp): AssertionBuilder; /** * A specific tool was called. */ hasToolCall(toolName: string, args?: Record): AssertionBuilder; /** * Tool was called exactly N times. */ toolCalledTimes(toolName: string, count: number): AssertionBuilder; /** * Total cost is less than threshold (USD). */ costLessThan(maxCost: number): AssertionBuilder; /** * Total cost is greater than threshold (USD). */ costGreaterThan(minCost: number): AssertionBuilder; /** * Trace completed within the given time (ms). */ completedWithin(maxMs: number): AssertionBuilder; /** * Total steps are within range. */ stepCount(min: number, max?: number): AssertionBuilder; /** * No tool errors occurred. */ noErrors(): AssertionBuilder; /** * Total tokens used is less than threshold. */ tokensLessThan(maxTokens: number): AssertionBuilder; /** * Tools were called in order. */ toolOrder(...tools: string[]): AssertionBuilder; /** * Custom predicate assertion. */ satisfies(name: string, predicate: (trace: AgentTrace) => boolean): AssertionBuilder; /** * Build the assertion into an evaluatable object. */ build(): BuiltAssertion; private addCheck; } //# sourceMappingURL=assertion-builder.d.ts.map