@capagents/forgeqe 3.1.9 → 3.2.1

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.
Files changed (139) hide show
  1. package/HOW_TO_USE.md +43 -4
  2. package/THIRD_PARTY_NOTICES.md +2 -1
  3. package/dist/docs-site/docs/area-api/index.html +1 -1
  4. package/dist/docs-site/docs/area-mobile/index.html +28 -8
  5. package/dist/docs-site/docs/area-quality/index.html +27 -3
  6. package/dist/docs-site/docs/area-setup/index.html +1 -1
  7. package/dist/docs-site/docs/get-started/index.html +4 -1
  8. package/dist/docs-site/docs/mobile/index.html +19 -7
  9. package/dist/docs-site/docs/search.js +1 -1
  10. package/dist/docs-site/docs/web-app/index.html +2 -1
  11. package/dist/forgeqe.js +1931 -1917
  12. package/dist/template.html +12 -12
  13. package/dist/vendor/ibm-ace.js +2 -0
  14. package/dist/web/assets/{3d-force-graph-CGHQthr3.js → 3d-force-graph-ByL874l5.js} +1 -1
  15. package/dist/web/assets/Agent-Drs4mcil.js +8 -0
  16. package/dist/web/assets/{AgentWork-DEZVZTuJ.js → AgentWork-DLcCZTgu.js} +1 -1
  17. package/dist/web/assets/ApiTests-BcrTspwJ.js +10 -0
  18. package/dist/web/assets/Browse-D9eaDrZT.js +1 -0
  19. package/dist/web/assets/Chat-CMNf9-ys.js +3 -0
  20. package/dist/web/assets/{CommandPalette-sokhT5PA.js → CommandPalette-Bcf1Muan.js} +1 -1
  21. package/dist/web/assets/Compare-V5xKnwGO.js +1 -0
  22. package/dist/web/assets/Cost-DC3DYthD.js +1 -0
  23. package/dist/web/assets/Data-DzrP-MdL.js +6 -0
  24. package/dist/web/assets/Desktop-DjTq9eAr.js +1 -0
  25. package/dist/web/assets/DesktopReview-Buecn3n5.js +2 -0
  26. package/dist/web/assets/DeviceScreen-CoArZGyY.js +1 -0
  27. package/dist/web/assets/Evidence-D6VvlFNK.js +1 -0
  28. package/dist/web/assets/Explore-YkonRPmA.js +2 -0
  29. package/dist/web/assets/Features-BKB4iSRj.js +1 -0
  30. package/dist/web/assets/Flags-4GGW38Xu.js +2 -0
  31. package/dist/web/assets/Flaky-BRcLjYrP.js +1 -0
  32. package/dist/web/assets/Impact-CvuahLDQ.js +3 -0
  33. package/dist/web/assets/Jobs-DBCw8Z8I.js +5 -0
  34. package/dist/web/assets/KindPage-Ige-qO2t.js +6 -0
  35. package/dist/web/assets/LiveDevice-DI7Bq6ag.js +1 -0
  36. package/dist/web/assets/Migration-CEwXGs4c.js +8 -0
  37. package/dist/web/assets/Mobile-BqyFTBeG.js +1 -0
  38. package/dist/web/assets/Observability-B2Y1pHpD.js +1 -0
  39. package/dist/web/assets/PageAgent-BRhWi7LL.js +1 -0
  40. package/dist/web/assets/Product-CXIbmmMF.js +12 -0
  41. package/dist/web/assets/Production-BOy7ew7l.js +1 -0
  42. package/dist/web/assets/Quality-Dtcq2AWE.js +1 -0
  43. package/dist/web/assets/Readiness-B53Drc7i.js +1 -0
  44. package/dist/web/assets/Record-BuCIDb1d.js +1 -0
  45. package/dist/web/assets/Regression-BpPXCQIv.js +5 -0
  46. package/dist/web/assets/{RelationGraph-CeBfmWYf.js → RelationGraph-UXFyQOKO.js} +1 -1
  47. package/dist/web/assets/Reports-CWCa9uof.js +2 -0
  48. package/dist/web/assets/Response-C6EmnnQz.js +9 -0
  49. package/dist/web/assets/Responsive-Bl6i7kB3.js +3 -0
  50. package/dist/web/assets/{RunDiff-T4e0xs_5.js → RunDiff-CWf9Bkmu.js} +1 -1
  51. package/dist/web/assets/Runs-C0tfrB_j.js +2 -0
  52. package/dist/web/assets/Settings-tgCcBEwu.js +21 -0
  53. package/dist/web/assets/Steps-xASPoq1N.js +3 -0
  54. package/dist/web/assets/TestCases-Cm4KwWIP.js +1 -0
  55. package/dist/web/assets/TestData-DMV5S00V.js +2 -0
  56. package/dist/web/assets/{TestDebt-WuBkOmz5.js → TestDebt-D54mt0ZT.js} +1 -1
  57. package/dist/web/assets/TestManagement-DBFlK8Xe.js +4 -0
  58. package/dist/web/assets/WhatsNew-Dp-zP-jw.js +1 -0
  59. package/dist/web/assets/agents-DPabR9dS.js +1 -0
  60. package/dist/web/assets/coverage-xSRsKFL6.js +5 -0
  61. package/dist/web/assets/dataParts-BPff7ClX.js +3 -0
  62. package/dist/web/assets/desktopAppPath-BVJxel_D.js +1 -0
  63. package/dist/web/assets/{diff-CZ0iWWGv.js → diff-BXu8cULX.js} +1 -1
  64. package/dist/web/assets/families-CrnKBjis.js +1 -0
  65. package/dist/web/assets/{highlight-CGRzYrMa.js → highlight-DCCKhwHj.js} +1 -1
  66. package/dist/web/assets/index-BsAaOk_G.js +64 -0
  67. package/dist/web/assets/index-CgpH1pj9.css +2 -0
  68. package/dist/web/assets/input-BmJ7dt1C.js +1 -0
  69. package/dist/web/assets/pageBack-BNLSF2VR.js +3 -0
  70. package/dist/web/assets/palette-BS9ixqiJ.js +1 -0
  71. package/dist/web/assets/{paletteCommands-DU0boMQR.js → paletteCommands-C3knXWbA.js} +1 -1
  72. package/dist/web/assets/{parts-CTmOGb8E.js → parts-69Ei7EPi.js} +1 -1
  73. package/dist/web/assets/productParts-CrAb3-j0.js +1 -0
  74. package/dist/web/assets/qualityParts-BQTnBwPs.js +1 -0
  75. package/dist/web/assets/{recordTest-H42EwQYC.js → recordTest-DVJCNI0y.js} +1 -1
  76. package/dist/web/assets/{route-Mq0QZuqV.js → route-D8G-pTdk.js} +1 -1
  77. package/dist/web/assets/{stepper-ceEfHcbV.js → stepper-t0O_8eQo.js} +1 -1
  78. package/dist/web/index.html +7 -7
  79. package/docs/MOBILE.md +22 -7
  80. package/docs/WEB_APP.md +2 -1
  81. package/docs/user-guide.html +40 -5
  82. package/forgeqe.example.yaml +3 -1
  83. package/package.json +2 -1
  84. package/prompts/browser-persona.md +1 -1
  85. package/py/forgeqe_engine/copilot_gateway.py +80 -1
  86. package/py/forgeqe_engine/diagnostics.py +119 -2
  87. package/py/forgeqe_engine/persona.py +200 -12
  88. package/py/forgeqe_engine/service.py +6 -3
  89. package/py/forgeqe_mobile/a11y.py +322 -0
  90. package/py/forgeqe_mobile/appium_driver.py +16 -0
  91. package/py/forgeqe_mobile/live.py +225 -0
  92. package/py/forgeqe_mobile/service.py +102 -4
  93. package/dist/web/assets/Agent-lzvUoYv1.js +0 -8
  94. package/dist/web/assets/ApiTests-k9bR9dXo.js +0 -10
  95. package/dist/web/assets/Browse-4bm1SVvY.js +0 -1
  96. package/dist/web/assets/Chat-CbyylnvP.js +0 -3
  97. package/dist/web/assets/Compare-ChWSXkvf.js +0 -1
  98. package/dist/web/assets/Cost-DlZnyY_C.js +0 -1
  99. package/dist/web/assets/Data-CElI9cSA.js +0 -6
  100. package/dist/web/assets/Desktop-YtONOq0M.js +0 -1
  101. package/dist/web/assets/DesktopReview-CldegMwj.js +0 -2
  102. package/dist/web/assets/Evidence-B9wlQQy6.js +0 -1
  103. package/dist/web/assets/Explore-Cp3eqrm2.js +0 -2
  104. package/dist/web/assets/Features-ySmycsYI.js +0 -1
  105. package/dist/web/assets/Flags-CnjZtCU3.js +0 -2
  106. package/dist/web/assets/Flaky-D7VtH51H.js +0 -1
  107. package/dist/web/assets/Impact-Dx1cn9WD.js +0 -3
  108. package/dist/web/assets/Jobs-BwfvwxGd.js +0 -5
  109. package/dist/web/assets/KindPage-BHGa8zq7.js +0 -6
  110. package/dist/web/assets/Migration-f-gLkpSC.js +0 -4
  111. package/dist/web/assets/Observability-CibZbiOA.js +0 -1
  112. package/dist/web/assets/PageAgent-UTRXl1j4.js +0 -1
  113. package/dist/web/assets/Product-LJxwGFzs.js +0 -12
  114. package/dist/web/assets/Production-DXwaHzaa.js +0 -1
  115. package/dist/web/assets/Quality-Di4cF4nd.js +0 -1
  116. package/dist/web/assets/Readiness-Bu1OXgnc.js +0 -1
  117. package/dist/web/assets/Record-olwaN1G1.js +0 -1
  118. package/dist/web/assets/Regression-DBu-34b_.js +0 -5
  119. package/dist/web/assets/Reports-hoagfsmM.js +0 -2
  120. package/dist/web/assets/Response-CJSq1qN7.js +0 -9
  121. package/dist/web/assets/Responsive-DYhEQEpT.js +0 -3
  122. package/dist/web/assets/Runs-CcG9BELK.js +0 -2
  123. package/dist/web/assets/Settings-lWl74aQY.js +0 -21
  124. package/dist/web/assets/Steps-BefTJLTB.js +0 -3
  125. package/dist/web/assets/TestCases-CyzfvT_X.js +0 -1
  126. package/dist/web/assets/TestData-DSusRbgZ.js +0 -2
  127. package/dist/web/assets/TestManagement-HwkjrA4a.js +0 -4
  128. package/dist/web/assets/WhatsNew-B-w1pGj6.js +0 -1
  129. package/dist/web/assets/agents-BUWN-VJv.js +0 -1
  130. package/dist/web/assets/coverage-CWE1aatw.js +0 -5
  131. package/dist/web/assets/dataParts-ClIBv7-8.js +0 -3
  132. package/dist/web/assets/families-CfIM4f2s.js +0 -1
  133. package/dist/web/assets/index-Cg0SmlXN.js +0 -64
  134. package/dist/web/assets/index-tPgJ7dv2.css +0 -2
  135. package/dist/web/assets/input-1RVqxCVH.js +0 -1
  136. package/dist/web/assets/logLevel-CFPS8IkY.js +0 -3
  137. package/dist/web/assets/palette-5nApQc76.js +0 -1
  138. package/dist/web/assets/productParts-CL2E8Uaf.js +0 -1
  139. package/dist/web/assets/qualityParts-CnlpML55.js +0 -1
