import type { PackScenario } from './pack-fetch.js'; import type { ScenarioDecision } from './scenario.js'; type Row = Record; /** A turn: the text, or tool calls, the reasoning when there is some, and why it finished. */ export type WireTurn = { text?: string | null; toolCalls?: Array<{ name: string; arguments: Row; }>; reasoning?: string | null; reasoningDetails?: Row[]; finishReason?: string; }; /** Tokens, estimated at about four characters a token: a twin's count, not a tokenizer's. */ export declare const estimateTokens: (text: string) => number; /** A message's content as text: a string, or its text parts joined. */ export declare const chatText: (content: unknown) => string; /** The last user message's text. */ export declare function chatLastUserText(messages: Row[]): string; /** The tool results the last message carries (a `tool` message), by its name or call id. */ export declare const chatToolResults: (messages: Row[]) => string[]; /** The labeled stub for a chat request: with tools offered (`tool_choice` not `none`) and the last message not a tool's * result, it calls the tool the choice names, else the first, with arguments its schema admits; with a JSON response * format, it answers a value the schema admits; otherwise it echoes the last user message. `label` names the twin. */ export declare function chatStubTurn(body: Row, label: string): WireTurn; export type ChatShape = { id: string; model: string; created: number; turn: WireTurn; messages: Row[]; /** the request's max_tokens / max_completion_tokens: a longer text is cut there and finishes `length` */ maxTokens?: number; /** each tool call's id */ callId: (i: number) => string; /** fields a vendor adds at the top of the answer and of each chunk (OpenRouter's `provider`) */ extra?: Row; /** top-level fields on interim stream chunks instead of extra; terminal chunks retain extra */ interimExtra?: Row; /** fields a vendor adds to the usage (OpenRouter's `cost`) */ usageExtra?: Row; /** the vendor also answers the provider's own finish reason (`native_finish_reason`) */ nativeFinish?: boolean; /** the name the reasoning takes in a message (`reasoning`, or `reasoning_content`) */ reasoningField?: string; }; /** A chat completion's body (`object: chat.completion`), one choice. */ export declare function chatCompletion(s: ChatShape): Row; /** A chat completion streamed: its chunks (`object: chat.completion.chunk`) as Server-Sent Events, the text in two * deltas, the last chunk carrying the finish reason and the usage, then `data: [DONE]`. `comment` is a keep-alive a * vendor sends first (OpenRouter's `: OPENROUTER PROCESSING`). */ export declare function chatCompletionSSE(s: ChatShape & { comment?: string; separateUsageChunk?: boolean; }): string; /** A V4 call's options as the chat completions request they mean: its prompt as messages, its tools, tool choice, * response format and output limit; so the chat stub and the wire's scenario read it. */ export declare function aiSdkChatBody(call: Row, model: string): Row; /** A V4 generate result: the turn's content (reasoning, text, tool calls with their input as JSON text), its finish * reason (unified, and the raw one) and its usage; `extra` is what the server adds (the gateway's provider metadata). */ export declare function languageModelResult(s: ChatShape): Row; /** A V4 stream: its parts as Server-Sent Events (stream-start, response-metadata, the reasoning, the text in two deltas, * each tool call's input then the call, and the finish), with no `[DONE]`: the SDK reads every event as a part. */ export declare function languageModelSSE(s: ChatShape): string; /** A Responses request's input as items: a string is one user message. */ export declare const responsesItems: (input: unknown) => Row[]; /** The last user message's text in a Responses input. */ export declare function responsesLastUserText(input: unknown): string; /** The function-call outputs the input ends with. */ export declare const responsesToolResults: (input: unknown) => string[]; /** The labeled stub for a Responses request: a function tool is called (unless the input already carries its output or * `tool_choice` is `none`), a JSON schema format answers a value it admits, otherwise the last user text is echoed. */ export declare function responsesStubTurn(body: Row, label: string): WireTurn; export type ResponsesShape = { id: string; model: string; createdAt: number; turn: WireTurn; body: Row; /** ids for the output items: the message, the reasoning, each function call and its call id */ itemId: (kind: 'msg' | 'rs' | 'fc' | 'call', i: number) => string; extra?: Row; /** Vendor defaults; explicit request values win, including nullable gateway defaults. */ defaults?: Row; }; /** A Responses object (`object: response`, `status: completed`): its output items (the reasoning when there is some, * the message with its output text, or function calls) and its usage. */ export declare function responsesAnswer(s: ResponsesShape): Row; /** A Responses object streamed: the events the wire sends (`response.created`, `response.in_progress`, each output * item's added, its text deltas and done, `response.completed`), each `event:` and `data:` with its sequence number. */ export declare function responsesSSE(s: ResponsesShape): string; export type WireRequest = { model: string; text: string; lastUser: string; tools: string[]; results: string[]; toolsForbidden?: boolean; }; /** Whether a request forbids every tool call: OpenAI's `tool_choice: 'none'`, Anthropic's `{ type: 'none' }`. */ export declare const forbidsTools: (choice: unknown) => boolean; /** The turn a scenario's decision scripts (`respond`: text, toolCalls, reasoning, finishReason), or undefined. */ export declare function scenarioTurn(decision: ScenarioDecision | undefined): WireTurn | undefined; /** A request as the scenario reads it: its model, its text, its last user text, the tools it offers and the tool * results it ends with, from a chat completion's messages or a Responses input. */ export declare function wireRequest(body: Row): WireRequest; /** The scenario of a vendor on this wire: its operations, and its error body for a scripted fault. `readers` reads an * operation whose request is another wire's (a gateway's Anthropic Messages surface: anthropicWire's * `messagesWireRequest`), so one scenario scripts every surface's turns alike. */ export declare function scenario(vendor: string, operations: string[], faultBody: (status: number, message: string | undefined) => unknown, readers?: Record WireRequest>): PackScenario; /** An admitted generation that fails: partial JSON or actual Chat Completions error frames. * The pack supplies its error envelope/type; the shared wire owns the SDK framing. */ export declare function chatCompletionFailure(s: { id: string; model: string; created: number; error: Row; text?: string; extra?: Row; }, stream: boolean): Row | string; /** Responses generation failures keep the response's canonical fields and native error code. */ export declare function responsesFailure(response: Row, stream: boolean, event?: string): Row | string; export {};