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

@sharpps/agent

v1.2.0

Published

General-purpose agent channel: an outbound WebSocket from a person's machine to a server, with plugins on both sides

Readme

@sharpps/agent

General-purpose agent channel: one outbound connection from a machine to a server, with plugins on both sides.

Commands: sharpps-agent install|list|login|run|serve (see sharpps-agent --help).

How it works

agent (client)  ══ one WebSocket, opened by the agent, Clerk token ══▶  listener (server)
  client side of each plugin                                            server side of each plugin

The agent always dials out; the server never connects to it. On that one connection, work goes both ways:

| | Who starts it | Declared by | Answered with | |---|---|---|---| | Call | server → agent | client plugin capabilities (and the server plugin that uses it) | result / error, events while working | | Request | agent → server | server plugin requests | response / response-error, request-events |

Calls and requests can carry streams: binary or text frames for continuous data (a browser connection). A stream belongs to one call or one request; a stream id is one two-way channel inside it.

Connecting

  1. WebSocket upgrade with Authorization: Bearer <token>; the listener checks it (fails closed) and rechecks it every 5 minutes.
  2. hello (protocol 2, machine, capabilities, plugins, features). The first server plugin with agentFor names the agent (default <user>:<machine id>); every plugin's onAgentHello may refuse it.
  3. welcome (agent id, name, features) or reject. One live connection per agent id: a newer one replaces the older.

Who may connect: people, through the server's authenticator (Clerk device login in sharpps-agent-service), and service clients that have no person (a web app on a serverless platform), through a server plugin's authenticate(token) (1.2.0). Plugins are asked first and return null for tokens they do not issue; the identity a plugin returns must use a userId no person can have. The recheck every 5 minutes applies to service tokens too, so they must outlive it; the client reconnects with a fresh token when one expires.

Features are optional parts of the protocol both sides announce. requests is the only one: an agent sends requests only when the server announced it, and the server takes requests only from agents that announced it. Older agents and servers keep working.

Requests: what an agent may ask the server

A server plugin declares each request it accepts, and who may send it (allow, required: nothing is open by default). allow is checked before the handler; refused agents get forbidden. The handler then gets the agent that sent it, as accepted at hello, and decides the rest with that; never trust identity fields in the input. Capabilities an agent offers are self-declared: use them only to sort agents, and prove anything that matters (who signed in, a key the agent holds).

// server side
const plugin: Plugin = {
  name: "replayr-browser",
  requests: {
    "browser.connect": {
      allow: (agent) => agent.capabilities.includes("runner.status"),   // who may send it; others get "forbidden"
      concurrency: 2,            // open at once per agent (default 4)
      timeoutMs: 0,              // 0 = until the agent cancels or disconnects (default: the call timeout)
      async handler(input, ctx) {
        if (!mayUse(ctx.agent.userId, input)) throw new Error("not allowed");   // goes back as response-error "failed"
        const call = host.startCall(target, "browser.open", {});
        host.relay(ctx, target, call.callId);          // request streams <-> call streams, same ids, both ways
        ctx.signal.addEventListener("abort", () => host.cancel(call.callId));
        return call.result;
      },
    },
  },
};
// client side: start() gets a context for requests
async start(values, ctx) {
  const answer = await ctx.request("area.action", input, { timeoutMs: 10_000 });
  const r = ctx.openRequest("browser.connect", { runId: 42 });   // with streams
  r.inbound((streamId, bytes, kind) => …);
  r.stream(1, bytes);  r.streamEnd(1);  r.cancel();
}

Rules the host enforces: only declared names; only agents allow accepts; one plugin per name; open requests per agent and name are limited; a request aborts when the agent cancels it, disconnects, it times out, or the listener stops. Error codes: unknown-request, not-enabled, busy, timeout, duplicate, failed, forbidden; on the client also not-connected, disconnected, cancelled.

Control port

--control-port serves /plugins/<name>/… to handleHttp on 127.0.0.1, for apps on the same server, with one shared token (SHARPPS_AGENT_CONTROL_TOKEN). It identifies nobody; agents elsewhere use requests instead.

Frames

Control messages are JSON text frames. Binary frames: byte 0 is 0/1 (call stream, text/binary) or 2/3 (request stream, text/binary), bytes 1–4 the stream id (big endian), then the payload.