@@ -8,6 +8,10 @@ that changes the browser or the agent's actions comes from fixed lists, never fr
8
8
  page's markup (find_elements).
9
9
  - input "keyboard": the mouse actions (click, input, select_dropdown, upload, scripts) are taken away; the agent moves
10
10
  with press_key and types with type_text into the focused field.
11
+ - input "touch": a touchscreen, no keyboard (no press_key). With a screen reader (VoiceOver, TalkBack) the agent moves
12
+ a reading cursor with swipe_next and swipe_previous and activates what it is on with double_tap, never a tap by sight.
13
+ - device: a phone or tablet of ForgeQE's list (src/responsive/devices.ts): its size, pixel ratio, touch and user agent;
14
+ text_scale: the system's larger text, as the browser's default font size.
11
15
  - vision, zoom and media: Chrome's own emulation (a colour vision deficiency or blur, a zoomed page, reduced motion,
12
16
  forced colours), applied to each page before the agent's step.
13
17
 
@@ -15,6 +19,7 @@ This is not functional testing: whether the feature works is not judged, only wh
15
19
  operate and understand it. Each barrier is recorded with record_accessibility_issue into persona-findings.json.
16
20
  """
17
21
 
22
+ import asyncio
18
23
  import json
19
24
  import logging
20
25
  import re
@@ -28,7 +33,9 @@ from .prompts import text as prompt_text
28
33
  logger = logging.getLogger(__name__)
29
34
 
30
35
  PERCEPTIONS = ("sight", "screen_reader")
31
- INPUTS = ("any", "keyboard")
36
+ INPUTS = ("any", "keyboard", "touch")
37
+ # A device's user agent: ForgeQE's own fixed strings (src/responsive/devices.ts userAgentOf), checked to be plain text.
38
+ UA = re.compile(r"[A-Za-z0-9 ()/;:._,+-]{1,300}")
32
39
  # Chrome's Emulation.setEmulatedVisionDeficiency types, by the persona's name for them.
33
40
  VISION = {
34
41
  "none": "none",
@@ -88,7 +95,7 @@ This run is accessibility testing, not functional testing. You act as the person
88
95
  - You MUST set `wcag` to the WCAG success criterion the barrier fails, such as 1.1.1 or 2.4.7, when one applies.
89
96
  - You MUST set `severity`: critical when it stops the person from reaching the goal, serious when they get past it only with a lot of effort or help, moderate when it slows or confuses them, minor for an annoyance.
90
97
  - When a barrier stops you, you MUST NOT go around it in a way this person could not, such as a mouse click for a keyboard user. Record it, then try another way this person has, such as another link or the browser's back.
91
- - You MUST finish with done. Start the text with "Goal reached: yes", "Goal reached: partly", or "Goal reached: no", then say in a few sentences how it went for this person. Use success=true when you reached the goal and success=false when a barrier stopped you.
98
+ - You MUST finish with done. Start the text with "Goal reached: yes", "Goal reached: partly", or "Goal reached: no", then say in a few sentences how it went for this person. Use success=true when you reached the goal and success=false when a barrier stopped you. You MUST call done in a step of its own, with no other action: a done that follows another action in the same step, such as record_accessibility_issue, is not carried out. Record the last barrier, then call done in the next step.
92
99
  """.strip()
