feat(history): 消息正向增量拉取(A5) — GET /sessions/{id}/messages?after=
- history/list_after.go: ListAfter(升序, created_at>after, 走覆盖索引, rowid兜底同毫秒) - HistoryStore 新增 ListAfter(store+fakes同步) - gateway history.go: handleListMessages解析after分流; after+before互斥400; 负数/非数字400 - 新增测试(list_after/history_after), build/vet/test绿+交叉编译 - Docs/api-client v0.26 + api-reference §3.4 同步
This commit is contained in:
1 parent
026b27b310
commit
f43751fd07
11 files changed
+407
-35
No files matched your search
@@ -297,8 +297,9 @@ curl -s http://<host>:8080/api/v1/personas -H "Authorization: Bearer $TOKEN" -H
|
||||
|------|------|:---:|------|------|
|
||||
| `limit` | int | 否 | 50 | 页大小,需 `>=1`,钳制上限 200(`maxPageLimit`);非法回 400 |
|
||||
| `before` | int64 | 否 | 0 | 游标:上一页最旧消息的 `createdAt`(Unix 毫秒),向更旧翻页 |
|
||||
| `after` | int64 | 否 | 0 | **正向增量**(A5):返回 `created_at > after`,**升序**;与 `before` **互斥**(同传 400);负数/非数字回 400 |
|
||||
| `platform` | string | 否 | - | 来源平台过滤(design/16 §4.4)。Web 端不传 = 全量共享主会话;IM 传本平台(如 `telegram`)只拉本渠道消息 |
|
||||
- **响应**:`200` `{"data":[<historyMessage>...]}`,**按时间倒序**(newest first);需 `reverse()` 渲染。
|
||||
- **响应**:`200` `{"data":[<historyMessage>...]}`;**`before` 时按时间倒序**(newest first,需 `reverse()` 渲染);**`after` 时按时间升序**(最旧在前,可直接顺序渲染/追加)。
|
||||
|
||||
`historyMessage` 全字段:
|
||||
| 字段 | 类型 | 说明 |
|
||||
@@ -321,7 +322,7 @@ curl -s http://<host>:8080/api/v1/personas -H "Authorization: Bearer $TOKEN" -H
|
||||
{"data":[{"id":"m1","sessionId":"web","role":"assistant","content":"你好","mode":"normal","mood":"calm","platform":"web","deviceId":"web:chrome:a1b2c3","createdAt":1753...}]}
|
||||
```
|
||||
|
||||
- **错误**:`400`(`limit`/`before` 非法、`id` 缺失);`501` `{"error":{"code":"not_implemented","message":"会话历史服务未配置(未注入 HistoryStore)"}}`;`500` `{"error":{"code":"messages_failed",...}}`。
|
||||
- **错误**:`400`(`limit`/`before`/`after` 非法、`before`+`after` 同传、`id` 缺失);`501` `{"error":{"code":"not_implemented","message":"会话历史服务未配置(未注入 HistoryStore)"}}`;`500` `{"error":{"code":"messages_failed",...}}`。
|
||||
- **备注**:热分页(design/16 §2.2,§5.1)。`thinking` 只在本 owner/admin 端点可见;WS 回放/广播已剥离。curl:
|
||||
|
||||
```bash
|
||||
|
||||
Reference in new issue
Block a user