Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

perf(cua-driver): filter list_windows by app and steer discovery away from host-wide lists (#4916)

Francesco Bonacci5e638b2113f7
diff --git a/docs/content/docs/cua-driver/reference/mcp-tools/apps-and-windows.mdx b/docs/content/docs/cua-driver/reference/mcp-tools/apps-and-windows.mdx
index fcf24286a5..4f7ba88301 100644
--- a/docs/content/docs/cua-driver/reference/mcp-tools/apps-and-windows.mdx
+++ b/docs/content/docs/cua-driver/reference/mcp-tools/apps-and-windows.mdx
@@ -42,7 +42,7 @@ List macOS apps, both currently running and installed-but-not-running, with per-
Standalone running entries include only apps with NSApplicationActivationPolicyRegular: background helpers and system UI agents are filtered out. Installed apps resolve their running/pid state against all live processes by bundle identifier, so an installed app whose process runs as an accessory (LSUIElement / menu-bar apps, e.g. Cua Driver itself) still reports its live pid. Installed apps come from scanning /Applications, /Applications/Utilities, ~/Applications, /System/Applications, and /System/Applications/Utilities.
-Use this for "is X installed?" as well as "is X running?". For per-window state, on-screen, on-current-Space, minimized, window titles, call list_windows instead. For just opening an app, running or not, call launch_app({bundle_id: ...}) directly; list_apps is not a prerequisite.
+Use this for "is X installed?" as well as "is X running?"; the list includes every installed app. To get an open app's pid and window_id, call list_windows({app: "Name"}) instead, which also gives per-window state (on-screen, on-current-Space, minimized, window titles). For just opening an app, running or not, call launch_app({bundle_id: ...}) directly; list_apps is not a prerequisite.
</Tab>
<Tab value="Linux">
@@ -94,7 +94,7 @@ Effect: read-only, idempotent. Platforms: macOS, Linux, Windows.
<Tabs items={['macOS', 'Linux', 'Windows']} groupId="platform" persist>
<Tab value="macOS">
-List layer-0 top-level windows known to WindowServer, including off-screen ones (minimized, other Space, hidden). Use it to find a `window_id` for get_window_state. AppKit-internal helper windows are omitted.
+List layer-0 top-level windows known to WindowServer, including off-screen ones (minimized, other Space, hidden). Use it to find a `pid` and `window_id` for get_window_state; filter with `app` or `pid`, because an unfiltered call lists every window on the host. AppKit-internal helper windows and the driver's own overlay are omitted.
Per record: window_id, pid, app_name, title, bounds, z_index, is_on_screen, space_ids, current_space_id, on_current_space. For the frontmost window take the maximum integer z_index; null means stacking is unavailable, so do not infer it from array order.
@@ -108,7 +108,7 @@ Per record: window_id, pid, app_name, title, bounds, z_index, is_on_screen, spac
</Tab>
<Tab value="Linux">
-List top-level windows. Each record includes z_index (integer or null; higher values are closer to the front; null means stacking order is unavailable and callers must not infer one). To select a frontmost candidate, take the maximum integer z_index; if every value is null, use an explicit fallback instead of relying on array order.
+List top-level windows. Each record includes z_index (integer or null; higher values are closer to the front; null means stacking order is unavailable and callers must not infer one). To select a frontmost candidate, take the maximum integer z_index; if every value is null, use an explicit fallback instead of relying on array order. Filter with `app` or `pid`: an unfiltered call lists every window on the host.
**Linux parameters**
@@ -126,7 +126,7 @@ Use this, not list_apps, for any window-level reasoning: "does this app have a v
Per-record fields: window_id (HWND), pid + app_name, title, bounds &#123;x, y, width, height&#125;, layer (always 0), z_index (integer or null; higher values are closer to the front; null means stacking order is unavailable and callers must not infer one), is_on_screen, minimized. To select a frontmost candidate, take the maximum integer z_index; if every value is null, use an explicit fallback instead of relying on array order. The macOS-specific on_current_space / space_ids fields are omitted on Windows; current_space_id is null.
-Inputs: pid (optional pid filter), on_screen_only (bool, default false).
+Inputs: pid (optional pid filter), app (app-name filter), on_screen_only (bool, default false). Filter with app or pid: an unfiltered call lists every window.
**Windows parameters**
@@ -142,6 +142,7 @@ Inputs: pid (optional pid filter), on_screen_only (bool, default false).
| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
+| <span id="list_windows--app"></span>`app` | `string` | | Only windows of apps whose name contains this text (case-insensitive), or whose bundle id equals it. Prefer this or `pid` over an unfiltered call, which returns every window on the host. |
| <span id="list_windows--session"></span>`session` | `string` | | For multi-call work, prefer a short public session label and repeat it on every call that accepts it. Omit it to use the authenticated transport's implicit lifecycle session. |
## `launch_app`
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/protocol.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/protocol.rs
index 5d76845f96..db0dc48738 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/protocol.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/protocol.rs
@@ -382,7 +382,7 @@ fn agent_instructions() -> String {
r#"cua-driver: background GUI automation. No shell: for non-GUI outcomes use an app API/SDK, CLI or filesystem and read the result back there.
Efficient loop:
-1. `list_windows` or `launch_app` for `pid` and `window_id`.
+1. `list_windows({{app:"Name"}})` or `launch_app` for `pid` and `window_id`. Unfiltered `list_windows`/`list_apps` list the whole host.
2. Read narrowly: `get_window_state` with `query:"Save"` (or `max_elements`). Re-read with `since:"latest"` for only what changed. For just a picture, `include_accessibility_tree:false` (tokens stay valid).
3. Act by `element_token` ({tree_kind}): row `[N]` is `<snapshot_id>:N`. Pixel `x,y` only for surfaces missing from the tree.
4. Act through `run_actions({{steps:[{{tool,args}}],observe:true}})`, even for one step: it stops at the first failure and returns what changed, so no separate re-read.
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/tool_args.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/tool_args.rs
index a972c7241d..126778ad1d 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/tool_args.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/tool_args.rs
@@ -661,3 +661,49 @@ mod tests {
assert!(args.bool_or("from_zoom", false));
}
}
+
+/// Description of the `app` filter that `list_windows` accepts on every
+/// platform.
+pub const LIST_WINDOWS_APP_FILTER_DESCRIPTION: &str = "Only windows of apps whose name contains this text (case-insensitive), or whose bundle id equals it. Prefer this or `pid` over an unfiltered call, which returns every window on the host.";
+
+/// Whether a window owned by `app_name` (and, where known, `bundle_id`)
+/// passes `list_windows`' `app` filter: a case-insensitive substring of the
+/// app name, or the exact bundle id. An empty filter matches everything.
+pub fn app_filter_matches(filter: &str, app_name: &str, bundle_id: Option<&str>) -> bool {
+ let filter = filter.trim();
+ if filter.is_empty() {
+ return true;
+ }
+ if bundle_id.is_some_and(|id| id.eq_ignore_ascii_case(filter)) {
+ return true;
+ }
+ app_name.to_lowercase().contains(&filter.to_lowercase())
+}
+
+#[cfg(test)]
+mod app_filter_tests {
+ use super::app_filter_matches;
+
+ #[test]
+ fn matches_name_substrings_and_exact_bundle_ids() {
+ assert!(app_filter_matches("libreoffice", "LibreOffice", None));
+ assert!(app_filter_matches("Office", "LibreOffice", None));
+ assert!(app_filter_matches(
+ "com.google.Chrome",
+ "Google Chrome",
+ Some("com.google.Chrome")
+ ));
+ assert!(app_filter_matches(
+ "COM.GOOGLE.CHROME",
+ "Google Chrome",
+ Some("com.google.Chrome")
+ ));
+ assert!(app_filter_matches(" ", "Anything", None));
+ assert!(!app_filter_matches(
+ "Safari",
+ "Google Chrome",
+ Some("com.google.Chrome")
+ ));
+ assert!(!app_filter_matches("com.google", "Finder", None));
+ }
+}
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
index 4ad9f79e90..3116681b1f 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
@@ -555,9 +555,11 @@ impl Tool for ListWindowsTool {
higher values are closer to the front; null means stacking order is unavailable \
and callers must not infer one). To select a frontmost candidate, take the maximum \
integer z_index; if every value is null, use an explicit fallback instead of \
- relying on array order.".into(),
+ relying on array order. Filter with `app` or `pid`: an unfiltered call lists \
+ every window on the host.".into(),
input_schema: json!({"type":"object","properties":{
"pid":{"type":"integer","description":"Only list windows owned by this process ID."},
+ "app":{"type":"string","description":cua_driver_core::tool_args::LIST_WINDOWS_APP_FILTER_DESCRIPTION},
"on_screen_only":{"type":"boolean","description":"When true, filter to visible windows only. Default false."}
},"additionalProperties":false}),
read_only: true, destructive: false, idempotent: true, open_world: false,
@@ -578,6 +580,11 @@ impl Tool for ListWindowsTool {
if on_screen_only {
windows.retain(|window| window.is_on_screen);
}
+ if let Some(filter) = args.opt_str("app") {
+ windows.retain(|window| {
+ cua_driver_core::tool_args::app_filter_matches(&filter, &window.app_name, None)
+ });
+ }
if crate::wayland::is_wayland() {
crate::wayland::remember_observed_window_origins(&windows);
}
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/list_apps.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/list_apps.rs
index e9fac6683d..925145aa04 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/list_apps.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/list_apps.rs
@@ -30,9 +30,11 @@ fn def() -> &'static ToolDef {
its live pid. Installed apps come from scanning /Applications, \
/Applications/Utilities, ~/Applications, /System/Applications, and \
/System/Applications/Utilities.\n\n\
- Use this for \"is X installed?\" as well as \"is X running?\". For \
- per-window state — on-screen, on-current-Space, minimized, \
- window titles — call list_windows instead. For just opening an \
+ Use this for \"is X installed?\" as well as \"is X running?\"; \
+ the list includes every installed app. To get an open app's pid \
+ and window_id, call list_windows({app: \"Name\"}) instead, which \
+ also gives per-window state (on-screen, on-current-Space, \
+ minimized, window titles). For just opening an \
app — running or not — call launch_app({bundle_id: ...}) directly; \
list_apps is not a prerequisite."
.into(),
@@ -61,20 +63,27 @@ impl Tool for ListAppsTool {
let text = crate::apps::format_app_list(&apps);
// Single flat array. Each entry is the unified shape — existing
// fields (`pid`, `name`, `bundle_id`, `running`, `active`) are
- // unchanged for backwards compatibility; the new fields
- // (`launch_path`, `kind`, `last_used`, `windows`) are additive.
+ // unchanged for backwards compatibility; `launch_path`, `kind` and
+ // `last_used` are additive and omitted when unknown, as the contract
+ // allows. Every agent reads this payload, so it carries no field that
+ // is always empty.
let structured = serde_json::json!({
- "apps": apps.iter().map(|a| serde_json::json!({
- "pid": a.pid,
- "name": a.name,
- "bundle_id": a.bundle_id,
- "active": a.active,
- "running": a.running,
- "launch_path": a.launch_path,
- "kind": a.kind,
- "last_used": a.last_used,
- "windows": Vec::<serde_json::Value>::new(),
- })).collect::<Vec<_>>()
+ "apps": apps.iter().map(|a| {
+ let mut entry = serde_json::json!({
+ "pid": a.pid,
+ "name": a.name,
+ "bundle_id": a.bundle_id,
+ "active": a.active,
+ "running": a.running,
+ "launch_path": a.launch_path,
+ "kind": a.kind,
+ "last_used": a.last_used,
+ });
+ if let Some(entry) = entry.as_object_mut() {
+ entry.retain(|_, value| !value.is_null());
+ }
+ entry
+ }).collect::<Vec<_>>()
});
ToolResult::text(text).with_structured(structured)
}
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/list_windows.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/list_windows.rs
index bf8bb1e7d7..5d0798576a 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/list_windows.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/list_windows.rs
@@ -12,7 +12,7 @@ static DEF: std::sync::OnceLock<ToolDef> = std::sync::OnceLock::new();
fn def() -> &'static ToolDef {
DEF.get_or_init(|| ToolDef {
name: "list_windows".into(),
- description: "List layer-0 top-level windows known to WindowServer, including off-screen ones (minimized, other Space, hidden). Use it to find a `window_id` for get_window_state. AppKit-internal helper windows are omitted.\n\
+ description: "List layer-0 top-level windows known to WindowServer, including off-screen ones (minimized, other Space, hidden). Use it to find a `pid` and `window_id` for get_window_state; filter with `app` or `pid`, because an unfiltered call lists every window on the host. AppKit-internal helper windows and the driver's own overlay are omitted.\n\
\n\
Per record: window_id, pid, app_name, title, bounds, z_index, is_on_screen, space_ids, current_space_id, on_current_space. For the frontmost window take the maximum integer z_index; null means stacking is unavailable, so do not infer it from array order.".into(),
input_schema: serde_json::json!({
@@ -22,6 +22,10 @@ fn def() -> &'static ToolDef {
"type": "integer",
"description": "Only this pid's windows."
},
+ "app": {
+ "type": "string",
+ "description": cua_driver_core::tool_args::LIST_WINDOWS_APP_FILTER_DESCRIPTION
+ },
"on_screen_only": {
"type": "boolean",
"description": "Drop windows not on the current Space."
@@ -58,6 +62,22 @@ impl Tool for ListWindowsTool {
if let Some(pid) = pid_filter {
windows.retain(|w| w.pid == pid);
}
+ // The driver's own windows (the agent cursor overlay) are not targets.
+ let own_pid = std::process::id() as i32;
+ windows.retain(|w| w.pid != own_pid);
+ if let Some(filter) = args.opt_str("app") {
+ let mut bundle_ids = std::collections::HashMap::new();
+ windows.retain(|w| {
+ let bundle_id = bundle_ids
+ .entry(w.pid)
+ .or_insert_with(|| crate::apps::bundle_id_for_pid(w.pid));
+ cua_driver_core::tool_args::app_filter_matches(
+ &filter,
+ &w.app_name,
+ bundle_id.as_deref(),
+ )
+ });
+ }
crate::windows::retain_ax_reachable(&mut windows, current_space_id);
let windows_json: Vec<Value> = windows.iter().map(window_record_json).collect();
diff --git a/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs b/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs
index 0173684024..785ceb44fa 100644
--- a/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs
+++ b/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs
@@ -946,9 +946,11 @@ impl Tool for ListWindowsTool {
explicit fallback instead of relying on array order. The macOS-specific \
on_current_space / space_ids fields are \
omitted on Windows; current_space_id is null.\n\n\
- Inputs: pid (optional pid filter), on_screen_only (bool, default false).".into(),
+ Inputs: pid (optional pid filter), app (app-name filter), on_screen_only (bool, \
+ default false). Filter with app or pid: an unfiltered call lists every window.".into(),
input_schema: json!({"type":"object","properties":{
"pid":{"type":"integer","description":"Optional pid filter. When set, only this pid's windows are returned."},
+ "app":{"type":"string","description":cua_driver_core::tool_args::LIST_WINDOWS_APP_FILTER_DESCRIPTION},
"on_screen_only":{"type":"boolean","description":"When true, drop windows that aren't currently on-screen. Default false."}
},"additionalProperties":false}),
read_only: true, destructive: false, idempotent: true, open_world: false,
@@ -971,6 +973,12 @@ impl Tool for ListWindowsTool {
if on_screen_only {
windows.retain(|w| w.is_on_screen);
}
+ if let Some(filter) = args.opt_str("app") {
+ windows.retain(|w| {
+ let app_name = pid_to_name.get(&w.pid).map(String::as_str).unwrap_or("");
+ cua_driver_core::tool_args::app_filter_matches(&filter, app_name, None)
+ });
+ }
// Swift surfaces a warning when a pid filter matches nothing.
let missing_pid_warning = if let Some(fp) = filter_pid {
diff --git a/scripts/docs-generators/cli-specs/cua-driver-mcp-linux.json b/scripts/docs-generators/cli-specs/cua-driver-mcp-linux.json
index d9fe4f9a47..c66ec35fed 100644
--- a/scripts/docs-generators/cli-specs/cua-driver-mcp-linux.json
+++ b/scripts/docs-generators/cli-specs/cua-driver-mcp-linux.json
@@ -18,12 +18,16 @@
"read_only": true
},
{
- "description": "List top-level windows. Each record includes z_index (integer or null; higher values are closer to the front; null means stacking order is unavailable and callers must not infer one). To select a frontmost candidate, take the maximum integer z_index; if every value is null, use an explicit fallback instead of relying on array order.",
+ "description": "List top-level windows. Each record includes z_index (integer or null; higher values are closer to the front; null means stacking order is unavailable and callers must not infer one). To select a frontmost candidate, take the maximum integer z_index; if every value is null, use an explicit fallback instead of relying on array order. Filter with `app` or `pid`: an unfiltered call lists every window on the host.",
"destructive": false,
"idempotent": true,
"input_schema": {
"additionalProperties": false,
"properties": {
+ "app": {
+ "description": "Only windows of apps whose name contains this text (case-insensitive), or whose bundle id equals it. Prefer this or `pid` over an unfiltered call, which returns every window on the host.",
+ "type": "string"
+ },
"on_screen_only": {
"description": "When true, filter to visible windows only. Default false.",
"type": "boolean"
diff --git a/scripts/docs-generators/cli-specs/cua-driver-mcp-macos.json b/scripts/docs-generators/cli-specs/cua-driver-mcp-macos.json
index 3f9418b153..42e40dffcf 100644
--- a/scripts/docs-generators/cli-specs/cua-driver-mcp-macos.json
+++ b/scripts/docs-generators/cli-specs/cua-driver-mcp-macos.json
@@ -1,7 +1,7 @@
{
"tools": [
{
- "description": "List macOS apps — both currently running and installed-but-not-running — with per-app state flags:\n\n- running: is a process for this app live? (pid is 0 when false)\n- active: is it the system-frontmost app? (implies running)\n- launch_path: filesystem path to the `.app` bundle, when known. Pass this to `launch_app` to start the app cold.\n- kind: `\"desktop\"` for `.app` bundles on macOS.\n- last_used: RFC3339 timestamp from the bundle's filesystem mtime, when readable; otherwise null.\n\nStandalone running entries include only apps with NSApplicationActivationPolicyRegular — background helpers and system UI agents are filtered out. Installed apps resolve their running/pid state against all live processes by bundle identifier, so an installed app whose process runs as an accessory (LSUIElement / menu-bar apps, e.g. Cua Driver itself) still reports its live pid. Installed apps come from scanning /Applications, /Applications/Utilities, ~/Applications, /System/Applications, and /System/Applications/Utilities.\n\nUse this for \"is X installed?\" as well as \"is X running?\". For per-window state — on-screen, on-current-Space, minimized, window titles — call list_windows instead. For just opening an app — running or not — call launch_app({bundle_id: ...}) directly; list_apps is not a prerequisite.",
+ "description": "List macOS apps — both currently running and installed-but-not-running — with per-app state flags:\n\n- running: is a process for this app live? (pid is 0 when false)\n- active: is it the system-frontmost app? (implies running)\n- launch_path: filesystem path to the `.app` bundle, when known. Pass this to `launch_app` to start the app cold.\n- kind: `\"desktop\"` for `.app` bundles on macOS.\n- last_used: RFC3339 timestamp from the bundle's filesystem mtime, when readable; otherwise null.\n\nStandalone running entries include only apps with NSApplicationActivationPolicyRegular — background helpers and system UI agents are filtered out. Installed apps resolve their running/pid state against all live processes by bundle identifier, so an installed app whose process runs as an accessory (LSUIElement / menu-bar apps, e.g. Cua Driver itself) still reports its live pid. Installed apps come from scanning /Applications, /Applications/Utilities, ~/Applications, /System/Applications, and /System/Applications/Utilities.\n\nUse this for \"is X installed?\" as well as \"is X running?\"; the list includes every installed app. To get an open app's pid and window_id, call list_windows({app: \"Name\"}) instead, which also gives per-window state (on-screen, on-current-Space, minimized, window titles). For just opening an app — running or not — call launch_app({bundle_id: ...}) directly; list_apps is not a prerequisite.",
"destructive": false,
"idempotent": true,
"input_schema": {
@@ -18,12 +18,16 @@
"read_only": true
},
{
- "description": "List layer-0 top-level windows known to WindowServer, including off-screen ones (minimized, other Space, hidden). Use it to find a `window_id` for get_window_state. AppKit-internal helper windows are omitted.\n\nPer record: window_id, pid, app_name, title, bounds, z_index, is_on_screen, space_ids, current_space_id, on_current_space. For the frontmost window take the maximum integer z_index; null means stacking is unavailable, so do not infer it from array order.",
+ "description": "List layer-0 top-level windows known to WindowServer, including off-screen ones (minimized, other Space, hidden). Use it to find a `pid` and `window_id` for get_window_state; filter with `app` or `pid`, because an unfiltered call lists every window on the host. AppKit-internal helper windows and the driver's own overlay are omitted.\n\nPer record: window_id, pid, app_name, title, bounds, z_index, is_on_screen, space_ids, current_space_id, on_current_space. For the frontmost window take the maximum integer z_index; null means stacking is unavailable, so do not infer it from array order.",
"destructive": false,
"idempotent": true,
"input_schema": {
"additionalProperties": false,
"properties": {
+ "app": {
+ "description": "Only windows of apps whose name contains this text (case-insensitive), or whose bundle id equals it. Prefer this or `pid` over an unfiltered call, which returns every window on the host.",
+ "type": "string"
+ },
"on_screen_only": {
"description": "Drop windows not on the current Space.",
"type": "boolean"
diff --git a/scripts/docs-generators/cli-specs/cua-driver-mcp-windows.json b/scripts/docs-generators/cli-specs/cua-driver-mcp-windows.json
index b3a37d06ea..d46509ecd3 100644
--- a/scripts/docs-generators/cli-specs/cua-driver-mcp-windows.json
+++ b/scripts/docs-generators/cli-specs/cua-driver-mcp-windows.json
@@ -18,12 +18,16 @@
"read_only": true
},
{
- "description": "List every top-level window currently known to the window manager. Each record self-contains its owning app identity so the caller never has to join back against list_apps.\n\nUse this — not list_apps — for any window-level reasoning: \"does this app have a visible window right now?\", \"which of this pid's windows is the main one?\".\n\nPer-record fields: window_id (HWND), pid + app_name, title, bounds {x, y, width, height}, layer (always 0), z_index (integer or null; higher values are closer to the front; null means stacking order is unavailable and callers must not infer one), is_on_screen, minimized. To select a frontmost candidate, take the maximum integer z_index; if every value is null, use an explicit fallback instead of relying on array order. The macOS-specific on_current_space / space_ids fields are omitted on Windows; current_space_id is null.\n\nInputs: pid (optional pid filter), on_screen_only (bool, default false).",
+ "description": "List every top-level window currently known to the window manager. Each record self-contains its owning app identity so the caller never has to join back against list_apps.\n\nUse this — not list_apps — for any window-level reasoning: \"does this app have a visible window right now?\", \"which of this pid's windows is the main one?\".\n\nPer-record fields: window_id (HWND), pid + app_name, title, bounds {x, y, width, height}, layer (always 0), z_index (integer or null; higher values are closer to the front; null means stacking order is unavailable and callers must not infer one), is_on_screen, minimized. To select a frontmost candidate, take the maximum integer z_index; if every value is null, use an explicit fallback instead of relying on array order. The macOS-specific on_current_space / space_ids fields are omitted on Windows; current_space_id is null.\n\nInputs: pid (optional pid filter), app (app-name filter), on_screen_only (bool, default false). Filter with app or pid: an unfiltered call lists every window.",
"destructive": false,
"idempotent": true,
"input_schema": {
"additionalProperties": false,
"properties": {
+ "app": {
+ "description": "Only windows of apps whose name contains this text (case-insensitive), or whose bundle id equals it. Prefer this or `pid` over an unfiltered call, which returns every window on the host.",
+ "type": "string"
+ },
"on_screen_only": {
"description": "When true, drop windows that aren't currently on-screen. Default false.",
"type": "boolean"