trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
52 lines • 1.81 kB
TypeScript
/**
* Auto-Embedding Middleware
*
* Kernel middleware that automatically embeds entity facts and links
* on graph mutations. Runs after successful ops to index new/changed
* content into the vector store.
*
* @module trellis/embeddings
*/
import type { KernelMiddleware } from '../core/kernel/middleware.js';
import type { Embedder } from './search.js';
import { VectorStore } from './store.js';
export interface AutoEmbedOptions {
/** Path to the vector store SQLite database. */
dbPath: string;
/** Custom embedder function (default: transformers.js embed). */
embedFn?: Embedder;
/** Whether to embed facts individually (default: false — only entity summaries). */
embedIndividualFacts?: boolean;
}
/**
* Creates a kernel middleware that auto-embeds entities on mutation.
*
* On addFacts/addLinks: embeds entity summaries into the vector store.
* On deleteFacts/deleteLinks: removes stale embeddings.
*/
export declare function createAutoEmbedMiddleware(options: AutoEmbedOptions): Promise<KernelMiddleware & {
close: () => void;
}>;
export interface RAGContext {
/** The original query. */
query: string;
/** Retrieved chunks ranked by relevance. */
chunks: Array<{
content: string;
entityId: string;
score: number;
chunkType: string;
}>;
/** Total token estimate (rough: 1 token ≈ 4 chars). */
estimatedTokens: number;
}
/**
* Build a RAG context from a natural language query.
* Searches the vector store and assembles ranked context chunks.
*/
export declare function buildRAGContext(query: string, vectorStore: VectorStore, embedFn?: Embedder, options?: {
maxChunks?: number;
maxTokens?: number;
minScore?: number;
}): Promise<RAGContext>;
//# sourceMappingURL=auto-embed.d.ts.map