/** * Cross-environment executor adapter for the native Ollama `/api/chat` endpoint. * * @module @nhtio/adk/batteries/llm/ollama/adapter * * @remarks * Native Ollama LLM adapter targeting `/api/chat` (NOT the OpenAI-compat `/v1` layer — the * `openai_chat_completions` battery already covers `/v1`). Works against both LOCAL Ollama * (`http://localhost:11434`, no auth) and CLOUD Ollama (`https://ollama.com`, `Authorization: * Bearer `); the only difference is `baseURL` + the auth header. Native is HTTP-only — a * Unix-socket deployment is reached via a custom `fetch` or an external bridge, not an adapter * option. * * Structurally a sibling of the OpenAI Chat Completions adapter, with the native-wire divergences: * * - Request body: generation params are NESTED under `options`; `think` / `format` / `keep_alive` * are top-level native controls; ADK control fields are stripped before sending. * - Streaming: NDJSON (newline-delimited JSON objects), terminated in-band by `done: true` — there * is no SSE `data:` framing and no `[DONE]` sentinel. Whole `tool_calls` arrive per chunk (no * delta accumulation). * - Reasoning: the single native `message.thinking` field (no multi-field precedence dance). * - Tool calls: `arguments` is already a JSON OBJECT (no `JSON.parse`); native calls carry no `id`, * so the adapter synthesizes one (uuidv6) for correlation / checksum / spool keying. Tool-result * history messages use `tool_name` (the originating tool), not `tool_call_id`. * - Generation stats: the terminal `done: true` object's token counts + nanosecond durations + * `done_reason` are surfaced via `helpers.reportGenerationStats`. */ import type { DispatchExecutorFn } from "../../../dispatch_runner"; import type { OllamaAdapterOptions } from "./types"; /** * Opinionated cross-environment LLM adapter for the native Ollama `/api/chat` wire shape. * * @remarks * Construction validates options eagerly via {@link validateOptions} and throws * {@link @nhtio/adk/batteries/llm/ollama!E_INVALID_OLLAMA_OPTIONS} on failure. The returned instance is reusable: call * {@link OllamaAdapter.executor} once per `DispatchRunner` configuration to obtain a * {@link @nhtio/adk!DispatchExecutorFn} bound to the baseline plus optional executor-scope * overrides. Per-iteration overrides live on `ctx.stash.ollama` and take highest precedence; * `headers`, `helpers`, `retry`, and the nested runtime `options` merge key-by-key across all three * layers, every other field is replaced wholesale at the highest layer that sets it. */ export declare class OllamaAdapter { #private; /** Customary key for per-iteration overrides on `ctx.stash`. */ static readonly STASH_KEY: "ollama"; /** * @param options - Constructor-baseline options. Re-validated on every iteration after * per-dispatch and per-iteration overrides are layered in. * @throws {@link @nhtio/adk/batteries/llm/ollama!E_INVALID_OLLAMA_OPTIONS} when `options` does not satisfy `ollamaOptionsSchema`. */ constructor(options: unknown); /** * Returns a {@link @nhtio/adk!DispatchExecutorFn} bound to this adapter's baseline plus optional * executor-scope overrides. * * @param overrides - Optional executor-scope overrides. Higher precedence than the baseline, * lower precedence than `ctx.stash[STASH_KEY]`. */ executor(overrides?: Partial): DispatchExecutorFn; /** * Returns `true` when `value` is an {@link OllamaAdapter} instance. */ static isOllamaAdapter(value: unknown): value is OllamaAdapter; }