victauri_plugin/mcp/other_params.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use std::fmt;
4
5// ── Enums ──────────────────────────────────────────────────────────────────
6
7/// Condition to poll for in the `wait_for` tool.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
9#[serde(rename_all = "snake_case")]
10pub enum WaitCondition {
11 /// Wait for text to appear in the page.
12 Text,
13 /// Wait for text to disappear from the page.
14 TextGone,
15 /// Wait for a CSS selector to match an element.
16 Selector,
17 /// Wait for a CSS selector to stop matching.
18 SelectorGone,
19 /// Wait for the URL to contain a substring.
20 Url,
21 /// Wait for all IPC calls to complete.
22 IpcIdle,
23 /// Wait for all network requests to complete.
24 NetworkIdle,
25}
26
27impl WaitCondition {
28 /// Returns the `snake_case` string for JS bridge consumption.
29 #[must_use]
30 pub fn as_str(self) -> &'static str {
31 match self {
32 Self::Text => "text",
33 Self::TextGone => "text_gone",
34 Self::Selector => "selector",
35 Self::SelectorGone => "selector_gone",
36 Self::Url => "url",
37 Self::IpcIdle => "ipc_idle",
38 Self::NetworkIdle => "network_idle",
39 }
40 }
41}
42
43impl fmt::Display for WaitCondition {
44 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45 f.write_str(self.as_str())
46 }
47}
48
49// ── Intent ─────────────────────────────────────────────────────────────────
50
51/// Parameters for the `resolve_command` tool.
52#[derive(Debug, Deserialize, JsonSchema)]
53pub struct ResolveCommandParams {
54 /// Natural language query describing what you want to do (e.g. "save the user's settings").
55 pub query: String,
56 /// Maximum number of results to return. Default: 5.
57 pub limit: Option<usize>,
58}
59
60/// Parameters for the `semantic_assert` tool.
61#[derive(Debug, Deserialize, JsonSchema)]
62pub struct SemanticAssertParams {
63 /// JavaScript expression to evaluate in the webview. The result is checked against the assertion.
64 pub expression: String,
65 /// Human-readable label for this assertion (e.g. "user is logged in").
66 pub label: String,
67 /// Condition to evaluate against the actual value.
68 pub condition: victauri_core::AssertionCondition,
69 /// Expected value for the assertion. Optional for truthy/falsy/exists conditions.
70 #[serde(default)]
71 pub expected: serde_json::Value,
72 /// Target webview label.
73 pub webview_label: Option<String>,
74}
75
76// ── Wait ───────────────────────────────────────────────────────────────────
77
78/// Parameters for the `wait_for` tool.
79#[derive(Debug, Deserialize, JsonSchema)]
80pub struct WaitForParams {
81 /// Condition to wait for.
82 pub condition: WaitCondition,
83 /// Value for the condition (text to find, CSS selector, URL substring).
84 pub value: Option<String>,
85 /// Maximum time to wait in milliseconds. Default: 10000.
86 pub timeout_ms: Option<u64>,
87 /// Polling interval in milliseconds. Default: 200.
88 pub poll_ms: Option<u64>,
89 /// Target webview label.
90 pub webview_label: Option<String>,
91}
92
93// ── Find Elements ──────────────────────────────────────────────────────────
94
95/// Parameters for the `find_elements` tool.
96#[derive(Debug, Deserialize, JsonSchema)]
97pub struct FindElementsParams {
98 /// Text content to search for (case-insensitive substring match).
99 pub text: Option<String>,
100 /// ARIA role to match (exact match).
101 pub role: Option<String>,
102 /// data-testid attribute value to match (exact match).
103 pub test_id: Option<String>,
104 /// CSS selector to match (also accepts `selector` as an alias).
105 pub css: Option<String>,
106 /// Alias for `css` — CSS selector to match.
107 pub selector: Option<String>,
108 /// Accessible name to search for (aria-label, title, placeholder -- case-insensitive substring).
109 pub name: Option<String>,
110 /// Maximum number of results to return. Default: 10.
111 pub max_results: Option<u32>,
112 /// HTML tag name to match (e.g. "button", "input").
113 pub tag: Option<String>,
114 /// Placeholder text to match (case-insensitive substring).
115 pub placeholder: Option<String>,
116 /// Alt text to match (case-insensitive substring).
117 pub alt: Option<String>,
118 /// Title attribute to match (case-insensitive substring).
119 pub title_attr: Option<String>,
120 /// Associated label text to match (finds inputs by their label).
121 pub label: Option<String>,
122 /// If true, text matching is exact instead of substring.
123 pub exact: Option<bool>,
124 /// Filter by enabled state.
125 pub enabled: Option<bool>,
126 /// Target webview label.
127 pub webview_label: Option<String>,
128}
129
130/// Parameters for the `get_diagnostics` tool.
131#[derive(Debug, Deserialize, JsonSchema)]
132pub struct DiagnosticsParams {
133 /// Target a specific webview window by label.
134 pub webview_label: Option<String>,
135}