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

@nykk/ur-agent-client

v0.2.6

Published

Headless SDK (SSE, zero runtime deps) to build chat clients against a ur agent from any framework

Readme

@nykk/ur-agent-client

SDK headless, sin dependencias de runtime, para construir clientes de chat contra un agente de ur. No renderiza nada: habla por SSE con el backend (POST /embed/:agent/chat, GET /embed/:agent/history) y entrega los eventos en bruto. Opcionalmente, createChatStore() monta encima un pequeño store framework-agnóstico con la lista de mensajes ya acumulada.

Funciona en cualquier framework, o en ninguno. Solo usa fetch, crypto.randomUUID, localStorage y AbortController.

Instalación

npm install @nykk/ur-agent-client

Paquete público en npmjs. No requiere ningún registro privado.

Uso mínimo

import { UrAgentClient } from '@nykk/ur-agent-client';

const client = new UrAgentClient({
  agent: '<identifier-del-agente>',
  apiBase: '<origen-de-tu-backend-ur>',
});

client.onToken((delta) => {
  /* añade `delta` al mensaje del bot que estás construyendo */
});
client.onDone((threadId) => {
  /* el turno ha terminado */
});
client.onError((message) => {
  /* muestra el error */
});

await client.sendMessage('Hola');

El agente tiene que tener habilitado el canal js_sdk en el admin de ur (en el panel se llama Integración a medida con tu propia interfaz). Es el canal de cualquier UI propia hecha sobre esta SDK, también un widget a medida: el canal widget es el de @nykk/ur-agent-widget.

Título y colores

El título y los colores de marca que se configuran en el admin para ese canal se piden con getConfig(). Cada canal tiene los suyos, así que no depende de que el widget esté activado.

const { style, title } = await client.getConfig().catch(() => ({ style: {}, title: undefined }));
// style.color, style.colorText, style.colorBot: '#rrggbb' o ausentes

Todo es opcional: lo que no venga, lo pones tú. Es cosmético, así que si falla (un 404 es el canal apagado) lo normal es seguir con tu paleta.

Contexto para las tools del agente

Tu aplicación puede enviar datos en cada mensaje, agrupados por tool:

const client = new UrAgentClient({
  agent: 'soporte',
  context: { visitor_context: { page: '/precios' } },
});

// Se actualiza sin recrear el cliente (recrearlo perdería la conversación):
client.setContext({ visitor_context: { page: '/contacto' } });

Qué claves acepta un agente lo declaran sus tools; el admin de ur muestra el snippet exacto para cada agente. Las claves que ninguna tool declare se descartan sin fallar, y vuelven listadas en la cabecera X-Ur-Context-Dropped.

No es una credencial. El canal público no lleva autenticación, así que cualquiera puede falsificar estos valores. Sirven para indicar qué mirar, nunca para decidir qué puede ver quien pregunta.

Con store incluido

import { UrAgentClient, createChatStore } from '@nykk/ur-agent-client';

const client = new UrAgentClient({ agent: '<identifier>', apiBase: '<origen>' });
const store = createChatStore(client);

store.subscribe(() => render(store.getState().messages));
if (!client.isNewSubject) {
  await store.loadHistory();
}
await store.send('Hola');

store.subscribe/store.getState encajan directamente en useSyncExternalStore (React) o en un signal de Angular.

Relación con @nykk/ur-agent-widget

El Web Component <ur-agent-chat> de @nykk/ur-agent-widget usa esta misma SDK por debajo. Si el widget no encaja con tu stack, esta es la pieza que habla con el backend y el resto lo decides tú.

Licencia

MIT