feat: AG-UI 协议对齐与路由导航功能
- 前端: 添加 SSE 流式支持、stateSnapshot 事件、路由导航工具 - 前端: 实现工具调用审批流程,支持 pending 状态展示 - 后端: Agent 状态管理与会话持久化相关重构 - 文档: 新增 agent-agui-full-alignance 设计文档 - 测试: 补充相关单元测试和集成测试
This commit is contained in:
+115
-34
@@ -714,43 +714,29 @@
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"session_id": "string? (optional, 为空时自动创建会话)",
|
||||
"prompt": "string (1-5000 chars)"
|
||||
"threadId": "string (UUID, required)",
|
||||
"runId": "string (required)",
|
||||
"parentRunId": "string? (optional)",
|
||||
"state": {},
|
||||
"messages": [
|
||||
{
|
||||
"id": "string",
|
||||
"role": "user",
|
||||
"content": "string | InputContent[]"
|
||||
}
|
||||
],
|
||||
"tools": [],
|
||||
"context": [],
|
||||
"forwardedProps": {}
|
||||
}
|
||||
```
|
||||
|
||||
**Response:** 202 Accepted
|
||||
```json
|
||||
{
|
||||
"task_id": "string",
|
||||
"session_id": "string",
|
||||
"created": true
|
||||
}
|
||||
```
|
||||
|
||||
**Errors:**
|
||||
- 401: 未认证
|
||||
- 403: 非会话 owner
|
||||
- 422: 请求参数无效
|
||||
|
||||
---
|
||||
|
||||
### POST /agent/runs/{session_id}/resume
|
||||
|
||||
恢复一次等待工具结果的 Agent 运行(需要认证)。
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"tool_call_id": "string"
|
||||
}
|
||||
```
|
||||
|
||||
**Response:** 202 Accepted
|
||||
```json
|
||||
{
|
||||
"task_id": "string",
|
||||
"session_id": "string",
|
||||
"taskId": "string",
|
||||
"threadId": "string",
|
||||
"runId": "string",
|
||||
"created": false
|
||||
}
|
||||
```
|
||||
@@ -762,12 +748,54 @@
|
||||
|
||||
---
|
||||
|
||||
### GET /agent/runs/{session_id}/events
|
||||
### POST /agent/runs/{thread_id}/resume
|
||||
|
||||
恢复一次等待工具结果的 Agent 运行(需要认证)。
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"threadId": "string (must match path thread_id)",
|
||||
"runId": "string",
|
||||
"parentRunId": "string? (optional)",
|
||||
"state": {},
|
||||
"messages": [
|
||||
{
|
||||
"id": "string",
|
||||
"role": "tool",
|
||||
"toolCallId": "string",
|
||||
"content": "string (JSON string, AG-UI ToolMessage content)"
|
||||
}
|
||||
],
|
||||
"tools": [],
|
||||
"context": [],
|
||||
"forwardedProps": {}
|
||||
}
|
||||
```
|
||||
|
||||
**Response:** 202 Accepted
|
||||
```json
|
||||
{
|
||||
"taskId": "string",
|
||||
"threadId": "string",
|
||||
"runId": "string",
|
||||
"created": false
|
||||
}
|
||||
```
|
||||
|
||||
**Errors:**
|
||||
- 401: 未认证
|
||||
- 403: 非会话 owner
|
||||
- 422: 请求参数无效
|
||||
|
||||
---
|
||||
|
||||
### GET /agent/runs/{thread_id}/events
|
||||
|
||||
订阅 Agent SSE 事件流(需要认证)。
|
||||
|
||||
**Headers:**
|
||||
- `Last-Event-ID` (optional): 断点续传游标
|
||||
- `Last-Event-ID` (optional): 断点续传游标,格式 `^\d+-\d+$`
|
||||
|
||||
**Response:** 200 OK
|
||||
`Content-Type: text/event-stream`
|
||||
@@ -775,7 +803,7 @@
|
||||
```text
|
||||
id: 2-0
|
||||
event: RUN_STARTED
|
||||
data: {"session_id":"..."}
|
||||
data: {"type":"RUN_STARTED","threadId":"...","runId":"..."}
|
||||
|
||||
```
|
||||
|
||||
@@ -785,6 +813,59 @@ data: {"session_id":"..."}
|
||||
|
||||
---
|
||||
|
||||
### GET /agent/runs/{thread_id}/history
|
||||
|
||||
按“天”读取指定会话的历史快照(需要认证)。
|
||||
|
||||
**Query:**
|
||||
- `before` (optional, `YYYY-MM-DD`): 读取该日期之前的最近一天
|
||||
|
||||
**Response:** 200 OK
|
||||
```json
|
||||
{
|
||||
"type": "STATE_SNAPSHOT",
|
||||
"threadId": "string",
|
||||
"snapshot": {
|
||||
"scope": "history_day",
|
||||
"threadId": "string",
|
||||
"day": "2026-03-07",
|
||||
"hasMore": true,
|
||||
"messages": []
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Errors:**
|
||||
- 401: 未认证
|
||||
- 403: 非会话 owner
|
||||
|
||||
---
|
||||
|
||||
### GET /agent/history
|
||||
|
||||
读取当前用户历史快照(需要认证)。当未传 `threadId` 时,默认返回最近活跃会话的按天快照。
|
||||
|
||||
**Query:**
|
||||
- `threadId` (optional): 指定会话
|
||||
- `before` (optional, `YYYY-MM-DD`): 读取该日期之前的最近一天
|
||||
|
||||
**Response:** 200 OK
|
||||
```json
|
||||
{
|
||||
"type": "STATE_SNAPSHOT",
|
||||
"threadId": "string?",
|
||||
"snapshot": {
|
||||
"scope": "history_day",
|
||||
"threadId": "string?",
|
||||
"day": "2026-03-07",
|
||||
"hasMore": false,
|
||||
"messages": []
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Infra
|
||||
|
||||
### GET /infra/health
|
||||
|
||||
Reference in New Issue
Block a user