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

@babav/knowledge-core-client

v0.28.0

Published

TypeScript client for the Babav Knowledge Core API (Deno + Node 18+, zero deps). Includes the babav.visual grammar TYPES at the ./visual subpath (types only; all visual rendering is server-side).

Readme

@babav/knowledge-core-client

TypeScript client for the Babav Knowledge Core API. Zero dependencies; runs in Supabase Edge Functions (Deno) and Railway (Node 18+) unchanged (uses the global fetch + ReadableStream). It lives in the babav-knowledge-core repo so every API change is reflected here 1:1 — wire shapes are snake_case to match the API.

The API key is server-side only. Use a TENANT key for data ops; never ship it to a browser. The frontend mediates end-user permissions + visibility.

Install / import

Published as a public npm package (free; no secrets in it — the API key is held server-side by you, never embedded). Use it like any other dependency.

Node / Railway:

npm install @babav/knowledge-core-client
import { KnowledgeCoreClient, KnowledgeCoreError } from "@babav/knowledge-core-client";

Deno / Supabase Edge:

import { KnowledgeCoreClient } from "npm:@babav/knowledge-core-client";

(or, to avoid the registry entirely, import the single self-contained source file <repo>/clients/typescript/mod.ts — zero deps.)

Usage

// You supply baseUrl + your tenant key at construction (from wherever your app keeps
// its config/secrets). The SDK never reads the environment or defaults a key itself.
const kc = new KnowledgeCoreClient({
  baseUrl: "https://knowledgecore.babav.ai",
  apiKey: myTenantKey, // your tenant key, provided by your app
});

// One-shot grounded query
const r = await kc.query(agentId, { corpus_ids: [corpusId], query: "..." });
console.log(r.answer, r.retrieval_contents, r.citations, r.groundedness);

// Conversational (persisted, history-aware)
const convo = await kc.conversations.create({ title: "Contract review", custom_metadata: { account_id } });
const turn = await kc.query(agentId, { corpus_ids: [corpusId], query: "...", conversation_id: convo.id });

// Streaming (SSE)
await kc.queryStream(agentId, { corpus_ids: [corpusId], query: "..." }, {
  onSources: (s) => render(s.retrieval_contents),
  onToken: (t) => append(t),
  onFinal: (f) => done(f),
  onError: (e) => fail(e),
});

// Attachment-backed review
const att = await kc.attachments.upload(convo.id, { filename: "c.pdf", content_type: "application/pdf", data: bytes });
await kc.attachments.waitReady(convo.id, att.id);
const review = await kc.query(agentId, { corpus_ids: [corpusId], conversation_id: convo.id, query: "Review the attached contract." });

// View/download a stored doc (signed URL)
const { content_url, content_type } = await kc.documents.contentUrl(documentId, "inline");

Error handling (structured guards)

try { await kc.query(agentId, body); }
catch (e) {
  if (e instanceof KnowledgeCoreError) {
    if (e.code === "attachments_pending") { /* a document is still parsing */ }
    else if (e.code === "attachment_exceeds_context_window") { /* too large; e.detail has sizes */ }
    else if (e.status === 404) { /* not found / not your tenant */ }
  }
}

Admin client (tenant + key + agent management — ADMIN key)

import { AdminClient } from "@babav/knowledge-core-client";
const admin = new AdminClient({ baseUrl, apiKey: ADMIN_KEY });
const created = await admin.tenants.createApiKey(tenantId, "label"); // created.api_key shown ONCE

Surface

  • query, queryStream, retrieve
  • corpora (CRUD, listFolders, listDocuments, createDocument, ingest)
  • folders (create, rename, delete, listDocuments)
  • documents (get, getMetadata, patchMetadata, update, contentUrl, delete)
  • conversations (CRUD, search, listMessages)
  • attachments (upload, list, get, contentUrl, delete, waitReady)
  • messages (get, createFeedback, listFeedback), feedback (get, delete)
  • parseJobs (list, get), agents (list, get)
  • AdminClient: tenants (CRUD + api-keys), agents (create/update/delete)