/**
 * Proxy Translation Engine
 *
 * Shared translation logic used by both Claude and OpenAI proxy routes.
 * Both formats follow the same pipeline:
 *   1. Parse request (format-specific, done by the caller)
 *   2. Loop through fallback attempts calling ctx.neurolink.stream()
 *   3. Serialize response (format-specific, via serializer/response builder)
 *
 * This module exports the helpers that were previously duplicated between
 * claudeProxyRoutes.ts and openaiProxyRoutes.ts, plus unified stream and
 * JSON handlers that accept a format discriminator.
 */
import type { ProxyTracer } from "./proxyTracer.js";
import type { ParsedClaudeRequest, ParsedOpenAIRequest, ProxyFormat, ProxyTranslationAttempt, ServerContext } from "../types/index.js";
/**
 * Extract text content from a stream chunk (handles various chunk formats).
 */
export declare function extractText(chunk: unknown): string | null;
/** Extract tool call arguments from various shapes. */
export declare function extractToolArgs(toolCall: unknown): unknown;
/** Check if there's meaningful output from translation. */
export declare function hasTranslatedOutput(collectedText: string, toolCalls: unknown[] | undefined): boolean;
/**
 * Normalize usage from various AI SDK / NeuroLink shapes.
 *
 * Handles:
 * - AI SDK v6: inputTokens / outputTokens
 * - AI SDK v4: promptTokens / completionTokens
 * - NeuroLink internal: input / output
 */
export declare function extractUsageFromStreamResult(usage: unknown): {
    input: number;
    output: number;
    total: number;
};
/**
 * Detect which proxy format a request is using based on path and headers.
 */
export declare function detectProxyFormat(path: string, headers: Record<string, string>): ProxyFormat;
/**
 * Build options for ctx.neurolink.stream() from a parsed request
 * and an optional provider/model override.
 *
 * Works for both ParsedClaudeRequest and ParsedOpenAIRequest — the
 * only differences are Claude-specific fields (topK, thinkingConfig)
 * which are safely absent on OpenAI parsed requests.
 */
export declare function buildTranslationOptions(parsed: ParsedClaudeRequest | ParsedOpenAIRequest, overrides?: {
    provider?: string;
    model?: string;
}): Record<string, unknown>;
/**
 * Handles a translated stream request for either Claude or OpenAI format.
 *
 * The streaming loop logic (iterate attempts, call neurolink.stream, collect
 * text, handle tool calls, keepalive timer) is identical across formats.
 * Only the serializer differs.
 */
export declare function handleTranslatedStreamRequest(args: {
    ctx: ServerContext;
    format: ProxyFormat;
    requestModel: string;
    parsed: ParsedClaudeRequest | ParsedOpenAIRequest;
    attempts: ProxyTranslationAttempt[];
    tracer?: ProxyTracer;
    requestStartTime: number;
}): Promise<Response>;
/**
 * Handles a translated non-streaming request for either Claude or OpenAI format.
 */
export declare function handleTranslatedJsonRequest(args: {
    ctx: ServerContext;
    format: ProxyFormat;
    requestModel: string;
    parsed: ParsedClaudeRequest | ParsedOpenAIRequest;
    attempts: ProxyTranslationAttempt[];
    tracer?: ProxyTracer;
    requestStartTime: number;
}): Promise<unknown>;
/**
 * Build the /v1/models response in OpenAI list format.
 * Used by both Claude and OpenAI proxy routes.
 */
export declare function buildModelsListResponse(modelRouter?: {
    getModelMappings?: () => Array<{
        from: string;
    }>;
    getPassthroughModels?: () => string[];
}): {
    object: string;
    data: Array<{
        id: string;
        object: string;
        created: number;
        owned_by: string;
    }>;
};
/**
 * Build an Anthropic-shaped `/v1/models` list response.
 *
 * Used by the Claude-compatible route so Anthropic SDK consumers receive
 * the schema they expect:
 *   { data: [{type, id, display_name, created_at}], first_id, last_id, has_more }
 *
 * The OpenAI route continues to use {@link buildModelsListResponse} for the
 * OpenAI list shape.
 */
export declare function buildAnthropicModelsListResponse(modelRouter?: {
    getModelMappings?: () => Array<{
        from?: string;
    }>;
    getPassthroughModels?: () => string[];
}): {
    data: Array<{
        type: "model";
        id: string;
        display_name: string;
        created_at: string;
    }>;
    first_id: string | null;
    last_id: string | null;
    has_more: boolean;
};
