tRAGar - v0.1.0
    Preparing search index...

    Interface TRAGarInstance

    interface TRAGarInstance {
        count: number;
        dim: number;
        modelId: string;
        namespace: string;
        storeMode: StoreMode;
        close(): Promise<void>;
        export(format: "json" | "binary"): Promise<Blob>;
        getAllVectors(): Promise<{ id: string; v: Float32Array }[]>;
        getVector(id: string): Promise<Float32Array<ArrayBufferLike>>;
        ingest(doc: IngestDoc): Promise<void>;
        query(text: string, opts?: QueryOptions): Promise<Hit[]>;
        queryStream(text: string, opts?: QueryOptions): AsyncIterable<Hit>;
        stats(): Promise<Stats>;
    }
    Index

    Properties

    count: number

    Number of chunks currently stored. Updated after each ingest() call.

    dim: number

    Embedding dimension.

    modelId: string

    Model identifier passed to the embedder.

    namespace: string

    Corpus namespace this instance was opened with.

    storeMode: StoreMode

    Active backing-store mode ("memory" | "opfs" | "indexeddb").

    Methods

    • Release all resources held by this instance. Resolves on success; rejects with TRAGarError("InstanceClosed") if already closed.

      Returns Promise<void>

    • Export the corpus as a Blob.

      • 'json': { meta, chunks, vectors_b64 } — vectors packed as a contiguous float32 matrix, base64-encoded
      • 'binary': STORE-method zip containing meta.json and chunks.jsonl; each line of chunks.jsonl is { id, text, source, vector: number[] } (float32 values as JSON)

      Parameters

      • format: "json" | "binary"

      Returns Promise<Blob>

    • Return all stored vectors as a snapshot array. Fires a DequantizationRequested warning once per instance lifetime via onWarn.

      Returns Promise<{ id: string; v: Float32Array }[]>

    • Return the stored float32 vector for the given chunk id. Rejects with TRAGarError("NotFound") if the id is unknown. Fires a DequantizationRequested warning once per instance lifetime via onWarn.

      Parameters

      • id: string

      Returns Promise<Float32Array<ArrayBufferLike>>

    • Ingest one document: chunk → embed → store. Resolves when all chunks are stored; rejects with TRAGarError("InstanceClosed") if closed.

      Parameters

      Returns Promise<void>

    • Query the corpus for the top-k most relevant chunks. Returns an empty array when no chunks have been ingested. Rejects with TRAGarError("InstanceClosed") if closed.

      Parameters

      Returns Promise<Hit[]>

    • Stream the top-k hits as an async iterator, yielding in descending score order. Safe to abandon with break or an exception — resources are released when the iterator protocol's return() method is called. Throws TRAGarError("InstanceClosed") on first iteration if closed.

      Parameters

      Returns AsyncIterable<Hit>

    • Return a summary of the current corpus state. Rejects with TRAGarError("InstanceClosed") if closed.

      Returns Promise<Stats>