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

@skillpet/chat-core

v0.11.5

Published

SSE 流式 AI 对话核心逻辑 — 类型定义、i18n、SSE 客户端、消息解析

Readme

@skillpet/chat-core


文档

框架无关的核心包,供 @skillpet/chat-react@skillpet/chat-vue 内部依赖。也可单独使用于 Headless 场景(自定义 UI、Node.js 后端等)。

React / Vue 用户:直接安装 @skillpet/chat-react@skillpet/chat-vue 即可,core 会作为依赖自动安装。

安装

npm install @skillpet/chat-core

导出一览

函数

| 名称 | 说明 | |------|------| | processSSEStream(options) | 发起 POST 请求并解析 SSE 流,通过回调更新消息状态 | | parseHistoryMessages(messages, uiStrings?) | 将后端历史消息还原为 ChatMessage[] | | setChatLanguage(lang) | 切换内置 i18n 语言(zh-CN / en / ja / ko / es / fr / zh-TW) | | cn(...inputs) | Tailwind class 合并工具(clsx + tailwind-merge) |

类型

| 名称 | 说明 | |------|------| | ChatMessage | 聊天消息 | | ChatPanelConfig | API 地址、鉴权等配置 | | ChatPanelProps | ChatPanel 组件完整 Props(含 readOnly?: boolean,v0.9+) | | ChatPanelEmptyState | 空状态自定义 | | ChatAttachment | 附件(id, name, type, url, previewUrl) | | InitCapabilities | 后端返回的能力配置 | | QueuedSendCap | 排队发送能力(enabled, maxQueueSize)(v0.6) | | QueuedMessage | 排队中的消息(id, content, attachments, createdAt)(v0.6) | | GeneratedImage | AI 生成单张图片元数据(v0.7) | | ImageGenerationAction | 图片生成交互动作(display / single_select / multi_select)(v0.7) | | ImageGenerationBlock | 消息中的图片生成内容块(v0.7) | | ReadOnlyMode | ChatPanelProps.readOnly?: boolean — 只读模式标志(v0.9) | | SlashCommand | 斜杠指令 | | AskUserQuestion | 结构化提问 | | SSECallbacks | SSE 回调集合 | | SSEStreamUiStrings | SSE 文案 | | ParseHistoryUiStrings | 历史解析文案 | | MessagePart / AgentToolStep / ToolInlineResult | 消息段落与工具结果 |

  • 图片生成(v0.7) — 通过 SSE image_generating / image_generation 推送生成态与结果,上述类型用于消息块与交互配置。

CSS

import "@skillpet/chat-core/styles.css";

内置蓝色品牌色主题(支持亮/暗模式),通过 CSS 变量可完全自定义。

SSE 流处理

import { processSSEStream } from "@skillpet/chat-core";

await processSSEStream({
  url: "/api/chat/stream",
  body: { message: "Hello", projectId: "demo" },
  token: "bearer-token",
  callbacks: {
    updateMessages: (updater) => setMessages(updater),
    onFinally: () => console.log("done"),
  },
});

主题 CSS 变量

覆盖 .skillpet-chat 上的变量即可自定义配色:

.skillpet-chat {
  --skillpet-chat-primary: oklch(0.6 0.22 145);
}

完整变量列表见 根 README

CDN 使用

<!-- unpkg -->
<script src="https://unpkg.com/@skillpet/chat-core/dist/index.umd.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@skillpet/chat-core/dist/skillpet-chat.css" />

<!-- jsdelivr -->
<script src="https://cdn.jsdelivr.net/npm/@skillpet/chat-core/dist/index.umd.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@skillpet/chat-core/dist/skillpet-chat.css" />

<script>
  // 全局变量 SkillpetChatCore
  const { processSSEStream, setChatLanguage } = SkillpetChatCore;
</script>

License

MIT