Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

Prepare exact scoped desktop goals

Steven Enamakel27094952f8cd
diff --git a/crates/openhuman-core/src/desktop/control/WORKFLOW.md b/crates/openhuman-core/src/desktop/control/WORKFLOW.md
index 85de86f8b7..307df436ee 100644
--- a/crates/openhuman-core/src/desktop/control/WORKFLOW.md
+++ b/crates/openhuman-core/src/desktop/control/WORKFLOW.md
@@ -7,4 +7,12 @@ description: Inspect and control native desktop apps when Desktop is enabled in
Use `tool_search` to discover `desktop_*` tools. Begin with `desktop_list_apps` and `desktop_list_windows`; if the app has no visible window, use `desktop_launch` to activate it. Use the exact `window_id` from `desktop_list_windows` in `desktop_snapshot` and `desktop_goal` to bind both to the same native window; an exact `window` title may also be supplied. Inspect a skeleton `desktop_snapshot` to obtain exact accessible target names, descriptions, or `native_id.value`, and the completion condition. Plan one bounded task, then call `desktop_goal` once: state the app and goal, enumerate allowed mutating operations and exact targets, supply any text in `text_slots` keyed by the target's exact name, description, or `native_id.value`, and give one or more positive `success` predicates using the same target identifier. A missing element in a bounded snapshot does not prove absence. If a target has no accessible name, use its observed native AX identifier when available; otherwise inspect further without broadening the target scope. The module executes and verifies multiple actions inside this one call. Read its `verified`, `stop`, and final observation before reporting completion.
+## Prepare a task from the user's words
+
+Choose the exact running app label from `desktop_list_apps`, including any direction marks in its accessible name. Treat text the user asks to send or type as a fixed value: copy it verbatim into one `text_slots` entry, preserving capitalization, punctuation, and spaces. The slot key must be one of the exact `allowed_targets` from the snapshot. Jev chooses actions and observed targets; it never writes or revises the prepared text. Keep the operation and target lists to those needed for this task.
+
+For a chat send, first inspect the active conversation header, the message composer, and the send control. A contact row in the chat list does not prove that its conversation is open. Scope the goal to the intended recipient's conversation, allow only the observed row, composer, and send targets, and require both the active message-list header with `name_present` and the outgoing message with `name_contains`. Set `fragment` to the visible outgoing-message prefix containing the exact prepared text, and `within` to that active message-list header. If the app's accessibility labels do not expose those facts, inspect further and stop without sending. An unverified send must never be repeated merely because the first result has not appeared yet.
+
+For Spotify playback, inspect the current player and playlist controls. A running Spotify process or Jev `DONE` answer is insufficient; use a fresh accessible Pause control for the chosen track as the success condition. If that relationship is not visible, narrow the task and report the verification limit.
+
If a ref is stale, take a fresh snapshot. If Accessibility is denied, ask the user to grant it to the process running OpenHuman. Desktop goals have action, model-call, and elapsed-time limits. With desktop approvals off (the default), the module runs in-scope actions without stopping for per-action approval. If the operator enables desktop approvals and the module returns a pending action, wait for their decision in Connections before using `desktop_continue_goal`. If `verified` is false, use the returned evidence to replan or explain the blocker; do not replay an uncertain action. Never claim success from a timeout or a model decision alone.
diff --git a/crates/openhuman-core/src/desktop/control/tools.rs b/crates/openhuman-core/src/desktop/control/tools.rs
index ac73a7732c..ef9975223d 100644
--- a/crates/openhuman-core/src/desktop/control/tools.rs
+++ b/crates/openhuman-core/src/desktop/control/tools.rs
@@ -123,6 +123,9 @@ fn goal_request(args: &Value, approvals_enabled: bool) -> anyhow::Result<Value>
let request: RunGoalRequest = serde_json::from_value(request)?;
if !request.success.iter().all(|predicate| match predicate {
VisiblePredicate::NamePresent { name } => !name.trim().is_empty(),
+ VisiblePredicate::NameContains { fragment, within } => {
+ !fragment.trim().is_empty() && !within.trim().is_empty()
+ }
VisiblePredicate::ValueEquals { name, .. } => !name.trim().is_empty(),
VisiblePredicate::ValueContains { name, value } => {
!name.trim().is_empty() && !value.trim().is_empty()
@@ -132,9 +135,16 @@ fn goal_request(args: &Value, approvals_enabled: bool) -> anyhow::Result<Value>
}
}) {
anyhow::bail!(
- "desktop_goal success predicates require nonblank names, state tokens, and value_contains fragments"
+ "desktop_goal success predicates require nonblank names, state tokens, fragments, and ancestor scopes"
);
}
+ if request
+ .text_slots
+ .keys()
+ .any(|name| !request.allowed_targets.iter().any(|target| target == name))
+ {
+ anyhow::bail!("desktop_goal text_slots keys must match an exact allowed target");
+ }
Ok(serde_json::to_value(request)?)
}
@@ -235,11 +245,14 @@ impl Tool for DesktopTool {
"goal":{"type":"string","description":"One bounded desktop task; describe the intended visible result"},
"allowed_operations":{"type":"array","minItems":1,"items":{"type":"string","enum":["CLICK","TYPE_TEXT","CHECK","UNCHECK","EXPAND","COLLAPSE","SCROLL"]},"description":"Mutating operations Jev may execute; enumerate those needed for this task"},
"allowed_targets":{"type":"array","minItems":1,"items":{"type":"string"},"description":"Exact accessible name, description, or native_id.value from desktop_snapshot or desktop_find for each action target"},
- "text_slots":{"type":"object","additionalProperties":{"type":"string"},"description":"Prepared text keyed by the target's exact accessible name, description, or native_id.value"},
+ "text_slots":{"type":"object","additionalProperties":{"type":"string"},"description":"Prepared text keyed by an exact allowed target. Copy user supplied text verbatim; do not normalize punctuation, spacing, or case"},
"success":{"type":"array","minItems":1,"items":{"type":"object","properties":{
- "kind":{"type":"string","enum":["name_present","value_equals","value_contains","state_contains"]},
- "name":{"type":"string","description":"Exact accessible name, description, or native_id.value from the snapshot"},"value":{"type":"string"},"state":{"type":"string"}},
- "required":["kind","name"]},"description":"All predicates must match a fresh accessibility observation before completion"},
+ "kind":{"type":"string","enum":["name_present","name_contains","value_equals","value_contains","state_contains"]},
+ "name":{"type":"string","description":"Exact accessible name, description, or native_id.value from the snapshot for name_present, value_equals, value_contains, or state_contains"},
+ "fragment":{"type":"string","description":"For name_contains, a stable substring of the visible descendant name, such as the exact outgoing message text"},
+ "within":{"type":"string","description":"For name_contains, the exact accessible name of the ancestor container, such as the active conversation message list"},
+ "value":{"type":"string"},"state":{"type":"string"}},
+ "required":["kind"]},"description":"All predicates must match a fresh accessibility observation before completion. name_contains requires fragment and within"},
"max_steps":{"type":"integer","minimum":1,"maximum":20},
"max_model_calls":{"type":"integer","minimum":1,"maximum":40},
"max_elapsed_ms":{"type":"integer","minimum":1000,"maximum":300000}},
diff --git a/crates/openhuman-core/src/desktop/control/tools_tests.rs b/crates/openhuman-core/src/desktop/control/tools_tests.rs
index 435a10fa49..7ea58ca7df 100644
--- a/crates/openhuman-core/src/desktop/control/tools_tests.rs
+++ b/crates/openhuman-core/src/desktop/control/tools_tests.rs
@@ -119,6 +119,12 @@ fn goal_request_carries_scoped_task_and_disables_confirmations() {
assert!(goal.parameters_schema()["properties"]
.get("window_id")
.is_some());
+ assert!(
+ goal.parameters_schema()["properties"]["success"]["items"]["properties"]["kind"]["enum"]
+ .as_array()
+ .unwrap()
+ .contains(&json!("name_contains"))
+ );
assert_eq!(request["allowed_operations"], json!(["TYPE_TEXT"]));
assert_eq!(request["allowed_targets"], json!(["Text Entry Area"]));
assert_eq!(request["text_slots"]["Text Entry Area"], "desktop-test-42");
@@ -160,6 +166,32 @@ fn goal_request_carries_scoped_task_and_disables_confirmations() {
let mut cleared = args.clone();
cleared["success"] = json!([{"kind":"value_equals","name":"Text Entry Area","value":""}]);
assert!(goal_request(&cleared, false).is_ok());
+
+ let outbound = json!({
+ "app":"WhatsApp", "goal":"Send exactly the prepared text to Alex Rivera",
+ "allowed_operations":["CLICK","TYPE_TEXT"],
+ "allowed_targets":["Compose message","Send"],
+ "text_slots":{"Compose message":"Hello from OpenHuman! "},
+ "success":[
+ {"kind":"name_present","name":"Messages in chat with Alex Rivera"},
+ {"kind":"name_contains","fragment":"Your message, Hello from OpenHuman! ","within":"Messages in chat with Alex Rivera"}
+ ]
+ });
+ let prepared = goal_request(&outbound, false).unwrap();
+ assert_eq!(
+ prepared["text_slots"]["Compose message"],
+ "Hello from OpenHuman! "
+ );
+ assert_eq!(
+ prepared["success"][1]["fragment"],
+ "Your message, Hello from OpenHuman! "
+ );
+ let mut wrong_slot = outbound.clone();
+ wrong_slot["text_slots"] = json!({"Other field":"Hello from OpenHuman! "});
+ assert!(goal_request(&wrong_slot, false).is_err());
+ let mut missing_scope = outbound;
+ missing_scope["success"][1]["within"] = json!(" ");
+ assert!(goal_request(&missing_scope, false).is_err());
}
#[test]