import { z } from 'zod'; export { completionStatsSchema, type CompletionStats } from './completion-event.js'; /** * Tool-call output dialect. Auto-detected from the model name; pass via * `completion({ toolDialect })` to override. * * Expected raw model output per dialect: * - `"hermes"`: `{"name":"get_weather","arguments":{"city":"Tokyo"}}` * - `"pythonic"`: `[get_weather(city="Tokyo")]` (optionally `<|tool_call_start|>...<|tool_call_end|>`-wrapped) * - `"json"`: `{"name":"get_weather","arguments":{"city":"Tokyo"}}` or `{"tool_calls":[{"name":"...","arguments":{...}}]}` * - `"harmony"`: `<|channel|>commentary to=functions.get_weather <|constrain|>json<|message|>{"city":"Tokyo"}<|call|>` * - `"qwen35"`: `VALUE` * - `"gemma4"`: `<|tool_call>call:NAME{key:<|"|>val<|"|>,...}` * - `"dsml"`: `<|DSML|tool_calls><|DSML|invoke name="NAME"><|DSML|parameter name="KEY" string="true">VALUE` * (DeepSeek Markup Language, emitted by DeepSeek V3.2 / V4) */ export declare const toolDialectSchema: z.ZodEnum<{ json: "json"; hermes: "hermes"; pythonic: "pythonic"; harmony: "harmony"; qwen35: "qwen35"; gemma4: "gemma4"; dsml: "dsml"; }>; export declare const attachmentSchema: z.ZodObject<{ path: z.ZodString; }, z.core.$strip>; export declare const generationParamsSchema: z.ZodObject<{ temp: z.ZodOptional; top_p: z.ZodOptional; top_k: z.ZodOptional; predict: z.ZodOptional; seed: z.ZodOptional; frequency_penalty: z.ZodOptional; presence_penalty: z.ZodOptional; repeat_penalty: z.ZodOptional; reasoning_budget: z.ZodOptional; tool_choice: z.ZodOptional; parallel_tool_calls: z.ZodOptional; }, z.core.$strict>; type ToolChoiceTool = { type: 'function'; name: string; deferLoading?: boolean | undefined; }; export declare function refineToolChoiceMatchesTools(data: { tools?: ToolChoiceTool[] | undefined; generationParams?: { tool_choice?: string | undefined; } | undefined; }, ctx: z.RefinementCtx): void; /** * `tool_search` is synthesised only when something defers, and would then * shadow a caller-declared tool of that name. Requests that defer nothing * keep the name free. */ export declare function refineReservedToolNames(data: { tools?: { name: string; deferLoading?: boolean | undefined; }[] | undefined; }, ctx: z.RefinementCtx): void; export declare const responseFormatSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"text">; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"json_object">; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"json_schema">; json_schema: z.ZodObject<{ name: z.ZodString; description: z.ZodOptional; schema: z.ZodRecord; strict: z.ZodOptional; }, z.core.$strict>; }, z.core.$strict>], "type">; export declare const historyMessageSchema: z.ZodPipe>; attachments: z.ZodOptional>>; toolCalls: z.ZodOptional; name: z.ZodString; arguments: z.ZodRecord; }, z.core.$strip>>>; toolCallId: z.ZodOptional; toolName: z.ZodOptional; }, z.core.$strip>, z.ZodTransform<{ content: string; role: string; attachments?: { path: string; }[] | undefined; toolCalls?: { name: string; arguments: Record; id?: string | undefined; }[] | undefined; toolCallId?: string | undefined; toolName?: string | undefined; }, { role: string; content?: string | null | undefined; attachments?: { path: string; }[] | undefined; toolCalls?: { name: string; arguments: Record; id?: string | undefined; }[] | undefined; toolCallId?: string | undefined; toolName?: string | undefined; }>>; export type HistoryMessage = z.infer; export declare const completionParamsSchema: z.ZodObject<{ history: z.ZodArray>; attachments: z.ZodOptional>>; toolCalls: z.ZodOptional; name: z.ZodString; arguments: z.ZodRecord; }, z.core.$strip>>>; toolCallId: z.ZodOptional; toolName: z.ZodOptional; }, z.core.$strip>, z.ZodTransform<{ content: string; role: string; attachments?: { path: string; }[] | undefined; toolCalls?: { name: string; arguments: Record; id?: string | undefined; }[] | undefined; toolCallId?: string | undefined; toolName?: string | undefined; }, { role: string; content?: string | null | undefined; attachments?: { path: string; }[] | undefined; toolCalls?: { name: string; arguments: Record; id?: string | undefined; }[] | undefined; toolCallId?: string | undefined; toolName?: string | undefined; }>>>; modelId: z.ZodString; kvCache: z.ZodOptional>; }, z.core.$strip>; export declare const completionClientParamsSchema: z.ZodObject<{ history: z.ZodArray>; attachments: z.ZodOptional>>; toolCalls: z.ZodOptional; name: z.ZodString; arguments: z.ZodRecord; }, z.core.$strip>>>; toolCallId: z.ZodOptional; toolName: z.ZodOptional; }, z.core.$strip>, z.ZodTransform<{ content: string; role: string; attachments?: { path: string; }[] | undefined; toolCalls?: { name: string; arguments: Record; id?: string | undefined; }[] | undefined; toolCallId?: string | undefined; toolName?: string | undefined; }, { role: string; content?: string | null | undefined; attachments?: { path: string; }[] | undefined; toolCalls?: { name: string; arguments: Record; id?: string | undefined; }[] | undefined; toolCallId?: string | undefined; toolName?: string | undefined; }>>>; modelId: z.ZodString; tools: z.ZodOptional; name: z.ZodString; description: z.ZodString; deferLoading: z.ZodOptional; group: z.ZodOptional; parameters: z.ZodObject<{ type: z.ZodLiteral<"object">; properties: z.ZodRecord, z.ZodArray>]>>; description: z.ZodOptional; enum: z.ZodOptional>>; }, z.core.$loose>>; required: z.ZodOptional>; }, z.core.$loose>; }, z.core.$strip>>>; stream: z.ZodBoolean; kvCache: z.ZodOptional>; generationParams: z.ZodOptional; top_p: z.ZodOptional; top_k: z.ZodOptional; predict: z.ZodOptional; seed: z.ZodOptional; frequency_penalty: z.ZodOptional; presence_penalty: z.ZodOptional; repeat_penalty: z.ZodOptional; reasoning_budget: z.ZodOptional; tool_choice: z.ZodOptional; parallel_tool_calls: z.ZodOptional; }, z.core.$strict>>; captureThinking: z.ZodOptional; emitRawDeltas: z.ZodOptional; toolDialect: z.ZodOptional>; responseFormat: z.ZodOptional; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"json_object">; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"json_schema">; json_schema: z.ZodObject<{ name: z.ZodString; description: z.ZodOptional; schema: z.ZodRecord; strict: z.ZodOptional; }, z.core.$strict>; }, z.core.$strict>], "type">>; requestId: z.ZodOptional; }, z.core.$strip>; export declare const completionStreamRequestSchema: z.ZodObject<{ history: z.ZodArray>; attachments: z.ZodOptional>>; toolCalls: z.ZodOptional; name: z.ZodString; arguments: z.ZodRecord; }, z.core.$strip>>>; toolCallId: z.ZodOptional; toolName: z.ZodOptional; }, z.core.$strip>, z.ZodTransform<{ content: string; role: string; attachments?: { path: string; }[] | undefined; toolCalls?: { name: string; arguments: Record; id?: string | undefined; }[] | undefined; toolCallId?: string | undefined; toolName?: string | undefined; }, { role: string; content?: string | null | undefined; attachments?: { path: string; }[] | undefined; toolCalls?: { name: string; arguments: Record; id?: string | undefined; }[] | undefined; toolCallId?: string | undefined; toolName?: string | undefined; }>>>; modelId: z.ZodString; tools: z.ZodOptional; name: z.ZodString; description: z.ZodString; deferLoading: z.ZodOptional; group: z.ZodOptional; parameters: z.ZodObject<{ type: z.ZodLiteral<"object">; properties: z.ZodRecord, z.ZodArray>]>>; description: z.ZodOptional; enum: z.ZodOptional>>; }, z.core.$loose>>; required: z.ZodOptional>; }, z.core.$loose>; }, z.core.$strip>>>; stream: z.ZodBoolean; kvCache: z.ZodOptional>; generationParams: z.ZodOptional; top_p: z.ZodOptional; top_k: z.ZodOptional; predict: z.ZodOptional; seed: z.ZodOptional; frequency_penalty: z.ZodOptional; presence_penalty: z.ZodOptional; repeat_penalty: z.ZodOptional; reasoning_budget: z.ZodOptional; tool_choice: z.ZodOptional; parallel_tool_calls: z.ZodOptional; }, z.core.$strict>>; captureThinking: z.ZodOptional; emitRawDeltas: z.ZodOptional; toolDialect: z.ZodOptional>; responseFormat: z.ZodOptional; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"json_object">; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"json_schema">; json_schema: z.ZodObject<{ name: z.ZodString; description: z.ZodOptional; schema: z.ZodRecord; strict: z.ZodOptional; }, z.core.$strict>; }, z.core.$strict>], "type">>; requestId: z.ZodOptional; type: z.ZodLiteral<"completionStream">; }, z.core.$strip>; export declare const completionStreamResponseSchema: z.ZodObject<{ type: z.ZodLiteral<"completionStream">; done: z.ZodOptional; events: z.ZodArray; seq: z.ZodNumber; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"rawDelta">; seq: z.ZodNumber; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"thinkingDelta">; seq: z.ZodNumber; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"toolCall">; seq: z.ZodNumber; call: z.ZodObject<{ id: z.ZodString; name: z.ZodString; arguments: z.ZodRecord; raw: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"toolError">; seq: z.ZodNumber; error: z.ZodObject<{ code: z.ZodEnum<{ PARSE_ERROR: "PARSE_ERROR"; VALIDATION_ERROR: "VALIDATION_ERROR"; UNKNOWN_TOOL: "UNKNOWN_TOOL"; }>; message: z.ZodString; raw: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"completionStats">; seq: z.ZodNumber; stats: z.ZodObject<{ timeToFirstToken: z.ZodOptional; tokensPerSecond: z.ZodOptional; promptTokensPerSecond: z.ZodOptional; cacheTokens: z.ZodOptional; promptTokens: z.ZodOptional; generatedTokens: z.ZodOptional; emittedTokens: z.ZodOptional; avgConcurrentSeq: z.ZodOptional; toolDefinitionsDropped: z.ZodOptional; backendDevice: z.ZodOptional>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"completionDone">; seq: z.ZodNumber; stopReason: z.ZodLiteral<"error">; error: z.ZodObject<{ message: z.ZodString; }, z.core.$strip>; raw: z.ZodOptional>; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"completionDone">; seq: z.ZodNumber; stopReason: z.ZodOptional>; raw: z.ZodOptional>; }, z.core.$strict>]>>; }, z.core.$strict>; export declare const completionOrchestrateRequestSchema: z.ZodObject<{ history: z.ZodArray>; attachments: z.ZodOptional>>; toolCalls: z.ZodOptional; name: z.ZodString; arguments: z.ZodRecord; }, z.core.$strip>>>; toolCallId: z.ZodOptional; toolName: z.ZodOptional; }, z.core.$strip>, z.ZodTransform<{ content: string; role: string; attachments?: { path: string; }[] | undefined; toolCalls?: { name: string; arguments: Record; id?: string | undefined; }[] | undefined; toolCallId?: string | undefined; toolName?: string | undefined; }, { role: string; content?: string | null | undefined; attachments?: { path: string; }[] | undefined; toolCalls?: { name: string; arguments: Record; id?: string | undefined; }[] | undefined; toolCallId?: string | undefined; toolName?: string | undefined; }>>>; modelId: z.ZodString; tools: z.ZodOptional; name: z.ZodString; description: z.ZodString; deferLoading: z.ZodOptional; group: z.ZodOptional; parameters: z.ZodObject<{ type: z.ZodLiteral<"object">; properties: z.ZodRecord, z.ZodArray>]>>; description: z.ZodOptional; enum: z.ZodOptional>>; }, z.core.$loose>>; required: z.ZodOptional>; }, z.core.$loose>; }, z.core.$strip>>>; stream: z.ZodBoolean; kvCache: z.ZodOptional>; generationParams: z.ZodOptional; top_p: z.ZodOptional; top_k: z.ZodOptional; predict: z.ZodOptional; seed: z.ZodOptional; frequency_penalty: z.ZodOptional; presence_penalty: z.ZodOptional; repeat_penalty: z.ZodOptional; reasoning_budget: z.ZodOptional; tool_choice: z.ZodOptional; parallel_tool_calls: z.ZodOptional; }, z.core.$strict>>; captureThinking: z.ZodOptional; emitRawDeltas: z.ZodOptional; toolDialect: z.ZodOptional>; responseFormat: z.ZodOptional; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"json_object">; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"json_schema">; json_schema: z.ZodObject<{ name: z.ZodString; description: z.ZodOptional; schema: z.ZodRecord; strict: z.ZodOptional; }, z.core.$strict>; }, z.core.$strict>], "type">>; requestId: z.ZodOptional; type: z.ZodLiteral<"completionOrchestrate">; maxToolTurns: z.ZodOptional; }, z.core.$strip>; /** * Downstream frame of the orchestrated completion duplex stream. Exactly one * payload field is set per frame: * * - `events` — pass-through of the inner completion turn's events (with * `turn` identifying which generation pass they belong to). * - `toolCallback` — the worker is asking the CLIENT to run a tool. The * client executes its registered handler and writes a JSON line * (`toolCallbackResultSchema`) up the request stream. The worker blocks * this run (not the socket) until the matching `callId` arrives. * - `done` — terminal frame; the loop ended (final answer produced, error, * cancellation, or the `maxToolTurns` cap). */ export declare const completionOrchestrateResponseSchema: z.ZodObject<{ type: z.ZodLiteral<"completionOrchestrate">; turn: z.ZodOptional; events: z.ZodOptional; seq: z.ZodNumber; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"rawDelta">; seq: z.ZodNumber; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"thinkingDelta">; seq: z.ZodNumber; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"toolCall">; seq: z.ZodNumber; call: z.ZodObject<{ id: z.ZodString; name: z.ZodString; arguments: z.ZodRecord; raw: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"toolError">; seq: z.ZodNumber; error: z.ZodObject<{ code: z.ZodEnum<{ PARSE_ERROR: "PARSE_ERROR"; VALIDATION_ERROR: "VALIDATION_ERROR"; UNKNOWN_TOOL: "UNKNOWN_TOOL"; }>; message: z.ZodString; raw: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"completionStats">; seq: z.ZodNumber; stats: z.ZodObject<{ timeToFirstToken: z.ZodOptional; tokensPerSecond: z.ZodOptional; promptTokensPerSecond: z.ZodOptional; cacheTokens: z.ZodOptional; promptTokens: z.ZodOptional; generatedTokens: z.ZodOptional; emittedTokens: z.ZodOptional; avgConcurrentSeq: z.ZodOptional; toolDefinitionsDropped: z.ZodOptional; backendDevice: z.ZodOptional>; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"completionDone">; seq: z.ZodNumber; stopReason: z.ZodLiteral<"error">; error: z.ZodObject<{ message: z.ZodString; }, z.core.$strip>; raw: z.ZodOptional>; }, z.core.$strict>, z.ZodObject<{ type: z.ZodLiteral<"completionDone">; seq: z.ZodNumber; stopReason: z.ZodOptional>; raw: z.ZodOptional>; }, z.core.$strict>]>>>; toolCallback: z.ZodOptional; }, z.core.$strip>>; done: z.ZodOptional; stopReason: z.ZodOptional>; }, z.core.$strict>; /** * Upstream JSON line the client writes after running a tool callback. * Newline-delimited on the duplex request stream, after the initial request * payload. `error` reports a handler failure; the worker forwards it to the * model as the tool result so the loop can recover or finish. */ export declare const toolCallbackResultSchema: z.ZodObject<{ callId: z.ZodString; result: z.ZodOptional; error: z.ZodOptional; }, z.core.$strip>; export type GenerationParams = z.infer; export type CompletionParams = z.infer; export type ToolDialect = z.infer; export type ResponseFormat = z.infer; export type CompletionClientParams = z.input; export type CompletionStreamRequest = z.infer; export type CompletionStreamResponse = z.infer; export type CompletionOrchestrateRequest = z.infer; export type CompletionOrchestrateResponse = z.infer; export type ToolCallbackResult = z.infer; export type Attachment = z.infer;