93
100
 
94
101
  SCREEN_READER_MESSAGE = """
@@ -106,6 +113,21 @@ You have no mouse. You MUST move with press_key (Tab, Shift+Tab, the arrow keys,
106
113
  """.strip()
107
114
 
108
115
 
116
+ TOUCH_READER_MESSAGE = """
117
+ ## You use a screen reader on a touchscreen
118
+ You use VoiceOver or TalkBack on a phone or tablet. You have no keyboard and you do not tap by sight.
119
+ - You MUST move with swipe_next and swipe_previous: each moves the screen reader's cursor to the next or previous item in reading order and says it, as a swipe right or left does.
120
+ - You MUST activate the item under the cursor with double_tap, and type into a field with type_text after double_tap has put focus in it.
121
+ - An item you cannot reach by swiping, an item announced with no name, a control that does nothing on double_tap, and a dialog or new content that the cursor does not move into are barriers.
122
+ """.strip()
123
+
124
+ TOUCH_MESSAGE = """
125
+ ## You use a touchscreen
126
+ You have no keyboard and no mouse: you tap, and you type on the on-screen keyboard.
127
+ - Targets that are small or close together, actions that need a precise gesture (drag, swipe, pinch) with no simple alternative, and content that appears only on hover are barriers.
128
+ """.strip()
129
+
130
+
109
131
  def parse_persona(raw: Any) -> Optional[Dict[str, Any]]:
