refactor: 重构聊天模块支持 SSE 断线重连及用户上下文隔离

This commit is contained in:
zl-q
2026-03-30 09:06:10 +08:00
parent 1aac62f39e
commit 4285b4ec80
28 changed files with 1624 additions and 658 deletions
@@ -25,16 +25,16 @@ class ChatApiImpl implements ChatApi {
@override
Future<Stream<String>> streamRunEvents(
String threadId, {
required String runId,
String? lastEventId,
}) {
final headers = <String, String>{'Accept': 'text/event-stream'};
if (lastEventId != null && lastEventId.isNotEmpty) {
headers['Last-Event-ID'] = lastEventId;
}
return _apiClient.getSseLines(
'/api/v1/agent/runs/$threadId/events',
headers: headers,
);
final encodedRunId = Uri.encodeQueryComponent(runId);
final path = '/api/v1/agent/runs/$threadId/events?runId=$encodedRunId';
return _apiClient.getSseLines(path, headers: headers);
}
@override