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

@thinhnguyenvn/chat-core

v0.2.1

Published

Chat state, reducer and NDJSON-over-HTTP adapter for the MyChat UI (React / React Native).

Readme

@thinhnguyenvn/chat-core

Chat state and transport for the MyChat UI: message types, conversationReducer, useConversation, the ChatAdapter interface, createHttpChatAdapter (NDJSON over HTTP, the gateway chat contract) and MockChatAdapter. No UI, no theme, no app aliases: it runs in any React Native (or React Native Web) app.

Source lives in the MyRN repo under packages/chat-core/. MyRN's own MyChat UI (src/components/ui/chat) is built on it.

Install

yarn add @thinhnguyenvn/chat-core

Peer dependencies: react and react-native. The package ships CommonJS + .d.ts, so Metro and Jest use it without extra transformIgnorePatterns or Babel config.

Use

import { createHttpChatAdapter, useConversation } from '@thinhnguyenvn/chat-core'

const adapter = createHttpChatAdapter({
  url: 'http://localhost:3300/chat',
  headers: { Authorization: `Bearer ${token}` },
  contractVersion: 3,
  getLocale: () => i18n.language,
  // Optional: keep the conversation on the gateway.
  session: { appId: 'my-store', userId: String(user.id), storage },
})

const { messages, send, sendMedia } = useConversation({ adapter })

Photos (contract v3)

With contractVersion: 3 and session, sendMedia(files, caption) uploads each file to POST /media first and then sends send_media with the ids. Without either (or with MockChatAdapter) it sends send_images like before. files are { uri, name, mimeType, file? }; on web pass the picked File as file. Send JPEG/PNG/WebP/HEIC up to 5 MB.

Ids the gateway shows on cards (media_choice.media, confirmation.media) are drawn from the local URI when this device sent them (localMediaUris(messages)), else from adapter.mediaSource(id) (GET /media/:id with the chat headers; 404 after 24h, show a placeholder). Answer a media_choice card with selectMedia(messageId, ids).

Session storage

session is optional. When set, the adapter sends X-Chat-Session and stores the id the gateway returns under the key chat.session.<appId>.<userId>. The package does not pick a storage: the app passes one with async getItem, setItem and removeItem (SecureStore, localStorage, AsyncStorage…).

import type { ChatSessionStorage } from '@thinhnguyenvn/chat-core'

const storage: ChatSessionStorage = {
  getItem: (key) => SecureStore.getItemAsync(key),
  setItem: (key, value) => SecureStore.setItemAsync(key, value),
  removeItem: (key) => SecureStore.deleteItemAsync(key),
}

Keys only contain [A-Za-z0-9._-] (other characters become _), so SecureStore accepts them.

API

| Export | Kind | |--|--| | useConversation, UseConversationOptions, UseConversationResult | hook | | conversationReducer, initialConversationState, ConversationState, ConversationAction | state | | ChatAdapter, ChatRequest, ChatStreamHandlers | adapter interface | | createHttpChatAdapter, HttpChatAdapterOptions, ChatSessionScope, ChatSessionStorage | HTTP adapter | | MockChatAdapter | scripted demo adapter | | generateMessageId, localMediaUris | util | | ChatMessage and its kinds, ConversationEvent, CardLockState, CARD_LOCK_STATES… | types |

Contract fixtures

contract/ is a copy of the gateway's wire fixtures (my-agent-platform/contract/); the package tests parse every stream in it. See contract/README.md.

Versions

0.x until the platform tags platform-v1.0.0, then 1.0.0. From 1.0.0: a new event or option that older clients can ignore is a minor; a breaking API change is a major. The wire contract version (X-Chat-Contract) is separate from the package version.

| Package | Chat contract (X-Chat-Contract) | |--|--| | 0.1.x | 1, 2 (plus optional X-Chat-Session) | | 0.2.x | 1, 2, 3 (media: POST /media, send_media, media_choice, select_media) |

See CHANGELOG.md.