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

socket-sdk-test-v1

v0.0.1

Published

React Native Socket SDK - WebSocket/auth/chat transport for the platform.

Readme

Artemis React Native Socket SDK

WebSocket + auth + chat transport for the Artemis platform, for React Native. This is a faithful TypeScript port of the Flutter artemis_flutter_socket_sdk.

  • Implements: the shared Artemis wire/event/config contract — token bootstrap (/api/v1/sdk/init) and refresh (/api/v1/sdk/refresh), WebSocket ticket (/api/v1/sdk/ws-ticket) with legacy subprotocol fallback, the /ws/sdk socket, streaming chat, persisted-history pagination, reconnection with exponential backoff, and pending-message resend.
  • Public surface: mirrors the Flutter AgentSDK (initialize, connect, sendMessage, getMessages, getWidgetConfig, event subscriptions).

Consumed by the sibling ../UI SDK.

Architecture

The SDK is split into the same four layers as the Flutter SDK:

| Class | Responsibility | | ---------------- | --------------------------------------------------------- | | AgentSDK | Public API, wires the clients together, fans out events. | | TokenManager | Bootstraps/refreshes short-lived SDK session tokens. | | SessionManager | Opens the WebSocket, handles session_start, reconnects. | | ChatClient | Sends messages, parses streaming responses, loads history.|

The SDK relies only on the global WebSocket and fetch that React Native provides — there are no extra runtime dependencies.

Configuration

Flutter loads configuration from bundled YAML assets. React Native has no equivalent, so configuration is supplied to initialize as a plain object. The keys mirror the Flutter sdk_configurations.yaml (snake_case), so an existing config translates directly:

const config = {
  environment: 'dev',
  connection: {
    project_id: '019ebab0-737a-7661-9c02-d8d416320a1c',
    api_key: 'pk_...',
    endpoint: 'https://agents-dev.kore.ai',
  },
  channel: {
    channel_id: '019eee30-53a9-7961-afb1-e9303a8c989f',
    channel_name: 'RN Demo App',
  },
  websocket: {
    reconnection: {
      enabled: true,
      max_attempts: 5,
      base_delay_ms: 1000,
      max_delay_ms: 30000,
      exponential_backoff: true,
    },
  },
  chat: {
    enable_typing_indicator: true,
    enable_thoughts: false,
  },
  debug: { enabled: true, log_level: 'debug', log_websocket_messages: true },
};

Authentication requires either connection.api_key or connection.bootstrap_token (not both).

Usage

import { AgentSDK } from '@artemis/react-native-socket-sdk';

const sdk = await AgentSDK.initialize({ config });

// Connection lifecycle events
sdk.on('event', (event) => {
  switch (event.type) {
    case 'connected':
      console.log('connected', event.sessionId);
      break;
    case 'disconnected':
      console.log('disconnected', event.reason);
      break;
    case 'reconnecting':
      console.log(`reconnecting ${event.attempt}/${event.maxAttempts}`);
      break;
    case 'error':
      console.warn('sdk error', event.code, event.error);
      break;
  }
});

// Chat events (streaming, history, typing)
sdk.on('chat', (event) => {
  switch (event.type) {
    case 'messageStart':
    case 'messageChunk':
    case 'messageEnd':
    case 'messageReceived':
    case 'historyLoaded':
      setMessages(sdk.getMessages());
      break;
    case 'typingIndicator':
      setTyping(event.isTyping);
      break;
    case 'thought':
      console.log('thought', event.content);
      break;
    case 'chatError':
      console.warn('chat error', event.error);
      break;
  }
});

const sessionId = await sdk.connect();
await sdk.sendMessage('Hello!');

// Optional: attach data to every outgoing message for this session
sdk.updateCustomData({ plan: 'enterprise' });

// Teardown
await sdk.dispose();

Public API

| Member | Description | | ------------------------------------- | ------------------------------------------------- | | AgentSDK.initialize({ config, … }) | Parse/validate config and wire up clients. | | AgentSDK.createWithConfig(config) | Create from an already-parsed SDKConfiguration. | | connect() | Connect; resolves with the sessionId. | | disconnect() | Close the socket (no end_session). | | endSession() | Send end_session, clear custom data, close. | | isConnected() / getSessionId() | Connection status helpers. | | getWidgetConfig() | Server-provided widget theming config. | | sendMessage(text, opts?) | Send a message; resolves with the local id. | | getMessages() | Locally-stored messages. | | updateCustomData() / getCustomData() / clearCustomData() | Session-scoped custom data. | | clearHistory() | Clear the local message store. | | on('event' \| 'chat', handler) | Subscribe; returns an unsubscribe function. | | dispose() | Tear down and release all resources. |

Build

npm install
npm run build   # tsc -> dist/

Examples

  • Headless smoke test — connect to the live runtime and send a message:
npm run smoke
  • React Native app (Android + iOS) — a chat UI that mirrors the Flutter example. The example/ folder is the app itself; see example/README.md for run instructions (cd example && npm install && npm run android / npm run ios).