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

@agent-provider/context

v0.1.5

Published

Bounded, revisioned, application-controlled page context extraction.

Readme

@agent-provider/context

Bounded, revisioned, application-controlled page context for Agent Provider.

npm install @agent-provider/context

Applications explicitly select context regions; the package does not crawl an entire page by default. It is ESM-only and requires a DOM-capable environment.

What it does

Agent Provider lets a trusted web application hand structured page context to a user-controlled agent. This package is the extraction half of that contract: the application names the DOM roots that may be observed, and createPageContext turns them into immutable, revisioned frames containing normalized text content, named regions, redaction records, and truncation metadata — never live DOM nodes.

Extraction is conservative by default:

  • Only elements under the declared roots are read.
  • script, style, template, noscript, svg, and canvas content is omitted, as is anything under a hidden or aria-hidden="true" subtree.
  • Password, file, and hidden inputs, and form controls whose name, label, or autocomplete suggests a token, one-time code, or payment detail, are redacted automatically and reported in the frame's redactions.
  • Elements carrying data-agent-provider-redact, or matching an application redact predicate, are excluded entirely.
  • Output is bounded in UTF-8 bytes, nesting depth, region count, and form-value size; every limit breach is recorded in truncation.

Quick start

import { createPageContext } from "@agent-provider/context";

const context = createPageContext({
  roots: () => document.querySelector("main"),
  regions: {
    summary: () => document.querySelector("#summary"),
  },
});

const frame = context.capture(); // revisioned, deeply frozen
console.log(frame.content); // normalized text
console.log(context.getRegion("summary", frame)?.content);
console.log(frame.redactions, frame.truncation);

const delta = context.diff(frame, context.capture());
console.log(delta.contentChanged, delta.changedRegions);

Roots and region resolvers run at every capture, so frames track DOM changes without retaining references. Regions can also be declared in markup with data-agent-provider-region="name"; configured regions take precedence over attributes with the same name. full() is an alias of capture() intended for lazy context-tool integrations. Custom extractors can replace the default rendering of selected elements with application-controlled text.

Notes

  • ESM-only; Node.js 22 or newer. No side effects.
  • Requires a DOM: the browser, or a DOM shim such as jsdom for tests.
  • Default limits (DEFAULT_CONTEXT_LIMITS): 32 KiB total, depth 32, 128 regions, 4 KiB per form value. Override via the limits option with positive integers; truncation is UTF-8-aware and never splits a code point.
  • A capture only consumes a revision when it succeeds. Redaction paths are structural (root[0]/div[2]/input[0]) and omit identifiers and field names.

Links

License

CC0-1.0 OR Unlicense.