Docket Docs

Adapter Contracts

The five frozen interfaces that all adapters implement.

Adapter Contracts

All adapter interfaces live in src/core/interfaces/ and are frozen. They can only change with architect approval.

The five contracts

ContractPurposeKey methods
LlmAdapterChat completionschat(messages, options)
EmbedderAdapterText embeddingsembed(text), embedBatch(texts)
StoreAdapterDatabase + vector searchcreateMemory, vectorSearch, getMemoryGraph
BlobAdapterRaw file storageput(key, data, metadata), get(key)
QueueAdapterBackground jobsenqueue(type, payload), dequeue(type), registerWorker

Common interface features

Every adapter contract includes:

  • constructor(config) — validates and stores config
  • initialize() — async setup (connections, migrations)
  • health() — returns { ok, latency, error? }
  • static get metadata() — adapter discovery info

Validation

All adapters validate config in the constructor. Use Zod or manual checks:

validateConfig(config) {
  if (!config || typeof config !== 'object') {
    throw new Error('Config must be an object');
  }
  if (!config.baseUrl) {
    throw new Error('baseUrl is required');
  }
  return config;
}

Health checks

The default health check in most interfaces performs a real operation (e.g., a 1-token chat or a test embedding). Override if your adapter has a cheaper ping method.

Metadata

static get metadata() {
  return {
    name: 'ollama-llm',
    version: '0.1.0',
    capabilities: ['chat', 'streaming'],
    docketCompatibility: '>=0.1.0 <0.3.0'
  };
}

Testing your adapter

Every adapter must pass the contract test suite in tests/integration/adapter-contracts/. These tests verify that your implementation satisfies the interface without knowing your internals.

Read the specific contract pages for implementation details:

On this page