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

@opsrabbit/chat

v0.5.0

Published

TypeScript SDK and framework-neutral web component for integrating OpsRabbit chat.

Readme

@opsrabbit/chat

TypeScript SDK and optional framework-neutral chat widget for integrating OpsRabbit agents and caller-scoped conversation history into web applications.

The SDK supplies transport, public types, safe error mapping, replayable event parsing, and an optional web-component UI. It does not persist messages, mint browser credentials, or grant access. Your backend authenticates your user and issues a short-lived OpsRabbit Embedded Chat JWT; OpsRabbit remains responsible for tenant isolation, agent and thread permissions, retention, event scrubbing, approvals, and rate limits.

ChatEvent includes clientAction for a trusted host-generated navigation hint. It contains a closed target enum and localization key, never a URL or executable payload; malformed actions map to unknown and must be ignored.

Install

npm install @opsrabbit/chat

Before creating a client, an OpsRabbit administrator and the customer backend owner must configure an Embedded Chat preset and its RSA signing keys. Follow the end-to-end setup guide; the private key stays only in the customer backend, while OpsRabbit stores only the public key.

The initial release is ESM-only and targets modern browsers. Node.js 20 or newer is supported for server-rendering and tests through its standards-compatible Fetch and Web Streams APIs. Repository development and publication use the version pinned in .nvmrc.

React Native

Use the supported headless native export with a saved native Embedded Chat preset. The standard React Native global fetch does not provide a progressively readable SSE response body, so it is insufficient for chat streaming. Supply a streaming-capable Fetch implementation explicitly. Expo applications can use expo/fetch; other runtimes must provide an equivalent standards-compatible implementation with Headers, TextEncoder, and readable response streams. The native app obtains a fresh short-lived token from its own authenticated backend; that backend must verify platform attestation (for example App Attest/Play Integrity) before signing the token. Never bundle the RSA signing key, an OpsRabbit administrative credential, or an attestation-provider secret in the app.

import { OpsRabbitNativeChat } from "@opsrabbit/chat/react-native";
import { fetch as expoFetch } from "expo/fetch";

const chat = new OpsRabbitNativeChat({
  baseUrl: "https://opsrabbit.example.com/api",
  widgetId: "ecw_mobile_support",
  tenantId: "tenant-a",
  agentName: "support-agent",
  getAccessToken: ({ signal }) => getMobileChatToken(signal),
  fetch: expoFetch,
});

The registered native client ID is an identifier, not an app secret. Keep it in the customer backend and place it only in that backend's signed token after app attestation succeeds; the SDK never needs it.

Create a client

For a quick UI, import @opsrabbit/chat/widget and use <opsrabbit-chat>. See the widget guide, including Angular.

import { OpsRabbitChat } from "@opsrabbit/chat";

const chat = new OpsRabbitChat({
  baseUrl: "https://opsrabbit.example.com/api",
  widgetId: "ecw_support",
  tenantId: "tenant-a",
  agentName: "support-agent",
  getAccessToken: async ({ signal }) => {
    const response = await fetch("/api/opsrabbit/chat-token", {
      credentials: "same-origin",
      signal,
    });
    if (!response.ok) throw new Error("Unable to start chat");
    return (await response.json()).token;
  },
});

getAccessToken is called for every operation and stream connection. The SDK does not cache the token. Your application may cache a token until shortly before its expiry, but must never place the JWT signing key or an OpsRabbit administrative credential in browser code.

Create one saved Embedded Chat preset and SDK client per agent when your UI can trigger different agents. OpsRabbit requires the preset, short-lived token's agent_name, requested agentName, and widget service principal's agent grant to agree.

List conversations

const page = await chat.conversations.list({ search: "payment failure", limit: 20 });

for (const conversation of page.conversations) {
  console.log(conversation.id, conversation.title, conversation.updatedAt);
}

if (page.nextCursor) {
  const nextPage = await chat.conversations.list({
    limit: 20,
    cursor: page.nextCursor,
    search: "payment failure",
  });
}

OpsRabbit returns only conversations bound to the token's exact external user, widget, tenant, and configured agent. This API never lists every conversation handled by an agent.

Send and stream

const conversation = chat.conversations.create({
  context: { accountId: "acct-123", orderId: "order-456", locale: "en-US" },
  bindings: { workspaceId: "workspace-123" },
});
const turn = await conversation.send({ message: "Why did checkout fail?" });

for await (const event of chat.turns.events({
  threadId: turn.threadId,
  turnId: turn.turnId,
  afterEventId: Math.max(0, turn.lastEventId - 1),
})) {
  if (event.type === "assistantText") {
    console.log(event.text);
  }
  if (event.type === "turnFailed") {
    console.error(event.message);
  }
}

To continue later, keep the returned threadId and the handle's conversationId in application state:

await chat.turns.send({
  threadId,
  conversationId,
  message: "Can you check the payment provider too?",
});

The SDK does not automatically persist either identifier and does not automatically reconnect or retry mutations. See conversation and streaming semantics.

Abort work

const controller = new AbortController();

for await (const event of chat.turns.events(
  { threadId, afterEventId },
  { signal: controller.signal },
)) {
  // Render event.
}

controller.abort();

Aborting the local stream does not stop the OpsRabbit turn. Call chat.turns.stop({ threadId }) when the user intends to stop server-side execution.

Documentation

Development

nvm use
npm install
npm run quality

Tests run serially and the packed artifact is verified before publication.

License

Apache-2.0