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

site-operator-react

v0.2.1

Published

React wrapper for site-operator, providing AgentChat component and hooks.

Readme

Site Operator React

The React 19 wrapper for Site Operator. It provides a seamless integration of the Site Operator agent widget into React applications.

Installation

npm install site-operator-react

import { AgentChat, type AppContext, type AppState } from 'site-operator-react';
import type { AgentChat as AgentChatElement } from 'site-operator';
import { useRef } from 'react';

const context: AppContext = {
  v: "1.1",
  site: { 
    name: "My Portal", 
    description: "Main customer management portal",
    deployment: "prod",
    baseUrl: "https://myportal.com", 
    locale: "en-US" 
  },
  user: { id: "u-123", displayName: "Jost" },
  nav: {
    globalClickTargets: [
      {
        id: "lnk.nav.clients",
        name: "ClientsLink",
        kind: "link",
        label: "Clients",
        locator: { testId: "nav-clients" },
        action: { "type": "navigate", "toRouteId": "clients.list", "toPath": "/clients" }
      }
    ],
    routes: [
      {
        id: "clients.list",
        path: "/clients",
        title: "Client Directory",
        description: "List of all active customers in the system",
        clickTargets: [
          {
            id: "btn.createClient",
            name: "CreateClient",
            kind: "button",
            label: "Add Client",
            description: "Opens the registration form for new customers",
            locator: { testId: "clients-create" },
            action: { "type": "navigate", "toRouteId": "clients.create", "toPath": "/clients/new" }
          }
        ]
      }
    ]
  }
};

const state: AppState = {
  v: "1.1",
  location: {
    routeId: "clients.list",
    path: "/clients?status=active",
    params: { "status": "active" },
    title: "Clientes"
  },
  ui: {
    visibleClickTargetIds: ["lnk.nav.clients", "btn.createClient"]
  },
  focus: { "type": "client", "id": "c-77", "label": "ACME S.A." }
};

function App() {
  const chatRef = useRef<AgentChatElement>(null);

  return (
    <div className="App">
      <AgentChat
        ref={chatRef}
        backendUrl="http://localhost:8001/ag_ui"
        appName="My React App"
        context={{ appContext: context, appState: state }}
      />
    </div>
  );
}

useChatPortal Hook

The useChatPortal hook allows you to register the "Copilot" capabilities (AppContext) for your application. This lets the agent understand the app structure and available targets. It can also return the live ChatController from AgentChat when you pass a chatRef.

import { useChatPortal, type AppContext } from 'site-operator-react';
import type { AgentChat as AgentChatElement } from 'site-operator';
import { useRef } from 'react';

const context: AppContext = {
  v: "1.1",
  // ... configuration ...
  site: { name: "Mi Portal" },
  user: { id: "u-123" },
  nav: {
    routes: []
  }
};

function App() {
  const chatRef = useRef<AgentChatElement>(null);
  const controller = useChatPortal(context, { chatRef });

  return (
    <AgentChat ref={chatRef} context={{ appContext: context }} />
  );
}

// How chatRef works:
// - pass it to <AgentChat /> so React forwards it to the web component
// - useChatPortal listens for the "controller-ready" event
// - once ready, it returns the live ChatController instance
// controller?.sendMessage('Hola');