实现 Booking Excel 预处理接入 SuperAgent

This commit is contained in:
andy
2026-07-20 00:32:01 +07:00
parent b7b04cf1ac
commit d1955f5097
45 changed files with 2955 additions and 10 deletions

View File

@@ -20,6 +20,7 @@ M001 已完成 AgentBus 邮件来源事实入库M004 已完成 Debug EML 人
AgentBus WebSocket 收到邮件
→ 写入 SourceMessage Inbox
→ 创建 SuperAgent dispatch / outbox 记录
→ M011 CP3 开启时worker 对 Excel 附件做 Booking 高亮行预处理
→ 异步 worker 调用 SuperAgent Open API
→ 保存 session_id / run_id / raw_answer / parsed_json / 状态
→ 等待 SuperAgent 通过现有任务结果通知接口或 MCP 提交业务结果
@@ -35,6 +36,7 @@ AgentBus WebSocket 收到邮件
- Debug EML 链路和生产自动分发链路复用 SuperAgent Open API client但运行记录表和 provider 必须区分。
- SuperAgent 返回内容只能保存为外部能力输出,不直接改变业务最终状态。
- 业务任务创建继续依赖 SuperAgent 后续调用本系统任务结果通知接口或 MCP 工具。
- M011 已在 Debug EML 和 AgentBus dispatch 链路验证 `attachment_extractions[]` 结构AgentBus worker 调用 SuperAgent 前追加该字段由独立配置控制,生产链路默认关闭。
## 3. 触发规则
@@ -124,6 +126,8 @@ KEY idx_dispatch_external_message (hotel_id, external_message_id)
| `agentbus.superagent-dispatch.lock-ttl` | `5m` | worker 处理锁有效期 |
| `agentbus.superagent-dispatch.initial-backoff` | `30s` | 首次失败后的重试等待时间 |
| `agentbus.superagent-dispatch.max-backoff` | `15m` | 最大重试等待时间 |
| `agentbus.superagent-dispatch.include-booking-excel-extractions` | `false` | M011 CP3是否在调用 SuperAgent 前追加 Booking Excel 高亮行预处理结果 |
| `agentbus.superagent-dispatch.booking-excel-download-max-size` | `10MB` | M011 CP3worker 读取单个 Excel 附件的最大大小 |
| `superagent.open-api.agentbus-external-subject-id` | `th-hotel-agentbus-source-message` | AgentBus 自动分发创建 session 时使用的 external subject id |
| `superagent.open-api.sse-recovery-max-attempts` | `5` | SSE 断流恢复最大次数 |
@@ -133,6 +137,8 @@ KEY idx_dispatch_external_message (hotel_id, external_message_id)
AgentBus 自动分发发送给 SuperAgent 的 message 第一版应基于 SourceMessage 原始 payload 构造。Debug EML 发送给 SuperAgent 的 `agentbus_like_payload` 也按 AgentBus Outlook-like 主结构组装,并包含 `reply_policy.mode``reply_policy.final_only`Debug EML V1 暂用 `mode=manual``final_only=true`,不能再使用旧的 Debug 专属 `debug_only`。Debug 来源区分仍保留在 SourceMessage `provider=DEBUG_EML_UPLOAD`、payload 表 `schemaVersion=debug-eml-upload-v1` 和 Open API metadata 中,不混入主 payload。后续 AgentBus 明确真实 `reply_policy.mode` 枚举后Debug EML 和实时链路需要一起对齐。
AgentBus 开启 M011 CP3 时message 主 payload 会追加 `attachment_extractions[]`。该字段只包含被识别为 Booking Update / Booking Surcharge 的高亮行安全摘要,以及人员名单类 Excel、附件读取失败或解析失败的安全排除结果 / warning不包含整份 Excel、完整附件 URL、OSS 签名参数、API Key、Cookie 或 Secret。详细契约见 `docs/project/requirements/M011-booking-excel-pre-superagent-enrichment-v1.md`
发送 metadata 建议包含:
```json
@@ -214,6 +220,7 @@ RUNNING / RETRYABLE_FAILED
- 新增 `SuperAgentDispatchRunEntity`、Mapper、Repository、Service 和配置类。
- AgentBus 捕获 `AGENTBUS + RECEIVED` 后,在配置开启时幂等创建 dispatch run重复投递可补偿缺失 outbox。
- worker 处理 `PENDING / RETRYABLE_FAILED / 锁已过期 RUNNING`,调用共享 SuperAgent Open API client。
- M011 CP3 已接入 worker配置开启时读取 SourceMessage 附件 URL下载 Excel 字节,复用 Booking Excel 预处理服务,并把非空 `attachment_extractions[]` 追加到发给 SuperAgent 的主 payload。
- Open API client 支持 `Content-Location``run_id`、SSE `id``Last-Event-ID``GET /runs/{run_id}``GET /runs/{run_id}/events` 恢复。
- Debug EML 继续复用共享 Open API client。
- dispatch 成功保存 session、run、last event id、raw answer、parsed json、trace 摘要和状态。