import { z } from 'zod'; import { type Tool, type ToolCallError, type ToolCallWithCall } from './tools.js'; import type { ToolDialect } from './completion-stream.js'; export declare const completionStatsSchema: 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>; export type CompletionStats = z.infer; export declare const seqSchema: z.ZodNumber; export declare const contentDeltaEventSchema: z.ZodObject<{ type: z.ZodLiteral<"contentDelta">; seq: z.ZodNumber; text: z.ZodString; }, z.core.$strip>; export declare const rawDeltaEventSchema: z.ZodObject<{ type: z.ZodLiteral<"rawDelta">; seq: z.ZodNumber; text: z.ZodString; }, z.core.$strip>; export declare const thinkingDeltaEventSchema: z.ZodObject<{ type: z.ZodLiteral<"thinkingDelta">; seq: z.ZodNumber; text: z.ZodString; }, z.core.$strip>; export declare const toolCallEventSchema: 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>; export declare const toolErrorEventSchema: 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>; export declare const statsEventSchema: 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>; export declare const completionErrorSchema: z.ZodObject<{ message: z.ZodString; }, z.core.$strip>; declare const stopReasonEnum: z.ZodEnum<{ cancelled: "cancelled"; length: "length"; eos: "eos"; stopSequence: "stopSequence"; }>; export declare const doneEventSchema: z.ZodUnion; 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>]>; export declare const completionEventSchema: z.ZodUnion; 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>]>; export type ContentDeltaEvent = z.infer; export type RawDeltaEvent = z.infer; export type ThinkingDeltaEvent = z.infer; export type ToolCallEvent = z.infer; export type ToolErrorEvent = z.infer; export type StatsEvent = z.infer; export type CompletionError = z.infer; export type DoneEvent = z.infer; export type CompletionEvent = z.infer; export type StopReason = z.infer; export type CompletionFinal = { contentText: string; thinkingText?: string; toolCalls: ToolCallWithCall[]; /** * Tool-call regions the model emitted that could not be turned into a * `toolCalls` entry — malformed markup, arguments failing the tool's * schema, or a call to an undeclared tool. Omitted when there were none. * Lets a caller tell "the model made a mistake" from "no tool was called". */ toolErrors?: ToolCallError[]; stats?: CompletionStats; stopReason?: StopReason; raw: { fullText: string; }; /** * Canonical assistant text to push back into `history` for the next turn * when using `kvCache: true` (auto-cache). Equals the assistant content * we persisted to the cache key on this turn, so re-using it * verbatim guarantees a cache hit on the next call. * * Derived from `raw.fullText` (or `contentText` if the addon didn't * emit raw text) by stripping `` reasoning blocks and trimming * surrounding whitespace — see `normalizeAssistantCacheContent`. * * Tool-call turns currently can't be auto-cached, so this * field is omitted when `toolCalls.length > 0`. */ cacheableAssistantContent?: string; }; export type CompletionRun = { /** * Stable identifier for this run, generated by the caller at call time * (UUIDv4 when `crypto.randomUUID` is available, otherwise an opaque * random hex token) and available synchronously the moment * `completion(...)` returns. Pass it to `cancel({ requestId })` to * target this specific request without affecting any other inference * running on the same model. The cancel only takes effect once the * request has begun, so a cancel issued in the same tick * as `completion(...)` may race the begin and is logged as a no-match. */ requestId: string; /** Ordered stream of typed completion events — the canonical consumption API. */ events: AsyncIterable; /** Resolves when the stream ends with aggregated content, thinking, tool calls, stats, and raw output. */ final: Promise; tokenStream: AsyncGenerator; toolCallStream: AsyncGenerator; text: Promise; toolCalls: Promise; stats: Promise; }; export type ToolCallingCapability = 'textParse' | 'none'; export type ThinkingFramingCapability = 'thinkTags' | 'none'; export type PluginCapabilities = { toolCalling: ToolCallingCapability; thinkingFraming: ThinkingFramingCapability; }; export declare const DEFAULT_PLUGIN_CAPABILITIES: PluginCapabilities; export type NormalizerConfig = { capabilities: PluginCapabilities; tools: Tool[]; captureThinking: boolean; emitRawDeltas: boolean; toolDialect?: ToolDialect; }; export {};