Skip to main content
The ExuluContext constructor takes a single options object. This page documents every option, verified against the current @exulu/backend source.

Identity

id
string
required
Unique identifier. Lowercased with spaces replaced by underscores, it becomes the Postgres table prefix: <id>_items, <id>_chunks, and (with the entity layer) <id>_entities. Must start with a letter or underscore, contain only letters, digits, and underscores, and be at most 80 characters — treat 5 as the practical minimum.
name
string
required
Human-readable name shown in the platform UI and logs.
description
string
required
What this context contains. Surfaced to users and agents choosing where to search.
active
boolean
required
Whether the context is active and available.
Never change id after the context has data — the tables are named after it, so a renamed context points at new, empty tables.

Fields

fields
ExuluContextFieldDefinition[]
required
The custom schema for items, on top of the built-in columns (id, name, description, tags, archived, external_id, created_by, ttl, rights_mode, embeddings_updated_at, last_processed_at, textlength, source, chunks_count, createdAt, updatedAt).
fields[].name
string
required
Column name. Sanitized to lowercase with underscores. For file fields, the actual column is <name>_s3key.
fields[].type
ExuluFieldTypes
required
One of text, longText, shortText, number, boolean, code, json, enum, markdown, file, date, uuid. See the type table below for the Postgres column each maps to.
fields[].editable
boolean
Whether the field can be edited in the platform UI after creation.
fields[].unique
boolean
Adds a unique constraint on the column.
fields[].required
boolean
Whether a value is required when creating items through the platform API.
fields[].default
any
Default value declared for the field. Surfaced through the context’s table definition (API and admin UI); the Postgres column itself is created without a database-level default.
fields[].calculated
boolean
Marks the field as computed (for example, filled by a processor) rather than user-provided.
fields[].index
boolean
Whether to index the field for faster filtering.
fields[].enumValues
string[]
For enum fields: the allowed values.
fields[].allowedFileTypes
allFileTypes[]
For file fields: the accepted file types (for example ["pdf", "docx"]).

Field type reference

Embedder

embedder
ExuluContextEmbedder
A reference to a LiteLLM embedding model, plus an optional queue. Without an embedder, vector and hybrid search are unavailable — the context still works for structured storage and full-text search.
embedder.model
string
required
The model_name of an embedding model declared in config.litellm.yaml. The model’s model_info must declare its dimensionality — the chunks table’s vector(n) column is sized from it, and table creation throws if it is missing.
embedder.queue
Promise<ExuluQueueConfig>
When set, embedding generation is scheduled as a BullMQ job on this queue instead of running inline. Required in practice for bulk generation: without a queue, embeddings.generate.all() refuses to process more than 2,000 items.
ExuluQueues.register(name, concurrency, ratelimit?, timeoutInSeconds?) registers a BullMQ queue and returns { use }; calling .use() yields the Promise<ExuluQueueConfig> the embedder, processor, and sources expect. Registering queues requires an Enterprise Edition license.

Chunker

chunker
ChunkerOperation
default:"defaultChunker"
Splits an item into embeddable chunks before the embedder runs. When omitted, the built-in defaultChunker (a sentence chunker) runs over the item’s content field — falling back to description — combined with name. Contexts with structured or file-backed content should supply their own.
maxChunkSize is the per-chunk token budget, derived from the embedding model. utils.storage gives file-backed chunkers access to object storage. Chunk metadata lands in the chunks table’s JSONB column, so any JSON-serializable value (for example a page number) is allowed.
@exulu/backend also exports ready-made chunkers under ExuluChunkers (sentence, markdown, recursive) and the defaultChunker itself.

Sources

sources
ExuluContextSource[]
required
Data sources that ingest items from external systems. Pass an empty array if the context has none.
sources[].id
string
required
Unique source ID — also used as the BullMQ job scheduler key.
sources[].name
string
required
Human-readable name.
sources[].description
string
required
What the source ingests.
sources[].config.schedule
string
Cron expression, for example "0 */6 * * *" for every six hours. When the worker process starts (app.bullmq.workers.create()), it upserts a BullMQ job scheduler per source that has both a schedule and a queue. Sources without a queue log a warning and are skipped.
sources[].config.queue
Promise<ExuluQueueConfig>
The queue the source job runs on.
sources[].config.retries
number
default:"3"
BullMQ retry attempts for a failed run.
sources[].config.backoff
object
default:"{ type: \"exponential\", delay: 2000 }"
Retry backoff strategy.
sources[].config.params
object[]
Declared input parameters (name, description, optional default) for manual runs — surfaced in the platform UI when triggering the source by hand. Values arrive in execute’s inputs.
sources[].execute
function
required
Async function that fetches external data and returns an array of items (ExuluItem). Each returned item is written with createItem: items carrying an external_id (or id) are upserted — existing rows with the same external_id are updated — while items without one are inserted fresh. Processor and embedding triggers apply as configured.

