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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tmesoft/ai-tools-core

v0.0.4

Published

a ai-tools-core

Readme

Hooks 组件文档

MessageManager

消息管理器,用于处理聊天消息的增删改查操作。

类型定义

export interface Message {
  /** 消息ID */
  _id: IMessageId
  /** 消息类型 */
  type: string
  /** 消息内容 */
  content: string
  /** 消息发送者 */
  sender: IMessageSender
  /** 消息创建时间 */
  createdAt: number
  /** 消息状态:等待中、成功、失败 */
  status: IMessageStatus
  /** 消息附带文件 */
  file?: File

  // 消息渲染方式二选一
  /** 消息内容渲染函数 */
  renderMessageContent?: (msg: Message) => DefineComponent
  /** 消息组件 */
  renderComponentName?: string

  /** 消息模型 */
  model?: String
  /** 知识库名称 */
  knowlegeName?: string
  /** 文件id列表 */
  fileIds?: string[]
  /** 文档名称列表 */
  documentNames?: string[]
  /** 自定义消息属性 */
  custom?: Record<string, any>
}

主要方法

| 方法名 | 参数 | 返回值 | 说明 | --------|------|--------|------| getMessages | - | Message[] | 获取所有消息 | prependMsgs | msgs: Message[] | void | 在消息列表前添加消息 | appendMsg | msg: MessageWithoutId | Message | 在消息列表后追加消息 | updateMsg | msg: Message | void | 更新指定消息 | deleteMsg | id: string | void | 删除指定消息 | clearMsgs | list?: Message[] | void | 清空消息列表或重置为指定列表 |

useRoom

房间管理 Hook,用于管理聊天房间。

类型定义

interface Room {
  /** 房间ID */
  roomId: IRoomId
  /** 房间名称 */
  roomName: string
  /** 房间消息列表 */
  messages: MessageManager
  /** 房间创建时间 */
  createTime: number
  /** 房间自定义信息 */
  custom?: Record<string, any>
}

主要方法

| 方法名 | 参数 | 返回值 | 说明 | --------|------|--------|------| addRoom |room?: RoomWithoutId | Room | 创建新房间 | updateRoom | room: Room | void | 更新房间信息 | prependRooms | rooms: Room[] | void | 在房间列表前添加房间 | deleteRoomById | roomId: string | void | 删除指定房间 | changeCurrentRoomById | roomId: string | void | 切换当前房间 |

使用示例

// 创建消息管理器
const messageManager = new MessageManager()

// 添加消息
messageManager.appendMsg({
  type: 'text',
  content: '你好',
  sender: IMessageSender.USER,
  status: IMessageStatus.SUCCESS
})

// 使用房间管理
const { rooms, currentRoom, addRoom } = useRoom()

// 创建新房间
const newRoom = addRoom({
  roomName: '新房间',
  messages: new MessageManager()
})