victauri_plugin/mcp/introspection_params.rs
1use schemars::JsonSchema;
2use serde::Deserialize;
3
4/// Actions available in the `introspect` compound tool.
5#[derive(Debug, Copy, Clone, Deserialize, JsonSchema)]
6#[serde(rename_all = "snake_case")]
7pub enum IntrospectAction {
8 /// Get per-command execution timing statistics (min/max/avg/p95).
9 CommandTimings,
10 /// Report which registered commands have been called during this session.
11 Coverage,
12 /// Record the current response shape of a command as a baseline contract.
13 ContractRecord,
14 /// Check all recorded contracts for schema drift.
15 ContractCheck,
16 /// List all recorded contract baselines.
17 ContractList,
18 /// Clear all recorded contract baselines.
19 ContractClear,
20 /// Report Victauri plugin startup phase timing breakdown.
21 StartupTiming,
22 /// Enumerate Tauri v2 capabilities, security config, plugin config, and window definitions.
23 Capabilities,
24 /// `SQLite` database health diagnostics (journal mode, WAL, page stats).
25 DbHealth,
26 /// Snapshot of the Victauri plugin's internal state (event log, registry, recording, faults).
27 PluginState,
28 /// Enumerate the host process and its child processes (sidecars, background workers).
29 Processes,
30 /// Report Victauri's own spawned async tasks (MCP server, event drain) and their status.
31 PluginTasks,
32 /// List captured Tauri event bus events (automatically intercepted).
33 EventBus,
34 /// Clear the event bus capture buffer.
35 EventBusClear,
36}
37
38/// Parameters for the `introspect` compound tool.
39#[derive(Debug, Deserialize, JsonSchema)]
40pub struct IntrospectParams {
41 /// Which introspection action to perform.
42 pub action: IntrospectAction,
43
44 /// For `command_timings`: only show commands slower than this threshold (ms).
45 #[serde(skip_serializing_if = "Option::is_none")]
46 pub slow_threshold_ms: Option<f64>,
47
48 /// For `contract_record`: the command to record a baseline for.
49 #[serde(skip_serializing_if = "Option::is_none")]
50 pub command: Option<String>,
51
52 /// For `contract_record`: optional arguments to pass when invoking the command.
53 #[serde(skip_serializing_if = "Option::is_none")]
54 pub args: Option<serde_json::Value>,
55
56 /// For `db_health`: path to the `SQLite` database file.
57 #[serde(skip_serializing_if = "Option::is_none")]
58 pub db_path: Option<String>,
59
60 /// Target webview for actions that need JS eval.
61 #[serde(skip_serializing_if = "Option::is_none")]
62 pub webview_label: Option<String>,
63}
64
65/// Actions available in the `fault` compound tool.
66#[derive(Debug, Copy, Clone, Deserialize, JsonSchema)]
67#[serde(rename_all = "snake_case")]
68pub enum FaultAction {
69 /// Inject a fault rule for a specific command.
70 Inject,
71 /// List all active fault injection rules.
72 List,
73 /// Remove a specific fault rule.
74 Clear,
75 /// Remove all fault rules.
76 ClearAll,
77}
78
79/// The type of fault to inject.
80#[derive(Debug, Copy, Clone, Deserialize, JsonSchema)]
81#[serde(rename_all = "snake_case")]
82pub enum FaultKind {
83 /// Add artificial delay before command execution.
84 Delay,
85 /// Return an error without executing the command.
86 Error,
87 /// Drop the response (return empty result).
88 Drop,
89 /// Execute normally but corrupt the response structure.
90 Corrupt,
91}
92
93/// Parameters for the `fault` compound tool.
94///
95/// SCOPE (important): injected faults apply ONLY to commands executed through
96/// Victauri's own `invoke_command` tool. They do NOT intercept the application's
97/// real frontend-driven IPC (`window.__TAURI_INTERNALS__.invoke` → Tauri's native
98/// transport), which runs below the JS layer Victauri can reach. Use `fault` to
99/// probe a backend handler's behavior under failure when YOU drive the command
100/// (e.g. "does my error path return the right shape on a DB error?"). It does not
101/// reproduce a failure a user clicking the UI would experience — that path is not
102/// interceptable cross-platform without CDP.
103#[derive(Debug, Deserialize, JsonSchema)]
104pub struct FaultParams {
105 /// Which fault action to perform.
106 pub action: FaultAction,
107
108 /// Target command name (required for `inject` and `clear`).
109 #[serde(skip_serializing_if = "Option::is_none")]
110 pub command: Option<String>,
111
112 /// Type of fault to inject (required for `inject`).
113 #[serde(skip_serializing_if = "Option::is_none")]
114 pub fault_type: Option<FaultKind>,
115
116 /// For `delay` faults: delay in milliseconds.
117 #[serde(skip_serializing_if = "Option::is_none")]
118 pub delay_ms: Option<u64>,
119
120 /// For `error` faults: error message to return.
121 #[serde(skip_serializing_if = "Option::is_none")]
122 pub error_message: Option<String>,
123
124 /// Maximum number of times to trigger (0 or omit for unlimited).
125 #[serde(skip_serializing_if = "Option::is_none")]
126 pub max_triggers: Option<u64>,
127}
128
129/// Actions available in the `explain` compound tool.
130#[derive(Debug, Copy, Clone, Deserialize, JsonSchema)]
131#[serde(rename_all = "snake_case")]
132pub enum ExplainAction {
133 /// Summarize recent activity across all layers (IPC, DOM, console, network, window events).
134 Summary,
135 /// Correlate the most recent burst of activity into a causal timeline.
136 LastAction,
137 /// Report what changed in the last N seconds (events, IPC calls, console entries).
138 Diff,
139}
140
141/// Parameters for the `explain` compound tool.
142#[derive(Debug, Deserialize, JsonSchema)]
143pub struct ExplainParams {
144 /// Which explain action to perform.
145 pub action: ExplainAction,
146
147 /// How many seconds to look back (default: 30 for summary, 5 for `last_action`, 10 for diff).
148 #[serde(skip_serializing_if = "Option::is_none")]
149 pub seconds: Option<u64>,
150
151 /// Target webview for JS eval (console/network log retrieval).
152 #[serde(skip_serializing_if = "Option::is_none")]
153 pub webview_label: Option<String>,
154}