Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

feat(optimus): moves and types like a person, with a "Mercury is driving" overlay (0.4.0)

Salman Qureshi0081220ebcc9
diff --git a/plugins/optimus/companion/Cargo.lock b/plugins/optimus/companion/Cargo.lock
index 568024aa..5dd5c514 100644
--- a/plugins/optimus/companion/Cargo.lock
+++ b/plugins/optimus/companion/Cargo.lock
@@ -1280,16 +1280,21 @@ dependencies = [
[[package]]
name = "mercury-optimus"
-version = "0.3.0"
+version = "0.4.0"
dependencies = [
"base64 0.22.1",
"core-foundation",
"core-graphics 0.24.0",
"cpal",
+ "dispatch2",
"enigo",
"futures-util",
"http",
"image",
+ "objc2",
+ "objc2-app-kit",
+ "objc2-foundation",
+ "objc2-quartz-core",
"serde_json",
"tokio",
"tokio-websockets",
@@ -1710,8 +1715,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f"
dependencies = [
"bitflags 2.13.2",
+ "block2",
+ "libc",
"objc2",
+ "objc2-core-foundation",
+ "objc2-core-graphics",
+ "objc2-core-video",
"objc2-foundation",
+ "objc2-metal",
]
[[package]]
diff --git a/plugins/optimus/companion/Cargo.toml b/plugins/optimus/companion/Cargo.toml
index b3d97487..320269d4 100644
--- a/plugins/optimus/companion/Cargo.toml
+++ b/plugins/optimus/companion/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "mercury-optimus"
-version = "0.3.1"
+version = "0.4.0"
edition = "2024"
rust-version = "1.94"
description = "Optimus: full computer control for Mercury (screen, mouse, keyboard, apps, voice)"
@@ -23,14 +23,20 @@ ureq = "3"
cpal = "0.16"
[target.'cfg(target_os = "macos")'.dependencies]
-core-graphics = "0.24"
+core-graphics = { version = "0.24", features = ["highsierra"] }
core-foundation = "0.10"
+# The "Mercury is driving" overlay (AppKit, on the main thread).
+objc2 = "0.6"
+objc2-foundation = { version = "0.3", features = ["NSString", "NSGeometry", "NSThread"] }
+objc2-app-kit = { version = "0.3", features = ["objc2-core-graphics", "objc2-quartz-core", "NSApplication", "NSWindow", "NSPanel", "NSView", "NSColor", "NSTextField", "NSControl", "NSResponder", "NSGraphics", "NSFont", "NSText", "NSScreen", "NSRunningApplication"] }
+objc2-quartz-core = { version = "0.3", features = ["CALayer", "objc2-core-foundation"] }
+dispatch2 = "0.3"
[target.'cfg(target_os = "linux")'.dependencies]
-x11rb = "0.13"
+x11rb = { version = "0.13", features = ["xfixes", "shape"] }
[target.'cfg(windows)'.dependencies]
-windows-sys = { version = "0.61", features = ["Win32_UI_HiDpi", "Win32_Foundation", "Win32_UI_WindowsAndMessaging", "Win32_UI_Input_KeyboardAndMouse"] }
+windows-sys = { version = "0.61", features = ["Win32_UI_HiDpi", "Win32_Foundation", "Win32_UI_WindowsAndMessaging", "Win32_UI_Input_KeyboardAndMouse", "Win32_Graphics_Gdi", "Win32_System_LibraryLoader"] }
[profile.release]
opt-level = 3
diff --git a/plugins/optimus/companion/src/mac.rs b/plugins/optimus/companion/src/mac.rs
index 1fef46ae..f6656dfa 100644
--- a/plugins/optimus/companion/src/mac.rs
+++ b/plugins/optimus/companion/src/mac.rs
@@ -128,11 +128,15 @@ pub fn agent_main(socket: &Path) -> ! {
}
// The plugin side closed: dropping tx ends the core.
});
- crate::core::run(rx, move |v| {
- let mut w = writer.lock().unwrap_or_else(|e| e.into_inner());
- let _ = writeln!(w, "{v}");
+ // The core runs on a thread; the main thread belongs to AppKit (the overlay).
+ std::thread::spawn(move || {
+ crate::core::run(rx, move |v| {
+ let mut w = writer.lock().unwrap_or_else(|e| e.into_inner());
+ let _ = writeln!(w, "{v}");
+ });
+ std::process::exit(0);
});
- std::process::exit(0)
+ crate::overlay::run_main_loop()
}
// ── In the plugin process ──────────────────────────────────────────────
diff --git a/plugins/optimus/companion/src/main.rs b/plugins/optimus/companion/src/main.rs
index 83b7cd6b..468f644c 100644
--- a/plugins/optimus/companion/src/main.rs
+++ b/plugins/optimus/companion/src/main.rs
@@ -22,7 +22,9 @@ mod hotkey;
mod links;
#[cfg(target_os = "macos")]
mod mac;
+mod motion;
mod ops;
+mod overlay;
mod voice;
pub use crate::core::log;
@@ -176,7 +178,7 @@ fn action_schema() -> Value {
"y": { "type": "number" },
"to_x": { "type": "number", "description": "drag: end x" },
"to_y": { "type": "number", "description": "drag: end y" },
- "text": { "type": "string", "description": "type/paste: the text (with x/y, clicks there first). Use paste for posts, emails and long text in web editors (X, Gmail, LinkedIn, Docs)" },
+ "text": { "type": "string", "description": "type/paste: the text (with x/y, clicks there first). type is the default for everything; paste is a fallback" },
"points": { "type": "array", "items": { "type": "array", "items": { "type": "number" } }, "description": "draw: [[x, y], …] one freehand stroke with the button held (many points for curves)" },
"keys": { "type": "string", "description": "key: one key or a combo, e.g. \"enter\", \"cmd+t\", \"ctrl+shift+esc\"" },
"modifiers": { "type": "string", "description": "click: keys held while clicking, e.g. \"cmd\" or \"shift\"" },
@@ -198,7 +200,7 @@ fn action_schema() -> Value {
const TOOL_DESCRIPTIONS: [(&str, &str); 7] = [
("look", "See the screen: a screenshot of the display the mouse is on (or `display` N), with the active window. Use `zoom` [x0,y0,x1,y1] for a closer look at part of the last screenshot (coordinates stay in the full screenshot)."),
- ("act", "Use the mouse and keyboard like a person: click, type, paste, press keys, scroll, drag, draw freehand. Returns a fresh screenshot. Pass `actions` as a list. For posts, emails and long text in web pages, use paste (click the box first) rather than type. Only for ordinary, reversible steps. Anything that submits, sends, posts, pays, buys, deletes, installs or changes settings must go through act_consequential instead. Never type passwords, card numbers or 2FA codes: ask the owner to do that part."),
+ ("act", "Use the mouse and keyboard like a person: click, type, paste, press keys, scroll, drag, draw freehand. Returns a fresh screenshot. Pass `actions` as a list. To write text (posts, emails, articles) click the box, then use type: it types key by key like a person, so it works in every editor (up to 3,000 characters per type action; longer text in parts). Use paste only if typing fails. Only for ordinary, reversible steps. Anything that submits, sends, posts, pays, buys, deletes, installs or changes settings must go through act_consequential instead. Never type passwords, card numbers or 2FA codes: ask the owner to do that part."),
("act_consequential", "Same as act, for the step that commits something: submit a form, send a message or email, post, pay or buy, delete, install, change a setting. The owner approves it first, so say what it will do."),
("open", "Open an app by name (\"Chrome\", \"Notes\", \"Freeform\"), a URL, or a file/folder path. Faster and more reliable than clicking through menus. If the app isn't installed, the reply lists what is. For drawing use Freeform (Mac), Paint (Windows) or a web canvas like https://excalidraw.com."),
("windows", "List open windows (app and title), front first."),
@@ -236,7 +238,8 @@ fn call_tool(shell: &Arc<Shell>, name: &str, args: &Value) -> Value {
return json!({ "content": [{ "type": "text", "text": NOT_ALLOWED }], "isError": true });
}
let op = if name == "act_consequential" { "act" } else { name };
- match shell.op(op, args, Duration::from_secs(150)) {
+ // Long articles are typed key by key, so act may take minutes.
+ match shell.op(op, args, Duration::from_secs(if op == "act" { 310 } else { 150 })) {
Ok(v) => {
let mut content = vec![json!({ "type": "text", "text": v["text"].as_str().unwrap_or("Done.") })];
if let (Some(data), Some(mime)) = (v["image"]["data"].as_str(), v["image"]["mimeType"].as_str()) {
diff --git a/plugins/optimus/companion/src/motion.rs b/plugins/optimus/companion/src/motion.rs
new file mode 100644
index 00000000..267d834f
--- /dev/null
+++ b/plugins/optimus/companion/src/motion.rs
@@ -0,0 +1,256 @@
+//! Moving like a person: the pointer glides along a gentle curve with
+//! ease-in/ease-out, scrolling arrives in many small steps, and typing goes
+//! key by key with a natural, uneven rhythm. Everything checks between steps
+//! whether the owner grabbed the mouse, and stops if so.
+//!
+//! Pace comes from the plugin setting `pace`: "natural" (default) or "fast".
+
+use std::time::Duration;
+
+use enigo::{Axis, Coordinate, Direction, Enigo, Key, Keyboard, Mouse};
+use serde_json::Value;
+
+/// The owner moving the mouse this far from where we put it means they took over.
+const TAKEOVER_PX: i32 = 12;
+
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+pub enum Pace {
+ Natural,
+ Fast,
+}
+
+pub fn pace() -> Pace {
+ match crate::core::settings().get("pace").and_then(Value::as_str) {
+ Some("fast") => Pace::Fast,
+ _ => Pace::Natural,
+ }
+}
+
+/// Small, dependency-free randomness for timing jitter and curve shape.
+struct Jitter(u64);
+
+impl Jitter {
+ fn new() -> Self {
+ let seed = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_nanos() as u64).unwrap_or(7) | 1;
+ Jitter(seed)
+ }
+ /// 0.0 ..< 1.0
+ fn next(&mut self) -> f64 {
+ self.0 ^= self.0 << 13;
+ self.0 ^= self.0 >> 7;
+ self.0 ^= self.0 << 17;
+ (self.0 >> 11) as f64 / (1u64 << 53) as f64
+ }
+ fn between(&mut self, lo: f64, hi: f64) -> f64 {
+ lo + (hi - lo) * self.next()
+ }
+}
+
+fn err(e: impl std::fmt::Display) -> String {
+ e.to_string()
+}
+
+const TOOK_OVER: &str = "you moved the mouse, so Optimus stopped and handed control back";
+
+/// Glide the pointer to `to` (screen coordinates). `last` is where we last put it.
+pub fn glide(e: &mut Enigo, to: (i32, i32), last: &mut Option<(i32, i32)>) -> Result<(), String> {
+ let from = e.location().unwrap_or(to);
+ if let Some((lx, ly)) = *last {
+ if (from.0 - lx).abs() > TAKEOVER_PX || (from.1 - ly).abs() > TAKEOVER_PX {
+ return Err(TOOK_OVER.into());
+ }
+ }
+ let (dx, dy) = ((to.0 - from.0) as f64, (to.1 - from.1) as f64);
+ let dist = (dx * dx + dy * dy).sqrt();
+ if dist < 2.0 {
+ e.move_mouse(to.0, to.1, Coordinate::Abs).map_err(err)?;
+ crate::overlay::follow(to.0, to.1);
+ *last = Some(to);
+ return Ok(());
+ }
+ let mut j = Jitter::new();
+ let ms = match pace() {
+ Pace::Natural => (180.0 + dist * 0.45).clamp(200.0, 750.0) * j.between(0.9, 1.15),
+ Pace::Fast => (60.0 + dist * 0.12).clamp(70.0, 220.0),
+ };
+ // A gentle bow sideways, like a wrist pivoting: a quadratic Bézier curve.
+ let bow = dist * j.between(0.04, 0.12) * if j.next() < 0.5 { -1.0 } else { 1.0 };
+ let (nx, ny) = (-dy / dist, dx / dist);
+ let ctrl = (from.0 as f64 + dx * 0.5 + nx * bow, from.1 as f64 + dy * 0.5 + ny * bow);
+ let step_ms = 8.0;
+ let steps = ((ms / step_ms) as usize).max(4);
+ let mut prev = from;
+ for i in 1..=steps {
+ let t = i as f64 / steps as f64;
+ // Ease in and out (smootherstep).
+ let s = t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
+ let u = 1.0 - s;
+ let x = u * u * from.0 as f64 + 2.0 * u * s * ctrl.0 + s * s * to.0 as f64;
+ let y = u * u * from.1 as f64 + 2.0 * u * s * ctrl.1 + s * s * to.1 as f64;
+ let p = (x.round() as i32, y.round() as i32);
+ if p != prev {
+ // Something other than us moved it since the last step: the owner took over.
+ if let Ok(now) = e.location() {
+ if (now.0 - prev.0).abs() > TAKEOVER_PX || (now.1 - prev.1).abs() > TAKEOVER_PX {
+ *last = None;
+ return Err(TOOK_OVER.into());
+ }
+ }
+ e.move_mouse(p.0, p.1, Coordinate::Abs).map_err(err)?;
+ if i % 2 == 0 || i == steps {
+ crate::overlay::follow(p.0, p.1);
+ }
+ prev = p;
+ }
+ std::thread::sleep(Duration::from_millis(step_ms as u64));
+ }
+ e.move_mouse(to.0, to.1, Coordinate::Abs).map_err(err)?;
+ crate::overlay::follow(to.0, to.1);
+ *last = Some(to);
+ // A beat before acting, as a hand settles.
+ std::thread::sleep(Duration::from_millis(if pace() == Pace::Natural { j.between(60.0, 140.0) as u64 } else { 20 }));
+ Ok(())
+}
+
+/// Type `text` key by key. Returns how many characters were typed.
+pub fn type_text(e: &mut Enigo, text: &str, last: &Option<(i32, i32)>) -> Result<usize, String> {
+ let mut j = Jitter::new();
+ let fast = pace() == Pace::Fast;
+ let mut n = 0usize;
+ for c in text.chars() {
+ if n % 12 == 0 {
+ if let (Some((lx, ly)), Ok(now)) = (*last, e.location()) {
+ if (now.0 - lx).abs() > TAKEOVER_PX || (now.1 - ly).abs() > TAKEOVER_PX {
+ return Err(format!("typed {n} characters, then {TOOK_OVER}"));
+ }
+ }
+ }
+ match c {
+ '\n' => e.key(Key::Return, Direction::Click).map_err(err)?,
+ '\t' => e.key(Key::Tab, Direction::Click).map_err(err)?,
+ '\r' => {}
+ _ => e.text(&c.to_string()).map_err(err)?,
+ }
+ n += 1;
+ let ms = if fast {
+ j.between(4.0, 12.0)
+ } else {
+ let mut d = j.between(28.0, 85.0);
+ if c == ' ' {
+ d += j.between(10.0, 60.0);
+ }
+ if matches!(c, '.' | ',' | '!' | '?' | ';' | ':' | '\n') {
+ d += j.between(90.0, 260.0);
+ }
+ // Now and then a short thinking pause.
+ if j.next() < 0.015 {
+ d += j.between(200.0, 500.0);
+ }
+ d
+ };
+ std::thread::sleep(Duration::from_millis(ms as u64));
+ }
+ Ok(n)
+}
+
+/// Scroll `amount` notches in `dir`, smoothly: many small steps instead of jumps.
+pub fn smooth_scroll(e: &mut Enigo, dir: &str, amount: i32) -> Result<(), String> {
+ let (sign, vertical) = match dir {
+ "down" => (1, true),
+ "up" => (-1, true),
+ "right" => (1, false),
+ "left" => (-1, false),
+ other => return Err(format!("scroll direction is up, down, left or right, not {other}")),
+ };
+ let fast = pace() == Pace::Fast;
+ platform_scroll(e, sign, vertical, amount, fast)
+}
+
+#[cfg(target_os = "macos")]
+fn platform_scroll(_e: &mut Enigo, sign: i32, vertical: bool, amount: i32, fast: bool) -> Result<(), String> {
+ use core_graphics::event::{CGEvent, CGEventTapLocation, ScrollEventUnit};
+ use core_graphics::event_source::{CGEventSource, CGEventSourceStateID};
+ // Pixel scrolling with an ease-out, like a trackpad flick: ~70 px per notch.
+ let total = (amount * 70) as f64;
+ let steps = if fast { 10 } else { 28 };
+ let weights: Vec<f64> = (0..steps).map(|i| 1.0 - i as f64 / steps as f64).collect();
+ let sum: f64 = weights.iter().sum();
+ let mut sent = 0i32;
+ for (i, w) in weights.iter().enumerate() {
+ let target = (total * weights[..=i].iter().sum::<f64>() / sum).round() as i32;
+ let px = target - sent;
+ sent = target;
+ if px == 0 {
+ continue;
+ }
+ let source = CGEventSource::new(CGEventSourceStateID::HIDSystemState).map_err(|_| "can't scroll".to_string())?;
+ // CoreGraphics: positive scrolls up/left; ours: positive is down/right.
+ let delta = -sign * px;
+ let ev = if vertical {
+ CGEvent::new_scroll_event(source, ScrollEventUnit::PIXEL, 2, delta, 0, 0)
+ } else {
+ CGEvent::new_scroll_event(source, ScrollEventUnit::PIXEL, 2, 0, delta, 0)
+ }
+ .map_err(|_| "can't scroll".to_string())?;
+ ev.post(CGEventTapLocation::HID);
+ let _ = w;
+ std::thread::sleep(Duration::from_millis(if fast { 8 } else { 14 }));
+ }
+ Ok(())
+}
+
+#[cfg(windows)]
+fn platform_scroll(_e: &mut Enigo, sign: i32, vertical: bool, amount: i32, fast: bool) -> Result<(), String> {
+ use windows_sys::Win32::UI::Input::KeyboardAndMouse::{INPUT, INPUT_0, INPUT_MOUSE, MOUSEEVENTF_HWHEEL, MOUSEEVENTF_WHEEL, MOUSEINPUT, SendInput};
+ // Windows wheel units are 120 per notch; modern apps scroll smoothly on smaller deltas.
+ let per_step = 20i32;
+ let steps = (amount * 120 / per_step).max(1);
+ for _ in 0..steps {
+ // Windows: positive wheel scrolls up; positive h-wheel scrolls right.
+ let delta = if vertical { -sign * per_step } else { sign * per_step };
+ let input = INPUT {
+ r#type: INPUT_MOUSE,
+ Anonymous: INPUT_0 {
+ mi: MOUSEINPUT {
+ dx: 0,
+ dy: 0,
+ mouseData: delta as _,
+ dwFlags: if vertical { MOUSEEVENTF_WHEEL } else { MOUSEEVENTF_HWHEEL },
+ time: 0,
+ dwExtraInfo: 0,
+ },
+ },
+ };
+ unsafe { SendInput(1, &input, std::mem::size_of::<INPUT>() as i32) };
+ std::thread::sleep(Duration::from_millis(if fast { 4 } else { 12 }));
+ }
+ Ok(())
+}
+
+#[cfg(all(not(target_os = "macos"), not(windows)))]
+fn platform_scroll(e: &mut Enigo, sign: i32, vertical: bool, amount: i32, fast: bool) -> Result<(), String> {
+ // X11 wheel clicks are whole notches: space them out so it reads as scrolling, not jumping.
+ for _ in 0..amount {
+ e.scroll(sign, if vertical { Axis::Vertical } else { Axis::Horizontal }).map_err(err)?;
+ std::thread::sleep(Duration::from_millis(if fast { 15 } else { 45 }));
+ }
+ Ok(())
+}
+
+#[cfg(any(target_os = "macos", windows))]
+#[allow(dead_code)]
+fn _axis_used(_: Axis) {}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn jitter_stays_in_range() {
+ let mut j = Jitter::new();
+ for _ in 0..1000 {
+ let v = j.between(2.0, 5.0);
+ assert!((2.0..5.0).contains(&v));
+ }
+ }
+}
diff --git a/plugins/optimus/companion/src/ops.rs b/plugins/optimus/companion/src/ops.rs
index 4dabeed2..d2eb1167 100644
--- a/plugins/optimus/companion/src/ops.rs
+++ b/plugins/optimus/companion/src/ops.rs
@@ -13,7 +13,7 @@
use std::time::{Duration, Instant};
use base64::Engine as _;
-use enigo::{Axis, Button, Coordinate, Direction, Enigo, Key, Keyboard, Mouse, Settings};
+use enigo::{Button, Coordinate, Direction, Enigo, Key, Keyboard, Mouse, Settings};
use serde_json::{Value, json};
use xcap::image::{DynamicImage, RgbaImage, codecs::jpeg::JpegEncoder, imageops::FilterType};
use xcap::{Monitor, Window};
@@ -27,7 +27,8 @@ const TAKEOVER_PX: i32 = 12;
const MAX_ACTIONS: usize = 60;
/// Points in one freehand stroke.
const MAX_DRAW_POINTS: usize = 2000;
-const MAX_TYPE_CHARS: usize = 4000;
+/// Typed key by key at a human pace: ~3,000 characters is a few minutes, inside one tool call.
+const MAX_TYPE_CHARS: usize = 3_000;
/// Where the last screenshot came from, to map its pixels back to the screen.
#[derive(Clone, Copy)]
@@ -150,7 +151,10 @@ impl Ops {
mon.width().map_err(err)?,
mon.height().map_err(err)?,
);
- let full = mon.capture_image().map_err(|e| capture_error(&e.to_string()))?;
+ let full = {
+ let _hidden = crate::overlay::capture_guard();
+ mon.capture_image().map_err(|e| capture_error(&e.to_string()))?
+ };
// Zoom: a closer look at part of the last screenshot. Coordinates keep
// referring to the full screenshot, so the zoom never moves the frame.
@@ -220,6 +224,9 @@ impl Ops {
}
}
}
+ if i > 0 {
+ std::thread::sleep(Duration::from_millis(if crate::motion::pace() == crate::motion::Pace::Natural { 120 } else { 30 }));
+ }
match self.one(a, &mut last_set) {
Ok(d) => done.push(d),
Err(e) => {
@@ -228,6 +235,7 @@ impl Ops {
}
}
}
+ crate::overlay::done();
// Let the screen settle, then show what happened (unless asked not to).
let mut out = json!({});
let mut text = if done.is_empty() { "Nothing was done.".to_string() } else { format!("Done: {}.", done.join("; ")) };
@@ -272,12 +280,8 @@ impl Ops {
_ => what.to_string(),
};
let e = self.enigo()?;
- let move_to = |e: &mut Enigo, p: (i32, i32), last: &mut Option<(i32, i32)>| -> Result<(), String> {
- e.move_mouse(p.0, p.1, Coordinate::Abs).map_err(err)?;
- *last = Some(p);
- std::thread::sleep(Duration::from_millis(30));
- Ok(())
- };
+ // The pointer glides there like a hand would (motion.rs), never jumps.
+ let move_to = |e: &mut Enigo, p: (i32, i32), last: &mut Option<(i32, i32)>| -> Result<(), String> { crate::motion::glide(e, p, last) };
match kind {
"click" | "double_click" | "triple_click" | "right_click" | "middle_click" => {
if let Some(p) = at {
@@ -326,31 +330,24 @@ impl Ops {
let e = self.enigo()?;
move_to(e, from, last_set)?;
e.button(Button::Left, Direction::Press).map_err(err)?;
- for s in 1..=12 {
- let t = s as f64 / 12.0;
- let p = (
- from.0 + ((to.0 - from.0) as f64 * t).round() as i32,
- from.1 + ((to.1 - from.1) as f64 * t).round() as i32,
- );
- e.move_mouse(p.0, p.1, Coordinate::Abs).map_err(err)?;
- std::thread::sleep(Duration::from_millis(16));
- }
- *last_set = Some(to);
+ std::thread::sleep(Duration::from_millis(60));
+ let moved = crate::motion::glide(e, to, last_set);
e.button(Button::Left, Direction::Release).map_err(err)?;
+ moved?;
Ok(format!("dragged to ({}, {})", a["to_x"], a["to_y"]))
}
"type" => {
let text = a.get("text").and_then(Value::as_str).ok_or("type needs text")?;
if text.chars().count() > MAX_TYPE_CHARS {
- return Err(format!("type at most {MAX_TYPE_CHARS} characters at a time"));
+ return Err(format!("type at most {MAX_TYPE_CHARS} characters per action; type the rest in the next act call"));
}
if let Some(p) = at {
move_to(e, p, last_set)?;
e.button(Button::Left, Direction::Click).map_err(err)?;
std::thread::sleep(Duration::from_millis(200)); // let the field take focus
}
- e.text(text).map_err(err)?;
- Ok(format!("typed {} characters", text.chars().count()))
+ let n = crate::motion::type_text(e, text, last_set)?;
+ Ok(format!("typed {n} characters"))
}
"paste" => {
// Rich web editors (X, Gmail, LinkedIn, Docs) take pasted text more reliably than typed keys.
@@ -424,14 +421,7 @@ impl Ops {
}
let dir = a.get("direction").and_then(Value::as_str).unwrap_or("down");
let amount = a.get("amount").and_then(Value::as_i64).unwrap_or(3).clamp(1, 30) as i32;
- let (len, axis) = match dir {
- "down" => (amount, Axis::Vertical),
- "up" => (-amount, Axis::Vertical),
- "right" => (amount, Axis::Horizontal),
- "left" => (-amount, Axis::Horizontal),
- other => return Err(format!("scroll direction is up, down, left or right, not {other}")),
- };
- e.scroll(len, axis).map_err(err)?;
+ crate::motion::smooth_scroll(e, dir, amount)?;
Ok(label(&format!("scrolled {dir} {amount}")))
}
"wait" => {
diff --git a/plugins/optimus/companion/src/overlay.rs b/plugins/optimus/companion/src/overlay.rs
new file mode 100644
index 00000000..41aba6b1
--- /dev/null
+++ b/plugins/optimus/companion/src/overlay.rs
@@ -0,0 +1,444 @@
+//! "Mercury is driving": a glowing ring around the pointer and a small label
+//! beside it while Optimus moves the mouse, so it's obvious the agent (not
+//! the owner) is in control. It fades out a moment after the last action.
+//!
+//! - macOS: two borderless AppKit windows on the main thread (Optimus.app
+//! runs an NSApplication for them), click-through, on every Space, and
+//! excluded from screen capture so Optimus's own screenshots never see them.
+//! - Windows: a layered, click-through, topmost tool window excluded from
+//! capture (WDA_EXCLUDEFROMCAPTURE).
+//! - Linux X11: a small label window that ignores input and is hidden while a
+//! screenshot is taken. Wayland doesn't let apps place such windows.
+//!
+//! `follow` and `done` can be called from any thread.
+
+use std::sync::atomic::{AtomicU64, Ordering};
+use std::time::Duration;
+
+pub const LABEL: &str = "☿ Mercury · Optimus is driving";
+
+/// Bumped on every follow: a pending hide only fires if nothing moved since.
+static GENERATION: AtomicU64 = AtomicU64::new(0);
+
+/// Show the overlay at the pointer (screen coordinates, as the input APIs use).
+pub fn follow(x: i32, y: i32) {
+ if !enabled() {
+ return;
+ }
+ GENERATION.fetch_add(1, Ordering::Relaxed);
+ platform::follow(x, y);
+}
+
+/// The batch of actions is over: fade out soon unless more come.
+pub fn done() {
+ let generation = GENERATION.load(Ordering::Relaxed);
+ std::thread::spawn(move || {
+ std::thread::sleep(Duration::from_millis(1600));
+ if GENERATION.load(Ordering::Relaxed) == generation {
+ platform::hide();
+ }
+ });
+}
+
+/// Around a screenshot on platforms that can't exclude the overlay from capture.
+pub fn capture_guard() -> CaptureGuard {
+ CaptureGuard(platform::hide_for_capture())
+}
+
+pub struct CaptureGuard(bool);
+
+impl Drop for CaptureGuard {
+ fn drop(&mut self) {
+ if self.0 {
+ platform::restore_after_capture();
+ }
+ }
+}
+
+fn enabled() -> bool {
+ crate::core::settings().get("showOverlay").and_then(serde_json::Value::as_bool) != Some(false)
+}
+
+// ── macOS ─────────────────────────────────────────────────────────────
+
+#[cfg(target_os = "macos")]
+mod platform {
+ use std::cell::RefCell;
+
+ use dispatch2::DispatchQueue;
+ use objc2::rc::Retained;
+ use objc2::{MainThreadMarker, MainThreadOnly};
+ use objc2_app_kit::{
+ NSApplication, NSApplicationActivationPolicy, NSBackingStoreType, NSColor, NSFont, NSScreen, NSTextField, NSWindow,
+ NSWindowCollectionBehavior, NSWindowSharingType, NSWindowStyleMask,
+ };
+ use objc2_foundation::{NSPoint, NSRect, NSSize, NSString};
+
+ const RING: f64 = 46.0;
+ const LABEL_W: f64 = 236.0;
+ const LABEL_H: f64 = 26.0;
+
+ struct Windows {
+ ring: Retained<NSWindow>,
+ label: Retained<NSWindow>,
+ shown: bool,
+ }
+
+ thread_local! {
+ static WINDOWS: RefCell<Option<Windows>> = const { RefCell::new(None) };
+ }
+
+ fn window(mtm: MainThreadMarker, w: f64, h: f64) -> Retained<NSWindow> {
+ let rect = NSRect::new(NSPoint::new(0.0, 0.0), NSSize::new(w, h));
+ let win = unsafe {
+ NSWindow::initWithContentRect_styleMask_backing_defer(NSWindow::alloc(mtm), rect, NSWindowStyleMask::Borderless, NSBackingStoreType::Buffered, false)
+ };
+ unsafe { win.setReleasedWhenClosed(false) };
+ win.setOpaque(false);
+ win.setBackgroundColor(Some(&NSColor::clearColor()));
+ win.setHasShadow(false);
+ win.setIgnoresMouseEvents(true);
+ win.setLevel(1000); // screen-saver level: above full-screen apps and menus
+ win.setCollectionBehavior(
+ NSWindowCollectionBehavior::CanJoinAllSpaces
+ | NSWindowCollectionBehavior::Stationary
+ | NSWindowCollectionBehavior::IgnoresCycle
+ | NSWindowCollectionBehavior::FullScreenAuxiliary,
+ );
+ // Never in screenshots, including Optimus's own.
+ win.setSharingType(NSWindowSharingType::None);
+ win
+ }
+
+ fn build(mtm: MainThreadMarker) -> Windows {
+ let accent = NSColor::colorWithSRGBRed_green_blue_alpha(0.46, 0.38, 1.0, 0.95);
+ let glow = NSColor::colorWithSRGBRed_green_blue_alpha(0.46, 0.38, 1.0, 0.16);
+ let dark = NSColor::colorWithSRGBRed_green_blue_alpha(0.09, 0.08, 0.16, 0.86);
+
+ let ring = window(mtm, RING, RING);
+ if let Some(view) = ring.contentView() {
+ view.setWantsLayer(true);
+ if let Some(layer) = view.layer() {
+ layer.setCornerRadius(RING / 2.0);
+ layer.setBorderWidth(3.0);
+ layer.setBorderColor(Some(&accent.CGColor()));
+ layer.setBackgroundColor(Some(&glow.CGColor()));
+ }
+ }
+
+ let label = window(mtm, LABEL_W, LABEL_H);
+ if let Some(view) = label.contentView() {
+ view.setWantsLayer(true);
+ if let Some(layer) = view.layer() {
+ layer.setCornerRadius(LABEL_H / 2.0);
+ layer.setBackgroundColor(Some(&dark.CGColor()));
+ layer.setBorderWidth(1.0);
+ layer.setBorderColor(Some(&accent.CGColor()));
+ }
+ let text = NSTextField::labelWithString(&NSString::from_str(super::LABEL), mtm);
+ text.setTextColor(Some(&NSColor::whiteColor()));
+ text.setFont(Some(&NSFont::boldSystemFontOfSize(12.0)));
+ text.setFrame(NSRect::new(NSPoint::new(12.0, 5.0), NSSize::new(LABEL_W - 20.0, LABEL_H - 9.0)));
+ view.addSubview(&text);
+ }
+ Windows { ring, label, shown: false }
+ }
+
+ /// Run AppKit on the main thread (never returns). The overlay windows live here.
+ pub fn run_main_loop() -> ! {
+ let mtm = MainThreadMarker::new().expect("main thread");
+ let app = NSApplication::sharedApplication(mtm);
+ app.setActivationPolicy(NSApplicationActivationPolicy::Accessory);
+ WINDOWS.with(|w| *w.borrow_mut() = Some(build(mtm)));
+ app.run();
+ std::process::exit(0)
+ }
+
+ pub fn follow(x: i32, y: i32) {
+ DispatchQueue::main().exec_async(move || {
+ let Some(mtm) = MainThreadMarker::new() else { return };
+ // AppKit's origin is the bottom-left of the main screen; ours is its top-left.
+ let screens = NSScreen::screens(mtm);
+ let Some(main) = screens.firstObject() else { return };
+ let h = main.frame().size.height;
+ let (fx, fy) = (x as f64, h - y as f64);
+ WINDOWS.with(|w| {
+ if let Some(w) = w.borrow_mut().as_mut() {
+ w.ring.setFrameOrigin(NSPoint::new(fx - RING / 2.0, fy - RING / 2.0));
+ w.label.setFrameOrigin(NSPoint::new(fx + RING / 2.0 + 4.0, fy - RING / 2.0 - LABEL_H + 6.0));
+ if !w.shown {
+ w.ring.orderFrontRegardless();
+ w.label.orderFrontRegardless();
+ w.shown = true;
+ }
+ }
+ });
+ });
+ }
+
+ pub fn hide() {
+ DispatchQueue::main().exec_async(|| {
+ WINDOWS.with(|w| {
+ if let Some(w) = w.borrow_mut().as_mut() {
+ w.ring.orderOut(None);
+ w.label.orderOut(None);
+ w.shown = false;
+ }
+ });
+ });
+ }
+
+ /// Excluded from capture already: nothing to do.
+ pub fn hide_for_capture() -> bool {
+ false
+ }
+ pub fn restore_after_capture() {}
+}
+
+// ── Windows ───────────────────────────────────────────────────────────
+
+#[cfg(windows)]
+mod platform {
+ use std::sync::atomic::{AtomicIsize, Ordering};
+ use std::sync::Once;
+
+ use windows_sys::Win32::Foundation::{COLORREF, HWND, LPARAM, LRESULT, RECT, WPARAM};
+ use windows_sys::Win32::Graphics::Gdi::{
+ BeginPaint, CreatePen, CreateSolidBrush, DeleteObject, Ellipse, EndPaint, FillRect, GetStockObject, NULL_BRUSH, PAINTSTRUCT, PS_SOLID,
+ RoundRect, SelectObject, SetBkMode, SetTextColor, TRANSPARENT, TextOutW,
+ };
+ use windows_sys::Win32::System::LibraryLoader::GetModuleHandleW;
+ use windows_sys::Win32::UI::WindowsAndMessaging::{
+ CreateWindowExW, DefWindowProcW, DispatchMessageW, GetMessageW, HWND_TOPMOST, LWA_ALPHA, LWA_COLORKEY, MSG, RegisterClassW,
+ SW_HIDE, SWP_NOACTIVATE, SWP_NOSIZE, SWP_SHOWWINDOW, SetLayeredWindowAttributes, SetWindowDisplayAffinity, SetWindowPos, ShowWindow,
+ TranslateMessage, WDA_EXCLUDEFROMCAPTURE, WM_PAINT, WNDCLASSW, WS_EX_LAYERED, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_EX_TOPMOST,
+ WS_EX_TRANSPARENT, WS_POPUP,
+ };
+
+ const W: i32 = 300;
+ const H: i32 = 52;
+ const RING: i32 = 44;
+ const KEY: COLORREF = 0x00FF00FF; // magenta = transparent
+
+ static HWND_: AtomicIsize = AtomicIsize::new(0);
+ static START: Once = Once::new();
+
+ fn wide(s: &str) -> Vec<u16> {
+ s.encode_utf16().chain(std::iter::once(0)).collect()
+ }
+
+ fn rgb(r: u8, g: u8, b: u8) -> COLORREF {
+ r as u32 | ((g as u32) << 8) | ((b as u32) << 16)
+ }
+
+ unsafe extern "system" fn wndproc(hwnd: HWND, msg: u32, wp: WPARAM, lp: LPARAM) -> LRESULT {
+ if msg == WM_PAINT {
+ unsafe {
+ let mut ps: PAINTSTRUCT = std::mem::zeroed();
+ let dc = BeginPaint(hwnd, &mut ps);
+ let key = CreateSolidBrush(KEY);
+ let all = RECT { left: 0, top: 0, right: W, bottom: H };
+ FillRect(dc, &all, key);
+ DeleteObject(key);
+ let pen = CreatePen(PS_SOLID, 3, rgb(118, 97, 255));
+ let old_pen = SelectObject(dc, pen);
+ let old_brush = SelectObject(dc, GetStockObject(NULL_BRUSH));
+ Ellipse(dc, 3, 3, RING, RING);
+ let dark = CreateSolidBrush(rgb(24, 20, 40));
+ SelectObject(dc, dark);
+ RoundRect(dc, RING + 4, 16, W - 2, H - 4, 14, 14);
+ SetBkMode(dc, TRANSPARENT as i32);
+ SetTextColor(dc, rgb(255, 255, 255));
+ let text = wide(super::LABEL);
+ TextOutW(dc, RING + 14, 22, text.as_ptr(), (text.len() - 1) as i32);
+ SelectObject(dc, old_pen);
+ SelectObject(dc, old_brush);
+ DeleteObject(pen);
+ DeleteObject(dark);
+ EndPaint(hwnd, &ps);
+ }
+ return 0;
+ }
+ unsafe { DefWindowProcW(hwnd, msg, wp, lp) }
+ }
+
+ fn ensure() {
+ START.call_once(|| {
+ std::thread::spawn(|| unsafe {
+ let class = wide("MercuryOptimusOverlay");
+ let hinst = GetModuleHandleW(std::ptr::null());
+ let wc = WNDCLASSW {
+ lpfnWndProc: Some(wndproc),
+ hInstance: hinst,
+ lpszClassName: class.as_ptr(),
+ ..std::mem::zeroed()
+ };
+ RegisterClassW(&wc);
+ let hwnd = CreateWindowExW(
+ WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE,
+ class.as_ptr(),
+ class.as_ptr(),
+ WS_POPUP,
+ 0,
+ 0,
+ W,
+ H,
+ std::ptr::null_mut(),
+ std::ptr::null_mut(),
+ hinst,
+ std::ptr::null(),
+ );
+ SetLayeredWindowAttributes(hwnd, KEY, 235, LWA_COLORKEY | LWA_ALPHA);
+ SetWindowDisplayAffinity(hwnd, WDA_EXCLUDEFROMCAPTURE);
+ HWND_.store(hwnd as isize, Ordering::Relaxed);
+ let mut msg: MSG = std::mem::zeroed();
+ while GetMessageW(&mut msg, std::ptr::null_mut(), 0, 0) > 0 {
+ TranslateMessage(&msg);
+ DispatchMessageW(&msg);
+ }
+ });
+ std::thread::sleep(std::time::Duration::from_millis(100));
+ });
+ }
+
+ pub fn follow(x: i32, y: i32) {
+ ensure();
+ let h = HWND_.load(Ordering::Relaxed);
+ if h != 0 {
+ unsafe { SetWindowPos(h as HWND, HWND_TOPMOST, x - RING / 2, y - RING / 2, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW) };
+ }
+ }
+
+ pub fn hide() {
+ let h = HWND_.load(Ordering::Relaxed);
+ if h != 0 {
+ unsafe { ShowWindow(h as HWND, SW_HIDE) };
+ }
+ }
+
+ pub fn hide_for_capture() -> bool {
+ false
+ }
+ pub fn restore_after_capture() {}
+}
+
+// ── Linux (X11) ───────────────────────────────────────────────────────
+
+#[cfg(target_os = "linux")]
+mod platform {
+ use std::sync::Mutex;
+
+ use x11rb::connection::Connection;
+ use x11rb::protocol::xfixes::ConnectionExt as _;
+ use x11rb::protocol::xproto::{ConfigureWindowAux, ConnectionExt, CreateGCAux, CreateWindowAux, EventMask, WindowClass};
+ use x11rb::rust_connection::RustConnection;
+
+ struct Overlay {
+ conn: RustConnection,
+ win: u32,
+ gc: u32,
+ shown: bool,
+ }
+
+ static OVERLAY: Mutex<Option<Option<Overlay>>> = Mutex::new(None);
+
+ fn open() -> Option<Overlay> {
+ if std::env::var_os("DISPLAY").is_none() {
+ return None;
+ }
+ let (conn, screen_num) = x11rb::connect(None).ok()?;
+ let screen = &conn.setup().roots[screen_num];
+ let (root, black, white) = (screen.root, screen.black_pixel, screen.white_pixel);
+ let win = conn.generate_id().ok()?;
+ conn.create_window(
+ x11rb::COPY_DEPTH_FROM_PARENT,
+ win,
+ root,
+ 0,
+ 0,
+ 250,
+ 22,
+ 1,
+ WindowClass::INPUT_OUTPUT,
+ 0,
+ &CreateWindowAux::new().override_redirect(1).background_pixel(0x2a2440).border_pixel(0x7661ff).event_mask(EventMask::EXPOSURE),
+ )
+ .ok()?;
+ // Clicks go straight through to what's underneath.
+ if conn.xfixes_query_version(5, 0).ok().and_then(|c| c.reply().ok()).is_some() {
+ if let Ok(region) = conn.generate_id() {
+ let _ = conn.xfixes_create_region(region, &[]);
+ let _ = conn.xfixes_set_window_shape_region(win, x11rb::protocol::shape::SK::INPUT, 0, 0, region);
+ let _ = conn.xfixes_destroy_region(region);
+ }
+ }
+ let gc = conn.generate_id().ok()?;
+ conn.create_gc(gc, win, &CreateGCAux::new().foreground(white).background(black)).ok()?;
+ conn.flush().ok()?;
+ Some(Overlay { conn, win, gc, shown: false })
+ }
+
+ fn with<F: FnOnce(&mut Overlay)>(f: F) {
+ let mut g = OVERLAY.lock().unwrap_or_else(|e| e.into_inner());
+ if g.is_none() {
+ *g = Some(open());
+ }
+ if let Some(Some(o)) = g.as_mut() {
+ f(o);
+ }
+ }
+
+ fn draw(o: &Overlay) {
+ let text = b"Mercury - Optimus is driving";
+ let _ = o.conn.image_text8(o.win, o.gc, 10, 15, text);
+ }
+
+ pub fn follow(x: i32, y: i32) {
+ with(|o| {
+ let _ = o.conn.configure_window(o.win, &ConfigureWindowAux::new().x(x + 22).y(y + 18).stack_mode(x11rb::protocol::xproto::StackMode::ABOVE));
+ if !o.shown {
+ let _ = o.conn.map_window(o.win);
+ o.shown = true;
+ }
+ draw(o);
+ let _ = o.conn.flush();
+ });
+ }
+
+ pub fn hide() {
+ with(|o| {
+ if o.shown {
+ let _ = o.conn.unmap_window(o.win);
+ o.shown = false;
+ let _ = o.conn.flush();
+ }
+ });
+ }
+
+ /// X11 can't keep a window out of a screenshot: hide it for the capture.
+ pub fn hide_for_capture() -> bool {
+ let mut was = false;
+ with(|o| {
+ if o.shown {
+ was = true;
+ let _ = o.conn.unmap_window(o.win);
+ let _ = o.conn.flush();
+ }
+ });
+ if was {
+ std::thread::sleep(std::time::Duration::from_millis(40));
+ }
+ was
+ }
+
+ pub fn restore_after_capture() {
+ with(|o| {
+ let _ = o.conn.map_window(o.win);
+ draw(o);
+ let _ = o.conn.flush();
+ });
+ }
+}
+
+#[cfg(target_os = "macos")]
+pub use platform::run_main_loop;
diff --git a/plugins/optimus/mercury-plugin.template.json b/plugins/optimus/mercury-plugin.template.json
index 1b0f411d..7cf92318 100644
--- a/plugins/optimus/mercury-plugin.template.json
+++ b/plugins/optimus/mercury-plugin.template.json
@@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "optimus",
"name": "Optimus",
- "version": "0.3.1",
+ "version": "0.4.0",
"description": "Mercury uses your computer like a person: sees the screen, moves the mouse, types and opens apps, by chat or out loud with a talk key. macOS, Windows and Linux. Asks before anything that submits, sends, pays or deletes.",
"kind": "out-of-process",
"author": "Cosmic Stack",
@@ -32,15 +32,15 @@
},
{
"name": "act",
- "description": "Use the mouse and keyboard like a person: click, type, paste, press keys, scroll, drag, draw freehand. Returns a fresh screenshot. Pass `actions` as a list. For posts, emails and long text in web pages, use paste (click the box first) rather than type. Only for ordinary, reversible steps. Anything that submits, sends, posts, pays, buys, deletes, installs or changes settings must go through act_consequential instead. Never type passwords, card numbers or 2FA codes: ask the owner to do that part.",
+ "description": "Use the mouse and keyboard like a person: click, type, paste, press keys, scroll, drag, draw freehand. Returns a fresh screenshot. Pass `actions` as a list. To write text (posts, emails, articles) click the box, then use type: it types key by key like a person, so it works in every editor (up to 3,000 characters per type action; longer text in parts). Use paste only if typing fails. Only for ordinary, reversible steps. Anything that submits, sends, posts, pays, buys, deletes, installs or changes settings must go through act_consequential instead. Never type passwords, card numbers or 2FA codes: ask the owner to do that part.",
"readOnly": true,
- "timeoutMs": 120000
+ "timeoutMs": 300000
},
{
"name": "act_consequential",
"description": "Same as act, for the step that commits something: submit a form, send a message or email, post, pay or buy, delete, install, change a setting. The owner approves it first, so say what it will do.",
"readOnly": false,
- "timeoutMs": 120000
+ "timeoutMs": 300000
},
{
"name": "open",
@@ -151,6 +151,26 @@
"voice": "🎙 Listening: press a key, talk, and hear Mercury answer"
}
},
+ "pace": {
+ "type": "enum",
+ "options": [
+ "natural",
+ "fast"
+ ],
+ "default": "natural",
+ "label": "How Optimus moves and types",
+ "description": "Natural: the pointer glides and text is typed key by key at a human pace. Fast: the same, quicker.",
+ "optionLabels": {
+ "natural": "Natural: like a person (recommended)",
+ "fast": "Fast: same moves, less waiting"
+ }
+ },
+ "showOverlay": {
+ "type": "boolean",
+ "default": true,
+ "label": "Show \"Mercury is driving\" by the pointer",
+ "description": "A ring around the pointer and a small label while Optimus moves the mouse, so it's clear the agent is in control. Never appears in Optimus's own screenshots."
+ },
"hotkey": {
"type": "string",
"default": "ctrl+alt+m",
diff --git a/src/plugins/channel-bridge.ts b/src/plugins/channel-bridge.ts
index 153a0d45..42af903f 100644
--- a/src/plugins/channel-bridge.ts
+++ b/src/plugins/channel-bridge.ts
@@ -615,7 +615,7 @@ export class PluginChannel extends BaseChannel {
return [
`## Channel: ${name} (voice, on the owner's computer)`,
'You\'re talking with the owner, out loud, at their own computer. Your answer is spoken: one to three short sentences, no markdown, lists, links or code.',
- `To see their screen use ${this.manifest.id}__look; to do things on it use ${this.manifest.id}__open and ${this.manifest.id}__act, and ${this.manifest.id}__act_consequential for the step that submits, sends, posts, pays, deletes or installs (e.g. the final Post or Send button). Give every open/act call a short \`say\` ("Opening Gmail", "Typing your post"): it is spoken the moment it happens, so the owner hears each step live. Look after each step and check it worked before the next.`,
+ `To see their screen use ${this.manifest.id}__look; to do things on it use ${this.manifest.id}__open and ${this.manifest.id}__act, and ${this.manifest.id}__act_consequential for the step that submits, sends, posts, pays, deletes or installs (e.g. the final Post or Send button). Give every open/act call a short \`say\` ("Opening Gmail", "Typing your post"): it is spoken the moment it happens, so the owner hears each step live. Look after each step and check it worked before the next. To write text, click the box and use a type action (it types like a person); paste only if typing fails.`,
'Access: Extended. Use your tools, skills, files and memory as you would anywhere else. Approvals are asked out loud and answered by voice.',
].join('\n');
}