import http from 'node:http'; import type { Chain } from '../config.js'; export interface ProxyOptions { port: number; apiUrl: string; chain?: Chain; modelOverride?: string; debug?: boolean; fallbackEnabled?: boolean; requestTimeoutMs?: number; streamTimeoutMs?: number; } /** * Decide the `max_tokens` the proxy forwards upstream. * * An explicit ask is honored; only a missing one gets the adaptive default. * This overwrote unconditionally until 3.35.6 — whatever the caller sent was * replaced by min(adaptive, modelCap), where `adaptive` grows to twice the * previous reply. A client asking for 500 tokens after a long turn got several * thousand instead, and because the gateway quotes on the ceiling it is * requested, that inflated the hold on a request the caller had deliberately * kept small. * * Clamping an explicit ask to `modelCap` stays: asking past the model's own * ceiling is a request the provider rejects outright, and failing it here is * worse than quietly making it legal. * * @param asked what the caller sent, if anything * @param lastOutput tokens the previous reply on this model produced (0 = none) * @param modelCap the model's own output ceiling */ export declare function resolveProxyMaxTokens(asked: unknown, lastOutput: number, modelCap: number): number; export declare function createProxy(options: ProxyOptions): http.Server; type RequestCategory = 'simple' | 'code' | 'default'; interface ClassifiedRequest { category: RequestCategory; suggestedModel?: string; } export declare function classifyRequest(body: string): ClassifiedRequest; export {};