import { agencyStore } from "./asyncContext.js";
import { runPrompt } from "./prompt.js";
import { getRuntimeContext } from "./asyncContext.js";
export async function llm(prompt, opts = {}) {
    const thread = opts.thread ?? getRuntimeContext().threads.getOrCreateActive();
    // Build clientConfig with `model` only when explicitly overridden.
    // Passing `{ model: undefined }` would still let `runPrompt`'s merge
    // with smoltalkDefaults pick up the default, but being explicit keeps
    // the contract obvious: omit means "don't touch the model".
    const clientConfig = {};
    if (opts.model !== undefined)
        clientConfig.model = opts.model;
    return runPrompt({
        prompt,
        messages: thread,
        responseFormat: opts.schema,
        clientConfig,
        checkpointInfo: agencyStore.getStore()?.callsite,
    });
}
