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

@deepinnet/ai-chat

v0.1.9

Published

Private H5 AI chat component package

Readme

@deepinnet/ai-chat

私有 H5 AI Chat 组件包(从业务项目解耦,可迁移到独立仓库发布)。

安装

pnpm add @deepinnet/ai-chat

最小接入

挂载后直接渲染全屏会话层(无内置悬浮入口、无内部显隐状态)。是否展示组件由宿主通过条件渲染等方式控制。

头部关闭按钮不会自行卸载组件,需传入 onCloseClick,在回调里执行卸载、路由返回等逻辑。

import { useState } from 'react';
import { AiChatH5 } from '@deepinnet/ai-chat';

export default function Demo() {
  const [visible, setVisible] = useState(false);

  if (!visible) {
    return (
      <button type="button" onClick={() => setVisible(true)}>
        打开 AI 助手
      </button>
    );
  }

  return (
    <AiChatH5
      title="AI 助手"
      onCloseClick={() => setVisible(false)}
    />
  );
}

指定会话 sessionId

传入 sessionId 后,组件会请求该会话详情并默认展示其历史消息(与侧栏切换会话相同的数据源)。sessionId 变化时会重新加载对应会话。

<AiChatH5
  sessionId={routeSessionId}
  onCloseClick={() => setVisible(false)}
/>

打包

pnpm install
pnpm type-check
pnpm build

迁移到独立项目

  1. 拷贝 packages/h5aichat-private 到新仓库根目录。
  2. 在新仓库执行 pnpm install
  3. 执行 pnpm build 产出 dist
  4. 配置私有源后执行 npm publish

内置业务 API

businessApiAdapter 默认已内置(/api 前缀):

  • POST /flight/order/orderPlanList
  • POST /category/tree
  • POST /cycle/plan/list
  • GET /flight/area/pool/position/list
  • POST /flight/order/create
  • POST /demand/create

如宿主接口网关一致,可不传 businessApiAdapter

内置会话 API

sessionAdapter 已内置(/aiServer 前缀),默认直接使用包内 SSE 与会话接口实现。

运行时依赖(重要)

该组件是特定业务组件,默认会直接请求后端接口,使用前请确认宿主应用具备以下运行时条件:

  • 已完成登录,localStorage 中存在 token(请求头会注入 satoken
  • localStorage.tenantId 可用(若无则默认使用 sz_unifly
  • 宿主已配置网关/代理:
    • 业务接口:/api/*
    • 会话与流式接口:/aiServer/*
  • 宿主允许组件读取浏览器 localStorage(用于鉴权头)

若以上条件不满足,组件可能出现:

  • 会话列表/流式消息请求失败
  • 表单下拉数据为空
  • 创建需求/规划接口调用失败

建议在接入前先验证:

  1. 当前页面登录态有效(token 未过期)
  2. /api/aiServer 代理可连通
  3. tenantId 与后端环境匹配