110
132
  """The persona of the run request, with each setting from its fixed list; None for no persona."""
111
133
  if not isinstance(raw, dict):
@@ -127,11 +149,54 @@ def parse_persona(raw: Any) -> Optional[Dict[str, Any]]:
127
149
  "zoom": min(4.0, max(1.0, zoom)),
128
150
  "media": list(dict.fromkeys(media)),
129
151
  "watch_for": watch,
152
+ "text_scale": _number(raw.get("text_scale"), 1.0, 1.0, 3.0),
153
+ "device": parse_device(raw.get("device")),
154
+ }
155
+
156
+
157
+ def _number(v: Any, default: float, low: float, high: float) -> float:
158
+ try:
159
+ n = float(v if v not in (None, "") else default)
160
+ except (TypeError, ValueError):
161
+ return default
162
+ return min(high, max(low, n)) if n == n else default
163
+
164
+
165
+ def parse_device(raw: Any) -> Optional[Dict[str, Any]]:
166
+ """A phone or tablet to emulate, each value in range and the user agent plain text; None for the browser's own."""
167
+ if not isinstance(raw, dict):
168
+ return None
169
+ try:
170
+ width, height = int(raw.get("width")), int(raw.get("height"))
171
+ except (TypeError, ValueError):
172
+ return None
173
+ if not (240 <= width <= 3000 and 240 <= height <= 3000):
174
+ return None
175
+ ua = str(raw.get("ua") or "")
176
+ return {
177
+ "id": re.sub(r"[^a-z0-9-]", "", str(raw.get("id") or "").lower())[:40],
178
+ "label": " ".join(str(raw.get("label") or "").split())[:60],
179
+ "width": width,
180
+ "height": height,
181
+ "scale": _number(raw.get("scale"), 1.0, 1.0, 4.0),
182
+ "mobile": raw.get("mobile") is True,
183
+ "ua": ua if UA.fullmatch(ua) else "",
130
184
  }
131
185
 
132
186
 
133
187
  def keyboard_only(persona: Dict[str, Any]) -> bool:
134
- return persona["input"] == "keyboard" or persona["perception"] == "screen_reader"
188
+ """Moves with keys: a keyboard user, and a screen reader user who is not on a touchscreen."""
189
+ return persona["input"] == "keyboard" or (persona["perception"] == "screen_reader" and persona["input"] != "touch")
190
+
191
+
192
+ def touch_reader(persona: Dict[str, Any]) -> bool:
193
+ """A screen reader on a touchscreen (VoiceOver, TalkBack): swipes and double taps, never a tap by sight."""
194
+ return persona["perception"] == "screen_reader" and persona["input"] == "touch"
195
+
196
+
197
+ def no_pointer(persona: Dict[str, Any]) -> bool:
198
+ """Has no mouse or tap by sight: the pointer actions are taken away."""
199
+ return keyboard_only(persona) or touch_reader(persona)
135
200
 
136
201
 
137
202
  def uses_vision(persona: Dict[str, Any]) -> bool:
@@ -146,6 +211,11 @@ def system_message(persona: Dict[str, Any]) -> str:
146
211
  setting = []
