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-corpus

v0.4.12

Published

Composable knowledge adapter: implements @agentproto/knowledge-engine's IKnowledgeProvider over an AIP-10 @agentproto/corpus workspace, wrapping any backing IKnowledgeProvider and hydrating every hit with canonical AIP-10 provenance + access policy. Publi

Readme

@agentproto/adapter-knowledge-corpus

The corpus composition backing for the @agentproto/knowledge-engine IKnowledgeProvider contract.

Wraps any backing IKnowledgeProvider (files, qdrant, gbrain, …) over an AIP-10 @agentproto/corpus workspace and:

  • reads canonical AIP-10 entries + sources directly from the workspace via an injected FsPort,
  • delegates the vector/graph query to the backing engine,
  • hydrates every hit with canonical provenance — entryPath, sourceIds, sourceHashes, kind, title, status, qualityScore, riskScore, domain, channel, and a live temporal decay score,
  • enforces the corpus access policy (silently filters hits/sources the caller can't see; fails closed on unverifiable provenance),
  • rejects public ingest() / deleteSource() — corpus writes go through the privileged CorpusInternalWriter at the end of the AIP-18 candidate lifecycle, never agent-side.

The composition sibling of @agentproto/adapter-knowledge-files.

What's in the box

| Export | Role | | --- | --- | | CorpusAdapterCore | The IKnowledgeProvider implementation. Consumes an injected FsPort + a backing engine; knows nothing about node:fs or process.env. | | CorpusInternalWriter | The privileged write path (NOT an IKnowledgeProvider) — pushChunks / removeEntry against the backing engine with corpus-namespaced metadata. | | buildCorpusIndex, hydrateHit, computeTemporalScore | The provenance-hydration + temporal-decay core. Confined to this package. | | readCorpusBlock / readCorpusFrontmatter / readCorpusTemporal | Typed metadata.corpus.* accessors. | | isCorpusBackingUnwrap | Structural guard for reaching the wrapped backing engine without an instanceof/engine-id branch. | | LocalFs | A node:fs-backed FsPort (from @agentproto/corpus) so the adapter runs standalone. Paths are workspace-relative and can't escape the root. | | createEmptyBacking() | A no-op in-process backing (zero query hits) for standalone health probes + the workspace-direct read paths. | | createStandaloneCorpusAdapter() | Wires LocalFs + the typed env + a (default empty) backing into a ready-to-use adapter. | | provider-kit family (KNOWLEDGE_CORPUS_CATALOG, makeKnowledgeCorpusResolver, resolveKnowledgeBackend) | Registers the corpus backend under the @agentproto/adapter-knowledge-* discovery convention. |

Usage

Wrapping a real backing engine (the common case):

import { CorpusAdapterCore } from "@agentproto/adapter-knowledge-corpus"

// `backing` is any IKnowledgeProvider — e.g. a FilesKnowledgeAdapter or a
// qdrant adapter. `fs` is a workspace-rooted FsPort.
const kb = new CorpusAdapterCore({ fs, workspacePath: "corpora/marketing", backing })
const { hits } = await kb.query({ query: "contrarian hook", topK: 5 })
// every hit.metadata carries entryPath, sourceIds, status, temporal, …

Standalone, driven by env (empty backing unless one is supplied):

import { createStandaloneCorpusAdapter } from "@agentproto/adapter-knowledge-corpus"

const kb = createStandaloneCorpusAdapter({ backing })

Through the provider-kit resolver (discovery / catalogs):

import { makeKnowledgeCorpusResolver } from "@agentproto/adapter-knowledge-corpus"

const handle = await makeKnowledgeCorpusResolver()("corpus")
const provider = handle?.provider({ backing })

Environment

Read once through the typed loadCorpusKnowledgeEnv() — the only place these names live:

| Var | Default | Meaning | | --- | --- | --- | | KNOWLEDGE_CORPUS_ROOT | process.cwd() | Absolute host path the LocalFs is rooted at. | | KNOWLEDGE_CORPUS_PATH | "" (root is the workspace) | Workspace-relative folder holding KNOWLEDGE.md + entries/ + sources/. |

Writes go through the lifecycle, not ingest()

CorpusAdapterCore.ingest() and deleteSource() always throw — this is the architectural invariant that keeps agent-side code from bypassing the AIP-18 candidate review pipeline. Chunks land in the backing engine via CorpusInternalWriter, which the host constructs at boot and hands only to the indexer.

Supersession and provenance

supersede(id, by?) flips an AIP-10 entry to deprecated, records a supersededBy link when by is given, and appends a deprecated attestation (a compare-and-swap write). When a caller is set it needs the curate capability. Passing a source id throws KnowledgeNotSupportedError (AIP-10 sources are immutable — supersede the entry that cites them).

explain(id) returns the entry's sources and attestation chain, honoring the same visibility rules as reads, or null when the id is unknown or not visible to the caller.

Capabilities

Derived from the wrapped backing engine, with citations forced to true (the adapter always emits entryPath + sourceIds provenance).

Relationship to studio

Lifted from the studio packages/integration/knowledge corpus provider. The adapter/hydrate/internal-writer/frontmatter/unwrap logic already carried no @acme/@demo/@agstudio edge — it re-homes verbatim (only the IKnowledgeProvider + data-type imports repoint to @agentproto/knowledge-engine). The guild-side KnowledgeEngineDescriptor (recursive registry resolution + Settings-UI fields) is not lifted; it stays studio-side, and this package registers as a provider-kit family instead.

Apache-2.0.