npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nestjs-agentic/rag

v1.0.0

Published

Production-grade, modular RAG engine for nestjs-agentic with advanced built-in strategies (Query Expansion, Hierarchical RAG, Late Chunking, Parent-Child Hydration, Contextual Compression, and Knowledge Graph RAG).

Downloads

2,627

Readme

@nestjs-agentic/rag

Experimental, opt-in retrieval primitives for the NestJS-native runtime for governed AI agents. The package provides a modular KnowledgeBase, an in-memory HybridVectorStore, retrieval strategies, and knowledge-graph abstractions for evaluation and application-directed integration.

It is not automatically attached to AgentRunner. Applications own ingestion, retrieval, authorization, persistence, embedding providers, and prompt assembly.

Status

Experimental: APIs are published for evaluation and feedback but do not yet carry production guarantees for durability, isolation, retries, or observability.

Installation

npm install @nestjs-agentic/rag @nestjs-agentic/memory nestjs-agentic

Included Primitives

  • KnowledgeBase for splitting, indexing, and querying documents.
  • HybridVectorStore for in-memory sparse keyword and optional dense-vector scoring.
  • UShapedContextStrategy for mitigating "Lost in the Middle" retrieval degradation (Liu et al., Stanford & UC Berkeley, TACL 2024) by positioning top-ranked documents at Primacy and Recency edges.
  • RAGPipeline for pre- and post-retrieval strategies.
  • Query expansion, parent-child hydration, reranking, late chunking, contextual compression, and graph strategies.
  • VectorStoreAdapter and VectorStoreFactory hooks for application-provided storage integrations.
  • SemanticStoreProvider compatibility for explicit use with @nestjs-agentic/memory.

The package does not include a built-in Prisma or production pgvector persistence layer. Custom factory adapters delegate storage behavior to application callbacks.

Quick Start

import {
  ContextualCompressionStrategy,
  HybridVectorStore,
  KnowledgeBase,
  QueryExpansionStrategy,
  RAGPipeline,
} from '@nestjs-agentic/rag';

const store = new HybridVectorStore({ embeddingProvider });
const knowledgeBase = new KnowledgeBase({ vectorStore: store });

await knowledgeBase.ingestDocument({
  title: 'Financial Transfer Policy',
  rawContent: 'Transfers above $10,000 require finance officer approval.',
  metadata: { tenantId: 'acme' },
});

const pipeline = new RAGPipeline({
  knowledgeBase,
  strategies: [
    new QueryExpansionStrategy({
      synonymsMap: { wire: ['transfer', 'payment'] },
    }),
    new ContextualCompressionStrategy({ maxCharacters: 1500 }),
  ],
});

const context = await pipeline.executePipeline(
  'wire transfer limits',
  5,
  { tenantId: 'acme' },
);

ContextualCompressionStrategy performs local extractive filtering; it does not imply a latency guarantee.

Metadata Filters and Isolation

const chunks = await knowledgeBase.queryChunks(
  'wire transfer',
  5,
  { tenantId: 'acme' },
);

Metadata filtering scopes retrieval only when the selected store adapter honors those filters. Applications and databases must still enforce authorization and hard tenant isolation.

Custom Stores

VectorStoreFactory exposes adapter hooks; it does not provide or configure your database:

import { VectorStoreFactory } from '@nestjs-agentic/rag';

const vectorStore = VectorStoreFactory.createCustom({
  addChunksFn: (chunks) => vectorStoreService.upsert(chunks),
  searchFn: async (query, limit, filter) => {
    const vector = await embeddingProvider.embedQuery(query);
    return vectorStoreService.search(vector, limit, filter);
  },
});

Optional Memory Integration

import { SemanticMemory } from '@nestjs-agentic/memory';
import { HybridVectorStore } from '@nestjs-agentic/rag';

const vectorStore = new HybridVectorStore({ embeddingProvider });
const semanticMemory = new SemanticMemory({ provider: vectorStore });

await semanticMemory.save({
  id: 'fact_1',
  sessionId: 'sess_101',
  type: 'semantic',
  content: 'Acme requires approval for high-value transfers.',
});

const facts = await semanticMemory.recall('transfer approval', {
  sessionId: 'sess_101',
});

This integration is application-managed and is not automatically connected to AgentRunner.

License

MIT © irzix