-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathcallbacks.dart
More file actions
109 lines (84 loc) · 3.85 KB
/
callbacks.dart
File metadata and controls
109 lines (84 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import 'conversation_status.dart';
import 'conversation_config.dart';
import 'events.dart';
/// Callbacks for conversation events
class ConversationCallbacks {
/// Called when connected to the agent
final void Function({required String conversationId})? onConnect;
/// Called when disconnected from the agent
final void Function(DisconnectionDetails details)? onDisconnect;
/// Called when connection status changes
final void Function({required ConversationStatus status})? onStatusChange;
/// Called when an error occurs
final void Function(String message, [dynamic context])? onError;
/// Called when a message is received (transcription or agent response)
final void Function({required String message, required Role source})?
onMessage;
/// Called when the conversation mode changes (listening/speaking)
final void Function({required ConversationMode mode})? onModeChange;
/// Called when audio data is received
final void Function(String base64Audio)? onAudio;
/// Called with voice activity detection scores
final void Function({required double vadScore})? onVadScore;
/// Called when an interruption occurs
final void Function(InterruptionEvent event)? onInterruption;
/// Called when an agent chat response part is received
final void Function(AgentChatResponsePart part)? onAgentChatResponsePart;
/// Called when conversation metadata is received
final void Function(ConversationMetadata metadata)? onConversationMetadata;
/// Called when ASR initiation metadata is received
final void Function(AsrInitiationMetadata metadata)? onAsrInitiationMetadata;
/// Called when feedback can be sent changes
final void Function({required bool canSendFeedback})? onCanSendFeedbackChange;
/// Called when a client tool call is not handled
final void Function(ClientToolCall toolCall)? onUnhandledClientToolCall;
/// Called when an MCP tool call is received
final void Function(McpToolCall toolCall)? onMcpToolCall;
/// Called when MCP connection status changes
final void Function(McpConnectionStatus status)? onMcpConnectionStatus;
/// Called when the agent is about to call a server-side tool (webhook, etc.)
final void Function(AgentToolRequest request)? onAgentToolRequest;
/// Called when an agent tool response is received
final void Function(AgentToolResponse response)? onAgentToolResponse;
/// Called with debug information
final void Function(dynamic data)? onDebug;
/// Called when the agent requests to end the call (via end_call tool)
final void Function()? onEndCallRequested;
/// Called when a tentative user transcript is received (real-time transcription)
final void Function({required String transcript, required int eventId})?
onTentativeUserTranscript;
/// Called when a user transcript is finalized
final void Function({required String transcript, required int eventId})?
onUserTranscript;
/// Called when an agent response correction is received
final void Function(Map<String, dynamic> correction)?
onAgentResponseCorrection;
/// Called when a tentative agent response is received (streaming text)
final void Function({required String response})? onTentativeAgentResponse;
const ConversationCallbacks({
this.onConnect,
this.onDisconnect,
this.onStatusChange,
this.onError,
this.onMessage,
this.onModeChange,
this.onAudio,
this.onVadScore,
this.onInterruption,
this.onAgentChatResponsePart,
this.onConversationMetadata,
this.onAsrInitiationMetadata,
this.onCanSendFeedbackChange,
this.onUnhandledClientToolCall,
this.onMcpToolCall,
this.onMcpConnectionStatus,
this.onAgentToolRequest,
this.onAgentToolResponse,
this.onDebug,
this.onEndCallRequested,
this.onTentativeUserTranscript,
this.onUserTranscript,
this.onAgentResponseCorrection,
this.onTentativeAgentResponse,
});
}