Interface MockRequest

Source
Expand description

A normalised view of an incoming request, regardless of the original wire format. This is what rule matchers and resolvers receive.

interface MockRequest {
    format: FormatName;
    headers: Readonly<Record<string, string | undefined>>;
    lastMessage: string;
    lastToolCallId: string | undefined;
    messages: readonly Message[];
    model: string;
    path: string;
    raw: unknown;
    streaming: boolean;
    systemMessage: string;
    toolNames: readonly string[];
    tools?: readonly ToolDef[];
}

Properties§

§readonly format: FormatName

Which API format route the request came in on.

§readonly headers: Readonly<Record<string, string | undefined>>

HTTP headers from the incoming request.

§readonly lastMessage: string

The last user message's text. This is what most matchers check.

§readonly lastToolCallId: string | undefined

Set when the last message was a tool result. Used by whenToolResult().

§readonly messages: readonly Message[]

Full conversation, normalised from whatever format came in.

§readonly model: string

The model string from the request, e.g. "gpt-5.4" or "claude-sonnet-4-6".

§readonly path: string

The URL path that was hit, e.g. /v1/chat/completions.

§readonly raw: unknown

The raw request body, for anything we don't extract.

§readonly streaming: boolean

Whether the client asked for SSE streaming (from the stream field).

defaultValue

true

§readonly systemMessage: string

System prompt text, or empty string if there wasn't one.

§readonly toolNames: readonly string[]

Tool names pulled out from tools for quick lookups via whenTool().

§readonly tools?: readonly ToolDef[]

Tool definitions from the request, if any were sent.