import { GlobalStore } from "./state/globalStore.js"; import { ThreadStore } from "./index.js"; import { RunNodeResult } from "./types.js"; import { ResultValue } from "./result.js"; export declare function deepClone(obj: T): T; export declare function deepFreeze(obj: T, seen?: WeakSet): T; /** Strict structured-output extraction: unwrap the provider's response * shape and validate against the schema. Returns success(value) with the * validated value, or failure(schemaError) — never the raw content. The * unwrap heuristics mirror the shapes providers actually return: the * { response: ... } wrapper for primitive schemas, single-key wrappers, * stringified JSON, and single-element arrays. */ export declare function extractStructuredResponse(rawValue: any, schema: any): ResultValue; export declare function extractResponse(rawValue: any, schema: any): any; export declare function createReturnObject({ result, globals, }: { result: { data: T; messages?: ThreadStore; }; globals: GlobalStore; }): RunNodeResult; export type ModelUsage = { model: string; inputTokens: number; outputTokens: number; /** Tokens read back from an existing cache entry. */ cachedInputTokens: number; /** Tokens written to a new cache entry. */ cacheCreationInputTokens: number; cost: number; }; /** * Normalize the raw `__tokenStats.models` map into a typed, defensively * narrowed array sorted by cost descending (model name as the tiebreak). * Single source of truth for reading the per-model breakdown — shared by * std::thread's `getModelCosts` and the REPL footer's token snapshot so * the field narrowing and ordering live in one place. */ export declare function normalizeModelUsage(rawModels: unknown): ModelUsage[]; /** The token-usage fields `updateTokenStats` reads (all optional — providers * vary, and a free/local model has no cost). */ type StatUsage = { inputTokens?: number; outputTokens?: number; cachedInputTokens?: number; cacheCreationInputTokens?: number; totalTokens?: number; }; type StatCost = { inputCost?: number; outputCost?: number; cachedInputCost?: number; cacheCreationInputCost?: number; totalCost?: number; }; export declare function updateTokenStats(args: { globals: GlobalStore; usage: StatUsage | null | undefined; cost?: StatCost | null; model?: string; }): void; export {};