@galaxycore/ai-chat 0.0.0-stage → 0.5.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 +62 -0
- package/README.md +220 -2
- package/dist/ag-ui.d.ts +33 -0
- package/dist/ag-ui.js +387 -0
- package/dist/ag-ui.js.map +1 -0
- package/dist/appearance-BUtKwRL5.d.ts +34 -0
- package/dist/appearance.d.ts +3 -0
- package/dist/appearance.js +3 -0
- package/dist/context.d.ts +86 -0
- package/dist/context.js +414 -0
- package/dist/context.js.map +1 -0
- package/dist/gateway.d.ts +58 -0
- package/dist/gateway.js +60 -0
- package/dist/gateway.js.map +1 -0
- package/dist/headless.d.ts +5 -0
- package/dist/headless.js +7 -0
- package/dist/history-menu.css +90 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +1433 -0
- package/dist/index.js.map +1 -0
- package/dist/labels-BM5o9a9K.js +116 -0
- package/dist/labels-BM5o9a9K.js.map +1 -0
- package/dist/labels-D8smv23O.d.ts +189 -0
- package/dist/markdown.d.ts +9 -0
- package/dist/markdown.js +41 -0
- package/dist/markdown.js.map +1 -0
- package/dist/styles.css +441 -0
- package/dist/ui-primitives-BCbe9Ds8.js +177 -0
- package/dist/ui-primitives-BCbe9Ds8.js.map +1 -0
- package/dist/utils-DqBGBYA1.js +32 -0
- package/dist/utils-DqBGBYA1.js.map +1 -0
- package/dist/voice.d.ts +80 -0
- package/dist/voice.js +347 -0
- package/dist/voice.js.map +1 -0
- package/docs/api-reference.md +163 -0
- package/docs/conversation-history.md +81 -0
- package/docs/deployment.md +130 -0
- package/docs/design.md +63 -0
- package/docs/example-project.md +94 -0
- package/docs/gateway.md +89 -0
- package/docs/integration.md +261 -0
- package/docs/migration.md +56 -0
- package/docs/patent-prototype.md +72 -0
- package/docs/patent-visual-baseline.json +121 -0
- package/docs/platform-adapters.md +214 -0
- package/docs/publishing.md +129 -0
- package/docs/quickstart.md +132 -0
- package/docs/research.md +135 -0
- package/docs/runtime-design.md +122 -0
- package/docs/runtime-research.md +115 -0
- package/docs/streaming.md +56 -0
- package/docs/ui-customization.md +97 -0
- package/docs/unified-integration.md +72 -0
- package/docs/validation-0.2.md +65 -0
- package/docs/validation.md +162 -0
- package/docs/voice-input.md +101 -0
- package/package.json +109 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
- Assistant text now renders Markdown by default, including headings, lists, tables and fenced code, using the existing streaming renderer. User input remains literal text.
|
|
6
|
+
- Existing `renderText` and part renderer overrides retain precedence.
|
|
7
|
+
- Streamdown is now a runtime dependency, installed automatically. The `/markdown` export remains compatible; `/headless` still does not import the Markdown renderer.
|
|
8
|
+
- Existing unsafe URL/HTML filtering and remote-image blocking remain enabled.
|
|
9
|
+
|
|
10
|
+
## 0.4.0
|
|
11
|
+
|
|
12
|
+
### 历史会话菜单
|
|
13
|
+
|
|
14
|
+
- 新增可复用的 `ChatHistoryMenu`:单行最近会话、当前会话标记、更多对话与本地搜索;支持宿主文案、底部入口、样式和图标覆盖。
|
|
15
|
+
- 工作台使用轻量三点入口,整合新对话和设置帮助;再次选择当前会话不会停止生成。
|
|
16
|
+
- 历史列表增加加载、失败重试与过期请求过滤,刷新期间保留现有记录。
|
|
17
|
+
- 文档新增可交互历史菜单示例,提供主题切换、搜索、选择和新建操作。
|
|
18
|
+
|
|
19
|
+
### 流式阅读体验
|
|
20
|
+
|
|
21
|
+
- 新增可关闭的 `smoothStreaming` 显示缓冲,按完整字符簇分批追赶;停止、完成和减少动态效果时直接显示收到的全文。
|
|
22
|
+
- 自动滚动统一到帧调度器,上滑立即暂停,返回底部恢复;跟随内容和容器尺寸,区别用户操作与浏览器高度钳制。
|
|
23
|
+
- 修复上滑阅读后主动发送新消息未回到底部的问题,发送时恢复滚动跟随;内容不足一屏时向上滑动不再误暂停跟随。
|
|
24
|
+
- 思考状态与消息操作复用稳定页脚,避免工具与文字交替时尾部整行反复增减;Markdown renderer 保持引用与已完成链接焦点稳定。
|
|
25
|
+
- 新增不依赖模型的疏密混合流式交互演示,可播放、停止、重播和比较开关效果。
|
|
26
|
+
|
|
27
|
+
### 文档与分发
|
|
28
|
+
|
|
29
|
+
- 文档迁移至 Rspress 2.0.23,提供全文搜索、代码高亮/复制、目录和深浅主题。
|
|
30
|
+
- 新增真实组件交互示例:本地流式聊天与停止、主题/密度、上下文引用及工具状态;可查看示例源码。
|
|
31
|
+
- 工作台、静态文档和网关可一起构建部署,支持 `/docs/` 深链接。
|
|
32
|
+
- 发布与安装配置由使用方选择,组件和网关不绑定 registry 产品;文档统一使用通用业务示例。
|
|
33
|
+
|
|
34
|
+
## 0.3.1
|
|
35
|
+
|
|
36
|
+
- 工具调用改为紧凑动作行,参数和结果按需展开,保留失败原因及审批操作的可见性。
|
|
37
|
+
- 新增 `toolPresentation`,自定义标题、图标和摘要,同时复用默认状态交互。
|
|
38
|
+
- 停止/历史未完成工具显示等待结果,preliminary 结果不会误标完成;toolCallId 隔离展开和审批状态。
|
|
39
|
+
- 示例新增工具体验页,展示运行、成功、失败、审批和等待状态。
|
|
40
|
+
|
|
41
|
+
## 0.3.0
|
|
42
|
+
|
|
43
|
+
- 打磨图标按钮、键盘/悬浮提示、引用标签、输入卡片、消息与工具状态,统一深浅主题与触屏目标。
|
|
44
|
+
- 新增可替换的语音输入适配器、浏览器听写、实时预览/停止/取消、权限反馈和可编辑草稿。
|
|
45
|
+
- 新增 ChatIconButton 公共组件与 ContextTray renderIcon。
|
|
46
|
+
- 将演示整理为 examples/playground,使用公共包入口,包含同源 Node 网关、登录保护、Docker 多阶段构建和持久卷。
|
|
47
|
+
- 示例内置技术文档站,新增快速开始/API/语音/主题/部署指南。
|
|
48
|
+
|
|
49
|
+
## 0.2.0
|
|
50
|
+
|
|
51
|
+
- 新增独立服务端包 `@galaxycore/ai-chat-gateway`,实现 pi core 运行时和 AI SDK UI Message Stream 网关。
|
|
52
|
+
- 新增浏览器 `/gateway` 客户端,提供能力查询、会话列表、历史恢复和显式取消请求。
|
|
53
|
+
- 新增 `/context` 平台适配协议、Hook、引用预览和受限文字选区适配器;宿主可接入表格、编辑器、图表等自己的选择逻辑。
|
|
54
|
+
- 图标统一使用 Lucide React;新增图标覆盖、布局 variant、消息 density 和运行时能力控制。
|
|
55
|
+
- 演示改为真实服务端模型调用,展示上下文引用、服务端会话、主题和密度切换。
|
|
56
|
+
|
|
57
|
+
Codex 仅预留服务端接口;本版不提供 Codex 运行时、活跃流重放、工具审批执行或 pi 附件处理。前端现有的自定义 Transport、附件上传和审批 UI 接口继续保留。
|
|
58
|
+
|
|
59
|
+
## 0.1.0
|
|
60
|
+
|
|
61
|
+
- React 组合式聊天 UI、AI SDK 7 headless Hook、可选 Markdown renderer。
|
|
62
|
+
- 严格子集 AG-UI Transport、工具与自定义消息 renderer、附件上传适配、npm 打包与发布支持。
|
package/README.md
CHANGED
|
@@ -1,3 +1,221 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @galaxycore/ai-chat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
GalaxyCore 通用 React AI 聊天组件。默认界面借鉴 Chrome AI 侧栏和 Codex 的消息阅读、工具状态与输入区布局,使用 Lucide 图标;支持完整面板、组合组件和 headless Hook。不同业务系统可分别适配文档、表格、图表或编辑器上下文,也可以使用自己的主题与组件库。
|
|
4
|
+
|
|
5
|
+
**当前版本:UI 包 0.5.0,网关包 0.1.0。** UI 提供平滑流式展示、历史会话菜单、语音输入、可部署示例和交互文档站。独立 Node 网关通过 pi core 实现流式文本、服务端工具调用、停止和持久化会话恢复。Codex 已预留运行时扩展接口,尚未实现其桥接。发布验收与真实模型联调状态见 [验证记录](docs/validation.md)。
|
|
6
|
+
|
|
7
|
+
## 本地运行
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
nvm install
|
|
11
|
+
npm ci
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
在仓库根目录创建 `.env.local`,按公司 OpenAI 兼容服务填写:
|
|
15
|
+
|
|
16
|
+
```dotenv
|
|
17
|
+
AI_BASE_URL=https://ai-gateway.example/v1
|
|
18
|
+
AI_MODEL=your-company-model
|
|
19
|
+
AI_API_KEY=replace-with-your-server-side-key
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`.env.local` 已被 Git 忽略。模型配置由服务端读取,不使用 `VITE_*` 或 `NEXT_PUBLIC_*` 暴露给浏览器。
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
# 终端一:启动示例服务(8080),读取 .env.local
|
|
26
|
+
npm run dev:demo-server
|
|
27
|
+
|
|
28
|
+
# 终端二:启动演示,/api 请求代理到本地网关
|
|
29
|
+
npm run dev
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npm run check # 前端与网关的类型检查、测试和构建
|
|
34
|
+
npm pack # 打包前端组件
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
完整示例位于 `examples/playground`,通过组件公共包入口接入;Rspress 文档站位于 `examples/docs`,与工作台一起构建和部署。开发预览为 `http://127.0.0.1:5178/`,文档为 `http://127.0.0.1:5178/docs/`。文档中的交互示例使用本地模拟 transport,不需要模型凭据;真实聊天工作台连接后端网关。Docker / Node 部署见 [部署指南](docs/deployment.md)。
|
|
38
|
+
|
|
39
|
+
网关独立包位于 `packages/gateway`,不是前端 bundle 的一部分。网关配置、工具注册、持久化与部署见 [网关接入](docs/gateway.md)。演示需要可用网关和模型配置,不会以模拟回答替代后端失败。
|
|
40
|
+
|
|
41
|
+
开发版本由 `package-lock.json` 固定:AI SDK 7、React 19、TypeScript 7、Streamdown 2、Lucide React。前端消费端支持 ESM、React 18.3.1 / 19.2.1+;Node 开发版本以 `.nvmrc` 为准。版本依据见 [版本调研](docs/research.md)。
|
|
42
|
+
|
|
43
|
+
## 安装与接入
|
|
44
|
+
|
|
45
|
+
从发布方指定的 npm registry 安装。如果使用私有仓库,按其要求配置项目 `.npmrc` 和登录身份,见 [发布与安装](docs/publishing.md)。组件本身不依赖任何 registry 产品,也不在运行时访问包仓库。
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm install @galaxycore/ai-chat ai@^7.0.137 @ai-sdk/react@^4.0.140
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
项目需已有 React / React DOM。下面对接本仓库的网关;生产项目应由同源代理和网关处理登录身份。
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
'use client';
|
|
55
|
+
|
|
56
|
+
import { useMemo, useRef, useState } from 'react';
|
|
57
|
+
import type { UIMessage } from 'ai';
|
|
58
|
+
import { ChatPanel, useAiChat } from '@galaxycore/ai-chat';
|
|
59
|
+
import { createGatewayClient, GatewayRequestError } from '@galaxycore/ai-chat/gateway';
|
|
60
|
+
import '@galaxycore/ai-chat/styles.css';
|
|
61
|
+
|
|
62
|
+
const gateway = createGatewayClient();
|
|
63
|
+
|
|
64
|
+
export function Conversation({ id, initialMessages = [] }: {
|
|
65
|
+
id: string;
|
|
66
|
+
initialMessages?: UIMessage[];
|
|
67
|
+
}) {
|
|
68
|
+
const transport = useMemo(() => gateway.createTransport(), []);
|
|
69
|
+
const chat = useAiChat({ id, transport, messages: initialMessages });
|
|
70
|
+
const [stopping, setStopping] = useState(false);
|
|
71
|
+
const pendingStop = useRef<Promise<void> | null>(null);
|
|
72
|
+
const controller = {
|
|
73
|
+
...chat,
|
|
74
|
+
stop() {
|
|
75
|
+
if (pendingStop.current) return pendingStop.current;
|
|
76
|
+
setStopping(true);
|
|
77
|
+
const operation = (async () => {
|
|
78
|
+
await chat.stop();
|
|
79
|
+
try { await gateway.cancel(id); }
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (!(error instanceof GatewayRequestError && error.status === 404)) throw error;
|
|
82
|
+
}
|
|
83
|
+
})().finally(() => { pendingStop.current = null; setStopping(false); });
|
|
84
|
+
pendingStop.current = operation;
|
|
85
|
+
return operation;
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
return <ChatPanel chat={controller}
|
|
89
|
+
title="工作助手"
|
|
90
|
+
style={{ height: 640 }}
|
|
91
|
+
composerProps={{ disabled: stopping }}
|
|
92
|
+
capabilities={{ regenerate: false }}
|
|
93
|
+
/>;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
停止确认完成前禁用所有发送入口,避免旧取消请求误取消下一轮。宿主有快捷提问按钮时也应使用同一个 `stopping` 状态。
|
|
98
|
+
|
|
99
|
+
新会话由宿主生成稳定 ID;恢复会话先 `await gateway.getConversation(id)`,再把 `messages` 作为 `initialMessages` 挂载。使用 `<Conversation key={accountScope + ':' + id} ... />` 隔离用户和会话。恢复结果仍在运行时,应先停止或等待原运行完成,再发下一轮;这是历史/运行时恢复,不是流重放。
|
|
100
|
+
|
|
101
|
+
`gateway.health()` 返回能力,宿主可据此显示功能。当前 pi 网关 `streaming/tools/cancel/sessionRestore=true`,`streamReplay/regenerate/attachments=false`;不要启用当前运行时不支持的重新生成或附件按钮。
|
|
102
|
+
|
|
103
|
+
助手回答默认渲染 Markdown,用户输入保留原文。Streamdown 随包自动安装;`renderText` 可覆盖默认渲染,`@galaxycore/ai-chat/markdown` 的 `MarkdownResponse` 入口保持兼容。包提供基础样式,无需 Tailwind;默认禁用远程图片加载,外链仅接受 HTTP(S)/站内绝对路径。数学公式、Mermaid 等插件由宿主按需接入。
|
|
104
|
+
|
|
105
|
+
## 三种使用层次
|
|
106
|
+
|
|
107
|
+
| 入口 | 用途 |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| `AiChat` | 完整面板;`options` 沿用 SDK `UseChatOptions<M>` |
|
|
110
|
+
| `useAiChat` + `ChatPanel` | 宿主管理会话、工具和上下文,复用默认面板 |
|
|
111
|
+
| `useAiChat` + `ChatMessages` + `ChatComposer` | 自由组合;完全自定义界面可使用 `/headless` |
|
|
112
|
+
|
|
113
|
+
`/gateway` 提供浏览器网关客户端;`/context` 提供可选上下文 Hook/Tray;`/markdown` 提供独立 Markdown renderer。服务器运行时位于独立包 `@galaxycore/ai-chat-gateway`,不要从浏览器引入该服务器包。
|
|
114
|
+
|
|
115
|
+
自定义 `renderers[part.type]` 优先于 `tools[toolName]`,再回退到默认展示。支持 text、reasoning、source、file 和静态/动态 tool parts;UI 支持的 part 不代表每个后端都提供该能力。默认工具卡展示状态,通用审批 UI 只应连接实现审批语义的后端;组件不会自行执行工具。
|
|
116
|
+
|
|
117
|
+
## 工具调用体验
|
|
118
|
+
|
|
119
|
+
默认工具调用以紧凑动作行显示,输入与结果点击展开。失败原因与审批保持可见,运行状态随实际消息更新。用 `toolPresentation` 定制动作名称、图标与摘要,或用现有 `tools` 完整替换业务工具界面。详情见 [组件 API](docs/api-reference.md#工具调用的渐进展示)。
|
|
120
|
+
|
|
121
|
+
示例的“工具体验”页面 `http://127.0.0.1:5178/#/examples/tool-activity` 可以切换五种工具状态;使用合成数据,不调用模型。
|
|
122
|
+
|
|
123
|
+
## 语音输入
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import { createBrowserSpeechAdapter } from '@galaxycore/ai-chat/voice';
|
|
127
|
+
const speechAdapter = createBrowserSpeechAdapter();
|
|
128
|
+
|
|
129
|
+
<ChatPanel chat={chat} composerProps={{
|
|
130
|
+
speech: { adapter: speechAdapter, lang: 'zh-CN' },
|
|
131
|
+
}} />;
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
用户主动点击后显示处理说明与确认;支持实时转写预览、完成和取消。识别文字只加入当前草稿,不自动发送。切换会话或卸载会中止录音,迟到结果不会进入另一会话。浏览器支持、安全上下文及权限限制会明确显示;内置 Web Speech 可能依赖浏览器厂商服务,可通过 `SpeechInputAdapter` 接入公司 ASR。完整契约与限制见 [语音输入](docs/voice-input.md)。
|
|
135
|
+
|
|
136
|
+
## 多平台上下文
|
|
137
|
+
|
|
138
|
+
业务系统通过 `ChatContextAdapter` 提供明确选中的领域数据。包不扫描整个页面,不读取全局输入框,也不绑定特定表格或图表库。
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
const context = useChatContext({ adapters: [ordersAdapter, chartAdapter] });
|
|
142
|
+
const transport = useMemo(() => gateway.createTransport({
|
|
143
|
+
body: () => ({ context: context.toRequestContext() }),
|
|
144
|
+
}), [context.toRequestContext]);
|
|
145
|
+
const chat = useAiChat({ id: conversationId, transport });
|
|
146
|
+
|
|
147
|
+
<ChatPanel chat={chat}
|
|
148
|
+
capabilities={{ regenerate: false }}
|
|
149
|
+
composerProps={{ context: <ContextTray context={context} /> }}
|
|
150
|
+
/>;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
上例的 `ordersAdapter`、`chartAdapter` 由宿主定义,Hook/Tray 从本包导入。上下文包含可序列化的 `id/kind/label/text/uri/metadata`,按适配器与 ID 去重,支持取消、预览、删除和宿主定位。默认限制数量、文字长度和字节数;后端另行验证身份与数据。内置文字选区适配器支持限定 `root`,表格、Canvas 图表和代码编辑器使用宿主 API。
|
|
154
|
+
|
|
155
|
+
完整示例、选区保留、权限边界和生命周期见 [平台适配](docs/platform-adapters.md)。上下文选择不会赋予模型修改页面或数据库的权限。
|
|
156
|
+
|
|
157
|
+
## 组合与视觉
|
|
158
|
+
|
|
159
|
+
- `header` / `headerActions` / `empty` / `composer` / `footer` 替换区域;传 `null` 隐藏支持的区域。
|
|
160
|
+
- `composerProps.context` / `toolbar` 可放宿主菜单、上下文标签或模型选择器。
|
|
161
|
+
- `theme="light | dark | auto"`,`variant="panel | sidebar | embedded"`,`density="comfortable | compact"`。
|
|
162
|
+
- CSS 变量覆盖品牌:`--gc-chat-bg`、`--gc-chat-surface`、`--gc-chat-text`、`--gc-chat-muted`、`--gc-chat-accent`、`--gc-chat-border`、`--gc-chat-radius`、`--gc-chat-font`。
|
|
163
|
+
- `labels={enUS}` 或局部覆盖文案;`ContextTray` 另有独立 `labels`。
|
|
164
|
+
- 完全沿用 Ant Design、shadcn、MUI 等设计系统时,只使用 Hook 和 transport,自行渲染 UI。
|
|
165
|
+
|
|
166
|
+
包内默认图标使用 **Lucide React**,按名称导入,不打包整个图标注册表。宿主可局部覆盖:
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import { SendHorizontal } from 'lucide-react';
|
|
170
|
+
import { ChatAppearanceProvider, ChatPanel } from '@galaxycore/ai-chat';
|
|
171
|
+
|
|
172
|
+
<ChatAppearanceProvider icons={{ send: SendHorizontal }}>
|
|
173
|
+
<ChatPanel chat={chat} className="product-assistant" density="compact" />
|
|
174
|
+
</ChatAppearanceProvider>;
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
```css
|
|
178
|
+
/* 在组件主题样式之后加载,直接覆盖组件根节点。 */
|
|
179
|
+
.product-assistant.gc-chat {
|
|
180
|
+
--gc-chat-accent: #5268cf;
|
|
181
|
+
--gc-chat-radius: 14px;
|
|
182
|
+
--gc-chat-font: inherit;
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
独立组件需置于 `.gc-chat` 主题作用域;父容器应有明确高度。Enter 发送、Shift+Enter 换行,中文输入法组合过程不会误发送;用户上翻阅读时不会被强制滚到底。
|
|
187
|
+
|
|
188
|
+
## 后端与会话
|
|
189
|
+
|
|
190
|
+
```text
|
|
191
|
+
业务页面 → 平台上下文适配器 → React AI Chat → ChatTransport
|
|
192
|
+
├─ UI Message Stream → Node 网关 → pi core → 公司模型接口
|
|
193
|
+
│ └─ RuntimeAdapter → Codex 等(待实现)
|
|
194
|
+
└─ AG-UI adapter → 已有 AG-UI 服务
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
网关在服务器执行 pi 的模型与工具循环,把运行时事件映射为 AI SDK UI Message Stream。模型提供商接口与 Agent 运行时是不同扩展点;更换模型不要求更换 UI,更换运行时也不要求重写平台上下文适配器。
|
|
198
|
+
|
|
199
|
+
`messages` 是 SDK 初始历史,不是受控 prop。浏览器组件不会写 localStorage;当前网关保存服务端会话,宿主通过客户端 API 加载。`chat.setMessages` 可用于显式更新历史,但不能用旧请求覆盖正在生成的会话。
|
|
200
|
+
|
|
201
|
+
通用 UI 的附件扩展需要宿主 `attachments.upload` 和支持 FileUIPart 的后端;当前 pi 网关不支持附件。`requestOptions` 可传单次参数,动态鉴权更适合 `gateway`/transport 的 `headers` 回调。模型密钥、业务工具权限和工作区访问均由服务端管理。
|
|
202
|
+
|
|
203
|
+
AG-UI 入口保留文本/工具基础子集,尚不支持 interrupt/resume、state snapshot、子 Agent、多模态及 reasoning;遇到不支持事件明确报错。运行时能力和 Codex 扩展边界见 [运行时设计](docs/runtime-design.md)。
|
|
204
|
+
|
|
205
|
+
## 交付与发布
|
|
206
|
+
|
|
207
|
+
- [快速开始](docs/quickstart.md)
|
|
208
|
+
- [组件与 API](docs/api-reference.md)
|
|
209
|
+
- [主题与界面定制](docs/ui-customization.md)
|
|
210
|
+
- [示例项目](docs/example-project.md)
|
|
211
|
+
- [Docker / Node 部署](docs/deployment.md)
|
|
212
|
+
- [完整方案](docs/design.md)
|
|
213
|
+
- [多系统统一接入目标与扩展路线](docs/unified-integration.md)
|
|
214
|
+
- [网关运行、工具注册与服务端部署](docs/gateway.md)
|
|
215
|
+
- [多平台上下文与界面适配](docs/platform-adapters.md)
|
|
216
|
+
- [接入、后端协议、上传与类型扩展](docs/integration.md)
|
|
217
|
+
- [已有应用迁移清单](docs/migration.md)
|
|
218
|
+
- [发布与安装](docs/publishing.md)
|
|
219
|
+
- [验证记录](docs/validation.md)
|
|
220
|
+
|
|
221
|
+
前端与网关分别打包、部署和发布,目标 registry 由发布方配置。执行 `npm pack` 可生成本地 tarball 并直接安装;使用内部 npm 服务或其他兼容 registry 都不影响组件 API 和运行时。
|
package/dist/ag-ui.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
import { ChatTransport, UIMessage, UIMessageChunk } from "ai";
|
|
3
|
+
//#region src/ag-ui.d.ts
|
|
4
|
+
type Resolvable<T> = T | (() => T | PromiseLike<T>);
|
|
5
|
+
type RecordValue = Record<string, unknown>;
|
|
6
|
+
export interface AgUiChatTransportOptions {
|
|
7
|
+
api: string;
|
|
8
|
+
headers?: Resolvable<HeadersInit>;
|
|
9
|
+
/** Extra RunAgentInput fields; prefer forwardedProps for backend-specific data. */
|
|
10
|
+
body?: Resolvable<RecordValue>;
|
|
11
|
+
credentials?: RequestCredentials;
|
|
12
|
+
fetch?: typeof globalThis.fetch;
|
|
13
|
+
/** Observability only. Unsupported events still fail explicitly. */
|
|
14
|
+
onEvent?: (event: Readonly<RecordValue>) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare class AgUiTransportError extends Error {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* AG-UI HTTP/SSE text + tool subset, projected into one SDK assistant message per run.
|
|
21
|
+
* Interrupts, snapshots, state patches, subagents and replay are intentionally unsupported.
|
|
22
|
+
* Aborting cancels HTTP; the gateway must propagate disconnects to its agent runtime.
|
|
23
|
+
*/
|
|
24
|
+
export declare class AgUiChatTransport<M extends UIMessage = UIMessage> implements ChatTransport<M> {
|
|
25
|
+
private readonly options;
|
|
26
|
+
constructor(options: AgUiChatTransportOptions);
|
|
27
|
+
reconnectToStream(): Promise<null>;
|
|
28
|
+
sendMessages(request: Parameters<ChatTransport<M>['sendMessages']>[0]): Promise<ReadableStream<UIMessageChunk>>;
|
|
29
|
+
private readEvents;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=ag-ui.d.ts.map
|