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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ixo/oracles-client-sdk

v1.0.9

Published

Client SDK for interacting with IXO Oracles, designed for React applications

Downloads

603

Readme

@ixo/oracles-client-sdk

Production-ready React SDK for building AI-powered applications with IXO Oracles

npm version TypeScript

Features

  • Real-time Streaming - AI responses with optimized streaming
  • Chat Management - Complete session and message management
  • Custom UI Components - Extensible component system for rich interactions
  • Voice & Video Calls - Encrypted live agent calls
  • Memory Engine - Optional persistent context across sessions
  • Payment Integration - Built-in oracle payment handling
  • Type Safe - Full TypeScript support with comprehensive types

Installation

npm install @ixo/oracles-client-sdk
# or
pnpm add @ixo/oracles-client-sdk
# or
yarn add @ixo/oracles-client-sdk

Quick Start

import {
  OraclesProvider,
  useChat,
  useOracleSessions,
  renderMessageContent,
} from '@ixo/oracles-client-sdk';

function App() {
  return (
    <OraclesProvider
      initialWallet={{
        address: 'ixo1...',
        did: 'did:ixo:entity:...',
        matrix: { accessToken: 'syt_...' },
      }}
      transactSignX={async (messages, memo) => {
        // Handle blockchain transactions
        return undefined;
      }}
    >
      <ChatInterface />
    </OraclesProvider>
  );
}

function ChatInterface() {
  const oracleDid = 'did:ixo:entity:oracle-id';

  // Create or get session
  const { createSession, sessions } = useOracleSessions(oracleDid);
  const sessionId = sessions?.[0]?.sessionId;

  // Chat functionality
  const { messages, sendMessage, isSending } = useChat({
    oracleDid,
    sessionId: sessionId || '',
    onPaymentRequiredError: (claimIds) => {
      console.log('Payment required:', claimIds);
    },
  });

  return (
    <div className="chat-container">
      {/* Create session button */}
      <button onClick={() => createSession()}>New Chat</button>

      {/* Messages */}
      <div className="messages">
        {messages.map((msg) => (
          <div key={msg.id} className={msg.type}>
            {/* Render message content (handles text and components) */}
            {renderMessageContent(msg.content)}
          </div>
        ))}
      </div>

      {/* Input */}
      <form
        onSubmit={(e) => {
          e.preventDefault();
          const input = e.currentTarget.message;
          sendMessage(input.value);
          input.value = '';
        }}
      >
        <input name="message" placeholder="Ask anything..." />
        <button type="submit" disabled={isSending}>
          {isSending ? 'Sending...' : 'Send'}
        </button>
      </form>
    </div>
  );
}

📚 Documentation

Key Concepts

Message Rendering

The SDK stores messages as plain data (not React elements) for optimal performance. Use renderMessageContent to transform messages into UI:

import { renderMessageContent } from '@ixo/oracles-client-sdk';

// Handles strings, custom components, and mixed content
{
  messages.map((msg) => (
    <div key={msg.id}>{renderMessageContent(msg.content, uiComponents)}</div>
  ));
}

Custom UI Components

Register custom components for rich interactions:

const uiComponents = {
  WeatherWidget: (props) => (
    <div>
      <h3>Weather in {props.city}</h3>
      <p>{props.temperature}°C</p>
    </div>
  ),
  PriceChart: (props) => <Chart data={props.data} />,
};

const { messages } = useChat({
  oracleDid,
  sessionId,
  uiComponents, // Pass to useChat
  onPaymentRequiredError: () => {},
});

Real-time Streaming

Messages stream in real-time with optimized performance:

  • RAF Batching: Uses requestAnimationFrame to batch multiple rapid updates into single render cycles, preventing UI stuttering during high-frequency streaming
  • Efficient State Updates: Shallow copies only (no expensive deep cloning)
  • Smooth Performance: Maintains 60fps streaming even at 100+ chunks/sec
  • Memory Optimized: Metadata-based component storage reduces memory footprint

Voice & Video (Optional)

Live agent calls are lazy loaded to keep your bundle small:

// Import separately to avoid loading ~500KB unless needed
import { useLiveAgent } from '@ixo/oracles-client-sdk/live-agent';

🛠️ Core APIs

Hooks

  • useChat - Real-time chat with streaming
  • useOracleSessions - Session management
  • useContractOracle - Payment and authorization
  • useMemoryEngine - Matrix room management and memory engine setup
  • useLiveAgent - Voice/video calls (separate bundle)

Components

  • OraclesProvider - Required context provider
  • renderMessageContent - Message renderer utility

Types

  • IMessage - Message structure
  • MessageContent - Content types (string | metadata | array)
  • IComponentMetadata - Custom component metadata
  • IChatSession - Session info

TypeScript Support

Fully typed with comprehensive interfaces:

import type {
  IMessage,
  MessageContent,
  IChatSession,
  UIComponentProps,
} from '@ixo/oracles-client-sdk';

📄 License

Licensed under the terms specified in License.txt

🔗 Links


Built with ❤️ by the IXO team