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

@zov-chatui/agent

v1.0.3

Published

AI Agent chat interface built on @zov-chatui/base

Readme

@zov-chatui/agent

智能体对话 SDK,提供完整的智能体对话功能接口。

安装

npm install @zov-chatui/agent

依赖

本包依赖以下 peer dependencies,需要在使用项目中安装:

npm install react react-dom styled-components @zov-chatui/base
# 或
yarn add react react-dom styled-components @chat-ui/base
# 或
pnpm add react react-dom styled-components @chat-ui/base

必需依赖:

  • react >= 16.8.0
  • react-dom >= 16.8.0
  • styled-components >= 5.0.0
  • @zov-chatui/base >= 1.0.0

注意:如果使用 React 组件(如 AgentChatApp),必须安装上述所有依赖。如果只使用 API 接口(如 agentApi),则只需要安装 @zov-chatui/base

快速开始

基础配置

import { setBaseURL, setAuthToken, setSuccessCode } from '@zov-chatui/agent';

// 设置 API 基础路径
setBaseURL('https://your-api-endpoint.com');

// 设置认证 Token
setAuthToken('your-share-token');

// 【可选】如果服务端还没有改造,使用旧格式(code: 0 表示成功)
// setSuccessCode(0);
// 默认使用新格式(code: 1 表示成功)

流式对话(自动创建会话)

import { agentApi } from '@zov-chatui/agent';

const messages = [
  {
    content: '你好,请介绍一下自己',
    doc_ids: [],
    id: 'msg_001',
    role: 'user'
  }
];

// 不提供 conversation_id,会自动创建新会话
for await (const chunk of agentApi.streamCompletion({
  agent_status: 1,
  messages: messages,
  dialog_id: 'dialog_001',
  chat_insulate: 'user_123'
})) {
  if (chunk.data?.is_new_conversation) {
    // 第一个片段:新会话信息
    console.log('新会话ID:', chunk.data.conversation.conversation_id);
  } else if (chunk.data === true) {
    // 最后一个片段:结束标志
    console.log('流式输出结束');
  } else if (chunk.data?.answer) {
    // 中间片段:答案内容
    console.log('答案:', chunk.data.answer);
  }
}

独立创建会话

import { agentApi } from '@zov-chatui/agent';

const response = await agentApi.createConversation({
  chat_insulate: 'user_123',
  dialog_id: 'dialog_001',
  name: '我的新对话'
});

console.log('会话ID:', response.data.conversation_id);

重要配置:成功状态码

SDK 默认使用 code: 1 表示成功(新格式)。如果您的服务端还没有改造,可以通过配置切换到旧格式。

方式1:统一配置所有接口

import { setSuccessCode } from '@zov-chatui/agent';

// 统一切换到旧格式(code: 0 表示成功)
setSuccessCode(0);

// 之后所有接口调用都会使用 code: 0 作为成功标志

方式2:分别配置流式接口和普通接口(推荐)

如果流式接口和普通接口的改造进度不同,可以分别配置:

import { setStreamSuccessCode, setApiSuccessCode } from '@zov-chatui/agent';

// 流式接口还没改造,使用旧格式
setStreamSuccessCode(0);

// 普通接口已改造,使用新格式
setApiSuccessCode(1);

配置说明

  • 新格式code: 1 表示成功,code !== 1 表示失败
  • 旧格式code: 0 表示成功,code !== 0 表示失败

主要功能

  • ✅ 流式对话输出
  • ✅ 自动创建会话
  • ✅ 会话管理(创建、更新、删除)
  • ✅ 附件上传
  • ✅ 语音转换(支持百度 ASR)
  • ✅ 会话分享
  • ✅ 完整的 TypeScript 类型支持
  • ✅ 新旧格式兼容
  • ✅ 灵活配置成功状态码
  • ✅ 支持流式接口和普通接口分别配置

文档

示例

查看 API.md 获取完整的使用示例和接口说明。

License

MIT