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

@agentskit/rag

v0.5.6

Published

Plug-and-play retrieval-augmented generation for AgentsKit.

Readme

@agentskit/rag

Plug-and-play retrieval-augmented generation: chunk documents, embed them, and retrieve the right context at query time.

npm version npm downloads bundle size license stability GitHub stars

Tags: ai · agents · llm · agentskit · rag · retrieval · vector-search · embeddings · ai-agents · semantic-search · knowledge-base

Verified proof

  • Package metadata and tests live under packages/rag/.
  • Package guide: https://www.agentskit.io/docs/reference/packages/rag
  • Stability map: docs/STABILITY.md

How this fits the ecosystem

@agentskit/rag is the retrieval layer: load documents, chunk them, embed them, rerank results, and feed precise context back to agents.

  • AgentsKit: compose it with the other packages in this repo to build agents from small, swappable parts.
  • Registry: look for ready agents and templates that already use this layer at registry.agentskit.io.
  • Playbook: learn the production patterns behind this layer at playbook.agentskit.io.
  • AKOS: run the same concepts with enterprise deployment, governance, and observability at akos.agentskit.io.

Docs: package guide · agent handoff

Why rag

  • Your data, your agent — no fine-tuning required; ingest plain text and query with natural language
  • Composable stack — uses any EmbedFn and any VectorMemory from @agentskit/adapters and @agentskit/memory; swap either layer without touching RAG logic
  • Retriever-readycreateRAG() returns a Retriever you pass to @agentskit/runtime or useChat so context is injected automatically
  • Tune chunking without a PhDchunkSize, chunkOverlap, or a custom split function — three knobs that cover 95% of use cases

Install

npm install @agentskit/rag @agentskit/memory @agentskit/adapters

The file-backed example also needs the optional vectra peer. Add vectra to the install command when using fileVectorMemory; the runtime integration example additionally needs @agentskit/runtime.

Quick example

import { createRAG } from '@agentskit/rag'
import { openaiEmbedder } from '@agentskit/adapters'
import { fileVectorMemory } from '@agentskit/memory'

const rag = createRAG({
  embed: openaiEmbedder({ apiKey: process.env.OPENAI_API_KEY! }),
  store: fileVectorMemory({ path: './vectors' }),
})

await rag.ingest([
  { id: 'doc-1', content: 'AgentsKit is a JavaScript agent toolkit...' },
])

const docs = await rag.search('How does AgentsKit work?', { topK: 5 })
console.log(docs)

With runtime (retriever)

Pass the RAG instance as retriever so the runtime injects retrieved context into the task:

import { createRuntime } from '@agentskit/runtime'
import { openai } from '@agentskit/adapters'

const runtime = createRuntime({
  adapter: openai({ apiKey: process.env.OPENAI_API_KEY!, model: 'gpt-4o' }),
  retriever: rag,
})

const result = await runtime.run('Explain the AgentsKit architecture based on ingested docs')
console.log(result.content)

You can also call rag.retrieve({ query, messages }) to satisfy the core Retriever contract (for example from a custom controller).

Features

  • createRAG({ embed, store }) — single entry point for ingest + retrieve.
  • rag.ingest(docs) — chunk, embed, and store documents.
  • rag.search(query, { topK }) — semantic similarity search.
  • rag.retrieve({ query, messages })Retriever contract v1 for runtime/controller injection.
  • Configurable chunking: chunkSize, chunkOverlap, custom split.
  • Works with any EmbedFn and any VectorMemory.
  • Rerankers: createRerankedRetriever (Voyage, Jina, custom RerankFn, BM25 default), createHybridRetriever (vector + BM25 blend), standalone bm25Score. Recipe.
  • Document loaders: loadUrl, loadGitHubFile, loadGitHubTree, loadNotionPage, loadConfluencePage, loadGoogleDriveFile, loadPdf, loadS3, loadGcs, loadDropbox, and loadOneDrive. Recipe.
  • Loader resilience: HTTP/network and response-body read/parse failures surface as RagError (AK_RAG_LOAD_FAILED). Every remote request and body read has a finite timeout and byte limit by default; both are configurable through timeoutMs and maxResponseBytes. Optional signal aborts are never swallowed as a per-object skip. Tree/list loaders may return partial success when at least one eligible download succeeded; if every attempted eligible download failed, they throw. Missing/invalid S3 object bodies count as failed downloads. Pagination that reports more data without a new cursor/token throws (no silent truncation). loadNotionPage follows Notion has_more / next_cursor with start_cursor until complete (preserving block order; incomplete or repeated cursors throw). loadUrl requires an HTTPS origin in allowedOrigins; it does not follow redirects. Non-positive / non-finite maxFiles yields [].
  • Score contracts: scoreless search/rerank results keep order. When any score is present, every result must have a finite numeric score and is sorted descending — mixed or non-finite scores throw (never fabricate -Infinity). Malformed Voyage/Jina/custom reranker output throws AK_RAG_RERANK_FAILED. Optional signal on voyageReranker / jinaReranker is forwarded to fetch; request/body aborts remain AK_RAG_RERANK_FAILED. bm25Score sanitizes invalid k1/b to documented defaults and always emits finite scores. Hybrid relative weights are normalized to a finite pair that sums to 1 (both zero → 0.5/0.5).
  • Chunk/config safety: invalid chunkSize / chunkOverlap / topK values are sanitized so chunking always terminates and search never sends non-finite limits to the store.
  • Ingestion behavior: rag.ingest embeds chunks serially and sends one vector-store batch per call. For large corpora, batch documents in the caller and persist progress between calls; the package does not silently add concurrency or an unbounded background queue.

S3 in Expo and React Native runtimes

Node consumers may install @aws-sdk/client-s3 and let loadS3 resolve it lazily. Browser, Expo/Metro, and React Native bundles keep that peer out of the universal entry; pass the command constructors explicitly when invoking the loader:

import { GetObjectCommand, ListObjectsV2Command, S3Client } from '@aws-sdk/client-s3'
import { loadS3 } from '@agentskit/rag'

await loadS3({
  client: new S3Client({}),
  bucket: 'knowledge',
  commands: { GetObjectCommand, ListObjectsV2Command },
})

Ecosystem

| Package | Role | |---------|------| | @agentskit/core | Retriever, VectorMemory, types | | @agentskit/memory | Vector backends (fileVectorMemory, etc.) | | @agentskit/adapters | openaiEmbedder and other embedders | | @agentskit/runtime | retriever integration for agents | | @agentskit/react | useChat + chat UI with the same core types |

Contributors

License

MIT — see LICENSE.

Docs

Full documentation · GitHub

Maturity and compatibility

  • Stability: beta — see docs/STABILITY.md
  • Node.js 20+ and TypeScript strict mode
  • Published as @agentskit/rag

Contributing

See CONTRIBUTING.md and the monorepo LICENSE.