feat(agent): add voice input capability and standardize tool naming
- Add voice recording with transcribe endpoint (ASR) for multimodal input - Android: add RECORD_AUDIO and INTERNET permissions - Refactor tool naming: frontend tools use 'front.' prefix, backend tools use 'back.' - Migrate calendar tools: create_calendar_event -> back.mutate/list/delete events - Add calendar_event_list.v1 and calendar_operation.v1 UI card types - Update all Flutter and Python tests to match new tool naming conventions - Add record package dependency for voice recording
This commit is contained in:
@@ -4,13 +4,7 @@ typedef ToolHandler =
|
||||
Future<Map<String, dynamic>> Function(Map<String, dynamic> args);
|
||||
|
||||
/// 工具常量
|
||||
const _toolNameCreateCalendar = 'create_calendar_event';
|
||||
const _toolNameNavigateRoute = 'navigate_to_route';
|
||||
const _defaultTimezone = 'Asia/Shanghai';
|
||||
const _defaultEventColor = '#4F46E5';
|
||||
const _defaultSourceType = 'agentGenerated';
|
||||
const _titleMinLength = 1;
|
||||
const _titleMaxLength = 100;
|
||||
const _toolNameNavigateRoute = 'front.navigate_to_route';
|
||||
|
||||
class ToolDefinition {
|
||||
final String name;
|
||||
@@ -33,38 +27,6 @@ class ToolRegistry {
|
||||
static void initialize() {
|
||||
if (_initialized) return;
|
||||
|
||||
_tools[_toolNameCreateCalendar] = ToolDefinition(
|
||||
name: _toolNameCreateCalendar,
|
||||
description: '创建一个日历事件或待办事项',
|
||||
parameters: {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'title': {
|
||||
'type': 'string',
|
||||
'description': '事件标题',
|
||||
'minLength': _titleMinLength,
|
||||
'maxLength': _titleMaxLength,
|
||||
},
|
||||
'description': {'type': 'string', 'description': '事件描述'},
|
||||
'startAt': {
|
||||
'type': 'string',
|
||||
'format': 'date-time',
|
||||
'description': '开始时间 (ISO8601)',
|
||||
},
|
||||
'endAt': {
|
||||
'type': 'string',
|
||||
'format': 'date-time',
|
||||
'description': '结束时间 (ISO8601)',
|
||||
},
|
||||
'timezone': {'type': 'string', 'default': _defaultTimezone},
|
||||
'location': {'type': 'string'},
|
||||
'notes': {'type': 'string'},
|
||||
},
|
||||
'required': ['title', 'startAt'],
|
||||
},
|
||||
handler: _handleCreateCalendarEvent,
|
||||
);
|
||||
|
||||
_tools[_toolNameNavigateRoute] = ToolDefinition(
|
||||
name: _toolNameNavigateRoute,
|
||||
description: '在前端执行路由跳转',
|
||||
@@ -82,25 +44,6 @@ class ToolRegistry {
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> _handleCreateCalendarEvent(
|
||||
Map<String, dynamic> args,
|
||||
) async {
|
||||
final eventId = 'evt_${DateTime.now().millisecondsSinceEpoch}';
|
||||
return {
|
||||
'eventId': eventId,
|
||||
'ok': true,
|
||||
'message': '日程已创建',
|
||||
'title': args['title'],
|
||||
'description': args['description'],
|
||||
'startAt': args['startAt'],
|
||||
'endAt': args['endAt'],
|
||||
'timezone': args['timezone'] ?? _defaultTimezone,
|
||||
'location': args['location'],
|
||||
'color': _defaultEventColor,
|
||||
'sourceType': _defaultSourceType,
|
||||
};
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> _handleNavigateRoute(
|
||||
Map<String, dynamic> args,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user