Processor

processor
ExuluContextProcessor
Transforms items after they are written — extract text from an uploaded file, enrich a record, compute derived fields. The result is written back to the items table and can trigger embedding generation.
processor.name
string
required
Processor name, used in job labels.
processor.description
string
required
What the processor does.
processor.filter
function
Optional predicate. Return a falsy value to skip processing for an item — for example, when no file is attached yet.
processor.execute
function
required
The transformation. Receives the item and utils.storage for reading files from object storage; must return the updated item, which is persisted with last_processed_at set.
processor.config.trigger
string
required
When the processor runs: manual (only explicit processField() calls), or automatically on writes. Both createItem() and updateItem() run the processor when the trigger is onInsert, onUpdate, or always — currently the three non-manual values behave identically on both write paths.
processor.config.queue
Promise<ExuluQueueConfig>
Run processing as a background job instead of inline.
processor.config.timeoutInSeconds
number
default:"600"
Job timeout in queue mode.
processor.config.generateEmbeddings
boolean
When true, embedding generation is triggered automatically after the processor finishes.

Retrieval hooks

queryRewriter
(query: string) => Promise<string>
Rewrites the natural-language query before retrieval — for example, expanding it with an LLM. Applied inside the search pipeline whenever a query is present.
resultReranker
(results: chunk[]) => Promise<chunk[]>
Declared hook for reordering retrieved chunks after search. Each chunk carries chunk_content, chunk_index, chunk_id, chunk_source, chunk_metadata, chunk_created_at, chunk_updated_at, item_id, item_external_id, and item_name.
resultReranker is accepted and stored on the context, but the current search pipeline does not invoke it — the call site is disabled in the source. Don’t rely on it running until a release notes otherwise.

Retrieval configuration

configuration
object
Retrieval and write behavior. When you omit the entire object, the defaults below apply. When you pass a partial object, only your keys are set — the per-key defaults are not merged in, so pass everything you rely on.
configuration.calculateVectors
"manual" | "onUpdate" | "onInsert" | "always"
default:"manual"
When embeddings are generated automatically: never (manual), when items are created (onInsert), updated (onUpdate), or both (always). With manual, call embeddings.generate.one() / .all() yourself or pass the generateEmbeddingsOverwrite flag on writes.
configuration.maxRetrievalResults
number
default:"10"
Fallback result limit used when a search() call passes no limit.
configuration.defaultRightsMode
"private" | "users" | "roles" | "teams" | "public"
default:"private"
Default rights_mode for new items — the items table column defaults to this value.
configuration.cutoffs
object
Minimum relevance scores per search method. Results scoring below the cutoff are dropped. Can be overridden per search() call.
configuration.expand
object
default:"{ before: 0, after: 0 }"
Number of neighboring chunks to include around each matched chunk, giving agents more surrounding context. Can be overridden per search() call.
configuration.languages
("german" | "english")[]
default:"[\"english\"]"
Languages for the generated full-text search columns. Each language adds a to_tsvector expression to the items and chunks tables, affecting stemming and stop words. Set before the tables are created — the columns are generated at table-creation time.

Entity layer

entities
ExuluEntitiesConfig
Opt-in entity extraction over chunks. When present (or when an admin has configured entity types for the context in the UI), IMP extracts typed entities from embedded content into <id>_entities, enabling entity filters and insights in search(). Absent → behavior is unchanged.
entities.types
object[]
Entity types declared in code, for example { name: "Person", description: "A natural person mentioned in the document." }. Merged (union) with types an admin declares in the UI.
entities.model
string
Model ID used for extraction. Falls back to a platform default when omitted.
entities.boostWeight
number
default:"0.3"
Weight of the shared-entity boost term in retrieval ranking.
entities.confidenceThreshold
number
default:"0.5"
Mentions below this extractor confidence are dropped.
entities.canonicalLanguage
string
default:"english"
Target language for canonical entity names.
See Entities for the admin-side view of the entity layer.

Complete example

Next steps

API reference

Search, item CRUD, embeddings, entity layer, and table methods.

ExuluApp

Register the context on the app.