docs: 添加 AG-UI 协议规则约束到 apps/AGENTS.md
This commit is contained in:
@@ -61,6 +61,7 @@ const _typeToWireMap = {
|
||||
AgUiEventType.toolCallEnd: AgUiEventTypeWire.toolCallEnd,
|
||||
AgUiEventType.toolCallResult: AgUiEventTypeWire.toolCallResult,
|
||||
AgUiEventType.toolCallError: AgUiEventTypeWire.toolCallError,
|
||||
AgUiEventType.messagesSnapshot: AgUiEventTypeWire.messagesSnapshot,
|
||||
AgUiEventType.unknown: '',
|
||||
};
|
||||
|
||||
@@ -102,6 +103,8 @@ class AgUiEvent {
|
||||
return ToolCallResultEvent.fromJson(json);
|
||||
case AgUiEventType.toolCallError:
|
||||
return ToolCallErrorEvent.fromJson(json);
|
||||
case AgUiEventType.messagesSnapshot:
|
||||
return MessagesSnapshotEvent.fromJson(json);
|
||||
case AgUiEventType.unknown:
|
||||
return UnknownAgUiEvent.fromJson(json);
|
||||
}
|
||||
@@ -297,3 +300,39 @@ class ToolCallErrorEvent extends AgUiEvent {
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$ToolCallErrorEventToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class MessagesSnapshotEvent extends AgUiEvent {
|
||||
final List<SnapshotMessage> messages;
|
||||
|
||||
MessagesSnapshotEvent({required this.messages})
|
||||
: super(type: AgUiEventType.messagesSnapshot);
|
||||
|
||||
factory MessagesSnapshotEvent.fromJson(Map<String, dynamic> json) =>
|
||||
_$MessagesSnapshotEventFromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$MessagesSnapshotEventToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class SnapshotMessage {
|
||||
final String id;
|
||||
final String role;
|
||||
final String? content;
|
||||
final String? toolCallId;
|
||||
final UiCard? ui;
|
||||
|
||||
SnapshotMessage({
|
||||
required this.id,
|
||||
required this.role,
|
||||
this.content,
|
||||
this.toolCallId,
|
||||
this.ui,
|
||||
});
|
||||
|
||||
factory SnapshotMessage.fromJson(Map<String, dynamic> json) =>
|
||||
_$SnapshotMessageFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$SnapshotMessageToJson(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user