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

@paralyn/sdk

v0.1.5

Published

PARALYN TypeScript SDK — widget, context injector, session, stream renderer, defineConfig types

Downloads

939

Readme

@paralyn/sdk

The fastest way to add a production AI assistant to your product.

Embed PARALYN's role-aware, streaming generative AI into any React application with a single component. No backend AI work required — your users get a smart, context-aware assistant that knows their role, their data, and what they're allowed to do.

npm license


Overview

Ship a production-grade AI assistant to your users in under an hour — without building WebSocket infrastructure, auth flows, or permission systems.

@paralyn/sdk connects your React app to the PARALYN Platform: one component handles streaming responses, role-based permissions, confirmation dialogs, and generative UI surfaces out of the box. Your team writes product logic; PARALYN handles the AI layer.

Key capabilities

| Feature | Description | |---------|-------------| | ParalynWidget | Floating React chat widget with streaming responses | | defineConfig / compileManifest | Declarative workspace configuration | | getGatewayWebSocketUrl | Derive WebSocket URL from your API base | | Web Component | <paralyn-widget> for non-React apps |


Installation

npm install @paralyn/sdk

Peer dependencies: react >=18, react-dom >=18

Get your credentials in 30 seconds

Run this once in your project root — it registers a workspace and writes your credentials to .env automatically:

npx @paralyn/cli init

You'll be prompted for a workspace slug, display name, and email. Your PARALYN_HANDOFF_SECRET and other env vars are written to .env immediately. No dashboard, no manual copy-paste.


Quick start (Next.js)

1. Mint a session token server-side

// app/api/paralyn-session/route.ts
import { NextResponse } from "next/server";

export async function GET() {
  const res = await fetch(`${process.env.PARALYN_API_URL}/api/auth/session`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.PARALYN_TENANT_ADMIN_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      sub: "user-123",          // your user's stable ID
      workspace: "acme-corp",
      tenant_id: "acme-corp",
      role: "user",
    }),
  });
  const { sessionToken } = await res.json();
  return NextResponse.json({ sessionToken });
}

2. Embed the widget

"use client";

import { ParalynWidget, getGatewayWebSocketUrl } from "@paralyn/sdk";

const API_BASE = process.env.NEXT_PUBLIC_PARALYN_API_URL!;

export function AIChatButton({ sessionToken, userId }: {
  sessionToken: string;
  userId: string;
}) {
  return (
    <ParalynWidget
      apiKey={sessionToken}
      userId={userId}
      userRole="user"
      workspace="acme-corp"
      tenantId="acme-corp"
      context={{ currentPage: "/dashboard" }}
      gatewayWsUrl={getGatewayWebSocketUrl(API_BASE)}
    />
  );
}

Widget props

| Prop | Type | Required | Description | |------|------|----------|-------------| | apiKey | string | ✅ | Short-lived PARALYN access JWT (never a raw API key) | | userId | string | ✅ | Your user's stable ID | | userRole | string | ✅ | "user", "admin", or "developer" | | workspace | string | ✅ | Workspace slug | | tenantId | string | | Defaults to workspace | | context | object | | Extra context merged into every message (page, cart state, etc.) | | gatewayWsUrl | string | | WebSocket endpoint, defaults to derived URL | | createWebSocket | function | | Override socket constructor (useful for testing) | | className | string | | Additional CSS classes |


Workspace config

import { defineConfig, compileManifest } from "@paralyn/sdk";

const config = defineConfig({
  workspace: "acme-corp",
  roles: ["user", "admin"],
  actions: [
    {
      name: "refund_order",
      roles: ["admin"],
      endpoint: "/paralyn/actions/refund",
      requiresConfirmation: true,
      confirmationMessage: "This will issue a full refund. Continue?",
    },
    {
      name: "track_order",
      roles: ["user", "admin"],
    },
  ],
});

// Compile to manifest JSON for the API gateway
const manifest = compileManifest(config);

Web Component (vanilla JS / non-React)

import { registerParalynWebComponent } from "@paralyn/sdk";
registerParalynWebComponent();
<paralyn-widget
  api-key="eyJ..."
  user-id="user-123"
  user-role="user"
  workspace="acme-corp"
  tenant-id="acme-corp"
  gateway-ws-url="wss://paralyn-api.onrender.com/ws"
  context-json='{"currentPage":"/home"}'
></paralyn-widget>

Wire protocol

The widget communicates over NDJSON WebSocket.

Server → Client

{ "type": "token",          "value": "Hello" }
{ "type": "error",          "code": "permission_denied" }
{ "type": "pending_action", "id": "a1", "requiresConfirmation": true, "message": "Refund $49?" }
{ "type": "ui_surface",     "id": "s1", "layout": "table", "title": "Orders", "data": [...] }

Client → Server

{ "type": "hello",          "apiKey": "...", "userId": "...", "userRole": "...", "context": {} }
{ "type": "user_message",   "text": "...", "context": { "conversationHistory": [] } }
{ "type": "action_confirm", "id": "a1" }
{ "type": "action_cancel",  "id": "a1" }
{ "type": "ping" }

The widget reconnects automatically with exponential backoff and sends a heartbeat ping every 30 seconds.


Security

  • Never pass PARALYN_TENANT_ADMIN_TOKEN or workspace API keys to the browser.
  • Always mint session tokens server-side and pass them as apiKey.
  • Tokens are short-lived (15 minutes by default). The widget will display an error if the session expires.

Related packages

| Package | Description | |---------|-------------| | @paralyn/identity | Handoff tokens and session JWT utilities |


License

AfriIntelligence — © PARALYN. All rights reserved.