import type { ResponseInput } from "./providers/openai-responses-wire.js"; import type { CacheRetention, OpenAIResponsesHistoryPayload, ProviderPayload } from "./types.js"; export { isRecord } from "@oh-my-pi/pi-utils"; /** * Read a header value ignoring key casing. HTTP header names are * case-insensitive, but `Record` header bags are not, so a * config-authored `User-Agent` and a caller-authored `user-agent` are the same * header to every provider that lowercases before merging. */ export declare function getHeaderCaseInsensitive(headers: Record | undefined, headerName: string): string | undefined; export declare function normalizeSystemPrompts(systemPrompt: readonly string[] | string | undefined | null): string[]; export declare function normalizeToolCallId(id: string): string; type ResponsesToolItemIdPrefix = "fc" | "ctc"; /** Preserve opaque call IDs for Responses replay while normalizing or generating the separate item ID. */ export declare function normalizeResponsesToolCallId(id: string, itemPrefix?: ResponsesToolItemIdPrefix): { callId: string; itemId: string; }; /** * Truncate an OpenAI Responses API item ID to 64 characters. * IDs exceeding the limit are replaced with a hash-based ID using the given prefix. */ export declare function truncateResponseItemId(id: string, prefix: string): string; interface OpenAIResponsesReplaySanitizeOptions { supportsImageDetailOriginal?: boolean; supportsComputerUse?: boolean; } /** * Removes response-only lifecycle status from item types that reject it when replayed as input. * * Returns the original array when no item needs sanitization. */ export declare function stripOpenAIResponsesOutputOnlyStatusesForReplay(items: TItem[]): TItem[]; export declare function sanitizeOpenAIResponsesHistoryItemsForReplay(items: Array>, options?: OpenAIResponsesReplaySanitizeOptions): ResponseInput; /** Strip reasoning IDs whose only linked native output is a computer call that will be demoted. */ export declare function stripOpenAIResponsesComputerLinkedReasoningIdsForReplay(items: ResponseInput): ResponseInput; /** * Finalize provisional native-computer reasoning IDs after the complete * Responses input has been rebuilt, model-adapted, and orphan-repaired. */ export declare function stripUnpairedOpenAIResponsesComputerReasoningIdsForReplay(items: ResponseInput): ResponseInput; /** * Sanitize assistant-native Responses history for replay. * * Returns `undefined` for hidden-empty turns that only contain reasoning and an * empty assistant message, allowing callers to rebuild visible transcript * history instead of replaying stale native state. * * When the turn does carry replayable output, whitespace-only assistant * messages are dropped rather than replayed. gpt-5.6 Codex ends a turn whose * text all landed in the `commentary` phase with an empty `final_answer` * message; replaying that item verbatim seeds the next turn with an empty slot * the model then fills - `""` → `"\n\n"` → stray words → non-Latin residue - * and each contaminated item is replayed in turn, so the drift compounds until * the visible answer collapses. Codex CLI replays the empty item too * (openai/codex#32389); this is the layer where omp can refuse to. */ export declare function sanitizeOpenAIResponsesAssistantHistoryItemsForReplay(items: Array>, options?: OpenAIResponsesReplaySanitizeOptions): ResponseInput | undefined; /** * Drop hidden-only fallback assistant replay after a native Responses snapshot is rejected. */ export declare function sanitizeOpenAIResponsesAssistantFallbackItemsForReplay(items: ResponseInput): ResponseInput; /** * Drop each native tool call with a malformed name and only the matching * `function_call_output` / `custom_tool_call_output` in the same window. * * `call_id` is not unique across a snapshot. Pair the same way * `sanitizeMalformedToolCalls` does for transcript messages: a per-id FIFO of * malformed-ness, keyed by function vs custom, cleared at user/developer and * other non-result client boundaries so a missing result cannot eat the next * window's output. Returns `items` itself when nothing is malformed. */ export declare function dropMalformedOpenAIResponsesToolCalls(items: readonly T[]): T[]; export declare function createOpenAIResponsesHistoryPayload(provider: string, items: Array>, incremental?: boolean): OpenAIResponsesHistoryPayload; export declare function getOpenAIResponsesHistoryPayload(providerPayload: ProviderPayload | undefined, currentProvider: string, fallbackProvider?: string): OpenAIResponsesHistoryPayload | undefined; export declare function getOpenAIResponsesHistoryItems(providerPayload: ProviderPayload | undefined, currentProvider: string, fallbackProvider?: string): Array> | undefined; /** * Resolve cache retention preference: explicit request option first, then the * `PI_CACHE_RETENTION` env override (`long` | `short` | `none`), then the * provider-supplied fallback. */ export declare function resolveCacheRetention(cacheRetention?: CacheRetention, fallback?: CacheRetention): CacheRetention;