Skip to main content

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