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

@prismshadow/amsp

v0.2.16

Published

AMSP (Agent Message Stream Protocol): the wire types of a PenguinHarness Agent's API and a zero-dependency client for Node 24 and browsers.

Readme

@prismshadow/amsp

The client of a PenguinHarness agent's API, and the types of AMSP (Agent Message Stream Protocol), the event stream that API serves. No runtime dependencies; runs in Node 24 and in current browsers on fetch, ReadableStream, TextDecoder and AbortController.

A Project owner turns an agent's API on in the PenguinHarness Web App (the agent's API tab) and mints a key there. A program then runs the agent, reads the run as it happens, and continues the conversation by its Session id:

import { AgentClient } from "@prismshadow/amsp";

const client = new AgentClient({
  baseUrl: "http://localhost:7364/api/amsp/v1",
  agent: "demo/coder", // <projectId>/<agentId>
  apiKey: process.env.PENGUIN_AGENT_KEY,
});

const run = client.stream({ input: "Summarize README.md" });
for await (const event of run) {
  if (event.type === "text.delta") process.stdout.write(event.text);
}
const first = await run.result();

const second = await client.run({
  sessionId: first.sessionId,
  input: "Now list its headings",
  onApproval: () => "allow", // without a callback, approval requests are denied
});
console.log(second.text, second.usage.total);
  • stream() starts the run and returns it: iterate it once for the events, await session for the Session id, result() for the outcome, and call abort() to have the server abort it. run() returns the result alone.
  • result() resolves for every run that reached run.done, whatever its status. A refusal before the stream rejects with AmspHttpError (status, code, message); a stream that ends or breaks before run.done rejects with AmspStreamError; aborting the signal rejects with its reason.
  • onApproval answers each approval.requested, and the client posts the answer; parseArguments reads a tool call's JSON arguments.
  • agent(), session(id), abort(id) and approve(id, toolCallId, decision) call the API's other routes; readSse is the SSE reader, for a program that reads a run's body itself.
  • Every AMSP event type is exported (AmspEvent, RunDone, ToolCallDone, …). Events of a type the client does not know are passed through.

The reader without the client

A program that sends the request itself — its own fetch, its own credentials or URL — reads the body with readSse and folds the events with RunCollector, which AgentClient uses for result():

import { readSse, RunCollector } from "@prismshadow/amsp";
import type { AmspEvent } from "@prismshadow/amsp";

const collector = new RunCollector();
for await (const data of readSse(response.body!)) {
  if (data === "[DONE]") break;
  collector.add(JSON.parse(data) as AmspEvent);
}
const result = collector.result(); // throws AmspStreamError when the stream ended before run.done

Documentation

  • Agent API: turning an agent's API on, keys, approval modes, routes, errors, the client in Node and browsers
  • AMSP: the protocol, event by event

Development

pnpm --filter @prismshadow/amsp build       # tsup → dist/ (exports point at dist)
pnpm --filter @prismshadow/amsp typecheck
pnpm --filter @prismshadow/amsp test

Part of PenguinHarness · Apache-2.0