feat(app): PC control through agent-desktop, with the emergency stop and the anti-cheat block
app/src/pc.rs runs every pc_action from the worker (admin.spec.md, "PC control"): one agent-desktop 1.2.0 run per command with a 15 s limit and its state in the data folder, never --force or raw input, typed text only through stdin. Each action is decided by permissions::decide for its asker (not registered, never, ask without consent), then refused during the emergency stop, while an anti-cheat game runs (Vanguard, EAC, BattlEye, FACEIT, GameGuard, XIGNCODE3 and the person's list), on an administrator window and in a password field. Results carry the window and its elements read again (200 at most, cut to 120 chars), agent-desktop's error codes become Korean reasons, and each action is recorded as pc.<action> with the program's file name only. The emergency stop is a global hotkey (pcControl.stopHotkey, default Ctrl+Shift+F12) on its own message loop; it kills the running command and blocks everything but reading until pressed again or lifted on the PC control screen. features.pcControl (on by default, nothing happens until someone is registered) and the pinned exe hash decide whether the brain gets the tool. The installer ships agent-desktop.exe from the pinned release archive, both hashes checked. Tested with a fake agent-desktop (342 lib tests pass) and cargo check for x86_64-pc-windows-gnu; not yet run against real agent-desktop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -184,6 +184,35 @@ pub struct ScreenAction {
|
||||
pub detail: Option<String>,
|
||||
}
|
||||
|
||||
/// The brain's pcControl tool asks the app for the person asking (voice_worker.spec.md, "PC control").
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||
pub struct PcAction {
|
||||
pub id: String,
|
||||
/// `windows`, `read`, `click`, `type`, `keys`, `run` or `close`.
|
||||
pub action: String,
|
||||
pub user: String,
|
||||
/// `voice` or `chat`: where they asked.
|
||||
#[serde(default)]
|
||||
pub via: Option<String>,
|
||||
#[serde(default)]
|
||||
pub channel: Option<String>,
|
||||
/// A window id from `windows`, or part of a program name or title.
|
||||
#[serde(default)]
|
||||
pub window: Option<String>,
|
||||
/// An element from the latest reading (`@<snapshot>:e<n>`).
|
||||
#[serde(default, rename = "ref")]
|
||||
pub element: Option<String>,
|
||||
#[serde(default)]
|
||||
pub text: Option<String>,
|
||||
#[serde(default)]
|
||||
pub keys: Option<String>,
|
||||
#[serde(default)]
|
||||
pub program: Option<String>,
|
||||
/// The person agreed in their next message (the tool checked it).
|
||||
#[serde(default)]
|
||||
pub consent: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum WorkerEvent {
|
||||
Ready(HelloOk),
|
||||
@@ -197,6 +226,7 @@ pub enum WorkerEvent {
|
||||
ScheduleAction(ScheduleAction),
|
||||
NoteAction(NoteAction),
|
||||
ScreenAction(ScreenAction),
|
||||
PcAction(PcAction),
|
||||
/// The brain's answer to `reply` (empty and `failed` when it gave none).
|
||||
ReplyText { id: String, text: String, failed: bool },
|
||||
/// Was the utterance said to Jarvis? (a failed judgement is a no)
|
||||
@@ -404,6 +434,14 @@ impl WorkerClient {
|
||||
self.app_action_result("screen_action_result", id, result);
|
||||
}
|
||||
|
||||
/// The outcome of a `pc_action`: `{ok, item}`, `{ok: false, error}` or `{ok: false, ask, kinds,
|
||||
/// window}`, as `pc.rs` made it.
|
||||
pub fn pc_action_result(&self, id: &str, mut reply: Value) {
|
||||
reply["type"] = json!("pc_action_result");
|
||||
reply["id"] = json!(id);
|
||||
self.send_json(reply);
|
||||
}
|
||||
|
||||
fn app_action_result(&self, kind: &str, id: &str, result: Result<Value, String>) {
|
||||
let msg = match result {
|
||||
Ok(Value::Object(mut m)) => {
|
||||
@@ -718,6 +756,7 @@ fn on_text(inner: &Inner, t: &str) {
|
||||
"schedule_action" => serde_json::from_value(v).ok().map(WorkerEvent::ScheduleAction),
|
||||
"note_action" => serde_json::from_value(v).ok().map(WorkerEvent::NoteAction),
|
||||
"screen_action" => serde_json::from_value(v).ok().map(WorkerEvent::ScreenAction),
|
||||
"pc_action" => serde_json::from_value(v).ok().map(WorkerEvent::PcAction),
|
||||
"llm_idle" => {
|
||||
if let Some(id) = v["id"].as_u64() {
|
||||
inner.llm_idle.send_if_modified(|got| if id > *got { *got = id; true } else { false });
|
||||
|
||||
Reference in New Issue
Block a user