feat: AG-UI 协议对齐与路由导航功能
- 前端: 添加 SSE 流式支持、stateSnapshot 事件、路由导航工具 - 前端: 实现工具调用审批流程,支持 pending 状态展示 - 后端: Agent 状态管理与会话持久化相关重构 - 文档: 新增 agent-agui-full-alignance 设计文档 - 测试: 补充相关单元测试和集成测试
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:social_app/features/chat/data/tools/route_navigation_tool.dart';
|
||||
import 'package:social_app/features/chat/data/tools/tool_registry.dart';
|
||||
|
||||
void main() {
|
||||
@@ -6,6 +7,10 @@ void main() {
|
||||
ToolRegistry.initialize();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
RouteNavigationTool.instance.clearNavigator();
|
||||
});
|
||||
|
||||
group('getTool', () {
|
||||
test('returns tool definition for create_calendar_event', () {
|
||||
final tool = ToolRegistry.getTool('create_calendar_event');
|
||||
@@ -87,6 +92,33 @@ void main() {
|
||||
expect(result['location'], 'Room A');
|
||||
expect(result['endAt'], '2026-03-01T11:00:00Z');
|
||||
});
|
||||
|
||||
test('navigate_to_route rejects disallowed target', () async {
|
||||
final result = await ToolRegistry.execute('navigate_to_route', {
|
||||
'target': '/admin',
|
||||
});
|
||||
|
||||
expect(result['ok'], false);
|
||||
expect(result['error'], contains('not allowed'));
|
||||
});
|
||||
|
||||
test('navigate_to_route executes allowed target when navigator is bound', () async {
|
||||
String? navigatedTo;
|
||||
bool replaced = false;
|
||||
RouteNavigationTool.instance.bindNavigator((target, {replace = false}) {
|
||||
navigatedTo = target;
|
||||
replaced = replace;
|
||||
});
|
||||
|
||||
final result = await ToolRegistry.execute('navigate_to_route', {
|
||||
'target': '/settings',
|
||||
'replace': true,
|
||||
});
|
||||
|
||||
expect(result['ok'], true);
|
||||
expect(navigatedTo, '/settings');
|
||||
expect(replaced, true);
|
||||
});
|
||||
});
|
||||
|
||||
group('getAllTools', () {
|
||||
|
||||
Reference in New Issue
Block a user