feat: 添加日历批量操作与客户端时区感知功能,优化前端 UI 交互体验
This commit is contained in:
@@ -185,6 +185,44 @@ interface Context {
|
||||
|
||||
---
|
||||
|
||||
## forwardedProps.client_time Schema
|
||||
|
||||
`RunAgentInput.forwardedProps` 支持透传客户端时间上下文。日历相关能力必须使用以下结构:
|
||||
|
||||
```typescript
|
||||
interface ForwardedProps {
|
||||
client_time?: {
|
||||
device_timezone: string; // IANA 时区,例如 "America/Los_Angeles"
|
||||
client_now_iso: string; // RFC3339 带偏移时间,例如 "2026-03-16T09:12:33-07:00"
|
||||
client_epoch_ms: number; // Unix epoch 毫秒
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### 时间来源优先级(固定)
|
||||
|
||||
后端在运行时按以下顺序解析事件时区:
|
||||
|
||||
1. `event_timezone`(工具调用显式传参)
|
||||
2. `forwardedProps.client_time.device_timezone`
|
||||
3. `users.profile.settings.timezone`
|
||||
4. `UTC`
|
||||
|
||||
### 约束
|
||||
|
||||
- `device_timezone` 必须是有效 IANA 时区。
|
||||
- `client_now_iso` 必须是 RFC3339 且包含时区偏移。
|
||||
- `client_epoch_ms` 必须是整数毫秒时间戳。
|
||||
- 业务代码不得使用服务器本地时区作为事件语义时区。
|
||||
|
||||
### 说明
|
||||
|
||||
- `forwardedProps` 是透传字段,不改变 AG-UI 主体协议结构。
|
||||
- 当 `forwardedProps.client_time` 缺失或非法时,运行时回退到 `users.profile.settings.timezone`。
|
||||
- 日历写入必须在最终工具调用中带上 `event_timezone`,不得依赖工具默认值。
|
||||
|
||||
---
|
||||
|
||||
## Validation Rules
|
||||
|
||||
Backend 实现了以下验证规则:
|
||||
@@ -203,6 +241,16 @@ Backend 实现了以下验证规则:
|
||||
| binary 不允许使用 data | `binary content data is not allowed` |
|
||||
| 单条消息最多 3 张附件 | `Too many attachments` |
|
||||
|
||||
### forwardedProps.client_time Validation
|
||||
|
||||
建议在后端校验层返回以下错误(按业务实现映射到 4xx):
|
||||
|
||||
| Rule | Error Message |
|
||||
|------|---------------|
|
||||
| `device_timezone` 非 IANA 时区 | `invalid client_time.device_timezone` |
|
||||
| `client_now_iso` 无法解析或缺少时区 | `invalid client_time.client_now_iso` |
|
||||
| `client_epoch_ms` 非整数毫秒值 | `invalid client_time.client_epoch_ms` |
|
||||
|
||||
---
|
||||
|
||||
## Request Example
|
||||
@@ -292,6 +340,32 @@ Backend 实现了以下验证规则:
|
||||
}
|
||||
```
|
||||
|
||||
### 带 forwardedProps.client_time 的请求
|
||||
|
||||
```json
|
||||
{
|
||||
"threadId": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"runId": "run-004",
|
||||
"state": {},
|
||||
"messages": [
|
||||
{
|
||||
"id": "msg-001",
|
||||
"role": "user",
|
||||
"content": "帮我明天早上9点创建一个日历"
|
||||
}
|
||||
],
|
||||
"tools": [],
|
||||
"context": [],
|
||||
"forwardedProps": {
|
||||
"client_time": {
|
||||
"device_timezone": "America/Los_Angeles",
|
||||
"client_now_iso": "2026-03-16T09:12:33-07:00",
|
||||
"client_epoch_ms": 1773658353000
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Response
|
||||
@@ -454,3 +528,4 @@ interface UiSchemaRenderer {
|
||||
- backend 验证通过后,会将 binary url 转换为内部存储路径
|
||||
- `tools` 是前端工具通道字段;当前后端运行时不基于该字段构造后端工具 prompt
|
||||
- `RunAgentInput` 同时接受 camelCase 与 snake_case 别名输入(推荐统一使用 camelCase)
|
||||
- 日历能力依赖 `forwardedProps.client_time` 透传设备时间上下文;缺失时回退用户 profile 时区
|
||||
|
||||
Reference in New Issue
Block a user