import type { AppConfig, MLCEngineInterface } from '@mlc-ai/web-llm'; import { type FeltDBContractSnapshot, type FeltDBFlowProposal, type DecisionBatch, type DecisionBatchEvaluation, type DecisionRuntime, type DecisionRuntimeCapabilities, type DecisionRequest, type DecisionResult } from '@feltdb/core'; export declare const DEFAULT_MODEL = "SmolLM2-360M-Instruct-q4f32_1-MLC"; export declare const RECOMMENDED_MODELS: Readonly<{ smallest: "SmolLM2-360M-Instruct-q4f32_1-MLC"; balanced: "SmolLM2-1.7B-Instruct-q4f32_1-MLC"; lowMemoryWithShaderF16: "SmolLM2-360M-Instruct-q4f16_1-MLC"; }>; export type Message = { role: 'user' | 'assistant' | 'system'; content: string; }; export type JsonResponseFormat = { type: 'json_object'; schema?: string | Record; }; export type GenerationOptions = { temperature?: number; maxTokens?: number; topP?: number; stopSequences?: string[]; responseFormat?: JsonResponseFormat; }; export type DecisionReadout = { probabilities: Record; selected?: string; }; export type DecisionCompletion = { choices?: Array<{ message?: { content?: string | null; }; logprobs?: { content?: Array<{ token?: string; top_logprobs?: Array<{ token?: string; logprob?: number; }>; }>; } | null; decision?: DecisionReadout; }>; }; export type WebLLMDecisionOptions = { model?: string; modelRevision?: string; promptRevision?: string; temperature?: number; maxTokens?: number; engineFactory?: EngineFactory; onProgress?: (progress: ModelLoadProgress) => void; }; export type ModelLoadProgress = { progress: number; text: string; timeElapsed?: number; }; export type CacheBackend = 'cache' | 'indexeddb' | 'opfs' | 'cross-origin'; export type EngineFactoryContext = { model: string; worker: Worker | null; appConfig?: AppConfig; onProgress: (progress: ModelLoadProgress) => void; }; export type EngineFactory = (context: EngineFactoryContext) => Promise; export interface WebLLMOptions { /** WebLLM model ID. Defaults to a roughly 580 MB VRAM SmolLM2 model. */ model?: string; /** Run inference outside the UI thread. Enabled by default. */ useWorker?: boolean; /** Supply an application-owned worker instead of the bundled worker. */ worker?: Worker; cacheBackend?: CacheBackend; appConfig?: AppConfig; onProgress?: (progress: ModelLoadProgress) => void; /** Test/custom integration hook. Supplying this bypasses browser capability checks. */ engineFactory?: EngineFactory; /** Contract grounding for FeltDB-aware generation. It must contain definitions, never records or secrets. */ contract?: FeltDBContractSnapshot | (() => FeltDBContractSnapshot | Promise); } export type GenerateFlowOptions = GenerationOptions & { snapshot?: FeltDBContractSnapshot; currentFlow: string; /** Permit a proposal that removes declared application primitives. Defaults to false. */ allowDestructiveProposal?: boolean; }; export declare function isWebGPUSupported(): boolean; export declare class WebLLMProvider { readonly options: WebLLMOptions; readonly kind: "webllm"; readonly private = true; readonly model: string; private engine; private initialization; private ownedWorker; constructor(options?: WebLLMOptions); isReady(): boolean; initialize(): Promise; private createEngine; private readyEngine; generate(messages: Message[], options?: GenerationOptions): Promise; directReadout(messages: Message[], labels: string[], options?: Pick): Promise; /** * Generate a validated, stale-base-protected feltdb.flow proposal. * This method has no filesystem or publish authority. */ generateFlow(intent: string, options: GenerateFlowOptions): Promise; stream(messages: Message[], options?: GenerationOptions): AsyncIterableIterator; interrupt(): void; shutdown(): Promise; } /** * Evaluates typed decisions using WebLLM direct readout. It has no database * reference and receives only the authorized context included in each request. */ export declare class WebLLMDecisionRuntime implements DecisionRuntime { readonly runtime = "webllm"; readonly model: string; readonly modelRevision: string; readonly promptVersion: string; readonly temperature: number; readonly maxTokens: number; private readonly provider; constructor(options?: WebLLMDecisionOptions); metadata(): { runtime: string; model: string; model_revision: string; prompt_revision: string; execution_method: "logit"; decision_schema_revision: string; }; capabilities(): DecisionRuntimeCapabilities; decide(request: DecisionRequest): Promise; execute(request: DecisionRequest): Promise; decideBatch(batch: DecisionBatch): Promise; executeBatch(batch: DecisionBatch): Promise; initialize(): Promise; shutdown(): Promise; } export declare function getAvailableModels(): Promise>;