147
212
  if persona["zoom"] > 1:
148
213
  setting.append(f"The page is zoomed to {round(persona['zoom'] * 100)}%, as this person zooms it. Text that is cut off or overlaps, and content that needs scrolling sideways, are barriers.")
214
+ if persona.get("device"):
215
+ d = persona["device"]
216
+ setting.append(f"You use {d['label'] or 'a handheld device'}: the page is shown at its size ({d['width']}×{d['height']} CSS pixels){', with touch' if d['mobile'] else ''}. Content that does not fit, needs scrolling sideways, or is hidden behind fixed bars is a barrier.")
217
+ if persona.get("text_scale", 1) > 1:
218
+ setting.append(f"Your system's text size is {round(persona['text_scale'] * 100)}%. Text that does not grow, is cut off, or overlaps is a barrier.")
149
219
  if persona["vision"] != "none":
150
220
  setting.append(f"The screenshots show the page as this person sees it ({persona['vision'].replace('_', ' ')}). Information that you can tell only by colour, and text that you cannot read, are barriers.")
151
221
  for m in persona["media"]:
@@ -163,9 +233,13 @@ def system_message(persona: Dict[str, Any]) -> str:
163
233
  who += ["", "Barriers that this person meets often (look for them, but record only what you meet):", *[f"- {w}" for w in persona["watch_for"]]]
164
234
  parts = [prompt_text("browser-persona", PERSONA_SYSTEM_MESSAGE)]
165
235
  if persona["perception"] == "screen_reader":
166
- parts.append(SCREEN_READER_MESSAGE)
167
- if keyboard_only(persona):
236
+ parts.append(SCREEN_READER_MESSAGE.replace("what press_key announces", "what swipe_next and double_tap announce") if touch_reader(persona) else SCREEN_READER_MESSAGE)
237
+ if touch_reader(persona):
238
+ parts.append(TOUCH_READER_MESSAGE)
239
+ elif keyboard_only(persona):
168
240
  parts.append(KEYBOARD_MESSAGE)
241
+ elif persona["input"] == "touch":
242
+ parts.append(TOUCH_MESSAGE)
169
243
  parts.append("\n".join(who))
170
244
  return "\n\n".join(parts)
171
245
 
@@ -186,7 +260,9 @@ async def _cdp(browser_session: BrowserSession):
186
260
 
187
261
  async def apply_emulation(browser_session: BrowserSession, persona: Dict[str, Any], viewport: Optional[List[int]], applied: Dict[str, Any]) -> None:
188
262
  """Vision, zoom and media of the persona on the page in focus: vision and media once per tab, zoom whenever it is gone."""
189
- if persona["vision"] == "none" and persona["zoom"] <= 1 and not persona["media"]:
263
+ device = persona.get("device")
264
+ scale = persona.get("text_scale", 1)
265
+ if persona["vision"] == "none" and persona["zoom"] <= 1 and not persona["media"] and not device and scale <= 1:
190
266
  return
191
267
  try:
192
268
  cdp = await _cdp(browser_session)
