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

@xclaw-ai/chat-sdk

v1.2.0

Published

xClaw Chat SDK — React & React Native client for xClaw AI Agent Platform

Readme

@xclaw-ai/chat-sdk

React & React Native SDK for xClaw AI Agent Platform — streaming chat, session management, and MCP integration.

Installation

npm install @xclaw-ai/chat-sdk

Quick Start — React

import { XClawProvider, useChat } from '@xclaw-ai/chat-sdk/react';

function App() {
  return (
    <XClawProvider config={{ baseUrl: 'https://api.xclaw.io', token: 'your-jwt' }}>
      <Chat />
    </XClawProvider>
  );
}

function Chat() {
  const { messages, send, isStreaming, cancel } = useChat({
    domainId: 'customer-service',
    webSearch: true,
  });

  return (
    <div>
      {messages.map(m => (
        <div key={m.id} className={m.role}>
          {m.content}
          {m.isStreaming && <span className="cursor" />}
        </div>
      ))}
      <input onKeyDown={e => e.key === 'Enter' && send(e.currentTarget.value)} />
      {isStreaming && <button onClick={cancel}>Stop</button>}
    </div>
  );
}

Quick Start — React Native

import { XClawProvider, useChat, createReactNativeConfig } from '@xclaw-ai/chat-sdk/react-native';

const config = createReactNativeConfig({
  baseUrl: 'https://api.xclaw.io',
  token: 'your-jwt',
});

export default function App() {
  return (
    <XClawProvider config={config}>
      <ChatScreen />
    </XClawProvider>
  );
}

Core Client (No React)

import { XClawClient } from '@xclaw-ai/chat-sdk';

const client = new XClawClient({
  baseUrl: 'https://api.xclaw.io',
  token: 'your-jwt',
});

// Non-streaming
const response = await client.chat('Hello!');
console.log(response.content);

// Streaming
const { done, cancel } = client.chatStream('Tell me a joke', {
  onTextDelta: (delta, full) => process.stdout.write(delta),
  onFinish: (usage) => console.log('\nTokens:', usage.totalTokens),
});
await done;

API Reference

XClawClient

| Method | Description | |--------|-------------| | login({ email, password }) | Authenticate and store token | | setToken(token) | Set JWT token directly | | chat(message, options?) | Send message (non-streaming) | | chatStream(message, callbacks?, options?) | Send message with SSE streaming | | listSessions() | List all chat sessions | | getMessages(sessionId) | Get session messages | | deleteSession(sessionId) | Delete a session | | uploadFile(file, filename) | Upload attachment (10MB max) | | feedback({ messageId, correction, sessionId }) | Submit correction for self-learning |

useChat(options?) Hook

const {
  messages,       // ChatMessage[] — all messages
  isStreaming,    // boolean — currently receiving
  send,           // (message: string) => void
  cancel,         // () => void — abort stream
  clear,          // () => void — clear all messages
  setMessages,    // (messages: ChatMessage[]) => void
  sessionId,      // string
  usage,          // TokenUsage | null
  error,          // Error | null
} = useChat({
  sessionId: 'custom-id',        // optional
  domainId: 'healthcare',        // optional
  webSearch: true,                // optional
  initialMessages: [],            // optional
  onFinish: (msg) => {},          // optional
  onError: (err) => {},           // optional
  onToolCall: (name, id) => {},   // optional
  onMeta: (key, data) => {},      // optional — RAG context, search results
});

useSessions() Hook

const {
  sessions,       // ChatSession[]
  loading,        // boolean
  refresh,        // () => Promise<void>
  deleteSession,  // (id: string) => Promise<void>
  getMessages,    // (id: string) => Promise<ChatMessage[]>
} = useSessions();

Stream Events

| Event Type | Description | |------------|-------------| | text-delta | Incremental text token | | tool-call-start | AI is calling a tool | | tool-call-args | Tool arguments (streamed) | | tool-call-end | Tool call complete | | tool-result | Tool execution result | | meta | Metadata (RAG context, search results, timing) | | finish | Stream complete with usage stats | | error | Error occurred |

Config Options

interface XClawConfig {
  baseUrl: string;          // Required — server URL
  token?: string;           // JWT token
  defaultDomain?: string;   // Default domain specialization
  webSearch?: boolean;      // Enable web search by default
  timeout?: number;         // Request timeout (default: 60000ms)
  fetch?: typeof fetch;     // Custom fetch (for React Native polyfills)
  headers?: Record<string, string>; // Custom headers
}

Available Domains

general · developer · healthcare · finance · legal · education · marketing · hr · customer-service · devops · data-analyst · creative

MCP Server Integration

The SDK includes a built-in MCP (Model Context Protocol) server, allowing AI agents like Claude, Copilot, or any MCP-compatible tool to interact with xClaw.

Setup

Add to your MCP configuration (e.g., .vscode/mcp.json, claude_desktop_config.json):

{
  "servers": {
    "xclaw": {
      "command": "node",
      "args": ["node_modules/@xclaw-ai/chat-sdk/dist/mcp/bin.js"],
      "env": {
        "XCLAW_BASE_URL": "https://api.xclaw.io",
        "XCLAW_TOKEN": "your-jwt-token"
      }
    }
  }
}

Or run standalone:

XCLAW_BASE_URL=https://api.xclaw.io XCLAW_TOKEN=... npx xclaw-chat-mcp

MCP Tools

| Tool | Description | |------|-------------| | xclaw_chat | Send a message and get a response | | xclaw_chat_stream | Send message with streaming (returns complete text) | | xclaw_list_sessions | List all chat sessions | | xclaw_get_messages | Get messages in a session | | xclaw_delete_session | Delete a session | | xclaw_feedback | Submit correction feedback | | xclaw_login | Authenticate with credentials |

Programmatic MCP Server

import { XClawClient } from '@xclaw-ai/chat-sdk';
import { createMcpServer } from '@xclaw-ai/chat-sdk/mcp';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';

const client = new XClawClient({ baseUrl: '...', token: '...' });
const server = createMcpServer(client);
await server.connect(new StdioServerTransport());

TypeScript

Full TypeScript support with exported types:

import type {
  ChatMessage,
  ChatSession,
  StreamEvent,
  TokenUsage,
  XClawConfig,
} from '@xclaw-ai/chat-sdk';

License

MIT © xDev Asia