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

@facet-llc/sdk-node

v0.1.3

Published

Agent-side discovery SDK for the Facet protocol (Node 20+). One-call entry point: discoverAndConnect("merchant.com") fetches /.well-known/agents.txt, validates the v1.2 manifest, and returns a configured Facet Terminal client.

Downloads

611

Readme

@facet-llc/sdk-node

Agent-side discovery SDK for the Facet protocol. Node 20+.

The one-call entry point an agent needs to connect to any Facet-protected merchant. Fetches /.well-known/agents.txt, validates the v1.1 / v1.2 manifest, optionally verifies the advertised capability set, and returns a configured Facet Terminal client.

For the Deno port see @facet-llc/sdk-deno.

Install

npm install @facet-llc/sdk-node
# pulls @facet-llc/client and @facet-llc/protocol as runtime deps

Quick start

import { discoverAndConnect } from "@facet-llc/sdk-node";

const client = await discoverAndConnect("merchant.example.com", {
  capabilityCheck: ["catalog"],
  kyaToken: async () => issuer.mintToken(),
});

const caps = await client.capabilities();
const results = await client.search({ query: "vanilla", limit: 10 });

The returned client is a FacetClient from @facet-llc/client. Same surface, same headers, same error envelope. The only difference vs constructing one manually is that terminalUrl is read from the manifest instead of hard-coded.

API

fetchAgentsTxt(domain, opts?)

import { fetchAgentsTxt, type AgentsTxt } from "@facet-llc/sdk-node";

const manifest: AgentsTxt = await fetchAgentsTxt("merchant.example.com");
console.log(manifest.terminal); // "https://api.merchant.example.com/v1"
console.log(manifest.capabilities); // ["catalog", "paywalled-content"]

Fetches https://<domain>/.well-known/agents.txt, runs it through the v1.2 parser in @facet-llc/protocol, and returns the typed manifest. The response is cached in-process.

Cache semantics:

  • Honors Cache-Control: max-age=N from the response.
  • Honors Cache-Control: no-cache / no-store (bypass cache).
  • Falls back to opts.ttlMs (default 1h) when no Cache-Control is set.
  • clearAgentsTxtCache(domain?) clears the cache (all entries, or one).

Options:

| Option | Type | Notes | | --------- | -------------- | ----------------------------------------------------------------------- | | ttlMs | number | Fallback TTL when Cache-Control is absent. Default: 3_600_000 (1h). | | signal | AbortSignal | Aborts the in-flight fetch. | | fetch | typeof fetch | Override (defaults to globalThis.fetch). | | noCache | boolean | Bypass cache for this call (still writes to cache afterwards). | | now | () => number | Timestamp source (testing). |

discoverAndConnect(domain, opts?)

import { discoverAndConnect } from "@facet-llc/sdk-node";

const client = await discoverAndConnect("merchant.example.com", {
  capabilityCheck: ["catalog", "paywalled-content"],
  kyaToken: "<kya-token-jwt>",
});

Chains fetchAgentsTxt with a configured Terminal client.

Options:

| Option | Type | Notes | | ----------------- | --------------------------------- | --------------------------------------------------------------------------------------- | | ttlMs | number | Same as fetchAgentsTxt. | | capabilityCheck | readonly string[] | Every entry must appear in manifest.capabilities or CapabilityMismatchError throws. | | signal | AbortSignal | Threaded into the manifest fetch. | | fetch | typeof fetch | Passed to both the manifest fetch and the returned client. | | kyaToken | string \| () => Promise<string> | Passed to the returned client. | | timeoutMs | number | Per-request timeout on the returned client. | | userAgent | string | User-Agent on the returned client. |

Errors

Every failure throws a named, typed error:

| Error | Cause | | ------------------------- | ------------------------------------------------------------------------ | | NoManifestError | HTTP 404 on /.well-known/agents.txt. | | InvalidManifestError | Parser rejected the body (malformed, missing required fields). | | UnsupportedVersionError | Facet-Version is not one of 0.2, 1.0, 1.1, 1.2. | | FetchError | Non-2xx response (other than 404), DNS / TLS / abort. | | CapabilityMismatchError | capabilityCheck includes a capability the manifest does not advertise. |

import {
  CapabilityMismatchError,
  NoManifestError,
  UnsupportedVersionError,
  discoverAndConnect,
} from "@facet-llc/sdk-node";

try {
  const client = await discoverAndConnect("merchant.example.com", {
    capabilityCheck: ["auction"],
  });
} catch (e) {
  if (e instanceof NoManifestError) {
    // Site is not Facet-enabled. Fall back to direct HTTP scraping.
  } else if (e instanceof UnsupportedVersionError) {
    // Manifest predates v0.2. Site needs to upgrade.
  } else if (e instanceof CapabilityMismatchError) {
    console.log("advertised:", e.advertised, "missing:", e.missing);
  }
}

Supported Facet-Version values

v0.2, v1.0, v1.1, and v1.2 documents are all accepted. The parser handles the additive evolution. Anything outside that set throws UnsupportedVersionError.

The constant SUPPORTED_FACET_VERSIONS is exported for callers that want to surface it.

License

Apache-2.0. See LICENSE.