Capability first · transport second

Ollama.js

Provides the first-class Arcane Ollama client without direct access to localhost:11434.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
On this page

Overview

Provides the first-class Arcane Ollama client without direct access to localhost:11434.

  • Artifact
    Ollama.js · esm
  • Classification
    public first party
  • Availability
    Native bridge
  • Normalization
    Principal methods preserve provider-native envelopes; readiness/text/unload helpers normalize.

Import and lifecycle

JavaScript
import * as module from '/arcane/modules/Ollama.js';

Import creates and freezes a singleton, installs non-writable globalThis.arcaneOllama once, and dispatches arcane-ollama-ready. Calls resolve globalThis.Arcane.ollama at call time and never access localhost directly.

Application-facing behavior: Ollama, singleton/default ollama; 24 methods; installs globalThis.arcaneOllama, emits arcane-ollama-ready.

Protocol and host implementation

Arcane.ollama through Core + per-realm globalThis.arcaneEvents authority This detail does not widen the application-facing API or grant authority.

Exports, signatures, parameters, and results

BindingFormDeclaration or signatureParameter syntax
OLLAMA_EVENT_TYPESvariable · valuevariable OLLAMA_EVENT_TYPES
OLLAMA_REASONSvariable · valuevariable OLLAMA_REASONS
Ollamaclassclass Ollama
ollamaclass · valuevariable ollama
defaultdefault · valuevariable default
MemberKindExact public declarationParameter syntax
Ollama.versionmethodversion()
Ollama.modelsmethodmodels()
Ollama.listmethodlist()
Ollama.runningmethodrunning()
Ollama.showmethodshow(model,options)model,options
Ollama.generatemethodgenerate(request,options)request,options
Ollama.chatmethodchat(request,options)request,options
Ollama.embedmethodembed(request)request
Ollama.pullmethodpull(model,options,streamOptions)model,options,streamOptions
Ollama.pushmethodpush(model,options,streamOptions)model,options,streamOptions
Ollama.createmethodcreate(request,options)request,options
Ollama.copymethodcopy(source,destination)source,destination
Ollama.deletemethoddelete(model)model
Ollama.selectionmethodselection()
Ollama.selectmethodselect(preference)preference
Ollama.settingsmethodsettings()
Ollama.saveSettingsmethodsaveSettings(settings)settings
Ollama.createBrainmethodcreateBrain(definition)definition
Ollama.serviceSettingsmethodserviceSettings()
Ollama.saveServiceSettingsmethodsaveServiceSettings(settings)settings
Ollama.readinessasync methodasync readiness()
Ollama.generateTextasync methodasync generateText(request,options)request,options
Ollama.chatTextasync methodasync chatText(request,options)request,options
Ollama.unloadmethodunload(model)model
Ollama.PUBLISH_OLLAMA_READYmethod[PUBLISH_OLLAMA_READY]()

Parameter meanings and results

Raw version/models/list/running/show/generate/chat/embed/pull/push/create/copy/delete/selection/select/settings/saveSettings/createBrain/serviceSettings/saveServiceSettings wrappers preserve arguments/results. Application pull() and copy() calls always reject in the pinned Core contract. readiness() returns frozen {ready,version,errorCode}; generateText()/chatText() return strings; unload(model) generates with keep_alive:0.

Events, side effects, and errors

Source-literal CustomEvent dispatches

No source-literal CustomEvent dispatch is part of this artifact.

Lifecycle and event flow

  • Global arcane-ollama-ready with {ollama}.

Direct coded failures

  • ARCANE_OLLAMA_UNAVAILABLE

Exported Error subclasses

This artifact exports no Error subclass.

Documented failure behavior

  • ARCANE_OLLAMA_UNAVAILABLE when the bridge is absent.
  • Provider/Core errors are preserved by raw wrappers; readiness() contains them as errorCode.

Availability and capabilities

Native bridge. Principal methods preserve provider-native envelopes; readiness/text/unload helpers normalize.

ai.inference covers chat/embed/generate and Kempo suppresses raw calls; ai.models.read covers diagnostics/reads with app restrictions; ai.models.manage covers admitted lifecycle/selection writes, but never makes application pull() or copy() available; ai.settings.manage covers Settings-only settings APIs.

Contract example

JavaScript
import ollama from '/arcane/modules/Ollama.js';

async function chatWithAdmittedOllamaAfterUserChoice(){
    const status = await Arcane.localAI.status();
    const model = status.models.ollama.find(item => item.runnable === true);
    if (!model) throw new Error('No admitted runnable model.');
    const response = await ollama.chat({
        model:model.id,
        messages:[{role:'user',content:'Reply with one word.'}]
    });
    console.log(response.message?.content);
}