@@ -201,8 +277,26 @@ async def apply_emulation(browser_session: BrowserSession, persona: Dict[str, An
201
277
  await send.Emulation.setEmulatedVisionDeficiency(params={"type": VISION[persona["vision"]]}, session_id=sid)
202
278
  if persona["media"]:
203
279
  await send.Emulation.setEmulatedMedia(params={"features": [{"name": MEDIA[m][0], "value": MEDIA[m][1]} for m in persona["media"]]}, session_id=sid)
280
+ if device and device["mobile"]:
281
+ await send.Emulation.setTouchEmulationEnabled(params={"enabled": True, "maxTouchPoints": 5}, session_id=sid)
282
+ if device and device["ua"]:
283
+ await send.Emulation.setUserAgentOverride(params={"userAgent": device["ua"]}, session_id=sid)
284
+ if scale > 1:
285
+ # The system's larger text, as the browser's default font size: text sized in rem or em grows, px does not.
286
+ await send.Page.setFontSizes(params={"fontSizes": {"standard": round(16 * scale), "fixed": round(13 * scale)}}, session_id=sid)
204
287
  applied[sid] = True
205
- if persona["zoom"] > 1:
288
+ if device:
289
+ # The device's size, at the persona's zoom; the browser library resets the viewport when a tab gains focus, so it is
290
+ # checked before every step and applied again once it is gone.
291
+ z = persona["zoom"]
292
+ width = max(240, round(device["width"] / z))
293
+ # screen.width, not innerWidth: a page with no viewport meta lays out wider (980px) on a phone, as it should.
294
+ now = ((await send.Runtime.evaluate(params={"expression": "screen.width", "returnByValue": True}, session_id=sid)).get("result") or {}).get("value")
295
+ if now != width:
296
+ await send.Emulation.setDeviceMetricsOverride(
297
+ params={"screenWidth": width, "screenHeight": max(240, round(device["height"] / z)), "width": width, "height": max(240, round(device["height"] / z)), "deviceScaleFactor": device["scale"] * z, "mobile": device["mobile"]}, session_id=sid
298
+ )
299
+ elif persona["zoom"] > 1:
206
300
  # Zooming a page is a smaller viewport in CSS pixels at a larger scale: the page reflows as it does at that zoom.
207
301
  w, h = (viewport or [1280, 800])[:2]
208
302
  z = persona["zoom"]
@@ -263,7 +357,14 @@ def announce(node: Dict[str, Any]) -> str:
263
357
  return " ".join(b for b in bits if b)
264
358
 
265
359
 
266
- def render_tree(nodes: List[Dict[str, Any]], view: str) -> str:
360
+ def reading_items(nodes: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
361
+ """What a touch screen reader's swipes move through, in reading order: each item as it is said, and its DOM node."""
362
+ items: List[Dict[str, Any]] = []
363
+ render_tree(nodes, "page", items)
364
+ return items
365
+
366
+
367
+ def render_tree(nodes: List[Dict[str, Any]], view: str, items: Optional[List[Dict[str, Any]]] = None) -> str:
267
368
  """The accessibility tree as a screen reader user hears it: the whole page, or one of its rotor lists."""
268
369
  by_id = {str(n.get("nodeId")): n for n in nodes if isinstance(n, dict)}
269
370
  lines: List[str] = []
@@ -285,7 +386,9 @@ def render_tree(nodes: List[Dict[str, Any]], view: str) -> str:
285
386
  if role in ("generic", "none", "presentation", "RootWebArea", "group", "LabelText", "paragraph", "Section") and not _ax_value(n.get("name")):
286
387
  return False
287
388
  if role == "StaticText":
288
- # Text inside a named element is already in that element's name.
389
+ # Empty or blank text is not said; text inside a named element is already in that element's name.
390
+ if not _ax_value(n.get("name")).strip():
391
+ return False
289
392
  parent = by_id.get(str(n.get("parentId")))
290
393
  return not (parent and _ax_value(parent.get("name")) and _ax_value(parent.get("role")) in INTERACTIVE | {"heading", "image", "img"})
291
394
  return True
@@ -299,6 +402,10 @@ def render_tree(nodes: List[Dict[str, Any]], view: str) -> str:
299
402
  role = _ax_value(n.get("role"))
300
403
  line = f"text {' '.join(_ax_value(n.get('name')).split())[:200]!r}" if role == "StaticText" else announce(n)
301
404
  lines.append((" " * min(depth, 8) if view == "page" else "") + line)
405
+ # A swipe stops on what VoiceOver and TalkBack stop on: not the page itself, a landmark, or an unnamed legend.
406
+ if items is not None and role not in LANDMARKS and role not in ("RootWebArea", "Legend"):
407
+ backend = n.get("backendDOMNodeId")
408
+ items.append({"line": line, "backend": backend if isinstance(backend, int) else None})
302
409
  for c in n.get("childIds") or []:
303
410
  walk(str(c), depth + (1 if shown else 0))
304
411
 
@@ -381,7 +488,8 @@ def register_persona_tools(tools: Any, persona: Dict[str, Any], findings: List[D
381
488
  pass
382
489
  item = {"title": title, "what_happened": what, "expected": clip(expected, 400), "severity": sev, "wcag": criterion, "element": clip(element, 200), "url": url}
383
490
  if any(f["title"].lower() == title.lower() and f["url"] == url for f in findings):
384
- return ActionResult(extracted_content=f"Already recorded on this page: {title}")
491
+ # The same barrier again is often a done that the library dropped for sharing a step with this record.
492
+ return ActionResult(extracted_content=f"Already recorded on this page: {title}. Record another barrier, go on, or, when you are finished, call done alone in a step of its own.")
385
493
  findings.append(item)
386
494
  save_findings(out_dir, persona, findings)
387
495
  return ActionResult(extracted_content=f"Recorded barrier ({sev}{f', WCAG {criterion}' if criterion else ''}): {title}")
@@ -411,12 +519,92 @@ def register_persona_tools(tools: Any, persona: Dict[str, Any], findings: List[D
411
519
  said = f"Pressed {'Shift+' if shift else ''}{name}. {focus_line(f, sighted)}"
412
520
  return ActionResult(extracted_content=said, long_term_memory=said)
413
521
 
414
- @tools.action("Type text into the field that has focus, as a keyboard user does. Move focus to the field with press_key first.")
522
+ if touch_reader(persona):
523
+ cursor: Dict[str, Any] = {"url": "", "at": -1, "line": "", "backend": None}
524
+
525
+ async def _items(browser_session: BrowserSession) -> List[Dict[str, Any]]:
526
+ cdp = await _cdp(browser_session)
527
+ try:
528
+ await cdp.cdp_client.send.Accessibility.enable(session_id=cdp.session_id)
529
+ except Exception:
530
+ pass
531
+ tree = await cdp.cdp_client.send.Accessibility.getFullAXTree(params={}, session_id=cdp.session_id)
532
+ return reading_items(tree.get("nodes") or [])
533
+
534
+ async def _place(browser_session: BrowserSession, items: List[Dict[str, Any]]) -> int:
535
+ """Where the cursor is now: on its item again after the page changed, at the start of a new page."""
536
+ url = ""
537
+ try:
538
+ url = str(await browser_session.get_current_page_url() or "")
539
+ except Exception:
540
+ pass
541
+ if url != cursor["url"]:
542
+ cursor.update({"url": url, "at": -1, "line": "", "backend": None})
543
+ return -1
544
+ for i, it in enumerate(items):
545
+ if cursor["backend"] is not None and it["backend"] == cursor["backend"] and it["line"] == cursor["line"]:
546
+ return i
547
+ return min(cursor["at"], len(items) - 1)
548
+
549
+ async def _swipe(step: int, browser_session: BrowserSession) -> ActionResult:
550
+ try:
551
+ items = await _items(browser_session)
552
+ at = await _place(browser_session, items) + step
553
+ except Exception as ex:
554
+ return ActionResult(error=f"The screen reader could not read the page: {ex}")
555
+ if not items:
556
+ return ActionResult(extracted_content="The screen reader announces nothing on this page.")
557
+ if at < 0 or at >= len(items):
558
+ return ActionResult(extracted_content="Start of the page: nothing before this." if at < 0 else "End of the page: nothing after this.")
559
+ cursor.update({"at": at, "line": items[at]["line"], "backend": items[at]["backend"]})
560
+ said = f"{'Swiped right' if step > 0 else 'Swiped left'}. {items[at]['line']}"
561
+ return ActionResult(extracted_content=said, long_term_memory=said)
562
+
563
+ @tools.action("Swipe right with the screen reader: move to the next item in reading order and hear it.")
564
+ async def swipe_next(browser_session: BrowserSession) -> ActionResult:
565
+ return await _swipe(1, browser_session)
566
+
567
+ @tools.action("Swipe left with the screen reader: move to the previous item in reading order and hear it.")
568
+ async def swipe_previous(browser_session: BrowserSession) -> ActionResult:
569
+ return await _swipe(-1, browser_session)
570
+
571
+ @tools.action("Double tap with the screen reader: activate the item the cursor is on (follow a link, press a button, put focus in a field).")
572
+ async def double_tap(browser_session: BrowserSession) -> ActionResult:
573
+ if cursor["backend"] is None:
574
+ return ActionResult(error="The cursor is on nothing that can be activated: move to an item with swipe_next first.")
575
+ try:
576
+ cdp = await _cdp(browser_session)
577
+ send, sid = cdp.cdp_client.send, cdp.session_id
578
+ await send.DOM.getDocument(params={"depth": 0}, session_id=sid)
579
+ await send.DOM.scrollIntoViewIfNeeded(params={"backendNodeId": cursor["backend"]}, session_id=sid)
580
+ box = ((await send.DOM.getBoxModel(params={"backendNodeId": cursor["backend"]}, session_id=sid)) or {}).get("model") or {}
581
+ quad = box.get("content") or box.get("border") or []
582
+ if len(quad) < 8:
583
+ return ActionResult(error=f"{cursor['line']} has no place on the screen: double tap does nothing on it.")
584
+ x, y = sum(quad[0::2]) / 4, sum(quad[1::2]) / 4
585
+ # A screen reader's double tap activates the item where it is, as a finger's tap there does: a touch, in the
586
+ # page's layout pixels (the input layer maps them onto a page a phone shows scaled). Without touch, a click.
587
+ try:
588
+ await send.Input.dispatchTouchEvent(params={"type": "touchStart", "touchPoints": [{"x": x, "y": y}]}, session_id=sid)
589
+ await send.Input.dispatchTouchEvent(params={"type": "touchEnd", "touchPoints": []}, session_id=sid)
590
+ except Exception:
591
+ for kind in ("mousePressed", "mouseReleased"):
592
+ await send.Input.dispatchMouseEvent(params={"type": kind, "x": x, "y": y, "button": "left", "clickCount": 1}, session_id=sid)
593
+ await asyncio.sleep(0.3)
594
+ f = await focused(browser_session)
595
+ except Exception as ex:
596
+ return ActionResult(error=f"Double tap did not reach {cursor['line']}: {ex}")
597
+ said = f"Double tapped {cursor['line']}. {focus_line(f, False)}"
598
+ return ActionResult(extracted_content=said, long_term_memory=said)
599
+
600
+ if touch_reader(persona) or keyboard_only(persona):
601
+
602
+ @tools.action("Type text into the field that has focus, as on the on-screen or a real keyboard. Put focus in the field first (press_key, or double_tap on a touchscreen).")
415
603
  async def type_text(text: str, browser_session: BrowserSession) -> ActionResult:
416
604
  try:
417
605
  f = await focused(browser_session)
418
606
  if f.get("none"):
419
- return ActionResult(error="Nothing has focus: move to the field with press_key first.")
607
+ return ActionResult(error="Nothing has focus: put focus in the field first.")
420
608
  cdp = await _cdp(browser_session)
421
609
  await cdp.cdp_client.send.Input.insertText(params={"text": str(text or "")}, session_id=cdp.session_id)
422
610
  f = await focused(browser_session)
@@ -150,6 +150,8 @@ class RunRequest:
150
150
  keep_headers: List[str] = field(default_factory=list)
151
151
  # axe-core for the accessibility checks: {"script": path to axe.min.js, "tags": [...]}; empty: the built-in checks.
152
152
  axe: Dict[str, Any] = field(default_factory=dict)
153
+ # IBM Equal Access instead of axe-core: {"script": path to ace.js, "ruleset", "levels", "recommendations", "version"}.
154
+ ibm: Dict[str, Any] = field(default_factory=dict)
153
155
  # Core Web Vitals and load timings of each page (performance.json).
154
156
  vitals: bool = True
155
157
  # Screenshots of each page for visual comparison: {"mask": [...], "pages": {...}, "full_page": bool}; None: off.
@@ -189,6 +191,7 @@ class RunRequest:
189
191
  keep_headers=[str(h) for h in (d.get("keep_headers") or [])[:20] if isinstance(h, str)] if isinstance(d.get("keep_headers"), list) else [],
190
192
  prompts={str(k): str(v) for k, v in (d.get("prompts") or {}).items()} if isinstance(d.get("prompts"), dict) else {},
191
193
  axe=dict(d["axe"]) if isinstance(d.get("axe"), dict) else {},
194
+ ibm=dict(d["ibm"]) if isinstance(d.get("ibm"), dict) else {},
192
195
  vitals=d.get("vitals") is not False,
193
196
  visual=dict(d["visual"]) if isinstance(d.get("visual"), dict) else None,
194
197
  goal=str(d.get("goal") or ""),
@@ -1114,7 +1117,7 @@ async def run_browser_task(req: RunRequest, emit: Emit, cancel_event: asyncio.Ev
1114
1117
  )
1115
1118
  _time_llm_calls(llm, llm_calls, lambda c: emit({"type": "call", **c}), failures=model_failures)
1116
1119
  use_prompts(req.prompts)
1117
- diag = Diagnostics(accessibility=req.accessibility, network=req.network, axe=req.axe or None, vitals=req.vitals, visual=req.visual, keep_headers=req.keep_headers)
1120
+ diag = Diagnostics(accessibility=req.accessibility, network=req.network, axe=req.axe or None, ibm=req.ibm or None, vitals=req.vitals, visual=req.visual, keep_headers=req.keep_headers)
1118
1121
 
1119
1122
  browser_cfg = req.browser if isinstance(req.browser, dict) else {}
1120
1123
  browser_provider = str(browser_cfg.get("provider") or "local")
@@ -1483,13 +1486,13 @@ async def run_browser_task(req: RunRequest, emit: Emit, cancel_event: asyncio.Ev
1483
1486
  if persona:
1484
1487
  personas.register_persona_tools(agent_tools, persona, persona_findings, req.out_dir)
1485
1488
  personas.save_findings(req.out_dir, persona, persona_findings)
1486
- if personas.keyboard_only(persona):
1489
+ if personas.no_pointer(persona):
1487
1490
  personas.exclude_mouse(agent_tools)
1488
1491
  if not personas.uses_vision(persona):
1489
1492
  personas.exclude_markup(agent_tools)
1490
1493
  # A screen reader user does not see the page: the agent gets no screenshots.
1491
1494
  agent_kw["use_vision"] = personas.uses_vision(persona)
1492
- emit({"type": "log", "level": "info", "text": f"Accessibility persona: {persona['name']} ({'screen reader' if persona['perception'] == 'screen_reader' else 'sight'}, {'keyboard only' if personas.keyboard_only(persona) else 'mouse and keyboard'})"})
1495
+ emit({"type": "log", "level": "info", "text": f"Accessibility persona: {persona['name']} ({'screen reader' if persona['perception'] == 'screen_reader' else 'sight'}, {'screen reader gestures' if personas.touch_reader(persona) else 'keyboard only' if personas.keyboard_only(persona) else 'touch' if persona['input'] == 'touch' else 'mouse and keyboard'}{', ' + persona['device']['label'] if persona.get('device') and persona['device'].get('label') else ''})"})
1493
1496
  else:
1494
1497
  register_checks(agent_tools, recorded_checks)
1495
1498
  register_click_selector(agent_tools, captured)