agentix-cli 0.149.0 → 0.150.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,6 +25,9 @@ enum AXTree {
25
25
  let x: Double, y: Double, width: Double, height: Double
26
26
  /// Index of the parent in the same flat array; -1 for the root.
27
27
  let parent: Int
28
+ /// AXSubrole. The window's traffic lights have no label, and this
29
+ /// is the only thing that says which one is "close".
30
+ let subrole: String?
28
31
  }
29
32
 
30
33
  struct Snapshot: Codable {
@@ -95,13 +98,21 @@ enum AXTree {
95
98
  // looks like it exposes nothing. Skipped nodes still have their
96
99
  // children walked; `parent` points at the nearest KEPT ancestor, so
97
100
  // the hierarchy stays usable for page-scoping.
101
+ //
102
+ // Nor on what is scrolled out of sight. A long article keeps its
103
+ // whole DOM in the tree: on Wikipedia 232 of 400 slots went to
104
+ // table cells below the fold, and controls on screen were cut.
105
+ let view = describe(root, id: 0, parent: -1).map {
106
+ CGRect(x: $0.x, y: $0.y, width: $0.width, height: $0.height)
107
+ }
98
108
  var queue: [(AXUIElement, Int)] = [(root, -1)]
99
109
  while !queue.isEmpty {
100
110
  if elements.count >= maxElements { truncated = true; break }
101
111
  let (node, parent) = queue.removeFirst()
102
112
 
103
113
  var keptIndex = parent
104
- if let e = describe(node, id: elements.count, parent: parent), worthKeeping(e) {
114
+ if let e = describe(node, id: elements.count, parent: parent), worthKeeping(e),
115
+ view.map({ $0.intersects(CGRect(x: e.x, y: e.y, width: e.width, height: e.height)) }) ?? true {
105
116
  keptIndex = elements.count
106
117
  elements.append(e)
107
118
  }
@@ -164,7 +175,8 @@ enum AXTree {
164
175
  enabled: enabled,
165
176
  x: frame.origin.x, y: frame.origin.y,
166
177
  width: frame.size.width, height: frame.size.height,
167
- parent: parent)
178
+ parent: parent,
179
+ subrole: string(node, kAXSubroleAttribute))
168
180
  }
169
181
 
170
182
  private static func string(_ node: AXUIElement, _ attr: String) -> String? {