chore: clean up legacy tool/UI code paths and remove unused events

This commit is contained in:
qzl
2026-04-22 17:33:12 +08:00
parent 4d55df45ab
commit ef931ee73c
7 changed files with 1 additions and 92 deletions
-24
View File
@@ -9,7 +9,6 @@ class AgUiEventTypeWire {
static const toolCallArgs = 'TOOL_CALL_ARGS';
static const toolCallEnd = 'TOOL_CALL_END';
static const toolCallResult = 'TOOL_CALL_RESULT';
static const toolCallError = 'TOOL_CALL_ERROR';
}
enum AgUiEventType {
@@ -23,7 +22,6 @@ enum AgUiEventType {
toolCallArgs,
toolCallEnd,
toolCallResult,
toolCallError,
unknown,
}
@@ -38,7 +36,6 @@ const _wireToTypeMap = {
AgUiEventTypeWire.toolCallArgs: AgUiEventType.toolCallArgs,
AgUiEventTypeWire.toolCallEnd: AgUiEventType.toolCallEnd,
AgUiEventTypeWire.toolCallResult: AgUiEventType.toolCallResult,
AgUiEventTypeWire.toolCallError: AgUiEventType.toolCallError,
};
const _typeToWireMap = {
@@ -52,7 +49,6 @@ const _typeToWireMap = {
AgUiEventType.toolCallArgs: AgUiEventTypeWire.toolCallArgs,
AgUiEventType.toolCallEnd: AgUiEventTypeWire.toolCallEnd,
AgUiEventType.toolCallResult: AgUiEventTypeWire.toolCallResult,
AgUiEventType.toolCallError: AgUiEventTypeWire.toolCallError,
AgUiEventType.unknown: '',
};
@@ -82,7 +78,6 @@ abstract class AgUiEvent {
AgUiEventType.toolCallArgs => ToolCallArgsEvent.fromJson(json),
AgUiEventType.toolCallEnd => ToolCallEndEvent.fromJson(json),
AgUiEventType.toolCallResult => ToolCallResultEvent.fromJson(json),
AgUiEventType.toolCallError => ToolCallErrorEvent.fromJson(json),
AgUiEventType.unknown => UnknownAgUiEvent(rawJson: json),
};
}
@@ -162,14 +157,12 @@ class TextMessageEndEvent extends AgUiEvent {
required this.answer,
required this.role,
required this.status,
required this.uiSchema,
}) : super(type: AgUiEventType.textMessageEnd);
final String messageId;
final String answer;
final String role;
final String status;
final Map<String, dynamic>? uiSchema;
factory TextMessageEndEvent.fromJson(Map<String, dynamic> json) =>
TextMessageEndEvent(
@@ -177,7 +170,6 @@ class TextMessageEndEvent extends AgUiEvent {
answer: _asString(json['answer']),
role: _asString(json['role'], fallback: 'assistant'),
status: _asString(json['status'], fallback: 'success'),
uiSchema: _asMap(json['ui_schema']),
);
}
@@ -247,22 +239,6 @@ class ToolCallResultEvent extends AgUiEvent {
);
}
class ToolCallErrorEvent extends AgUiEvent {
ToolCallErrorEvent({required this.toolCallId, required this.error, this.code})
: super(type: AgUiEventType.toolCallError);
final String toolCallId;
final String error;
final String? code;
factory ToolCallErrorEvent.fromJson(Map<String, dynamic> json) =>
ToolCallErrorEvent(
toolCallId: _asString(json['toolCallId']),
error: _asString(json['error'], fallback: 'Tool call failed'),
code: json['code'] as String?,
);
}
class HistorySnapshot {
const HistorySnapshot({
required this.scope,