@galaxycore/ai-chat 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +1 -1
- package/dist/headless.d.ts +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +69 -20
- package/dist/index.js.map +1 -1
- package/dist/{labels-D8smv23O.d.ts → labels-a_-_yLBi.d.ts} +9 -3
- package/dist/styles.css +1 -0
- package/dist/targeting.css +205 -0
- package/dist/targeting.d.ts +101 -0
- package/dist/targeting.js +585 -0
- package/dist/targeting.js.map +1 -0
- package/docs/api-reference.md +2 -1
- package/docs/publishing.md +9 -9
- package/docs/streaming.md +27 -1
- package/docs/validation.md +23 -0
- package/package.json +5 -1
package/docs/api-reference.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 组件与 API
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
以下接口对应当前源码。类型声明随 npm 包发布,组件保留 SDK 的 `UIMessage` 泛型。
|
|
4
4
|
|
|
5
5
|
## 模块入口
|
|
6
6
|
|
|
@@ -47,6 +47,7 @@ options 沿用 `@ai-sdk/react` 的 `UseChatOptions<M>`。返回 SDK `UseChatHelp
|
|
|
47
47
|
| `composerProps` | Composer props 子集 | 上下文、toolbar、attachments、speech、disabled |
|
|
48
48
|
| `renderText` | `({text,isStreaming}) => ReactNode` | 覆盖默认助手 Markdown / 用户纯文本渲染 |
|
|
49
49
|
| `smoothStreaming` | `boolean`,默认 `true` | 活跃文本的短窗口平滑显示;停止立即展示全文,自定义 part renderer 自行控制。见 [流式体验](streaming.md) |
|
|
50
|
+
| `scrollRef` | `Ref<ChatScrollHandle>` | 定位消息区中的元素或文字范围。见 [定位消息内容](streaming.md#定位消息内容) |
|
|
50
51
|
| `renderers` | 按 part.type 映射 | 最高优先级的自定义消息片段 |
|
|
51
52
|
| `tools` | 按 toolName 映射 | 自定义业务工具结果卡片 |
|
|
52
53
|
| `toolPresentation` | `ToolPresentationResolver<M>` | 只定制默认工具动作行的标题、图标和摘要 |
|
package/docs/publishing.md
CHANGED
|
@@ -36,7 +36,7 @@ mkdir -p artifacts
|
|
|
36
36
|
npm pack --pack-destination artifacts
|
|
37
37
|
|
|
38
38
|
# 消费项目:替换为真实文件的绝对路径
|
|
39
|
-
npm install /absolute/path/to/galaxycore-ai-chat-0.
|
|
39
|
+
npm install /absolute/path/to/galaxycore-ai-chat-0.7.0.tgz
|
|
40
40
|
npm install ai@^7.0.137 @ai-sdk/react@^4.0.140
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -53,12 +53,12 @@ npm run check
|
|
|
53
53
|
npm pack --dry-run
|
|
54
54
|
mkdir -p artifacts
|
|
55
55
|
npm pack --pack-destination artifacts
|
|
56
|
-
tar -tzf artifacts/galaxycore-ai-chat-0.
|
|
56
|
+
tar -tzf artifacts/galaxycore-ai-chat-0.7.0.tgz
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
`check` 执行类型检查、组件与网关测试、库构建和可部署示例构建;示例构建包含文档站。`prepack` 构建库,`prepublishOnly` 执行完整检查。tarball 应包含公开 JS 入口、声明、CSS、README 和文档,不应包含模型凭据、认证配置或业务数据。
|
|
60
60
|
|
|
61
|
-
检查根入口及 `headless`、`markdown`、`ag-ui`、`context`、`gateway`、`appearance`、`voice`、`styles.css` 子入口。React 与 AI SDK 应保持 peer dependency,Markdown 默认启用并保留独立入口。
|
|
61
|
+
检查根入口及 `headless`、`markdown`、`ag-ui`、`context`、`gateway`、`appearance`、`voice`、`targeting`、`styles.css` 子入口。React 与 AI SDK 应保持 peer dependency,Markdown 默认启用并保留独立入口。
|
|
62
62
|
|
|
63
63
|
在独立 Vite React 消费项目中安装 tarball,验证类型、样式、流式消息与停止;需要 Next.js 时另外验证客户端边界及 SSR 构建。不要只依赖仓库开发 alias 的演示结果。每次发布记录实际使用的 Node、React 和 AI SDK 版本,以及通过的消费测试,见 [验证记录](validation.md)。
|
|
64
64
|
|
|
@@ -85,12 +85,12 @@ CI 构建和测试步骤无需发布凭据。发布 job 可使用 CI secret 注
|
|
|
85
85
|
|
|
86
86
|
## 版本与发布
|
|
87
87
|
|
|
88
|
-
当前组件版本为 `0.
|
|
88
|
+
当前组件版本为 `0.7.0`,网关版本为 `0.2.0`,两者独立升级。0.x 阶段,修复使用 patch,新增功能和未冻结接口调整使用 minor,并在 changelog 说明兼容性。稳定 API 后再发布 1.0。
|
|
89
89
|
|
|
90
90
|
下面以 npmjs.org 公开发布为例。命令会实际上传产物,应在完成验收后由发布负责人执行;发布私有 registry 时替换地址,并按该服务调整可见性参数:
|
|
91
91
|
|
|
92
92
|
```sh
|
|
93
|
-
npm publish ./artifacts/galaxycore-ai-chat-0.
|
|
93
|
+
npm publish ./artifacts/galaxycore-ai-chat-0.7.0.tgz \
|
|
94
94
|
--access public --tag latest \
|
|
95
95
|
--registry=https://registry.npmjs.org/
|
|
96
96
|
```
|
|
@@ -98,7 +98,7 @@ npm publish ./artifacts/galaxycore-ai-chat-0.5.0.tgz \
|
|
|
98
98
|
使用 tarball 发布时,先显式执行完整检查,不依赖源仓库的生命周期脚本一定被触发。`latest` 是不指定版本安装时使用的标签,不代表 API 已冻结。需要独立试用通道时,可以采用预发布版本及 `next` 标签。发布后检查远端版本和完整性:
|
|
99
99
|
|
|
100
100
|
```sh
|
|
101
|
-
npm view @galaxycore/ai-chat@0.
|
|
101
|
+
npm view @galaxycore/ai-chat@0.7.0 version dist.integrity \
|
|
102
102
|
--registry=https://registry.npmjs.org/
|
|
103
103
|
npm dist-tag ls @galaxycore/ai-chat \
|
|
104
104
|
--registry=https://registry.npmjs.org/
|
|
@@ -113,16 +113,16 @@ npm dist-tag ls @galaxycore/ai-chat \
|
|
|
113
113
|
```sh
|
|
114
114
|
npm run check:gateway
|
|
115
115
|
npm pack --workspace=@galaxycore/ai-chat-gateway --pack-destination artifacts
|
|
116
|
-
tar -tzf artifacts/galaxycore-ai-chat-gateway-0.
|
|
116
|
+
tar -tzf artifacts/galaxycore-ai-chat-gateway-0.2.0.tgz
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
验收后公开发布网关包:
|
|
120
120
|
|
|
121
121
|
```sh
|
|
122
|
-
npm publish ./artifacts/galaxycore-ai-chat-gateway-0.
|
|
122
|
+
npm publish ./artifacts/galaxycore-ai-chat-gateway-0.2.0.tgz \
|
|
123
123
|
--access public --tag latest \
|
|
124
124
|
--registry=https://registry.npmjs.org/
|
|
125
|
-
npm view @galaxycore/ai-chat-gateway@0.
|
|
125
|
+
npm view @galaxycore/ai-chat-gateway@0.2.0 version dist.integrity \
|
|
126
126
|
--registry=https://registry.npmjs.org/
|
|
127
127
|
```
|
|
128
128
|
|
package/docs/streaming.md
CHANGED
|
@@ -25,7 +25,7 @@ const chat = useAiChat({ transport });
|
|
|
25
25
|
## 滚动与阅读
|
|
26
26
|
|
|
27
27
|
- 在底部阅读时,新内容继续进入可见区域。
|
|
28
|
-
-
|
|
28
|
+
- 滚轮、触摸、键盘或滚动条主动向上查看历史时,暂停自动跟随。Markdown 重排和消息区尺寸变化期间继续跟随。
|
|
29
29
|
- 主动发送新消息时,回到底部并恢复跟随;流式回答过程中仍可再次上滑阅读。
|
|
30
30
|
- 内容不足一屏时,向上滑动不会误暂停后续内容的跟随。
|
|
31
31
|
- 点击“回到底部”恢复跟随。
|
|
@@ -36,6 +36,32 @@ const chat = useAiChat({ transport });
|
|
|
36
36
|
|
|
37
37
|
操作系统的“减少动态效果”偏好优先于视觉平滑效果。平滑展示不是网络缓冲,也不会让模型更快响应;较长的服务端停顿仍然需要等待实际数据。
|
|
38
38
|
|
|
39
|
+
### 定位消息内容
|
|
40
|
+
|
|
41
|
+
`ChatPanel`、`ChatMessages` 和 `AiChat` 都可以接收 `scrollRef`。宿主可以传入消息区内的元素或文字 `Range`,用于定位搜索命中、引用或正在朗读的句子。
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { useRef } from 'react';
|
|
45
|
+
import { ChatPanel, type AiChatController, type ChatScrollHandle } from '@galaxycore/ai-chat';
|
|
46
|
+
|
|
47
|
+
function Conversation({ chat, match }: { chat: AiChatController; match: Element | Range | null }) {
|
|
48
|
+
const scrollRef = useRef<ChatScrollHandle>(null);
|
|
49
|
+
return (
|
|
50
|
+
<ChatPanel
|
|
51
|
+
chat={chat}
|
|
52
|
+
scrollRef={scrollRef}
|
|
53
|
+
headerActions={
|
|
54
|
+
<button type="button" disabled={!match} onClick={() => match && scrollRef.current?.reveal(match)}>
|
|
55
|
+
显示匹配内容
|
|
56
|
+
</button>
|
|
57
|
+
}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`reveal` 只滚动当前面板的消息区。目标已完整可见、已卸载或属于其他面板时返回 `false`。如果滚动位置发生变化,返回 `true` 并暂停跟随。普通目标尽量居中,超过视口高度的目标从顶部显示。发送新消息、滚动到底部或使用“回到最新”可以恢复跟随。调用方负责决定何时定位,以及如何高亮文字和读取历史。
|
|
64
|
+
|
|
39
65
|
## Markdown 与工具
|
|
40
66
|
|
|
41
67
|
通过 `renderText={MarkdownResponse}` 使用流式 Markdown。文字、工具活动和工具后的回答保持消息中的顺序。模型凭据、工具执行、服务端停止与会话恢复仍然由网关负责,具体见 [网关接入](./gateway.md)。
|
package/docs/validation.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# 0.4.0 发布验收 · 2026-10-13
|
|
2
2
|
|
|
3
|
+
## 0.7.0 — 消息滚动与定位 (2026-11-23)
|
|
4
|
+
|
|
5
|
+
- 流式回复在布局重排时继续跟随最新消息,用户主动向上滚动时暂停跟随。宿主可通过 `scrollRef` 定位消息区中的元素或文字范围。
|
|
6
|
+
- `npm run check` 在 Node 24.22.1 下通过。组件 204 项、网关 11 项、示例服务 9 项测试通过,类型、组件库、工作台、文档站和服务构建均通过。
|
|
7
|
+
- 发布包在独立的 React 19 / AI SDK 7 Vite 项目中验收。Chromium 验证了原生滚动条拖动和文字范围定位。公开版本、标签和完整性见 `artifacts/npm-publication-0.7.json`。
|
|
8
|
+
|
|
9
|
+
## 0.6.0 — 页面指向 (2026-11-23)
|
|
10
|
+
|
|
11
|
+
- 新增可选页面指向:划选文字、双击段落、拖选图片区域可以变成聊天上下文引用。公开入口是 `useChatTargeting`、`ChatTargetingOverlay`、`toChatContextItem` 和 `/targeting`。不挂载时,原有发送和界面保持不变。
|
|
12
|
+
- Node 24.22.1 下 `npm run check` 通过:组件 200 项、网关 11 项、示例服务 9 项;类型检查、组件库、文档站、工作台和示例服务构建通过。
|
|
13
|
+
- `0.6.0` tarball 含 61 个文件,没有环境文件或凭据。本地包与 registry 完整性一致。
|
|
14
|
+
- 已公开发布到 npmjs.org,`latest` 为 `0.6.0`。记录见 `artifacts/npm-publication-0.6.json`。网关仍是 `0.2.0`,本轮没有重发。
|
|
15
|
+
|
|
16
|
+
## 0.5.0 — Default Markdown (2026-10-20)
|
|
17
|
+
|
|
18
|
+
- Assistant text uses the existing safe Streamdown renderer by default; user input remains literal and host renderers retain precedence. Streamdown is installed as a runtime dependency.
|
|
19
|
+
- Verified with Node 24.19.0: `npm run check` passed (194 component tests, 11 gateway tests, 9 playground tests, type checks, library/demo/docs/server builds).
|
|
20
|
+
- The new default-rendering regression failed on 0.4.0 and passed after the fix. Existing Markdown security, streaming, focus and scroll coverage passed. The scroll fixture now supports multiple ResizeObserver instances.
|
|
21
|
+
- The built public entry passed an SSR smoke check for headings and emphasis. The 0.5.0 tarball contains 57 allowlisted files and no environment files or credentials.
|
|
22
|
+
- `npm publish` accepted `@galaxycore/ai-chat@0.5.0` for public npmjs.org distribution with the `latest` tag. Registry propagation is verified separately in `artifacts/npm-publication-0.5.json` when available.
|
|
23
|
+
- No new browser screenshot review or live model integration was performed for this change. Earlier validation records below apply to their named versions.
|
|
24
|
+
|
|
25
|
+
|
|
3
26
|
本次版本:`@galaxycore/ai-chat@0.4.0` 与 `@galaxycore/ai-chat-gateway@0.1.0`,两个包独立分发。前端新增 `ChatHistoryMenu` 与 `smoothStreaming`,并包含主动发送后恢复滚动跟随、短列表向上滑动不误暂停跟随的修复。
|
|
4
27
|
|
|
5
28
|
- Node 24.21.0 下执行 `npm run check` 全部通过:前端及文档示例 183 项、网关 11 项、示例 HTTP 服务 9 项,共 **203 项测试**;类型检查、组件库、Rspress、前端工作台和示例服务构建均通过。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galaxycore/ai-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Composable React AI chat for GalaxyCore, powered by Vercel AI SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
"./voice": {
|
|
53
53
|
"types": "./dist/voice.d.ts",
|
|
54
54
|
"import": "./dist/voice.js"
|
|
55
|
+
},
|
|
56
|
+
"./targeting": {
|
|
57
|
+
"types": "./dist/targeting.d.ts",
|
|
58
|
+
"import": "./dist/targeting.js"
|
|
55
59
|
}
|
|
56
60
|
},
|
|
57
61
|
"scripts": {
|