@corbits/ollama-adapter provides @intx/inference adapter factories for Ollama's OpenAI-compatible /v1/chat/completions and Anthropic-compatible /v1/messages surfaces. It owns the request overrides (maxOutputTokens, reasoning) and the stream repairs Ollama needs on /v1/chat/completions. It does not own SSE parsing or message marshaling (the wrapped Interchange adapters) or Ollama's native /api endpoints.
src/adapter.ts:createOllamaAdapter(wraps the OpenAI Chat Completions adapter) andcreateOllamaAnthropicAdapter(wraps the Anthropic adapter on/messages).src/overrides.ts: theOllamaAdapterConfig,OllamaAdapterOverrideandReasoningschemas, legacy-key migration and per-model resolution.src/think-tags.ts: reclassifies inline<think>text into thinking deltas.src/inline-tool-json.ts: reclassifies a tool call emitted as JSON text into tool-call events.src/index.ts: the public entry (the two factories and three schemas).src/*.test.ts: unit tests next to the module they cover.e2e/: the inference-harness suite and the live suites gated onOLLAMA_BASE_URL.
- Consume
@intx/inference,@intx/logand@intx/typesaspeerDependencies(^0.4.0), never vendored. A host must resolve exactly one copy. - Parse the
quirksbag with arktype; unknown override keys are rejected. exactOptionalPropertyTypesis on: omit optional keys, never assignundefinedto them.- Leave the wrapped adapters' parsing unmodified; repairs apply only on the OpenAI-compatible surface, since Ollama's Anthropic surface already emits native
thinkingandtool_useblocks.
bun install && bun run check- Read
README.mdbefore changing public behavior. - Keep changes focused; update docs and tests alongside code changes.
- Run
bun run checkbefore declaring work complete.