refactor: 重构 Tool Result 契约,移除 ui_hints 统一使用 result 字段

- ToolAgentOutput 移除 result_summary 和 ui_hints,统一使用 result 字段
- 日历/用户查找工具移除 ui_hints 输出,改为机器可读的结构化结果
- Agent History 移除 tool 消息的 ui_hints 处理逻辑
- App 版本检查改为 manifest.json 方式,支持多渠道发布
- 更新 settings 配置和测试用例适配新结构
This commit is contained in:
qzl
2026-03-17 12:18:09 +08:00
parent c26cdbbc27
commit aa30fe0ce6
44 changed files with 984 additions and 655 deletions
@@ -264,24 +264,10 @@ class ChatBloc extends Cubit<ChatState> {
}
void _handleToolCallResult(ToolCallResultEvent event) {
final timestamp = DateTime.now();
final items = state.items.where((item) {
return !(item is ToolCallItem && item.id == event.toolCallId);
}).toList();
if (event.uiSchema != null) {
_upsertById(
items,
ToolResultItem(
id: event.messageId,
callId: event.toolCallId,
uiSchema: event.uiSchema!,
timestamp: timestamp,
sender: MessageSender.ai,
),
);
}
emit(state.copyWith(items: items));
}
@@ -326,7 +312,7 @@ class ChatBloc extends Cubit<ChatState> {
);
}
if (msg.uiSchema != null) {
if (!isTool && msg.uiSchema != null) {
converted.add(
ToolResultItem(
id: '${msg.id}-ui',
@@ -444,15 +430,6 @@ class ChatBloc extends Cubit<ChatState> {
}
}
void _upsertById(List<ChatListItem> items, ChatListItem nextItem) {
final index = items.indexWhere((item) => item.id == nextItem.id);
if (index >= 0) {
items[index] = nextItem;
return;
}
items.add(nextItem);
}
Future<String> transcribeAudioFile(String filePath) {
return _service.transcribeAudio(filePath);
}
@@ -2,32 +2,41 @@ import 'package:social_app/core/api/i_api_client.dart';
class AppVersionResponse {
final bool hasUpdate;
final String latestVersion;
final int latestBuild;
final String minRequiredVersion;
final String latestVersionName;
final int latestVersionCode;
final int minSupportedVersionCode;
final String updateType;
final String? downloadUrl;
final String? releaseNotes;
final String? fileName;
final int? fileSize;
final String? sha256;
AppVersionResponse({
required this.hasUpdate,
required this.latestVersion,
required this.latestBuild,
required this.minRequiredVersion,
required this.latestVersionName,
required this.latestVersionCode,
required this.minSupportedVersionCode,
required this.updateType,
this.downloadUrl,
this.releaseNotes,
this.fileName,
this.fileSize,
this.sha256,
});
factory AppVersionResponse.fromJson(Map<String, dynamic> json) {
return AppVersionResponse(
hasUpdate: json['has_update'] as bool,
latestVersion: json['latest_version'] as String,
latestBuild: json['latest_build'] as int,
minRequiredVersion: json['min_required_version'] as String,
latestVersionName: json['latest_version_name'] as String,
latestVersionCode: json['latest_version_code'] as int,
minSupportedVersionCode: json['min_supported_version_code'] as int,
updateType: json['update_type'] as String,
downloadUrl: json['download_url'] as String?,
releaseNotes: json['release_notes'] as String?,
fileName: json['file_name'] as String?,
fileSize: json['file_size'] as int?,
sha256: json['sha256'] as String?,
);
}
}
@@ -39,20 +48,18 @@ class SettingsApi {
SettingsApi(this._client);
Future<AppVersionResponse> checkUpdates({
required int currentBuild,
String? currentVersion,
required int currentVersionCode,
required String currentVersionName,
String platform = 'android',
String channel = 'release',
}) async {
final params = <String, String>{
'platform': platform,
'current_build': currentBuild.toString(),
'channel': channel,
'current_version_code': currentVersionCode.toString(),
'current_version_name': currentVersionName,
};
if (currentVersion != null) {
params['current_version'] = currentVersion;
}
final queryString = params.entries
.map((e) => '${e.key}=${e.value}')
.join('&');
final queryString = Uri(queryParameters: params).query;
final response = await _client.get('$_prefix/check-updates?$queryString');
return AppVersionResponse.fromJson(response.data);
}
@@ -532,8 +532,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
try {
final settingsApi = sl<SettingsApi>();
final result = await settingsApi.checkUpdates(
currentBuild: AppConstants.build,
currentVersion: AppConstants.version,
currentVersionCode: AppConstants.build,
currentVersionName: AppConstants.version,
platform: 'android',
);
@@ -545,8 +545,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
}
final message = result.updateType == 'required'
? '有新版本可用 (${result.latestVersion}),请立即更新'
: '发现新版本 (${result.latestVersion}),是否更新?';
? '有新版本可用 (${result.latestVersionName}),请立即更新'
: '发现新版本 (${result.latestVersionName}),是否更新?';
final shouldUpdate = await showDialog<bool>(
context: context,