refactor(server): move OneTalk summaries to internal network

This commit is contained in:
YBF
2026-09-07 19:12:03 +08:00
parent 6e8eca944d
commit 161e166b2c
36 changed files with 772 additions and 1261 deletions
+3 -22
View File
@@ -14,7 +14,7 @@ Access-Control-Allow-Credentials: true
Vary: Origin
```
OPTIONS 允许 GET、OPTIONS 和 Content-Type、X-Mind-Purpose。若浏览器的 Access-Control-Request-Headers 包含任一其它 header(比较不区分大小写)则返回 403;不允许的 Origin 同样返回 403,且不会调用读取服务或授权读取。
OPTIONS 允许 GET、OPTIONS 和 Content-Type。若浏览器的 Access-Control-Request-Headers 包含任一其它 header(比较不区分大小写)则返回 403;不允许的 Origin 同样返回 403,且不会调用读取服务或授权读取。
```ts
type Scope = {
@@ -172,28 +172,9 @@ type CenterMessage =
响应绝不暴露原始数字或原始顶层字段,包括原始 contentType、readStatus、messageStatus、unreadCount、messageRevision、conversationRevision、updatedAtMs、recalledAtMs、deliveryStatus、顶层 text、顶层 subject 和 attachmentSummaryText。
## 纪要读取门槛
## 内部纪要读取
普通页面读取可省略时间窗,并可读取已持久化的部分历史。Mind 读取纪要窗口时必须同时提供两个时间端点,并发送精确 header:
```http
X-Mind-Purpose: communication_summary_read
```
若该会话 historyComplete 为 falseBright 返回:
```http
503 Service Unavailable
Retry-After: 30
```
```ts
{
error: {
code: "history_incomplete";
}
}
```
本页面 API 只接受 Mind Session/Cookie 授权;`Authorization``X-Mind-Purpose``X-Mind-Workspace-Id` 不会选择另一条读取路径。供 Mind 后台生成纪要的内部 Docker 网络接口、固定时间窗和 `history_incomplete` 规则见 [OneTalk 内部纪要读取接口](./onetalk-summary-internal-api.md)。
## 分页与错误
+41
View File
@@ -0,0 +1,41 @@
# OneTalk 内部纪要读取接口
> 本文交付给 trade-mind 所有者。它描述 Center 已发布的内部 Docker listenerMind 代码和部署改动不在本仓库。
## 前提与安全边界
Center 与 Mind 容器必须运行在同一 Docker daemon,并共同加入名为 `trade-message-center-summary` 的 Docker `internal` 网络。该网络的成员资格是唯一访问控制:加入网络的任意容器可读取任意已知 `channelAccountId + conversationId` 的摘要历史;它不提供 workspace、用户、账号或会话级授权,也不防护 Docker socket 持有者或宿主机 root。
Center 运行在仅供其公网发布与 egress 的 `trade-message-center-public` bridge 网络,并额外挂载 summary internal 网络;其它业务容器不得加入前者来访问 Center。Center 仍通过宿主机发布 public `7878`;内部 `7777` 绝不配置 Docker `--publish` 或 Compose `ports``EXPOSE 7777` 只是镜像元数据,不会对外发布端口。
## Mind 请求
```http
GET http://trade-message-center:7777/api/bright/onetalk/accounts/:channelAccountId/conversations/:conversationId/messages?fromSentAtMs=:inclusiveEpochMs&toSentAtMs=:exclusiveEpochMs&cursor=:opaqueCursor&limit=:1to100
```
- `fromSentAtMs``toSentAtMs` 必填,均为 safe integer,窗口为 `[fromSentAtMs,toSentAtMs)`,且前者必须小于后者。
- `cursor` 仅可原样回传上一页 `nextCursor``limit` 默认为 50,范围 1..100。
- 不发送 Cookie、`Authorization``X-Mind-Purpose``X-Mind-Workspace-Id`。Center 不读取这些头,也不会回调 Mind 的授权接口。
- 成功响应只含 `conversationId`、语义化 `messages``page`;没有 `scope``workspaceId``mindUserId`、binding 或授权版本。Mind 以自己的调用上下文关联 workspace。
- `historyComplete=false` 时返回 `503 { error: { code: "history_incomplete" } }``Retry-After: 30`。其它分页、内容投影和错误码与 [Bright OneTalk 会话读取 API](./bright-conversation-list-api.md) 的消息读取契约一致。
## 部署与验收
Center 的 release workflow 会创建或验证该网络为 `internal`,并在启动后将容器 `trade-message-center` 接入其中。Mind 部署所有者需要在同一 Docker daemon 执行等价操作:
```bash
docker network connect trade-message-center-summary <mind-container-name>
```
发布后至少验证:
```bash
docker network inspect trade-message-center-summary
docker network inspect trade-message-center-public
docker port trade-message-center
docker exec <mind-container-name> \
curl -fsS 'http://trade-message-center:7777/api/bright/onetalk/accounts/<account>/conversations/<conversation>/messages?fromSentAtMs=<from>&toSentAtMs=<to>&limit=1'
```
`docker port trade-message-center` 不得出现 `7777`。若 Center 回滚到不含内部 listener 的旧镜像,Mind 必须同时回滚其 base URL/请求头;共享网络不应在回滚时删除。