agentmux_mcp/tools/browser/
granted.rs1use serde_json::Value;
7
8pub(super) fn granted_text(d: &Value) -> String {
12 let sites: Vec<&str> = d["origins"].as_array().map(|a| a.iter().filter_map(|v| v.as_str()).collect()).unwrap_or_default();
13 let has = |p: &str| d["powers"].as_array().is_some_and(|a| a.iter().any(|v| v.as_str() == Some(p)));
14 let (terminal, per_line) = (has("terminal") && !has("terminal_ask"), has("terminal_ask"));
16 let how_long = if d["always"].as_bool() == Some(true) {
17 "until the user revokes it".to_string()
18 } else {
19 format!("for {} more min", d["minutes_left"].as_u64().unwrap_or(0))
20 };
21 let keys = if has("enter_space") {
23 "eval stays refused, and Enter and Space (action key) are taken as the click they are: a form's default button, \
24 a button, a link or a checkbox, checked like any click; on anything else they are refused, so click by ref"
25 } else {
26 "eval and Enter/Space stay refused"
27 };
28 let cut = match (d["cut_from"].as_u64(), d["minutes"].as_u64()) {
30 (Some(was), Some(now)) => format!(" Auto-approve was already on this pane with {was} more min; it was cut to the {now} you asked for."),
31 _ => String::new(),
32 };
33 format!(
34 "Auto-approve on {how_long} on {}: committing clicks (action click) run without asking. Nobody \
35 checks them now, so check each one yourself. A payment still asks, {keys}, and on any other site clicks ask as \
36 before.{}{}{} Stop it with action stop_auto_approve when the job is done.",
37 sites.join(", "),
38 if terminal {
39 " You may also type and run commands in a web terminal on these sites with action terminal: \
40 nobody checks each line, the user can Stop or Pause you, and a password or code prompt is theirs to type."
41 } else if per_line {
42 " You may also use a web terminal on these sites with action terminal, one line per call: the user is shown \
43 each line (give a `reason`) and presses Run it or Don't run; a password or code prompt is theirs to type."
44 } else {
45 ""
46 },
47 if has("uploads") {
48 " When a page opens its file chooser, AgentMux keeps it for 30 seconds: fill it with action set_files, chooser true and \
49 paths (files in your own workspace); a chooser nobody fills in time is cancelled."
50 } else {
51 ""
52 },
53 cut
54 )
55}