export type AgentProxy = { /** URL agents use as their provider base. */ url: string; port: number; upstream: string; close(): Promise; }; export type ProxyServerOpts = { /** Upstream root URL (no trailing slash sensitivity). */ upstream: string; /** Match the URL we should intercept (e.g. `(u) => u.includes('/v1/messages')`). */ match: (url: string) => boolean; /** * Mutate the parsed request body before forwarding upstream — the * caller restores originals, splices substitutions, etc. */ transformRequest?: (parsed: TRequest) => Promise | void; /** * Validate that the upstream JSON body is the shape we expect to * synthesize SSE from. Return false to pass the response through * unchanged (e.g. error envelopes). */ isValidResponse: (parsed: unknown) => parsed is TResponse; /** * Mutate the parsed response body before synthesizing SSE — the * caller runs the middleware chain on each tool call here. */ transformResponse?: (parsed: TResponse) => Promise | void; /** Synthesize the SSE byte stream the agent expects. */ synthesizeSse: (parsed: TResponse) => string; /** * Called once per matched upstream round-trip with the raw request * and response bytes (post our restore-originals transform on the * request, raw upstream body on the response). Used by the runner's * `record` mode to capture exchanges for later replay. Bytes, not * parsed objects — the recording stays format-agnostic. */ onExchange?: (request: string, response: string) => void; /** Called once when `proxy.close()` runs. */ onClose?: () => void; }; export declare function startProxyServer(opts: ProxyServerOpts): Promise; //# sourceMappingURL=http-server.d.ts.map