rskit_agent/hooks/
events.rs1use rskit_hook::{Event, EventType};
2use rskit_llm::types::{AssistantMessage, CompletionRequest, CompletionResponse};
3use rskit_tool::{ToolInput, ToolResult};
4
5use super::{
6 on_error_type, on_event_type, on_mcp_call_type, on_mcp_result_type, post_llm_call_type,
7 post_tool_call_type, pre_llm_call_type, pre_tool_call_type, turn_end_type, turn_start_type,
8};
9
10#[derive(Debug, Clone)]
14pub struct OnEvent {
15 pub event: rskit_ai::StreamEventRef,
17}
18
19impl Event for OnEvent {
20 fn event_type(&self) -> EventType {
21 on_event_type()
22 }
23}
24
25#[derive(Debug, Clone)]
27pub struct OnMCPCall {
28 pub method: String,
30}
31
32impl Event for OnMCPCall {
33 fn event_type(&self) -> EventType {
34 on_mcp_call_type()
35 }
36}
37
38#[derive(Debug, Clone)]
40pub struct OnMCPResult {
41 pub method: String,
43 pub result: Option<serde_json::Value>,
45 pub error: Option<String>,
47}
48
49impl Event for OnMCPResult {
50 fn event_type(&self) -> EventType {
51 on_mcp_result_type()
52 }
53}
54
55#[derive(Debug, Clone)]
57pub struct PreToolCall {
58 pub name: String,
60 pub input: ToolInput,
62}
63
64impl Event for PreToolCall {
65 fn event_type(&self) -> EventType {
66 pre_tool_call_type()
67 }
68}
69
70#[derive(Debug, Clone)]
72pub struct PostToolCall {
73 pub name: String,
75 pub input: ToolInput,
77 pub result: Option<ToolResult>,
79 pub error: Option<String>,
81}
82
83impl Event for PostToolCall {
84 fn event_type(&self) -> EventType {
85 post_tool_call_type()
86 }
87}
88
89#[derive(Debug, Clone)]
91pub struct PreLLMCall {
92 pub request: CompletionRequest,
94}
95
96impl Event for PreLLMCall {
97 fn event_type(&self) -> EventType {
98 pre_llm_call_type()
99 }
100}
101
102#[derive(Debug, Clone)]
104pub struct PostLLMCall {
105 pub response: CompletionResponse,
107 pub error: Option<String>,
109}
110
111impl Event for PostLLMCall {
112 fn event_type(&self) -> EventType {
113 post_llm_call_type()
114 }
115}
116
117#[derive(Debug, Clone)]
119pub struct OnError {
120 pub error: String,
122 pub source: String,
124}
125
126impl Event for OnError {
127 fn event_type(&self) -> EventType {
128 on_error_type()
129 }
130}
131
132#[derive(Debug, Clone)]
134pub struct TurnStart {
135 pub turn: u32,
137}
138
139impl Event for TurnStart {
140 fn event_type(&self) -> EventType {
141 turn_start_type()
142 }
143}
144
145#[derive(Debug, Clone)]
147pub struct TurnEnd {
148 pub turn: u32,
150 pub message: AssistantMessage,
152}
153
154impl Event for TurnEnd {
155 fn event_type(&self) -> EventType {
156 turn_end_type()
157 }
158}