Skip to content

Commit 49383b0

Browse files
Copilot0xrinegade
andcommitted
Add browser automation service with Playwright integration
- Created BrowserService for headless browser automation - Added browser command handler with subcommands - Integrated with MCP architecture for tool execution - Support for navigate, screenshot, click, type, snapshot, evaluate, wait-for - Added comprehensive CLI interface with help text - All commands build and execute correctly Co-authored-by: 0xrinegade <[email protected]>
1 parent 4c2d375 commit 49383b0

File tree

7 files changed

+797
-3
lines changed

7 files changed

+797
-3
lines changed

src/clparse.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ use {
33
solana_clap_utils::input_validators::{is_url_or_moniker, is_valid_signer},
44
};
55

6-
// Import all modularized command builders (full refactoring - 19 commands)
6+
// Import all modularized command builders (full refactoring - 20 commands)
77
mod agent;
88
mod audit;
99
mod balance;
10+
mod browser; // Browser automation command
1011
mod chat;
1112
mod database;
1213
mod deploy;
@@ -60,6 +61,7 @@ COMMAND CATEGORIES:
6061
chat Advanced multi-session chat interface
6162
agent Execute single AI-powered command
6263
plan Create AI-powered execution plans
64+
browser Headless browser automation (Playwright)
6365
6466
Data Management:
6567
snapshot Analyze and manage Solana snapshots
@@ -84,6 +86,7 @@ QUICK START:
8486
osvm agent \"<prompt>\" Execute single AI command
8587
osvm doctor Check system health
8688
osvm mcp setup Set up Solana MCP integration
89+
osvm browser status Check browser automation status
8790
8891
# Isolation control:
8992
OSVM_SKIP_MICROVM=1 osvm Skip microVM for development
@@ -280,5 +283,6 @@ Issues & feedback: https://github.com/opensvm/osvm-cli/issues",
280283
.subcommand(qa::build_qa_command())
281284
.subcommand(ovsm::build_ovsm_command())
282285
.subcommand(settings::build_settings_command())
286+
.subcommand(browser::browser_command()) // Browser automation command
283287
.get_matches()
284288
}

src/clparse/browser.rs

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
// Browser command parser for CLI
2+
//
3+
// Defines the browser automation subcommand and its options.
4+
5+
use clap::{Arg, ArgAction, Command};
6+
7+
pub fn browser_command() -> Command {
8+
Command::new("browser")
9+
.about("Browser automation using Playwright (headless browser control)")
10+
.long_about(
11+
"Browser automation commands for web scraping, testing, and interaction.\n\
12+
\n\
13+
Powered by Playwright with MCP integration for secure, isolated execution.\n\
14+
\n\
15+
Examples:\n\
16+
osvm browser install Install/verify Playwright\n\
17+
osvm browser status Show automation status\n\
18+
osvm browser tools List available tools\n\
19+
osvm browser navigate --url https://example.com Navigate to URL\n\
20+
osvm browser screenshot --filename page.png Take screenshot\n\
21+
osvm browser click --selector \"#submit-button\" Click element\n\
22+
osvm browser type --selector \"#search\" --text \"query\" Type text\n\
23+
osvm browser snapshot Get page snapshot\n\
24+
osvm browser evaluate --script \"document.title\" Run JavaScript\n\
25+
osvm browser wait-for --selector \".loading\" Wait for element\n\
26+
\n\
27+
Security:\n\
28+
• Runs in sandboxed environment\n\
29+
• Configurable timeouts\n\
30+
• Screenshot verification\n\
31+
• DOM access controls\n"
32+
)
33+
.subcommand_required(false)
34+
.arg_required_else_help(true)
35+
.subcommand(
36+
Command::new("install")
37+
.about("Install or verify Playwright installation")
38+
.long_about(
39+
"Checks if Playwright is installed and available.\n\
40+
In MCP environment, Playwright should be pre-installed."
41+
)
42+
)
43+
.subcommand(
44+
Command::new("status")
45+
.about("Show browser automation status and configuration")
46+
)
47+
.subcommand(
48+
Command::new("tools")
49+
.about("List all available browser automation tools")
50+
.long_about(
51+
"Display all browser tools with their descriptions and input schemas.\n\
52+
Use --debug for detailed schema information."
53+
)
54+
)
55+
.subcommand(
56+
Command::new("navigate")
57+
.about("Navigate to a URL")
58+
.arg(
59+
Arg::new("url")
60+
.long("url")
61+
.short('u')
62+
.value_name("URL")
63+
.required(true)
64+
.help("URL to navigate to")
65+
)
66+
)
67+
.subcommand(
68+
Command::new("screenshot")
69+
.about("Take a screenshot of the current page")
70+
.arg(
71+
Arg::new("filename")
72+
.long("filename")
73+
.short('f')
74+
.value_name("PATH")
75+
.help("Optional filename for the screenshot (default: timestamped)")
76+
)
77+
)
78+
.subcommand(
79+
Command::new("click")
80+
.about("Click an element on the page")
81+
.arg(
82+
Arg::new("selector")
83+
.long("selector")
84+
.short('s')
85+
.value_name("SELECTOR")
86+
.required(true)
87+
.help("CSS selector for the element to click")
88+
)
89+
)
90+
.subcommand(
91+
Command::new("type")
92+
.about("Type text into an element")
93+
.arg(
94+
Arg::new("selector")
95+
.long("selector")
96+
.short('s')
97+
.value_name("SELECTOR")
98+
.required(true)
99+
.help("CSS selector for the element")
100+
)
101+
.arg(
102+
Arg::new("text")
103+
.long("text")
104+
.short('t')
105+
.value_name("TEXT")
106+
.required(true)
107+
.help("Text to type into the element")
108+
)
109+
)
110+
.subcommand(
111+
Command::new("snapshot")
112+
.about("Capture accessibility snapshot of the current page")
113+
.long_about(
114+
"Captures the page structure in a machine-readable format.\n\
115+
Useful for understanding page layout and element hierarchy."
116+
)
117+
)
118+
.subcommand(
119+
Command::new("evaluate")
120+
.about("Evaluate JavaScript on the page")
121+
.arg(
122+
Arg::new("script")
123+
.long("script")
124+
.short('s')
125+
.value_name("JAVASCRIPT")
126+
.required(true)
127+
.help("JavaScript code to evaluate")
128+
)
129+
)
130+
.subcommand(
131+
Command::new("wait-for")
132+
.about("Wait for an element to appear on the page")
133+
.arg(
134+
Arg::new("selector")
135+
.long("selector")
136+
.short('s')
137+
.value_name("SELECTOR")
138+
.required(true)
139+
.help("CSS selector to wait for")
140+
)
141+
.arg(
142+
Arg::new("timeout")
143+
.long("timeout")
144+
.short('t')
145+
.value_name("MILLISECONDS")
146+
.help("Timeout in milliseconds (default: 30000)")
147+
)
148+
)
149+
}

0 commit comments

Comments
 (0)