@sophonsai/agent-embed-react 0.1.0 → 0.2.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/README.md +6 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,16 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## 应用接入
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
最终 iframe 地址是 `endpoint + baseUrl + '/' + encodeURIComponent(token)`。
|
|
5
|
+
传入 SAAP 服务地址 `endpoint` 和智能体的应用接入凭证 `token`。
|
|
7
6
|
|
|
8
7
|
```tsx
|
|
9
8
|
<AgentEmbed endpoint='https://agent.example.com' token='应用接入Token' style={{ height: 600 }} />
|
|
10
9
|
```
|
|
11
10
|
|
|
12
|
-
不再接收完整 `url`、旧 `initConfig`、Agent ID 或平台用户凭证。
|
|
13
|
-
`threadId`、外观配置、实例命令和事件回调继续支持。
|
|
14
|
-
|
|
15
11
|
## 安装
|
|
16
12
|
|
|
17
13
|
```bash
|
|
@@ -36,7 +32,7 @@ bun add @sophonsai/agent-embed-react react
|
|
|
36
32
|
pnpm dev:agent-embed
|
|
37
33
|
```
|
|
38
34
|
|
|
39
|
-
命令会复用或启动
|
|
35
|
+
命令会复用或启动 SAAP 开发服务(3040)和 Agent Embed Playground(4171),就绪后打开浏览器。Playground 支持服务地址、应用接入 Token、appearance、实例命令和 bridge 生命周期日志。
|
|
40
36
|
|
|
41
37
|
## 快速开始
|
|
42
38
|
|
|
@@ -86,7 +82,6 @@ export function ChatPage() {
|
|
|
86
82
|
| ------------------- | ----------------------- | ---- | ------------------------------------- |
|
|
87
83
|
| `endpoint` | `string` | 是 | 服务地址 |
|
|
88
84
|
| `token` | `string` | 是 | Agent 应用接入凭证 |
|
|
89
|
-
| `baseUrl` | `string` | 否 | 嵌入路径,默认 `/e/v1/embed` |
|
|
90
85
|
| `threadId` | `string` | 否 | 初始会话 ID |
|
|
91
86
|
| `runtime_variables` | `AgentRuntimeVariables` | 否 | 新会话绑定的运行时变量,值必须为 JSON |
|
|
92
87
|
| `appearance` | `AgentAppearance` | 否 | 主题、字号和头部按钮配置 |
|
|
@@ -105,12 +100,11 @@ export function ChatPage() {
|
|
|
105
100
|
<AgentEmbed
|
|
106
101
|
endpoint='https://agent.example.com'
|
|
107
102
|
token='应用接入Token'
|
|
108
|
-
baseUrl='/e/v1/embed'
|
|
109
103
|
threadId='可选初始会话ID'
|
|
110
104
|
/>
|
|
111
105
|
```
|
|
112
106
|
|
|
113
|
-
|
|
107
|
+
初始化配置与回调只在挂载时读取;需要切换服务、token、会话或回调时,修改组件 `key` 重新挂载:
|
|
114
108
|
|
|
115
109
|
```tsx
|
|
116
110
|
<AgentEmbed key={`${endpoint}:${token}:${threadId}`} endpoint={endpoint} token={token} threadId={threadId} />
|
|
@@ -132,7 +126,7 @@ type AgentAppearance = {
|
|
|
132
126
|
}
|
|
133
127
|
```
|
|
134
128
|
|
|
135
|
-
`header.themeSettingButton` 默认值为 `
|
|
129
|
+
`header.themeSettingButton` 默认值为 `true`,显式设置为 `false` 时隐藏主题设置按钮。
|
|
136
130
|
|
|
137
131
|
可用主题:
|
|
138
132
|
|
|
@@ -247,7 +241,7 @@ agent?.focusInput()
|
|
|
247
241
|
| `onConcurrentSend` | 无 | 回复生成期间再次发送消息 |
|
|
248
242
|
| `onEvent` | `AgentServerEvent` | 接收原始服务端事件 |
|
|
249
243
|
| `onSessionContextReady` | `AgentSessionContext` | 会话上下文可用,包含 `threadId` 和 `turnId` |
|
|
250
|
-
| `
|
|
244
|
+
| `onToolCallReady` | `AgentToolCallReadyEvent`, `AgentSessionEventContext` | 创建一个工具调用 |
|
|
251
245
|
| `onToolApprovalRequested` | `AgentToolApprovalRequestedEvent`, `AgentSessionEventContext` | 一组工具调用需要确认 |
|
|
252
246
|
| `onToolCallStarted` | `AgentToolCallStartedEvent`, `AgentSessionEventContext` | 工具调用开始 |
|
|
253
247
|
| `onToolCallProgressUpdated` | `AgentToolCallProgressUpdatedEvent`, `AgentSessionEventContext` | 工具调用进度更新 |
|
|
@@ -255,6 +249,7 @@ agent?.focusInput()
|
|
|
255
249
|
| `onToolCallSucceeded` | `AgentToolCallSucceededEvent`, `AgentSessionEventContext` | 工具调用成功 |
|
|
256
250
|
| `onToolCallFailed` | `AgentToolCallFailedEvent`, `AgentSessionEventContext` | 工具调用失败 |
|
|
257
251
|
| `onToolCallCancelled` | `AgentToolCallCancelledEvent`, `AgentSessionEventContext` | 工具调用取消 |
|
|
252
|
+
| `onClientToolRequest` | `AgentToolCallStartedEvent`, `AgentSessionEventContext` | 客户端工具执行请求;需领取并回传结果,或使用 SDK `clientTools` 自动执行 |
|
|
258
253
|
| `onClientActionRequest` | `AgentClientActionRequestEvent`, `AgentSessionEventContext` | 智能体请求宿主执行客户端动作 |
|
|
259
254
|
| `onUserFeedbackConsumed` | `AgentUserFeedbackConsumedEvent`, `AgentSessionEventContext` | 用户反馈已被处理 |
|
|
260
255
|
| `onUserSteerConsumed` | `AgentUserSteerConsumedEvent`, `AgentSessionEventContext` | 用户 steer 指令已被处理 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sophonsai/agent-embed-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React adapter for Sophon Agent Embed.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@sophonsai/agent-embed-sdk": "0.
|
|
28
|
+
"@sophonsai/agent-embed-sdk": "0.2.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": ">=18"
|