/** * @file Node/browser-agnostic simulator of the stable `LanguageModel` Prompt * API. Useful for CI, node-smol SEA builds, and any environment where * Chrome's on-device model is unavailable. The simulator conforms to the same * shape as the browser global so `createBuiltinModel` works unchanged. */ /** * One message in a prompt exchange. */ export interface Message { readonly role: 'system' | 'user' | 'assistant'; readonly content: string; } /** * The session-like shape the Prompt API exposes. */ export interface SessionLike { prompt(messages: Message[]): Promise; promptStreaming(messages: Message[]): AsyncIterable; } /** * The factory-like shape the Prompt API exposes. */ export interface LanguageModelLike { availability(): Promise; create(options?: object | undefined): Promise; } export interface ResponseRule { readonly response: string; readonly when: (text: string) => boolean; } export interface LanguageModelSimulatorOptions { /** * Object the simulator is installed onto. Defaults to `globalThis`; a test * passes its own to avoid touching the real global. */ readonly target?: typeof globalThis | undefined; /** * Ordered list of rules. The first rule whose `when` predicate returns true * determines the response. */ readonly rules?: ResponseRule[] | undefined; /** * Response used when no rule matches. */ readonly fallback?: string | undefined; } export declare class LanguageModelSimulator implements LanguageModelLike { #private; constructor(options?: LanguageModelSimulatorOptions | undefined); availability(): Promise<'available'>; create(_options?: object | undefined): Promise; } export declare class LanguageModelSessionSimulator implements SessionLike { #private; constructor(rules: ResponseRule[], fallback: string); prompt(messages: Message[]): Promise; promptStreaming(messages: Message[]): AsyncIterable; } /** * Install the simulator onto `globalThis.LanguageModel` so * `createBuiltinModel` finds it. */ export declare function installLanguageModelSimulator(options?: LanguageModelSimulatorOptions | undefined): LanguageModelSimulator;