import type { HostFiles, Located } from "../host/host.js"; import { type LlmBaseUrls } from "../runtime/llmConfig.js"; import type { RetryConfig } from "../runtime/llmRetry.js"; import type { ReplyLimits } from "../runtime/localDefaults.js"; import type { WarnAtRoundsLeft } from "../runtime/roundWarning.js"; import { type OpenRouterOptions } from "smoltalk"; /** * Fields that may be set as LLM defaults via `setLlmOptions`. A * deliberately small subset of the per-call `llm()` options. All ride * the same `stack.other.llmDefaults` bag; `runPrompt` routes * model/temperature/reasoningEffort/maxTokens into the smoltalk config * and `maxToolResultChars` into the tool-result cap. * * Extends `RetryConfig` (single source for `retries` / `timeout` / `backoff`, * shared with `LlmOpts` and the type-checker's `llmOptions` shape). Per-call * `llm()` options override these; these override the built-in defaults. */ export type LlmDefaults = RetryConfig & { model?: string; provider?: string; temperature?: number; reasoningEffort?: "low" | "medium" | "high"; /** Thinking on or off, with an optional budget of tokens to think for. * See `withLocalDefaults` for what a local MLX model does with it. */ thinking?: { enabled: boolean; budgetTokens?: number; }; /** The MLX chat server's limits on a reply that goes in circles: how * many second thoughts ("But wait") and how many repeats of one * sentence it allows, and whether the answer is watched as well as the * thinking. `0` turns a limit off. Other providers ignore it. */ replyLimits?: ReplyLimits; maxTokens?: number; maxToolResultChars?: number; maxToolCallRounds?: number; /** Refuse a tool call after this many identical runs with the same result; 0 disables. */ maxRepeatedToolCalls?: number; /** When to warn the model that its tool rounds are running out, and * what to say. See lib/runtime/roundWarning.ts. */ warnAtRoundsLeft?: WarnAtRoundsLeft; /** Which companies OpenRouter may send the call to. Other providers ignore it. */ openRouter?: OpenRouterOptions; /** The base URLs to use for the providers it names. A later * `setLlmOptions` call with `baseUrl` replaces this one whole. A * provider it leaves out uses the URL from `agency.json`, or its * default. */ baseUrl?: LlmBaseUrls; /** Spread into the provider's request body as given. */ rawAttributes?: Record; }; /** * Merge `opts` into the ACTIVE branch stack's LLM defaults * (`stack.other.llmDefaults`). Only present (non-undefined) keys are * written, and a key set to `null` is removed, so the baked `agency.json` * value for it applies again. Switching between text and decision models * without a provider selects the new model's registry provider. * * Branch-scoped: inside a fork/race/tool branch this writes that * branch's own slice (seeded from the parent at fork time by * `runBatch.inheritBranchMemory`), so the change is visible in-branch * and does not leak to siblings or the parent after join. It rides the * serialized `stack.other`, so it survives interrupt/resume. `runPrompt` * merges it over the baked `smoltalkDefaults` and under any per-call * `llm({...})` option. */ export declare function _setLlmOptions(opts: LlmDefaults): void; /** Load a provider module by path at runtime and register its provider into * agency's own smoltalk — the runtime counterpart of `loadProviderModules` * (which runs at bootstrap). The Agency wrapper raised * `std::llm::registerProvider` on the real path, so the default `locate` * refuses a link in it, and a link at the file itself is refused too. */ export declare function _registerProviderModule(modulePath: string, locate?: Locate): Promise; /** How a path a function was given becomes a root plus a final name. */ export type Locate = (files: HostFiles, p: string) => Promise; /** After an interrupt: the spelling the approver saw, with no link in it. */ export declare const fixed: Locate; /** With no interrupt, as from the CLI: the caller's own spelling. */ export declare const whole: Locate; /** * Stable, flat view of one hosted model for discovery/pickers. Maps smoltalk's * `ModelType` (union, optional-heavy fields) into a fixed shape the CLI, the * agent, and `std::llm` all share. Field order is mirrored by the Agency-side * `HostedModelInfo` in `stdlib/llm.agency` — keep the two in sync. */ export type HostedModelInfo = { name: string; provider: string; openWeights: boolean; inputCost: number; outputCost: number; contextWindow: number; family: string; }; /** All known hosted TEXT models (baked catalog + any refreshed data). Non-text * members of the `ModelType` union lack pricing/context and are excluded. */ export declare function _listHostedModels(): HostedModelInfo[]; /** Metadata for one hosted text model by name, or null if unknown/non-text. */ export declare function _hostedModelInfo(name: string): HostedModelInfo | null; /** Hosted-search capability names to request for a call on `model` via * `provider`, backing `std::agents/lib/search.hostedSearchTools`. Every * smoltalk client keys the request on the literal string "web_search", so * that is the only name this ever returns (the catalog's per-provider tool * names like "google_search" are catalog entries, not request keys). * * The answer depends on the ROUTE, not the model family: gpt-4o-mini has * hosted search through "openai-responses" and none through the base * "openai" client. This resolves the pair the way the call will (see * `resolveLlmRoute`) and asks smoltalk's `getHostedTools` about exactly * that pair, which is the same check that later rejects an unsupported * request. * * A local provider (the MLX server, llama.cpp) never has hosted search, * whatever the model: the answer is the empty list before the catalog is * consulted. Local model names are never in the catalog, so without this * check they fell into the err-open case below, the request went out * with `web_search`, and smoltalk refused the whole call. * * Two cases err open, because withholding search wrongly is the invisible * failure: a model unknown to the catalog (brand new, custom) and an empty * model with no default anywhere. */ export declare function _hostedSearchTools(model: string, provider?: string): string[]; /** Tri-state modality probe backing `std::llm.modelSupportsInput`. Returns * null (not undefined — Agency has no undefined) when the model is unknown * or carries no modality data; that matches smoltalk's send-time gate, * which only blocks on an explicit false. */ export declare function _modelSupportsInput(model: string, modality: string): boolean | null; /** Fetch the latest model-data blob and return it pre-serialized. No * registration — the CLI prints this to stdout for the user to save and later * load with `std::llm.loadModelData`. */ export declare function _fetchModelData(url: string): Promise<{ ok: boolean; json: string; error: string; }>; /** Read a model-data JSON file (the shape `agency models refresh` prints) and * register it, ACCUMULATING over any previously registered data (this file * wins on provider+name collisions, deep-merging fields) and over the baked * catalog. Errors are returned, never thrown, so the Agency wrapper can map * them to a Result. Returns the number of models in THIS file. * * `locate` splits the path into its parent and final name. The Agency * wrapper raised `std::read` on the real spelling, so the default refuses * a link in it; a CLI caller with no approval passes `wholePath`. */ export declare function _loadModelData(path: string, locate?: Locate): Promise<{ ok: boolean; count: number; error: string; }>;