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

@agentproto/adapter-knowledge-gbrain-doc

v0.2.1

Published

Knowledge adapter: implements @agentproto/knowledge-engine's IKnowledgeProvider over a gbrain server's document API (put_page / search) via pure fetch over its JSON-RPC /mcp endpoint. gbrain fuses lexical (tsvector) + semantic recall. Registers as a provi

Downloads

240

Readme

@agentproto/adapter-knowledge-gbrain-doc

The document-retrieval backing for the @agentproto/knowledge-engine IKnowledgeProvider contract.

Implements the ingest/query contract over a gbrain server's document API — put_page (ingest) + search (query) — reached over its JSON-RPC /mcp endpoint via pure fetch (no vendor SDK). gbrain fuses lexical (tsvector) + semantic recall, so a query stamps modeUsed: "hybrid".

The document-retrieval sibling of @agentproto/adapter-knowledge-files (BM25), @agentproto/adapter-knowledge-corpus (AIP-10 composition), and @agentproto/adapter-knowledge-qdrant (vector).

Distinct from the code-graph gbrain adapter. @agentproto/adapter-code-brain-gbrain is the code-graph gbrain adapter (ICodeBrainProvider: define / callers / callees). This package is the knowledge-document one (IKnowledgeProvider over gbrain's document store). Same backend, different contract — they never share a package edge; gbrain is reached only at runtime over HTTP.

No studio edge. Lifted from a studio provider whose only cross-package import was a type-only import of JsonRpcRequest / JsonRpcResponse from the studio core/protocol package. That edge is replaced by two inline JSON-RPC interfaces — no studio dependency survives.

What's in the box

| Export | Role | | --- | --- | | GbrainDocKnowledgeAdapter | The IKnowledgeProvider implementation. Config-driven — consumes a plain GbrainDocAdapterConfig; knows nothing about process.env. | | GbrainDocAdapterConfigSchema / parseGbrainDocAdapterConfig | The zod config contract (endpoint, bearer token, timeout). | | extractJsonRpcPayload | Pulls the JSON-RPC envelope out of a gbrain Streamable-HTTP (SSE) response body (exported for testing). | | loadGbrainDocKnowledgeEnv / gbrainDocEnvToConfig | The typed env module — the ONE place GBRAIN_* is read. | | createStandaloneGbrainDocAdapter() | Wires the typed env into a ready-to-use adapter. | | provider-kit family (KNOWLEDGE_GBRAIN_DOC_CATALOG, makeKnowledgeGbrainDocResolver, resolveKnowledgeBackend) | Registers the gbrain-doc backend under the @agentproto/adapter-knowledge-* discovery convention. |

Environment

| Var | Required | Default | Meaning | | --- | --- | --- | --- | | GBRAIN_BEARER_TOKEN | ✅ | — | Machine bearer token accepted by the gbrain /mcp endpoint (OAuth 2.1 client_credentials). Shared with the code-graph gbrain adapter's HTTP backend by design. | | GBRAIN_ENDPOINT | | http://127.0.0.1:3132 | gbrain HTTP base URL (the /mcp endpoint is appended). | | GBRAIN_HTTP_TIMEOUT_MS | | 45000 | Per-request timeout (ms). |

Usage

import {
  GbrainDocKnowledgeAdapter,
  createStandaloneGbrainDocAdapter,
} from "@agentproto/adapter-knowledge-gbrain-doc"

// From the ambient GBRAIN_* env:
const kb = createStandaloneGbrainDocAdapter()

// Or construct directly (e.g. a host resolving a per-KB config + vault secret):
const direct = new GbrainDocKnowledgeAdapter({
  endpoint: "http://127.0.0.1:3132",
  bearerToken: process.env.GBRAIN_BEARER_TOKEN!,
})

await kb.ingest({ kind: "text", uri: "doc://intro", title: "Intro", content: "…" })
const { hits } = await kb.query({ query: "how do I ship", topK: 5 })

Scope

Supported: ingest (put_page a markdown doc), query (search — stamps modeUsed: "hybrid"; minScore is applied client-side since gbrain search has no server-side score floor), listSources / getSource / deleteSource (via list_pages / get_page / delete_page), healthCheck (GET /health).

Testing

Unit tests run against a mocked globalThis.fetch returning canned gbrain Streamable-HTTP (SSE) frames — no live gbrain (CI-safe). They assert the put_page / search request shapes and the result mapping into KnowledgeSource / KnowledgeHit. A guarded live e2e (put_pagesearch against a running gbrain) runs only when the container is reachable, mirroring the code-brain gbrain adapter's guarded e2e.

pnpm --filter @agentproto/adapter-knowledge-gbrain-doc test

License

Apache-2.0