refactor: unify skills+cli runtime and streamline ag-ui flow

This commit is contained in:
qzl
2026-04-22 17:09:37 +08:00
parent eeed737949
commit 4d55df45ab
111 changed files with 4858 additions and 3264 deletions
@@ -210,16 +210,42 @@ extension _ChatBlocEvents on ChatBloc {
if (_shouldRefreshCalendarForTool(event)) {
unawaited(_refreshCalendarAfterToolMutation());
}
emit(
state.copyWith(
items: state.items.map((item) {
if (item is ToolCallItem && item.id == event.toolCallId) {
return item.copyWith(status: ToolCallStatus.completed);
}
return item;
}).toList(),
),
final timestamp = DateTime.now();
final items = state.items.map((item) {
if (item is ToolCallItem && item.id == event.toolCallId) {
return item.copyWith(status: ToolCallStatus.completed);
}
return item;
}).toList();
final uiSchema = event.uiSchema;
if (uiSchema != null) {
_upsertToolResultUi(items, event.toolCallId, uiSchema, timestamp);
}
emit(state.copyWith(items: items));
}
void _upsertToolResultUi(
List<ChatListItem> items,
String toolCallId,
Map<String, dynamic> uiSchema,
DateTime timestamp,
) {
final uiItemId = '$toolCallId-ui';
final uiItem = ToolResultItem(
id: uiItemId,
callId: toolCallId,
uiSchema: uiSchema,
timestamp: timestamp,
sender: MessageSender.ai,
);
final existingIndex = items.indexWhere((item) => item.id == uiItemId);
if (existingIndex >= 0) {
items[existingIndex] = uiItem;
return;
}
items.add(uiItem);
}
void _handleToolCallError(ToolCallErrorEvent event) {