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/protocol

v0.1.5

Published

Versioned Agent Provider wire protocol and safe-value codec.

Readme

@agent-provider/protocol

Versioned wire messages, safe-value encoding, guards, and protocol negotiation for Agent Provider browser bridges.

npm install @agent-provider/protocol

What it does

Agent Provider is a browser extension that brokers user-controlled LLM access for trusted web applications: credentials stay in the extension, and access is granted per exact origin. This package defines the wire contract both sides of that bridge share:

  • Bootstrap messages (hello / ready / reject) and version negotiation between a page-side client and the extension.
  • Bridge envelopes — the typed message shapes for sessions, permission requests and results, model generate/stream/cancel calls, tool approvals, tool execution reports, and structured errors (BridgeErrorCode).
  • Wire values — a safe-value codec (encodeWireValue / decodeWireValue) that carries plain JSON plus undefined, bigint, Uint8Array, ArrayBuffer, Date, and Error as tagged values, and rejects functions, symbols, class instances, cyclic objects, and non-finite numbers.
  • Guards and constructorsisBootstrapMessage, isBridgeEnvelope, isBridgeEnvelopeForDirection, isInternalPortMessage, createBootstrapHello, createBootstrapReady, createBridgeEnvelope, and negotiateProtocolVersion, so every incoming message is validated before it is trusted.
  • Canonicalizationcanonicalize and sha256Canonical, used to fingerprint approvals and model-alias authority so a granted operation cannot be silently altered before dispatch.

Quick start

import {
  createBootstrapHello,
  isBootstrapMessage,
  negotiateProtocolVersion,
  createBridgeEnvelope,
  encodeWireValue,
  decodeWireValue,
} from "@agent-provider/protocol";

const hello = createBootstrapHello({ clientId: "client-1", min: 2, max: 2 });
if (!isBootstrapMessage(hello)) throw new Error("invalid hello");

const version = negotiateProtocolVersion(hello, { min: 1, max: 2 });
if (version === undefined) throw new Error("no protocol overlap");

const envelope = createBridgeEnvelope({
  direction: "page-to-extension",
  clientId: hello.clientId,
  type: "session.open",
  requestId: "req-1",
  payload: { sdkVersion: "0.1.0" },
});

const decoded = decodeWireValue(encodeWireValue({ when: new Date(0) }));

Most applications never touch this package directly — it is the shared foundation under the runtime, React bindings, and the extension itself. Integrate at that level unless you are building a new bridge implementation.

Notes

  • ESM-only; no CommonJS build is published.
  • Intended for browser-capable TypeScript or JavaScript environments: the codec uses btoa / atob, and sha256Canonical uses globalThis.crypto.subtle (available in browsers and Node.js 22+).
  • New in 0.1.4sha256Canonical now has a pure-JS SHA-256 fallback (sha256Hex) that activates when crypto.subtle is unavailable (non-secure HTTP origins, sandboxed iframes). Returns the same 64 lowercase hex chars as Web Crypto. This fixes tool execution on LAN HTTP dogfood origins where isSecureContext === false.
  • This package defines message shapes and validation only. It does not open ports, grant permissions, or hold credentials — that is the extension's job.

Links

License

CC0-1.0 OR Unlicense.