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

@wrongstack/client

v1.0.29

Published

Typed client for a running WrongStack WebUI server: open sessions, send prompts, stream the run and answer tool confirmations over the WebSocket protocol, and read live sessions over the HTTP API. No runtime dependencies; works in Node 22+ and the browser

Readme

@wrongstack/client

Typed client for a running WrongStack WebUI server (wstack --webui). It lets you:

  • open sessions and resume them
  • send prompts and stream the run
  • answer tool confirmations
  • read every live session on the machine over the HTTP API

It works in Node 22+ and in the browser. At runtime it loads only one small module from @wrongstack/webui-protocol, and that module imports nothing. The install is heavier: that package, which the types come from, depends on @wrongstack/core.

npm install @wrongstack/client

Conversation

import { WrongStackClient } from '@wrongstack/client';

const client = await WrongStackClient.connect({
  url: 'http://127.0.0.1:3456',
  token: process.env.WEBUI_TOKEN, // the token in the URL `wstack --webui` prints
  onConfirm: (request) => (request.toolName === 'read' ? 'yes' : undefined),
});

const run = client.send('Summarise README.md');
for await (const event of run) {
  if (event.type === 'provider.text_delta') process.stdout.write(event.payload.text);
  if (event.type === 'tool.started') console.log(`\n[${event.payload.name}]`);
}
const result = await run.result; // { status, iterations, text, error? }
client.close();
  • send(text, { sessionId?, images?, freshContext? }) returns a Run. You can use it in three ways:
    • Iterate it for the protocol's own frames (provider.text_delta, tool.started, tool.executed, tool.confirm_needed, …).
    • Await run.result for how it ended.
    • Await run.text() for the answer. It throws when the run did not finish.
  • run.abort() stops the run. The result then has status: 'aborted'.
  • Confirmations: onConfirm answers them as they arrive. Return nothing to answer later with run.confirm(id, decision).
  • Sessions:
    • listSessions(limit) lists sessions.
    • newSession() and resumeSession(id) switch the client's current session, the one prompts go to.
  • Other frames: client.on(type, listener) is typed for the conversation core and accepts any other type the server sends with an unknown payload. client.post(frame) sends any frame.
  • The server drops a prompt identical to the previous one if it comes within 1.5 s of that run ending, as an accidental double send. That run reports done with 0 iterations.

Reconnecting

If the socket drops, the client reconnects on its own and catches up on what the server sent in the meantime:

  • A run in flight keeps its events, gets the frames it missed in order and exactly once, and still settles with its result.
  • client.state is open, reconnecting or closed. onStateChange(listener) reports each change, with the error that caused a drop.
  • While reconnecting, send and post fail with connection/reconnecting, which is retryable.
  • The retry policy is reconnect: { attempts: 10, initialDelayMs: 500, maxDelayMs: 10_000 } (the delay doubles after each failure). Pass reconnect: false to make a drop final.

Some losses the server cannot make up for. The affected run fails with:

| code | when | | --- | --- | | server_restarted | the server restarted while the run was in flight | | result_lost | the run ended while the connection was down, and the server's log no longer holds its result |

Errors

Every failure is a WrongStackError with a stable kind, a narrowing code, a human detail and retryable.

| kind | when | | --- | --- | | auth | the access token was refused (code: '401') | | connection | the server is unreachable, the socket closed for good, or it is reconnecting | | timeout | no answer within timeoutMs (default 15 s) | | server | the server refused the turn (session_not_ready, a busy session, a failed agent.run) | | run / aborted | on result.error when the run did not finish | | invalid / not_found | HTTP 400 / 404 | | protocol | a response that is not what the contract says |

HTTP session API

import { createHttpClient } from '@wrongstack/client';

const api = createHttpClient({ url: 'http://127.0.0.1:3456', token });
const sessions = await api.listLiveSessions(); // every live session on the machine
await api.messageSession(sessions[0].sessionId, { text: 'wrap up', type: 'steer' });

The contract

The frame and body types are the ones in @wrongstack/webui-protocol, and the server and the WebUI build against them too. For clients in other languages, that package publishes files generated from those types:

  • @wrongstack/webui-protocol/schema/ws-core.schema.json: JSON Schema of the conversation core.
  • @wrongstack/webui-protocol/schema/openapi.json: OpenAPI 3.1 of the HTTP session API.