/** A matched route: the handler, and the parameters read out of the path. */ export interface RouteMatch { /** What the route does. */ handler: T; /** Path parameters, such as `{ threadId: 'thread-1' }`. */ params: Record; } /** * A tiny path router: literal segments, and `:name` parameters. * * Written rather than imported so the server entry point carries no routing dependency; the whole * surface is a dozen routes, which is well under the size of any router worth installing. */ export declare class Routes { private readonly routes; /** Registers a route, such as `add('POST', '/threads/:threadId/runs', handler)`. */ add(method: string, pattern: string, handler: T): this; /** The route for a method and path, or `undefined`. A path that matches another method is reported. */ match(method: string, pathname: string): RouteMatch | 'method-not-allowed' | undefined; } /** A JSON response with the given status. */ export declare function json(value: unknown, status?: number, headers?: Record): Response; /** The error response for any thrown value: a `ServerError` keeps its status, anything else is a 500. */ export declare function errorResponse(error: unknown): Response; /** Reads a JSON body, treating an empty body as `{}` and bad JSON as a 400. */ export declare function readJson(request: Request): Promise; /** One server-sent event, with the id a client resumes from. */ export declare function formatSse(event: { id?: number; event?: string; data: unknown; }): string; /** The headers an event stream needs, including the ones that stop a proxy buffering it. */ export declare const SSE_HEADERS: Record;