@exulu/backend source. For constructor options, see Configuration.
Constructor
Search
search()
Runs vector, full-text, or hybrid retrieval over the context’s chunks, with RBAC filtering, score cutoffs, and chunk expansion.string
Natural-language query. Embedded via the context’s embedding model for
cosineDistance and hybridSearch. If a queryRewriter is configured, it runs first.string[]
Keywords for full-text matching (
tsvector and hybridSearch).SearchFilters
required
Filters on item columns.
SearchFilters is an array of objects mapping field names to operators: eq, ne, in, contains, and, or — plus lte/gte for numbers and dates. Pass [] for none.SearchFilters
required
Filters on chunk columns, same operator shape. Pass
[] for none.User
When set, access control is applied — only chunks from items the user may read (by
rights_mode, ownership, role, or team) are returned.string
Role ID used alongside
user for access control.VectorMethod
required
"cosineDistance" (vector similarity), "tsvector" (full-text), or "hybridSearch" (both combined).any
required
Sort configuration; pass
undefined for relevance ordering.STATISTICS_LABELS
required
Where the search originated, recorded in usage statistics — for example
"api" or "agent".number
required
Maximum results. When falsy, falls back to
configuration.maxRetrievalResults (default 10).number
required
Page number for pagination.
object
Per-call override of the configured score cutoffs.
object
Per-call override of the configured chunk expansion window.
EntityFilter
Entity-layer filter:
{ entityIds?: string[]; entities?: { type: string; name: string }[]; mode?: "any" | "all" }. With "any" (default) a chunk must mention at least one of the entities; with "all", all of them. Requires the entity layer.number[]
Precomputed query embedding — skips re-embedding the query. Must come from this context’s embedding model.
VectorSearchChunkResult[]
Matched chunks. Each carries
chunk_content, chunk_index, chunk_id, chunk_source, chunk_metadata, timestamps, item_id, item_external_id, item_name, item timestamps, the method-specific scores (chunk_cosine_distance, chunk_fts_rank, chunk_hybrid_score), and — with the entity layer on — chunk_entities.object
{ name, id, embedder } of the searched context.EntityInsights
Present when the entity layer is on: entities recognized in the query, how often they matched, and their top co-occurring entities.
Item management
createItem()
Inserts (or upserts) an item, then runs the processor and embedding generation as configured.Item
required
Item data matching the context’s schema.
json field values that are objects or arrays are stringified automatically; tags arrays are joined to a comma-separated string.ExuluConfig
required
The app’s
ExuluConfig — needed for storage access in processors and chunkers.number
User ID for tracking and access control.
string
Role ID for tracking and access control.
boolean
default:"false"
When
true, requires external_id or id on the item and merges on conflict — external_id takes precedence. Throws when neither is present.boolean
Per-call override of
configuration.calculateVectors: true forces embedding generation, false suppresses it.Item
An object containing only the generated
id — re-fetch with getItem() if you need the full row.string
Comma-separated job IDs when the processor and/or embedder ran in queue mode.
Embeddings are generated when the context has an embedder,
generateEmbeddingsOverwrite is not false, and either the override is true or calculateVectors is onInsert / always. The processor runs when its trigger is onInsert, onUpdate, or always.updateItem()
Updates an existing item byid, then runs the processor and embedding generation as configured.
Item
required
Must include
id plus the fields to update. Throws when no row matches.ExuluConfig
required
The app’s
ExuluConfig.number
User ID for tracking.
string
Role ID for tracking.
boolean
true forces embedding generation, false suppresses it; otherwise calculateVectors of onUpdate / always applies.boolean
true forces the processor to run, false suppresses it; otherwise any non-manual trigger applies.Item
The item as it was before the update — the method returns the previously fetched record, not the merged result.
string
Comma-separated job IDs when the processor and/or embedder ran in queue mode.
deleteItem()
Deletes an item and its chunks. Accepts eitherid or external_id.
Item
required
Object with
id or external_id. When only external_id is given, the row is resolved first; throws when not found.string
ID of the deleted item.
getItem()
Fetches a single item byid or external_id, with its chunk count.
Item
required
Object with
id or external_id.Promise<Item>
The item with all columns plus a
chunksCount property.getItems()
Fetches items with optional filters, field selection, and access control.any[]
Filter array in the same operator shape as
search() filters, for example [{ category: { eq: "guide" } }].string[]
Columns to return. Defaults to all.
User
When set, access control is applied and only rows the user may read are returned. When omitted, no access control is applied.
string
Role ID folded into the access-control check alongside
user.deleteAll()
Deletes every item, every chunk, and — when the entity layer is on — every entity in the context.Embeddings
embeddings.generate.one()
Generates embeddings for one item: loads the full record, chunks it, embeds the chunks through LiteLLM, and replaces the item’s rows in the chunks table. When the embedder has aqueue, the work is scheduled as a job instead.
Item
required
Must contain
id. The full record is re-fetched from the database, so partial items are safe.STATISTICS_LABELS
required
Statistics label, for example
"api" or "processor".ExuluConfig
required
The app’s
ExuluConfig.string
The item ID.
string
Job ID when the embedder runs in queue mode (
chunks is 0 in that case).number
Number of chunks written when run inline.
embeddings.generate.all()
Generates (or queues) embeddings for all items in the context, onegenerate.one() call per item.
ExuluConfig
required
The app’s
ExuluConfig.number
User ID for tracking.
string
Role ID for tracking.
number
Cap on the number of items to process.
string[]
Job IDs (queue mode).
number
Number of items processed.
createAndUpsertEmbeddings()
Low-level worker used byembeddings.generate.one(): chunks, embeds, deletes the item’s old chunks, inserts the new ones, updates chunks_count and embeddings_updated_at, and re-runs entity extraction when the entity layer is on.
Processing
processField()
Runs the configured processor on an item — either inline or, when the processor has aqueue, as a background job. On inline success the result is written back to the items table with last_processed_at set, and embeddings are triggered when processor.config.generateEmbeddings is true.
STATISTICS_LABELS
required
Statistics label for the run.
Item
required
The item to process.
ExuluConfig
required
The app’s
ExuluConfig — provides storage access to the processor’s utils.storage.Item | undefined
The processed item, or
undefined when the job was queued or the processor’s filter skipped the item.string
Job ID in queue mode, or the follow-up embeddings job ID when
generateEmbeddings queued one.Sources
executeSource()
Runs a source’sexecute function with the given inputs and returns the fetched items. It does not write them — the worker’s scheduled source jobs handle persistence, upserting returned items that carry an external_id (or id) and inserting the rest.
ExuluContextSource
required
One of the context’s sources.
any
required
Input values, spread into the source’s
execute arguments alongside exuluConfig.Promise<Item[]>
The items the source produced.
Entity layer
Available undercontext.entityLayer when the entity layer is enabled. See Entities for the admin UI these methods power.
entityLayer.countStale()
Counts items whose entities were extracted with an out-of-date entity-type set — used for the admin “run backfill?” prompt.0 when the entity layer is disabled. When the signature column doesn’t exist yet, every item counts as stale.
entityLayer.backfill()
Re-extracts entities across existing items, inline and in batches.boolean
default:"true"
Limit the run to items whose entity-type signature is out of date.
number
default:"5000"
Cap per run; items beyond it are reported in
skipped and left for the next run.This re-runs entity extraction only — it does not re-embed items.
entityLayer.extractItem()
Extracts and ingests entities for a single item. Powers the item detail page’s extraction test action.entityLayer.detachItem()
Removes all entity links from one item and prunes entities that end up orphaned.entityLayer.purgeType()
Deletes all entities of a given type; their chunk mentions cascade away.Table management
These are called byExuluDatabase.init() / platform database initialization — you rarely invoke them yourself.
createItemsTable()
Creates<id>_items with the built-in columns, your custom fields, the generated fts tsvector column (per configured language), and a GIN index on it.
createChunksTable()
Creates<id>_chunks with content, JSONB metadata, chunk_index, a pgvector embedding column sized from the embedding model’s declared dimensionality, a generated fts column, a GIN index, and an HNSW cosine index.
tableExists()
<id>_items exists.
chunksTableExists()
<id>_chunks exists.
Properties
All constructor options are exposed as public properties:Complete workflow
See also
Read API
RBAC-safe direct reads by item ID or external ID — for targeted lookups that bypass vector search.