import type { ReasoningSelection } from "@velum-labs/routekit-contracts"; import { type AnthropicReasoningExtension, type GoogleReasoningExtension, type Reasoning } from "@velum-labs/routekit-contracts/protocol-ir"; export type OpenAiToolCall = { id?: string; index?: number; function?: { name?: string; arguments?: string; }; }; /** * Lossless Anthropic reasoning metadata carried beside the portable * `reasoning` string. Native Anthropic streams need block lifecycle and opaque * signatures to survive a round trip; other dialects can ignore this field. */ export declare function googleThoughtDetailsOf(value: unknown): Reasoning[]; export declare function anthropicReasoningDetailsOf(value: unknown, mode: "message" | "stream"): Reasoning[]; export type AnthropicThinkingConfig = { type: "enabled"; budget_tokens: number; display?: "summarized" | "omitted" | null; } | { type: "adaptive"; display?: "summarized" | "omitted" | null; } | { type: "disabled"; }; export type AnthropicRequestMetadata = { thinking?: AnthropicThinkingConfig; output_config?: { effort?: string | null; [key: string]: unknown; } | null; }; /** * Symbol-keyed metadata stays in-process through object spreads while * JSON.stringify omits it. This lets an Anthropic backend receive exact native * controls/history without leaking Anthropic-only fields to OpenAI providers. */ export declare const ANTHROPIC_REQUEST_METADATA: unique symbol; export declare const ANTHROPIC_MESSAGE_CONTENT: unique symbol; export declare const REASONING_SELECTION: unique symbol; export declare const REASONING_SELECTION_ERROR: unique symbol; /** * Opaque OpenAI Responses reasoning state carried only inside the gateway. * The symbol key survives in-process object spreads but is omitted by JSON, * while the value itself is plain serializable data for deterministic replay * by a Responses-capable provider backend. */ export declare const RESPONSES_REASONING_METADATA: unique symbol; export declare const GOOGLE_TOOL_CALL_INDEXES: unique symbol; export type ResponsesReasoningState = { items: Reasoning[]; includeEncryptedContent: boolean; }; export declare function attachResponsesReasoningMetadata(target: Record, metadata: { items: readonly unknown[]; includeEncryptedContent: boolean; }): void; export declare function responsesReasoningMetadataErrorOf(value: unknown): string | undefined; export declare function responsesReasoningMetadataOf(value: unknown): ResponsesReasoningState | undefined; /** * Explicitly namespaced, JSON-safe fidelity metadata. Chat providers must strip * this extension before egress; compound/proxy layers may serialize it while * reconstructing a request for another RouteKit gateway. */ export type RouteKitReasoningEnvelope = { version: 1; selection?: ReasoningSelection; anthropic?: { request?: AnthropicRequestMetadata; }; responses?: ResponsesReasoningState; }; export type RouteKitMessageEnvelope = { version: 1; anthropic?: { content?: AnthropicNativeContentBlock[]; }; responses?: ResponsesReasoningState; google?: { toolCallIndexes?: Record; }; }; export declare const ROUTEKIT_EXTENSION_KEY: "x_routekit"; export declare function attachAnthropicRequestMetadata(target: Record, metadata: AnthropicRequestMetadata): void; export declare function anthropicRequestMetadataOf(value: unknown): AnthropicRequestMetadata | undefined; export declare function hasExplicitReasoningSelection(value: unknown): boolean; export declare function attachAnthropicMessageContent(target: Record, content: readonly AnthropicNativeContentBlock[]): void; export declare function anthropicMessageContentOf(value: unknown): AnthropicNativeContentBlock[] | undefined; export declare function attachGoogleToolCallIndexes(target: Record, indexes: Readonly>): void; export declare function googleToolCallIndexesOf(value: unknown): Readonly>; /** Remove the private namespaced extension at a final non-RouteKit provider boundary. */ export declare function withoutRouteKitExtensions(value: unknown): unknown; export declare function attachReasoningSelection(target: Record, selection: ReasoningSelection): void; export declare function attachReasoningSelectionError(target: Record, message: string): void; /** * Replace all request-local reasoning state with one authoritative selection. * * The clone is intentional: attached symbol metadata is non-configurable on * its source object, while object spread creates replaceable own properties. */ export declare function withReasoningSelection(target: Record, selection: ReasoningSelection): Record; export type RouteKitRequestValidationError = { code: "invalid_reasoning_control" | "invalid_reasoning_metadata"; path: string; message: string; }; export declare function routeKitRequestValidationErrorOf(value: unknown): RouteKitRequestValidationError | undefined; export declare function reasoningSelectionErrorOf(value: unknown): string | undefined; export declare function reasoningSelectionOf(value: unknown): ReasoningSelection; export type AnthropicNativeContentBlock = { type: "text"; text: string; } | { type: "thinking"; thinking: string; signature: string; } | { type: "redacted_thinking"; data: string; } | { type: "tool_use"; id: string; name: string; input: unknown; }; export declare function reasoningIndex(reasoning: Reasoning): number; export declare function anthropicReasoningExtension(reasoning: Reasoning): AnthropicReasoningExtension["value"] | undefined; export declare function googleReasoningExtension(reasoning: Reasoning): GoogleReasoningExtension["value"] | undefined; export declare function responsesReasoningItem(reasoning: Reasoning): Record | undefined; export type OpenAiDelta = { content?: string | null; reasoning?: string | null; reasoning_content?: string | null; reasoning_details?: Reasoning[]; tool_calls?: OpenAiToolCall[]; }; export type OpenAiChoice = { index?: number; delta?: OpenAiDelta; message?: { role?: string; content?: string | null; reasoning?: string | null; reasoning_content?: string | null; reasoning_details?: Reasoning[]; tool_calls?: OpenAiToolCall[]; }; finish_reason?: string | null; anthropic_stop_reason?: string | null; anthropic_stop_sequence?: string | null; };