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

@tdesign/ai-chat-engine

v0.0.2

Published

TDesign ChatEngine - Framework-agnostic AI chat engine core

Readme

@tdesign/ai-chat-engine

English | 简体中文

TDesign AI Chat Engine is a framework-agnostic chat engine core package. It manages conversation state, streaming request orchestration, protocol adapters, and event dispatching, so it can serve as the runtime foundation for UI components, React/Vue hooks, or business SDKs without binding to a specific view framework.

Installation

pnpm add @tdesign/ai-chat-engine immer

immer is a peer dependency and should be provided by the consuming project.

Features

  • Message state management: manages user, assistant, and system messages with statuses such as pending, streaming, complete, stop, and error.
  • Streaming orchestration: supports fetch, SSE, and WebSocket transports, including abort handling, reconnect options, and error callbacks.
  • Protocol adapters: includes stream handling strategies for the default protocol, AG-UI, and OpenClaw to reduce protocol-specific logic in upper layers.
  • Content block merging: supports incremental updates for content types such as text, markdown, thinking, toolcall, activity, suggestion, and attachment.
  • Event bus: exposes engine lifecycle, message changes, request state, protocol events, and custom events for UI and business logic integration.
  • json-render / A2UI utilities: provides protocol-to-json-render conversion, surface state management, action binding, and patch update helpers.
  • Browser builds: ships both ESM output for npm/bundlers and an IIFE build for CDN or <script> usage.

Quick Start

import ChatEngine, { ChatEngineEventType } from '@tdesign/ai-chat-engine';
import type { ChatServiceConfig } from '@tdesign/ai-chat-engine';

const engine = new ChatEngine();

const config: ChatServiceConfig = {
  endpoint: '/api/chat',
  transport: 'sse',
  protocol: 'default',
  onMessage(chunk) {
    return {
      type: 'markdown',
      data: String(chunk.data ?? ''),
    };
  },
};

await engine.init(config);

engine.eventBus.on(ChatEngineEventType.REQUEST_COMPLETE, ({ message }) => {
  console.log('AI response completed:', message);
});

await engine.sendUserMessage({ prompt: 'Introduce TDesign AI Chat Engine' });

Common Imports

import ChatEngine, { ChatEngineEventType, createEventBus } from '@tdesign/ai-chat-engine';

import type { AIMessageContent, ChatMessagesData, ChatRequestParams, ChatServiceConfig } from '@tdesign/ai-chat-engine';

CDN / IIFE

<script src="https://unpkg.com/@tdesign/ai-chat-engine/dist/index.iife.js"></script>
<script>
  const { default: ChatEngine } = window.TDesignAIChatEngine;
  const engine = new ChatEngine();
</script>