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.
70 pub expected: serde_json::Value,
71 /// Target webview label.
72 pub webview_label: Option<String>,
73}
74
75// ── Wait ───────────────────────────────────────────────────────────────────
76
77/// Parameters for the `wait_for` tool.
78#[derive(Debug, Deserialize, JsonSchema)]
79pub struct WaitForParams {
80 /// Condition to wait for.
81 pub condition: WaitCondition,
82 /// Value for the condition (text to find, CSS selector, URL substring).
83 pub value: Option<String>,
84 /// Maximum time to wait in milliseconds. Default: 10000.
85 pub timeout_ms: Option<u64>,
86 /// Polling interval in milliseconds. Default: 200.
87 pub poll_ms: Option<u64>,
88 /// Target webview label.
89 pub webview_label: Option<String>,
90}
91
92// ── Find Elements ──────────────────────────────────────────────────────────
93
94/// Parameters for the `find_elements` tool.
95#[derive(Debug, Deserialize, JsonSchema)]
96pub struct FindElementsParams {
97 /// Text content to search for (case-insensitive substring match).
98 pub text: Option<String>,
99 /// ARIA role to match (exact match).
100 pub role: Option<String>,
101 /// data-testid attribute value to match (exact match).
102 pub test_id: Option<String>,
103 /// CSS selector to match.
104 pub css: Option<String>,
105 /// Accessible name to search for (aria-label, title, placeholder -- case-insensitive substring).
106 pub name: Option<String>,
107 /// Maximum number of results to return. Default: 10.
108 pub max_results: Option<u32>,
109 /// Target webview label.
110 pub webview_label: Option<String>,
111}