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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
//! Event types for the Astrid event bus.
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use uuid::Uuid;
/// Metadata attached to every event.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EventMetadata {
/// Unique event identifier.
pub event_id: Uuid,
/// When the event was created.
pub timestamp: DateTime<Utc>,
/// Correlation ID for tracing related events.
pub correlation_id: Option<Uuid>,
/// Session ID if applicable.
pub session_id: Option<Uuid>,
/// User ID if applicable.
pub user_id: Option<Uuid>,
/// Source component that generated the event.
pub source: String,
}
impl EventMetadata {
/// Create new event metadata.
#[must_use]
pub fn new(source: impl Into<String>) -> Self {
Self {
event_id: Uuid::new_v4(),
timestamp: Utc::now(),
correlation_id: None,
session_id: None,
user_id: None,
source: source.into(),
}
}
/// Set correlation ID.
#[must_use]
pub fn with_correlation_id(mut self, id: Uuid) -> Self {
self.correlation_id = Some(id);
self
}
/// Set session ID.
#[must_use]
pub fn with_session_id(mut self, id: Uuid) -> Self {
self.session_id = Some(id);
self
}
/// Set user ID.
#[must_use]
pub fn with_user_id(mut self, id: Uuid) -> Self {
self.user_id = Some(id);
self
}
}
impl Default for EventMetadata {
fn default() -> Self {
Self::new("unknown")
}
}
/// All events that can occur in the Astrid runtime.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum AstridEvent {
// ========== Agent Lifecycle ==========
/// Runtime started.
RuntimeStarted {
/// Event metadata.
metadata: EventMetadata,
/// Runtime version.
version: String,
},
/// Runtime stopped.
RuntimeStopped {
/// Event metadata.
metadata: EventMetadata,
/// Reason for stopping.
reason: Option<String>,
},
/// Agent started within the runtime.
AgentStarted {
/// Event metadata.
metadata: EventMetadata,
/// Agent ID.
agent_id: Uuid,
/// Agent name.
agent_name: String,
},
/// Agent stopped.
AgentStopped {
/// Event metadata.
metadata: EventMetadata,
/// Agent ID.
agent_id: Uuid,
/// Reason for stopping.
reason: Option<String>,
},
// ========== Session Events ==========
/// Session created.
SessionCreated {
/// Event metadata.
metadata: EventMetadata,
/// Session ID.
session_id: Uuid,
},
/// Session ended.
SessionEnded {
/// Event metadata.
metadata: EventMetadata,
/// Session ID.
session_id: Uuid,
/// Reason for ending.
reason: Option<String>,
},
/// Session resumed from persisted state.
SessionResumed {
/// Event metadata.
metadata: EventMetadata,
/// Session ID.
session_id: Uuid,
},
// ========== Message Flow ==========
/// User message received by the runtime.
MessageReceived {
/// Event metadata.
metadata: EventMetadata,
/// Message ID.
message_id: Uuid,
/// Frontend the message came from.
frontend: String,
},
/// Message fully processed (response sent).
MessageProcessed {
/// Event metadata.
metadata: EventMetadata,
/// Message ID.
message_id: Uuid,
/// Duration in milliseconds.
duration_ms: u64,
},
// ========== LLM Events ==========
/// LLM request started.
LlmRequestStarted {
/// Event metadata.
metadata: EventMetadata,
/// Request ID.
request_id: Uuid,
/// Provider name.
provider: String,
/// Model name.
model: String,
},
/// LLM request completed (non-streaming or final).
LlmRequestCompleted {
/// Event metadata.
metadata: EventMetadata,
/// Request ID.
request_id: Uuid,
/// Whether the request succeeded.
success: bool,
/// Input tokens used.
input_tokens: Option<u32>,
/// Output tokens used.
output_tokens: Option<u32>,
/// Duration in milliseconds.
duration_ms: u64,
},
/// LLM streaming response started.
LlmStreamStarted {
/// Event metadata.
metadata: EventMetadata,
/// Request ID.
request_id: Uuid,
/// Model name.
model: String,
},
/// LLM stream chunk received.
LlmStreamChunk {
/// Event metadata.
metadata: EventMetadata,
/// Request ID.
request_id: Uuid,
/// Chunk index (0-based).
chunk_index: u32,
/// Number of tokens in this chunk.
token_count: u32,
},
/// LLM streaming response completed.
LlmStreamCompleted {
/// Event metadata.
metadata: EventMetadata,
/// Request ID.
request_id: Uuid,
/// Total input tokens.
input_tokens: Option<u32>,
/// Total output tokens.
output_tokens: Option<u32>,
/// Total duration in milliseconds.
duration_ms: u64,
},
// ========== Tool Events ==========
/// Tool call started (generic, any tool source).
ToolCallStarted {
/// Event metadata.
metadata: EventMetadata,
/// Tool call ID.
call_id: Uuid,
/// Tool name.
tool_name: String,
/// Server name (if MCP tool).
server_name: Option<String>,
},
/// Tool call completed successfully.
ToolCallCompleted {
/// Event metadata.
metadata: EventMetadata,
/// Tool call ID.
call_id: Uuid,
/// Tool name.
tool_name: String,
/// Duration in milliseconds.
duration_ms: u64,
},
/// Tool call failed.
ToolCallFailed {
/// Event metadata.
metadata: EventMetadata,
/// Tool call ID.
call_id: Uuid,
/// Tool name.
tool_name: String,
/// Error message.
error: String,
/// Duration in milliseconds.
duration_ms: u64,
},
// ========== MCP Events ==========
/// MCP server connected.
McpServerConnected {
/// Event metadata.
metadata: EventMetadata,
/// Server name.
server_name: String,
/// Protocol version.
protocol_version: String,
},
/// MCP server disconnected.
McpServerDisconnected {
/// Event metadata.
metadata: EventMetadata,
/// Server name.
server_name: String,
/// Reason for disconnection.
reason: Option<String>,
},
/// MCP tool called.
McpToolCalled {
/// Event metadata.
metadata: EventMetadata,
/// Server name.
server_name: String,
/// Tool name.
tool_name: String,
/// Tool arguments (may be redacted for security).
arguments: Option<Value>,
},
/// MCP tool completed.
McpToolCompleted {
/// Event metadata.
metadata: EventMetadata,
/// Server name.
server_name: String,
/// Tool name.
tool_name: String,
/// Whether the call succeeded.
success: bool,
/// Duration in milliseconds.
duration_ms: u64,
},
// ========== SubAgent Events ==========
/// Sub-agent spawned by a parent agent.
SubAgentSpawned {
/// Event metadata.
metadata: EventMetadata,
/// Sub-agent ID.
subagent_id: Uuid,
/// Parent agent ID.
parent_id: Uuid,
/// Task description.
task: String,
/// Depth in the agent tree.
depth: u32,
},
/// Sub-agent progress update.
SubAgentProgress {
/// Event metadata.
metadata: EventMetadata,
/// Sub-agent ID.
subagent_id: Uuid,
/// Progress message.
message: String,
},
/// Sub-agent completed successfully.
SubAgentCompleted {
/// Event metadata.
metadata: EventMetadata,
/// Sub-agent ID.
subagent_id: Uuid,
/// Duration in milliseconds.
duration_ms: u64,
},
/// Sub-agent failed.
SubAgentFailed {
/// Event metadata.
metadata: EventMetadata,
/// Sub-agent ID.
subagent_id: Uuid,
/// Error message.
error: String,
/// Duration in milliseconds.
duration_ms: u64,
},
/// Sub-agent cancelled.
SubAgentCancelled {
/// Event metadata.
metadata: EventMetadata,
/// Sub-agent ID.
subagent_id: Uuid,
/// Reason for cancellation.
reason: Option<String>,
},
// ========== Security Events ==========
/// Capability granted.
CapabilityGranted {
/// Event metadata.
metadata: EventMetadata,
/// Capability ID.
capability_id: Uuid,
/// Resource being accessed.
resource: String,
/// Action being performed.
action: String,
},
/// Capability revoked.
CapabilityRevoked {
/// Event metadata.
metadata: EventMetadata,
/// Capability ID.
capability_id: Uuid,
/// Reason for revocation.
reason: Option<String>,
},
/// Capability check performed.
CapabilityChecked {
/// Event metadata.
metadata: EventMetadata,
/// Resource being accessed.
resource: String,
/// Action being performed.
action: String,
/// Whether the check passed.
allowed: bool,
},
/// Authorization denied.
AuthorizationDenied {
/// Event metadata.
metadata: EventMetadata,
/// Resource being accessed.
resource: String,
/// Action being performed.
action: String,
/// Reason for denial.
reason: String,
},
/// Security violation detected.
SecurityViolation {
/// Event metadata.
metadata: EventMetadata,
/// Violation type.
violation_type: String,
/// Details of the violation.
details: String,
},
// ========== Approval Events ==========
/// Approval requested.
ApprovalRequested {
/// Event metadata.
metadata: EventMetadata,
/// Request ID.
request_id: Uuid,
/// Resource being accessed.
resource: String,
/// Action being performed.
action: String,
/// Description of what's being requested.
description: String,
},
/// Approval granted.
ApprovalGranted {
/// Event metadata.
metadata: EventMetadata,
/// Request ID.
request_id: Uuid,
/// Duration of approval (if limited).
duration: Option<String>,
},
/// Approval denied.
ApprovalDenied {
/// Event metadata.
metadata: EventMetadata,
/// Request ID.
request_id: Uuid,
/// Reason for denial.
reason: Option<String>,
},
// ========== Budget Events ==========
/// Budget allocated for a session or agent.
BudgetAllocated {
/// Event metadata.
metadata: EventMetadata,
/// Budget ID.
budget_id: Uuid,
/// Amount allocated (in smallest currency unit, e.g. cents).
amount_cents: u64,
/// Currency code.
currency: String,
},
/// Budget threshold warning.
BudgetWarning {
/// Event metadata.
metadata: EventMetadata,
/// Budget ID.
budget_id: Uuid,
/// Amount remaining (cents).
remaining_cents: u64,
/// Percentage used.
percent_used: f64,
},
/// Budget exceeded.
BudgetExceeded {
/// Event metadata.
metadata: EventMetadata,
/// Budget ID.
budget_id: Uuid,
/// Amount over budget (cents).
overage_cents: u64,
},
// ========== Plugin Events ==========
/// Plugin loaded successfully.
PluginLoaded {
/// Event metadata.
metadata: EventMetadata,
/// Plugin identifier.
plugin_id: String,
/// Plugin name.
plugin_name: String,
},
/// Plugin failed to load.
PluginFailed {
/// Event metadata.
metadata: EventMetadata,
/// Plugin identifier.
plugin_id: String,
/// Error message.
error: String,
},
/// Plugin unloaded.
PluginUnloaded {
/// Event metadata.
metadata: EventMetadata,
/// Plugin identifier.
plugin_id: String,
/// Plugin name.
plugin_name: String,
},
// ========== System Events ==========
/// Gateway daemon started.
GatewayStarted {
/// Event metadata.
metadata: EventMetadata,
/// Gateway version.
version: String,
},
/// Gateway daemon shutting down.
GatewayShutdown {
/// Event metadata.
metadata: EventMetadata,
/// Reason for shutdown.
reason: Option<String>,
},
/// Configuration reloaded from disk.
ConfigReloaded {
/// Event metadata.
metadata: EventMetadata,
},
/// Configuration value changed.
ConfigChanged {
/// Event metadata.
metadata: EventMetadata,
/// Config key that changed.
key: String,
},
/// Health check completed.
HealthCheckCompleted {
/// Event metadata.
metadata: EventMetadata,
/// Overall health state.
healthy: bool,
/// Number of checks performed.
checks_performed: u32,
/// Number of checks that failed.
checks_failed: u32,
},
// ========== Audit Events ==========
/// Audit entry created.
AuditEntryCreated {
/// Event metadata.
metadata: EventMetadata,
/// Audit entry ID.
entry_id: Uuid,
/// Entry type.
entry_type: String,
},
// ========== Error Events ==========
/// Error occurred.
ErrorOccurred {
/// Event metadata.
metadata: EventMetadata,
/// Error code.
code: String,
/// Error message.
message: String,
/// Stack trace if available.
stack_trace: Option<String>,
},
// ========== IPC Events ==========
/// An IPC message routed from a WASM guest or host.
Ipc {
/// Event metadata.
metadata: EventMetadata,
/// The decoded IPC message.
message: crate::ipc::IpcMessage,
},
// ========== Custom Events ==========
/// Custom event for extensions.
Custom {
/// Event metadata.
metadata: EventMetadata,
/// Event name.
name: String,
/// Event data.
data: Value,
},
}
impl AstridEvent {
/// Get the event metadata.
#[must_use]
pub fn metadata(&self) -> &EventMetadata {
match self {
Self::RuntimeStarted { metadata, .. }
| Self::RuntimeStopped { metadata, .. }
| Self::AgentStarted { metadata, .. }
| Self::AgentStopped { metadata, .. }
| Self::SessionCreated { metadata, .. }
| Self::SessionEnded { metadata, .. }
| Self::SessionResumed { metadata, .. }
| Self::MessageReceived { metadata, .. }
| Self::MessageProcessed { metadata, .. }
| Self::LlmRequestStarted { metadata, .. }
| Self::LlmRequestCompleted { metadata, .. }
| Self::LlmStreamStarted { metadata, .. }
| Self::LlmStreamChunk { metadata, .. }
| Self::LlmStreamCompleted { metadata, .. }
| Self::ToolCallStarted { metadata, .. }
| Self::ToolCallCompleted { metadata, .. }
| Self::ToolCallFailed { metadata, .. }
| Self::McpServerConnected { metadata, .. }
| Self::McpServerDisconnected { metadata, .. }
| Self::McpToolCalled { metadata, .. }
| Self::McpToolCompleted { metadata, .. }
| Self::SubAgentSpawned { metadata, .. }
| Self::SubAgentProgress { metadata, .. }
| Self::SubAgentCompleted { metadata, .. }
| Self::SubAgentFailed { metadata, .. }
| Self::SubAgentCancelled { metadata, .. }
| Self::PluginLoaded { metadata, .. }
| Self::PluginFailed { metadata, .. }
| Self::PluginUnloaded { metadata, .. }
| Self::CapabilityGranted { metadata, .. }
| Self::CapabilityRevoked { metadata, .. }
| Self::CapabilityChecked { metadata, .. }
| Self::AuthorizationDenied { metadata, .. }
| Self::SecurityViolation { metadata, .. }
| Self::ApprovalRequested { metadata, .. }
| Self::ApprovalGranted { metadata, .. }
| Self::ApprovalDenied { metadata, .. }
| Self::BudgetAllocated { metadata, .. }
| Self::BudgetWarning { metadata, .. }
| Self::BudgetExceeded { metadata, .. }
| Self::GatewayStarted { metadata, .. }
| Self::GatewayShutdown { metadata, .. }
| Self::ConfigReloaded { metadata, .. }
| Self::ConfigChanged { metadata, .. }
| Self::HealthCheckCompleted { metadata, .. }
| Self::AuditEntryCreated { metadata, .. }
| Self::ErrorOccurred { metadata, .. }
| Self::Ipc { metadata, .. }
| Self::Custom { metadata, .. } => metadata,
}
}
/// Get the event type as a string.
#[must_use]
pub fn event_type(&self) -> &'static str {
match self {
// Agent Lifecycle
Self::RuntimeStarted { .. } => "runtime_started",
Self::RuntimeStopped { .. } => "runtime_stopped",
Self::AgentStarted { .. } => "agent_started",
Self::AgentStopped { .. } => "agent_stopped",
// Session
Self::SessionCreated { .. } => "session_created",
Self::SessionEnded { .. } => "session_ended",
Self::SessionResumed { .. } => "session_resumed",
// Message Flow
Self::MessageReceived { .. } => "message_received",
Self::MessageProcessed { .. } => "message_processed",
// LLM
Self::LlmRequestStarted { .. } => "llm_request_started",
Self::LlmRequestCompleted { .. } => "llm_request_completed",
Self::LlmStreamStarted { .. } => "llm_stream_started",
Self::LlmStreamChunk { .. } => "llm_stream_chunk",
Self::LlmStreamCompleted { .. } => "llm_stream_completed",
// Tool
Self::ToolCallStarted { .. } => "tool_call_started",
Self::ToolCallCompleted { .. } => "tool_call_completed",
Self::ToolCallFailed { .. } => "tool_call_failed",
// MCP
Self::McpServerConnected { .. } => "mcp_server_connected",
Self::McpServerDisconnected { .. } => "mcp_server_disconnected",
Self::McpToolCalled { .. } => "mcp_tool_called",
Self::McpToolCompleted { .. } => "mcp_tool_completed",
// SubAgent
Self::SubAgentSpawned { .. } => "subagent_spawned",
Self::SubAgentProgress { .. } => "subagent_progress",
Self::SubAgentCompleted { .. } => "subagent_completed",
Self::SubAgentFailed { .. } => "subagent_failed",
Self::SubAgentCancelled { .. } => "subagent_cancelled",
// Plugin
Self::PluginLoaded { .. } => "plugin_loaded",
Self::PluginFailed { .. } => "plugin_failed",
Self::PluginUnloaded { .. } => "plugin_unloaded",
// Security
Self::CapabilityGranted { .. } => "capability_granted",
Self::CapabilityRevoked { .. } => "capability_revoked",
Self::CapabilityChecked { .. } => "capability_checked",
Self::AuthorizationDenied { .. } => "authorization_denied",
Self::SecurityViolation { .. } => "security_violation",
// Approval
Self::ApprovalRequested { .. } => "approval_requested",
Self::ApprovalGranted { .. } => "approval_granted",
Self::ApprovalDenied { .. } => "approval_denied",
// Budget
Self::BudgetAllocated { .. } => "budget_allocated",
Self::BudgetWarning { .. } => "budget_warning",
Self::BudgetExceeded { .. } => "budget_exceeded",
// System
Self::GatewayStarted { .. } => "gateway_started",
Self::GatewayShutdown { .. } => "gateway_shutdown",
Self::ConfigReloaded { .. } => "config_reloaded",
Self::ConfigChanged { .. } => "config_changed",
Self::HealthCheckCompleted { .. } => "health_check_completed",
// Audit
Self::AuditEntryCreated { .. } => "audit_entry_created",
// Error
Self::ErrorOccurred { .. } => "error_occurred",
// IPC
Self::Ipc { .. } => "ipc",
// Custom
Self::Custom { .. } => "custom",
}
}
/// Check if this is a security-related event.
#[must_use]
pub fn is_security_event(&self) -> bool {
matches!(
self,
Self::CapabilityGranted { .. }
| Self::CapabilityRevoked { .. }
| Self::CapabilityChecked { .. }
| Self::AuthorizationDenied { .. }
| Self::SecurityViolation { .. }
| Self::ApprovalRequested { .. }
| Self::ApprovalGranted { .. }
| Self::ApprovalDenied { .. }
)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_event_metadata_creation() {
let meta = EventMetadata::new("test_source");
assert_eq!(meta.source, "test_source");
assert!(meta.correlation_id.is_none());
assert!(meta.session_id.is_none());
assert!(meta.user_id.is_none());
}
#[test]
fn test_event_metadata_builder() {
let correlation = Uuid::new_v4();
let session = Uuid::new_v4();
let user = Uuid::new_v4();
let meta = EventMetadata::new("test")
.with_correlation_id(correlation)
.with_session_id(session)
.with_user_id(user);
assert_eq!(meta.correlation_id, Some(correlation));
assert_eq!(meta.session_id, Some(session));
assert_eq!(meta.user_id, Some(user));
}
#[test]
fn test_event_type() {
let event = AstridEvent::RuntimeStarted {
metadata: EventMetadata::new("runtime"),
version: "0.1.0".to_string(),
};
assert_eq!(event.event_type(), "runtime_started");
}
#[test]
fn test_security_event_detection() {
let security_event = AstridEvent::CapabilityGranted {
metadata: EventMetadata::new("security"),
capability_id: Uuid::new_v4(),
resource: "tool:test".to_string(),
action: "execute".to_string(),
};
assert!(security_event.is_security_event());
let non_security_event = AstridEvent::RuntimeStarted {
metadata: EventMetadata::new("runtime"),
version: "0.1.0".to_string(),
};
assert!(!non_security_event.is_security_event());
}
#[test]
fn test_event_serialization() {
let event = AstridEvent::McpToolCalled {
metadata: EventMetadata::new("mcp"),
server_name: "filesystem".to_string(),
tool_name: "read_file".to_string(),
arguments: Some(serde_json::json!({"path": "/tmp/test.txt"})),
};
let json = serde_json::to_string(&event).unwrap();
assert!(json.contains("mcp_tool_called"));
assert!(json.contains("filesystem"));
}
}