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

@pitolabs/agent-docs

v0.1.4

Published

S3 document archive with LLM extraction, hybrid libSQL search (FTS5 + vectors) and Mastra agent tools

Readme

👋 Welcome to agent-docs

Give your AI agent a filing cabinet with a memory. People send it PDFs, photos and office documents in a chat; the agent files them in a private S3 bucket (after the person says yes 👍), a model reads each one once, and from then on the agent can answer "when does the accountant's contract end?" or "find the October energy bill" — by keyword, by meaning, by date.

Built for Mastra agents, with a framework-neutral core you can use anywhere.

✨ What you get

  • 🗂️ An S3 archive that never overwrites: documents/YYYY/MM/<kebab-name>.pdf, a one-line description on each file, 7-day download links, an IAM policy of list, get, put and nothing else.
  • 🧠 One extraction per document: full text as Markdown plus type, title, parties, date, deadlines and a summary — validated with a schema, never invented.
  • 🔎 Hybrid search in a single libSQL file: FTS5 keywords (accents folded) + chunk vectors, fused by reciprocal rank, filtered by type, year or "a deadline before…".
  • ✅ A "yes" before anything is written: propose_file shows what will happen; only the same person's next message, if it is just a yes/ok/👍, lets save run. Or skip it with immediate: true.
  • 🧩 Ready-made Mastra tools: received_files, propose_file, save, archive_file, list_documents, search_documents, read_document, document_link.
  • 🔌 Pick your embedder: any Mastra model id (openai/text-embedding-3-small), Amazon Bedrock, OpenRouter, or any OpenAI-compatible /embeddings (Ollama, vLLM, Azure…).
  • 🔒 Privacy by construction: errors never carry document text; the index is pinned to its bucket and model.

🪶 Light, cheap, yours

  • 🪶 Lightweight: three runtime dependencies (@libsql/client, aws4fetch, zod), 31 files, 117 kB unpacked, no native build, no vector database to run. The index is one SQLite file next to your agent.
  • 💸 Low cost: one model call and one embedding pass per document, ever; searches are a keyword query and one query embedding. Storage is an S3 bucket you already have.
  • 🧘 Simple to run: in-process, one file at a time; a crash or a restart only delays reading, the sweep catches up. No queue, no worker, no cron to install.
  • 🔐 Yours: your bucket, your database file, your choice of where text goes (Bedrock keeps it in-region; a local OpenAI-compatible server keeps it on your machine). Delete the file and the index rebuilds itself from S3.

🚀 Quick start

bun add @pitolabs/agent-docs      # or: npm install @pitolabs/agent-docs
import { Agent } from "@mastra/core/agent";
import {
	ApprovalGate,
	archiveInstructions,
	archiveTools,
	DocsArchive,
	docsConfig,
	extractorAgent,
	extractWith,
	mastraEmbedder,
	openAgentIndex,
} from "@pitolabs/agent-docs/mastra";

const cfg = docsConfig("CLERK"); // CLERK_DOCS_BUCKET, _REGION, _AWS_ACCESS_KEY_ID, _AWS_SECRET_ACCESS_KEY
if ("off" in cfg) throw new Error(cfg.off);
const docs = new DocsArchive(cfg);
const embedder = mastraEmbedder("openai/text-embedding-3-small", { dims: 1536 }); // reads OPENAI_API_KEY
const extractor = extractorAgent({ model: "openai/gpt-4o-mini" });
const opened = await openAgentIndex({ url: "file:./docs-clerk.db", bucket: cfg.bucket, docs, embedder, extract: extractWith(extractor, "openai/gpt-4o-mini") });
if ("off" in opened) throw new Error(opened.off);
const gate = new ApprovalGate();
const archive = { gate, docs, ...opened, embedder, where: "WhatsApp da empresa", archiveName: "no arquivo da empresa" };

export const clerk = new Agent({
	id: "clerk",
	name: "Clerk",
	model: "openai/gpt-4o-mini",
	// archiveInstructions: how to search, propose, wait for the "sim" and save, for exactly these tools.
	instructions: ["You file the company's documents and find them again.", archiveInstructions(archive)].join("\n\n"),
	tools: archiveTools(archive),
});
opened.indexer.start(); // reads what the bucket has and the index does not, now and every 6 h

Then, in whatever delivers messages to the agent, three lines per turn: gate.onMessage(…) (a yes approves, anything else drops), gate.setFiles(…) (the turn's attachments) and grantPass(requestContext, { conversation, sender }) (who is writing). The guide walks through it.

📚 Learn more

| | | |---|---| | 📖 Guide | Wiring the gate and the pass, the tools one by one, extra and keyFilter, the extractor | | 🔎 Reference | Embedders, where the index lives, the search, S3 layout and IAM, what is stored and where text goes | | 🗺️ Design notes | Why a libSQL file and not @mastra/rag, why the approval gate is code and not a prompt, what is planned | | 🧑‍💻 Contributing | Hooks, formatting, tests, the privacy scan |

🌍 Languages

Tool descriptions, proposals and the extractor's prompt are in Brazilian Portuguese in this release (it was born on WhatsApp in Brazil 🇧🇷). The prompt is one string you can replace (extractorAgent({ instructions })); an English set is on the list.

💛 Made by Pito Labs

Extracted from the agents we run for our own businesses, family and health documents. MIT licensed — use it, fork it, tell us what you built.