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

@formant/realtime-tools

v0.0.0

Published

Client for cortex Realtime Tool Sources — register JSON-RPC tools over WebSocket and upload files.

Readme

@formant/realtime-tools

Client for Formant cortex Realtime Tool Sources. Register JSON-RPC tools over a WebSocket, handle tools/call requests, and upload files to your source's HTTP endpoint — without writing any plumbing.

Install

npm install @formant/realtime-tools

Requires Node.js 18+ (uses the built-in fetch).

Quick start

Create a source at /admin/remote-realtime-tools in your cortex deployment — it gives you a wsUrl and a sourceId. Then:

import { RealtimeToolSourceClient } from '@formant/realtime-tools';

const client = new RealtimeToolSourceClient({
  wsUrl: process.env.WS_URL,      // ws://host/sources/ws?token=...
  sourceId: process.env.SOURCE_ID,
});

client.tool({
  name: 'echo',
  description: 'Echo back its input.',
  inputSchema: {
    type: 'object',
    properties: { msg: { type: 'string' } },
    required: ['msg'],
  },
  handler: async ({ msg }) => ({ msg }),
});

client.tool({
  name: 'make_readme',
  description: 'Upload a text file and return its public URL.',
  inputSchema: {
    type: 'object',
    properties: { body: { type: 'string' } },
    required: ['body'],
  },
  handler: async ({ body }, ctx) => {
    const { url } = await ctx.uploadFile(Buffer.from(body, 'utf8'), 'text/plain');
    return { url };
  },
});

client.start();

API

new RealtimeToolSourceClient(options)

| Option | Type | Description | | --- | --- | --- | | wsUrl | string | The ws(s)://…?token=… URL from the admin console. Required. | | sourceId | string | The source id from the admin console. Required. | | httpOrigin | string | Override the http(s) origin derived from wsUrl. | | log | (...a) => void | Logger for info messages. Defaults to console.log. | | error | (...a) => void | Logger for errors. Defaults to console.error. | | installSignalHandlers | boolean | Install a SIGINT handler to close cleanly. Default true. |

client.tool({ name, description, inputSchema, handler })

Register a tool. Must be called before start(). Returns the client for chaining.

handler(args, ctx) receives:

  • args — the JSON arguments from tools/call.
  • ctx{ sourceId, httpOrigin, uploadFile }.

Whatever the handler returns becomes the JSON-RPC result. Thrown errors become a JSON-RPC error with code -32000.

client.uploadFile(bytes, mimeType)

POSTs bytes to /realtime/sources/:sourceId/files and returns { url, mimeType, sizeBytes, fileId }. url is absolute (origin-prefixed).

client.start()

Opens the WebSocket, sends the register notification, and begins dispatching tools/call requests.

client.stop(reason?)

Closes the WebSocket with code 1000.

License

MIT