@developerz.ai/ui-debugger-mcp 1.1.0 → 1.3.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.
Files changed (163) hide show
  1. package/README.md +45 -10
  2. package/dist/adapters/android/adb.d.ts +34 -5
  3. package/dist/adapters/android/adb.js +74 -20
  4. package/dist/adapters/android/adb.js.map +1 -1
  5. package/dist/adapters/android/android-adapter.d.ts +23 -7
  6. package/dist/adapters/android/android-adapter.js +106 -36
  7. package/dist/adapters/android/android-adapter.js.map +1 -1
  8. package/dist/adapters/android/android-adapter.test-helpers.d.ts +52 -0
  9. package/dist/adapters/android/android-adapter.test-helpers.js +115 -0
  10. package/dist/adapters/android/android-adapter.test-helpers.js.map +1 -0
  11. package/dist/adapters/android/commands.d.ts +27 -4
  12. package/dist/adapters/android/commands.js +66 -4
  13. package/dist/adapters/android/commands.js.map +1 -1
  14. package/dist/adapters/android/ports.d.ts +32 -0
  15. package/dist/adapters/android/ports.js +47 -0
  16. package/dist/adapters/android/ports.js.map +1 -0
  17. package/dist/adapters/android/uiautomator.d.ts +10 -2
  18. package/dist/adapters/android/uiautomator.js +36 -4
  19. package/dist/adapters/android/uiautomator.js.map +1 -1
  20. package/dist/adapters/browser/browser-adapter.d.ts +16 -13
  21. package/dist/adapters/browser/browser-adapter.js +196 -313
  22. package/dist/adapters/browser/browser-adapter.js.map +1 -1
  23. package/dist/adapters/browser/cdp.d.ts +40 -2
  24. package/dist/adapters/browser/cdp.js +223 -19
  25. package/dist/adapters/browser/cdp.js.map +1 -1
  26. package/dist/adapters/browser/extractor.d.ts +53 -0
  27. package/dist/adapters/browser/extractor.js +224 -0
  28. package/dist/adapters/browser/extractor.js.map +1 -0
  29. package/dist/adapters/browser/filters.d.ts +15 -0
  30. package/dist/adapters/browser/filters.js +93 -0
  31. package/dist/adapters/browser/filters.js.map +1 -0
  32. package/dist/adapters/browser/launch.d.ts +41 -0
  33. package/dist/adapters/browser/launch.js +61 -0
  34. package/dist/adapters/browser/launch.js.map +1 -0
  35. package/dist/adapters/budget.d.ts +16 -0
  36. package/dist/adapters/budget.js +25 -0
  37. package/dist/adapters/budget.js.map +1 -0
  38. package/dist/adapters/contract.d.ts +82 -6
  39. package/dist/adapters/desktop/atspi.d.ts +15 -0
  40. package/dist/adapters/desktop/atspi.js +37 -17
  41. package/dist/adapters/desktop/atspi.js.map +1 -1
  42. package/dist/adapters/desktop/capture.js +8 -1
  43. package/dist/adapters/desktop/capture.js.map +1 -1
  44. package/dist/adapters/desktop/desktop-adapter.d.ts +9 -2
  45. package/dist/adapters/desktop/desktop-adapter.js +84 -32
  46. package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
  47. package/dist/adapters/desktop/input.d.ts +16 -1
  48. package/dist/adapters/desktop/input.js +30 -0
  49. package/dist/adapters/desktop/input.js.map +1 -1
  50. package/dist/adapters/desktop/proc.d.ts +18 -3
  51. package/dist/adapters/desktop/proc.js +48 -5
  52. package/dist/adapters/desktop/proc.js.map +1 -1
  53. package/dist/adapters/factory.d.ts +3 -1
  54. package/dist/adapters/factory.js +6 -2
  55. package/dist/adapters/factory.js.map +1 -1
  56. package/dist/adapters/limit.d.ts +10 -0
  57. package/dist/adapters/limit.js +19 -0
  58. package/dist/adapters/limit.js.map +1 -0
  59. package/dist/agent/belt/act.d.ts +44 -9
  60. package/dist/agent/belt/act.js +176 -21
  61. package/dist/agent/belt/act.js.map +1 -1
  62. package/dist/agent/belt/look.d.ts +1 -1
  63. package/dist/agent/belt/look.js +31 -2
  64. package/dist/agent/belt/look.js.map +1 -1
  65. package/dist/agent/belt/observe.d.ts +42 -16
  66. package/dist/agent/belt/observe.js +134 -22
  67. package/dist/agent/belt/observe.js.map +1 -1
  68. package/dist/agent/belt/report.d.ts +29 -9
  69. package/dist/agent/belt/report.js +77 -10
  70. package/dist/agent/belt/report.js.map +1 -1
  71. package/dist/agent/belt/trail.d.ts +34 -0
  72. package/dist/agent/belt/trail.js +64 -0
  73. package/dist/agent/belt/trail.js.map +1 -0
  74. package/dist/agent/capabilities.d.ts +4 -4
  75. package/dist/agent/capabilities.js +41 -13
  76. package/dist/agent/capabilities.js.map +1 -1
  77. package/dist/agent/loop.d.ts +70 -21
  78. package/dist/agent/loop.js +146 -48
  79. package/dist/agent/loop.js.map +1 -1
  80. package/dist/agent/prompts/compose.d.ts +9 -1
  81. package/dist/agent/prompts/compose.js +5 -4
  82. package/dist/agent/prompts/compose.js.map +1 -1
  83. package/dist/agent/prompts/debug-agent.d.ts +13 -1
  84. package/dist/agent/prompts/debug-agent.js +98 -14
  85. package/dist/agent/prompts/debug-agent.js.map +1 -1
  86. package/dist/agent/prompts/desktop-addendum.d.ts +1 -1
  87. package/dist/agent/prompts/desktop-addendum.js +1 -1
  88. package/dist/agent/prompts/web-addendum.d.ts +1 -1
  89. package/dist/agent/prompts/web-addendum.js +84 -16
  90. package/dist/agent/prompts/web-addendum.js.map +1 -1
  91. package/dist/cli/control.d.ts +3 -1
  92. package/dist/cli/control.js +26 -40
  93. package/dist/cli/control.js.map +1 -1
  94. package/dist/cli/help.d.ts +3 -1
  95. package/dist/cli/help.js +6 -2
  96. package/dist/cli/help.js.map +1 -1
  97. package/dist/cli/init.d.ts +3 -6
  98. package/dist/cli/init.js +64 -16
  99. package/dist/cli/init.js.map +1 -1
  100. package/dist/config/fingerprint.d.ts +32 -0
  101. package/dist/config/fingerprint.js +47 -0
  102. package/dist/config/fingerprint.js.map +1 -0
  103. package/dist/config/load.d.ts +7 -1
  104. package/dist/config/load.js +17 -4
  105. package/dist/config/load.js.map +1 -1
  106. package/dist/config/schema.d.ts +12 -5
  107. package/dist/config/schema.js +17 -7
  108. package/dist/config/schema.js.map +1 -1
  109. package/dist/errors.d.ts +14 -2
  110. package/dist/errors.js +24 -4
  111. package/dist/errors.js.map +1 -1
  112. package/dist/index.d.ts +1 -1
  113. package/dist/index.js +1 -1
  114. package/dist/main.js +26 -8
  115. package/dist/main.js.map +1 -1
  116. package/dist/mcp/server.d.ts +16 -1
  117. package/dist/mcp/server.js +23 -2
  118. package/dist/mcp/server.js.map +1 -1
  119. package/dist/mcp/server.test-helpers.d.ts +23 -0
  120. package/dist/mcp/server.test-helpers.js +49 -0
  121. package/dist/mcp/server.test-helpers.js.map +1 -0
  122. package/dist/mcp/tools/describe.js +5 -0
  123. package/dist/mcp/tools/describe.js.map +1 -1
  124. package/dist/mcp/tools/end-session.js +5 -0
  125. package/dist/mcp/tools/end-session.js.map +1 -1
  126. package/dist/mcp/tools/get-findings.js +23 -3
  127. package/dist/mcp/tools/get-findings.js.map +1 -1
  128. package/dist/mcp/tools/output.d.ts +50 -0
  129. package/dist/mcp/tools/output.js +55 -0
  130. package/dist/mcp/tools/output.js.map +1 -0
  131. package/dist/mcp/tools/result.d.ts +24 -1
  132. package/dist/mcp/tools/result.js +106 -5
  133. package/dist/mcp/tools/result.js.map +1 -1
  134. package/dist/mcp/tools/send-message.js +5 -0
  135. package/dist/mcp/tools/send-message.js.map +1 -1
  136. package/dist/mcp/tools/start-debug.js +7 -1
  137. package/dist/mcp/tools/start-debug.js.map +1 -1
  138. package/dist/services/debug-service.d.ts +47 -8
  139. package/dist/services/debug-service.js +185 -14
  140. package/dist/services/debug-service.js.map +1 -1
  141. package/dist/services/session-builder.d.ts +20 -3
  142. package/dist/services/session-builder.js +43 -13
  143. package/dist/services/session-builder.js.map +1 -1
  144. package/dist/services/summarize.d.ts +1 -1
  145. package/dist/services/summarize.js +8 -1
  146. package/dist/services/summarize.js.map +1 -1
  147. package/dist/session/atomic-write.d.ts +24 -0
  148. package/dist/session/atomic-write.js +39 -0
  149. package/dist/session/atomic-write.js.map +1 -0
  150. package/dist/session/findings-store.js +3 -4
  151. package/dist/session/findings-store.js.map +1 -1
  152. package/dist/session/process-identity.d.ts +16 -0
  153. package/dist/session/process-identity.js +29 -0
  154. package/dist/session/process-identity.js.map +1 -1
  155. package/dist/session/session.js +36 -4
  156. package/dist/session/session.js.map +1 -1
  157. package/dist/session/state-file.d.ts +64 -5
  158. package/dist/session/state-file.js +76 -9
  159. package/dist/session/state-file.js.map +1 -1
  160. package/dist/session/workspace.d.ts +11 -0
  161. package/dist/session/workspace.js +14 -1
  162. package/dist/session/workspace.js.map +1 -1
  163. package/package.json +4 -1
@@ -9,13 +9,29 @@
9
9
  * the pure orchestration without spawning anything.
10
10
  *
11
11
  * Fails loud — a non-zero exit rejects through `execFile`, and callers re-wrap it
12
- * as an {@link AdapterError}; never a silent fallback.
12
+ * as an {@link AdapterError}; never a silent fallback. Every invocation is also
13
+ * wall-clock capped, so no wedged tool can park the run (see {@link makeExec}).
13
14
  */
14
15
  import { execFile } from 'node:child_process';
15
16
  import { promisify } from 'node:util';
17
+ import { ExecTimeoutError } from '../../errors.js';
16
18
  const pExecFile = promisify(execFile);
17
19
  /** 16 MiB stdout cap — busctl JSON is small; the screenshots route through a file. */
18
20
  const MAX_BUFFER = 16 * 1024 * 1024;
21
+ /**
22
+ * Default per-invocation wall-clock cap. These tools do wedge in practice — `busctl`
23
+ * against an unresponsive AT-SPI peer, `xdotool --sync` waiting on a window that never
24
+ * settles — and an unbounded `execFile` parks the whole operation behind that one call
25
+ * until the outer session timeout. 10 s is far above any healthy input/a11y round-trip;
26
+ * capture passes its own, longer cap (`capture.ts`).
27
+ */
28
+ export const DEFAULT_EXEC_TIMEOUT_MS = 10_000;
29
+ /**
30
+ * Kill signal on expiry. SIGKILL, not SIGTERM: a tool blocked on a hung X11/D-Bus
31
+ * round-trip is exactly the process that ignores a polite signal, and Node only
32
+ * rejects once the child is actually gone.
33
+ */
34
+ const KILL_SIGNAL = 'SIGKILL';
19
35
  /**
20
36
  * A child env with `DISPLAY` overridden when a target display is configured (else inherit).
21
37
  * An explicit display also drops any inherited `WAYLAND_DISPLAY` — the user pointed us at
@@ -30,13 +46,40 @@ export function desktopEnv(display) {
30
46
  }
31
47
  return env;
32
48
  }
33
- /** The real {@link Exec}: `execFile` bound to a fixed child env. */
34
- export function makeExec(env) {
49
+ /**
50
+ * The real {@link Exec}: `execFile` bound to a fixed child env and a wall-clock cap
51
+ * (`timeoutMs`, default {@link DEFAULT_EXEC_TIMEOUT_MS}). Expiry kills the child and
52
+ * rejects as an {@link ExecTimeoutError} naming the cap; every other failure passes through
53
+ * **raw** so callers can still triage the real `execFile` error (ENOENT, exit code,
54
+ * stderr) — `xdotool search` exiting non-zero with empty stderr means "no window yet".
55
+ */
56
+ export function makeExec(env, timeoutMs = DEFAULT_EXEC_TIMEOUT_MS) {
35
57
  return async (cmd, args) => {
36
- const { stdout } = await pExecFile(cmd, args, { env, maxBuffer: MAX_BUFFER });
37
- return stdout;
58
+ try {
59
+ const { stdout } = await pExecFile(cmd, args, {
60
+ env,
61
+ maxBuffer: MAX_BUFFER,
62
+ timeout: timeoutMs,
63
+ killSignal: KILL_SIGNAL,
64
+ });
65
+ return stdout;
66
+ }
67
+ catch (error) {
68
+ if (!killedByTimeout(error))
69
+ throw error;
70
+ throw new ExecTimeoutError(`desktop: \`${cmd}\` timed out after ${timeoutMs}ms (${KILL_SIGNAL}ed — the tool or its display/bus is wedged)`, { cause: error });
71
+ }
38
72
  };
39
73
  }
74
+ /**
75
+ * True when `execFile` killed the child on `timeout` expiry. `killed` alone is not
76
+ * enough: a `maxBuffer` overflow also kills, and that is a different (still loud) bug.
77
+ */
78
+ function killedByTimeout(error) {
79
+ if (!(error instanceof Error) || error.killed !== true)
80
+ return false;
81
+ return error.code !== 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER';
82
+ }
40
83
  /** True when an error is a "binary not found on PATH" (`ENOENT`) — for a clear, loud message. */
41
84
  export function isEnoent(error) {
42
85
  return error instanceof Error && error.code === 'ENOENT';
@@ -1 +1 @@
1
- {"version":3,"file":"proc.js","sourceRoot":"","sources":["../../../src/adapters/desktop/proc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,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GG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,IAAK,KAA8B,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC/F,OAAQ,KAA+B,CAAC,IAAI,KAAK,mCAAmC,CAAC;AACvF,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,KAAK,YAAY,KAAK,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,CAAC;AACtF,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -16,8 +16,10 @@ import type { Adapter } from './contract.js';
16
16
  * @param config — the resolved `.ui-debugger-mcp.json` config
17
17
  * @param profileDir — absolute path to persistent profile dir (for managed browser adapter)
18
18
  * @param onLog — optional sink for streaming console/network logs to findings store
19
+ * @param timeoutMs — the run's remaining wall-clock budget for getting the target up;
20
+ * only the browser launches/connects here, so only it shortens its wait by it
19
21
  * @returns the wired Adapter instance
20
22
  * @throws TargetNotFoundError if targetName doesn't exist in config.targets
21
23
  * @throws AdapterError if the adapter type is not yet implemented
22
24
  */
23
- export declare function createAdapter(targetName: string, config: Config, profileDir: string, onLog?: BrowserAdapterInit['onLog']): Promise<Adapter>;
25
+ export declare function createAdapter(targetName: string, config: Config, profileDir: string, onLog?: BrowserAdapterInit['onLog'], timeoutMs?: number): Promise<Adapter>;
@@ -17,24 +17,28 @@ import { DesktopAdapter } from './desktop/desktop-adapter.js';
17
17
  * @param config — the resolved `.ui-debugger-mcp.json` config
18
18
  * @param profileDir — absolute path to persistent profile dir (for managed browser adapter)
19
19
  * @param onLog — optional sink for streaming console/network logs to findings store
20
+ * @param timeoutMs — the run's remaining wall-clock budget for getting the target up;
21
+ * only the browser launches/connects here, so only it shortens its wait by it
20
22
  * @returns the wired Adapter instance
21
23
  * @throws TargetNotFoundError if targetName doesn't exist in config.targets
22
24
  * @throws AdapterError if the adapter type is not yet implemented
23
25
  */
24
- export async function createAdapter(targetName, config, profileDir, onLog) {
26
+ export async function createAdapter(targetName, config, profileDir, onLog, timeoutMs) {
25
27
  const target = config.targets[targetName];
26
28
  if (!target) {
27
29
  throw new TargetNotFoundError(`target "${targetName}" not found in config.targets`);
28
30
  }
29
31
  switch (target.adapter) {
30
32
  case 'browser':
31
- return BrowserAdapter.create({ config: target, profileDir, onLog });
33
+ return BrowserAdapter.create({ config: target, profileDir, onLog, timeoutMs });
32
34
  case 'desktop':
33
35
  // Desktop is managed-only (no attach handle), so `profileDir`/`onLog` don't apply.
36
+ // Nothing launches here either — `open` spawns the app, and caps itself there.
34
37
  return DesktopAdapter.create({ config: target });
35
38
  case 'android':
36
39
  // Managed (boot `emulator @avd`) unless `adbSerial` attaches — `create` reads that
37
40
  // off the config. No page profile or CDP log sink applies, so neither is threaded.
41
+ // The emulator boots in `open`, which is where the run budget caps it.
38
42
  return AndroidAdapter.create({ config: target });
39
43
  default: {
40
44
  const unreachable = target;
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/adapters/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAA2B,MAAM,8BAA8B,CAAC;AAEvF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAkB,EAClB,MAAc,EACd,UAAkB,EAClB,KAAmC;IAEnC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,UAA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Z,MAAM,IAAI,mBAAmB,CAAC,WAAW,UAAU,+BAA+B,CAAC,CAAC;IACtF,CAAC;IAED,QAAQ,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,KAAK,SAAS;YACZ,OAAO,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAEjF,KAAK,SAAS;YACZ,mFAAmF;YACnF,+EAA+E;YAC/E,OAAO,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAEnD,KAAK,SAAS;YACZ,mFAAmF;YACnF,mFAAmF;YACnF,uEAAuE;YACvE,OAAO,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAEnD,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,WAAW,GAAU,MAAM,CAAC;YAClC,MAAM,IAAI,YAAY,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Shared `limit` guard for adapter reads.
3
+ *
4
+ * `limit` reaches adapters straight from agent input, and `Array.slice` misreads
5
+ * bad values SILENTLY: `-1` drops only the last row, `NaN` yields `[]`, `1.5`
6
+ * rounds. A blind driver would then reason over a quietly truncated tree, so
7
+ * every read cap goes through here and fails loud instead.
8
+ */
9
+ /** Cap `items` at `limit` (`undefined` = uncapped). Throws on a negative/non-integer limit. */
10
+ export declare function capToLimit<T>(items: T[], limit?: number): T[];
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Shared `limit` guard for adapter reads.
3
+ *
4
+ * `limit` reaches adapters straight from agent input, and `Array.slice` misreads
5
+ * bad values SILENTLY: `-1` drops only the last row, `NaN` yields `[]`, `1.5`
6
+ * rounds. A blind driver would then reason over a quietly truncated tree, so
7
+ * every read cap goes through here and fails loud instead.
8
+ */
9
+ import { AdapterError } from '../errors.js';
10
+ /** Cap `items` at `limit` (`undefined` = uncapped). Throws on a negative/non-integer limit. */
11
+ export function capToLimit(items, limit) {
12
+ if (limit === undefined)
13
+ return items;
14
+ if (!Number.isInteger(limit) || limit < 0) {
15
+ throw new AdapterError('`limit` must be a non-negative integer');
16
+ }
17
+ return items.slice(0, limit);
18
+ }
19
+ //# sourceMappingURL=limit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limit.js","sourceRoot":"","sources":["../../src/adapters/limit.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,+FAA+F;AAC/F,MAAM,UAAU,UAAU,CAAI,KAAU,EAAE,KAAc;IACtD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,YAAY,CAAC,wCAAwC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAC/B,CAAC"}
@@ -10,7 +10,7 @@
10
10
  * - `click` → `find` + `click` (resolve the node, then click it)
11
11
  * - `type` → `find` + `type` (resolve the field, then type into it)
12
12
  * - `navigate` → `open` (go to a URL / window / activity)
13
- * - `wait` → `waitFor` (block on a node / network idle / timeout)
13
+ * - `wait` → `waitFor` (block on a node and/or network idle, capped by timeout)
14
14
  * - `key` → `pressKey` (press a key / chord on the focused element)
15
15
  * - `scroll` → `scroll` (wheel the viewport, or a `target`-scoped region)
16
16
  *
@@ -21,13 +21,17 @@
21
21
  *
22
22
  * After the action it records one step: a line to `logs/agent.log` plus an ordered
23
23
  * post-action frame to `screenshots/` (the replay video). Recording is not
24
- * best-effort — a failed capture surfaces, never a silent fallback.
24
+ * best-effort — a failed capture surfaces, never a silent fallback. Every finished
25
+ * step lands on the run's {@link ActTrail} at act time, `ok: true` with its frame
26
+ * or `ok: false` with the error (then rethrown, so the driver still sees it) — the
27
+ * trail tells the truth about what worked AND what did not.
25
28
  */
26
29
  import { z } from 'zod';
27
- import type { Adapter } from '../../adapters/contract.js';
30
+ import type { Adapter, TabInfo } from '../../adapters/contract.js';
28
31
  import type { LogChannel } from '../../session/findings-store.js';
29
- /** The six action verbs `act` routes to the shared contract. */
30
- export declare const ACT_ACTIONS: readonly ["click", "type", "key", "scroll", "navigate", "wait"];
32
+ import type { ActTrail } from './trail.js';
33
+ /** The action verbs `act` routes to the shared contract. */
34
+ export declare const ACT_ACTIONS: readonly ["click", "type", "key", "scroll", "navigate", "wait", "switch_tab"];
31
35
  /**
32
36
  * `act` input — ONE flat object the driver fills per call: `action` picks the
33
37
  * verb, the rest are its (optional) operands, validated per-action in
@@ -48,9 +52,11 @@ export declare const ActInputSchema: z.ZodObject<{
48
52
  scroll: "scroll";
49
53
  navigate: "navigate";
50
54
  wait: "wait";
55
+ switch_tab: "switch_tab";
51
56
  }>;
52
57
  target: z.ZodOptional<z.ZodString>;
53
58
  text: z.ZodOptional<z.ZodString>;
59
+ clear: z.ZodOptional<z.ZodBoolean>;
54
60
  key: z.ZodOptional<z.ZodString>;
55
61
  direction: z.ZodOptional<z.ZodEnum<{
56
62
  up: "up";
@@ -69,8 +75,24 @@ export interface ActResult {
69
75
  action: ActInput['action'];
70
76
  /** Target-derived step label, e.g. `click button "Save"`. */
71
77
  label: string;
78
+ /**
79
+ * Whether the step worked — always `true` here, since a failed act throws (and
80
+ * reaches the trail as `ok: false`). Told to the driver so it never has to
81
+ * guess whether an act landed.
82
+ */
83
+ ok: true;
72
84
  /** Path to the post-action screenshot saved as evidence. */
73
85
  screenshot: string;
86
+ /**
87
+ * Every open tab — present ONLY once more than one is open.
88
+ *
89
+ * A click that opens a tab (`target="_blank"`, an OAuth popup) leaves a blind
90
+ * driver reading the tab it is still on, concluding "nothing happened", and
91
+ * abandoning the flow. Surfacing the tab list exactly when it becomes relevant
92
+ * turns that dead end into an obvious next step (`act switch_tab`), and costs
93
+ * nothing on the single-tab pages that are the norm.
94
+ */
95
+ tabs?: TabInfo[];
74
96
  }
75
97
  /**
76
98
  * The slice of the findings store `act` records through. {@link FindingsStore}
@@ -85,13 +107,26 @@ export interface StepRecorder {
85
107
  /**
86
108
  * Route one `act` call through the {@link Adapter}, then record the step. Pure
87
109
  * over the contract + {@link StepRecorder} seams, so it unit-tests against fakes.
110
+ *
111
+ * The step lands on `trail` the moment it finishes — announced through
112
+ * {@link ActTrail.begin} first, so a `report` racing in the SAME step waits for it
113
+ * instead of writing a verdict that never mentions this act. Anything that throws
114
+ * — a missing operand, an unresolved target, a dead adapter, a failed capture — is
115
+ * recorded as an `ok: false` entry and then RETHROWN: the driver still sees the
116
+ * error (and can retry), while the evidence trail keeps the step that did not work
117
+ * instead of silently dropping it.
118
+ */
119
+ export declare function runAct(adapter: Adapter, recorder: StepRecorder, input: ActInput, trail?: ActTrail): Promise<ActResult>;
120
+ /**
121
+ * Build the `act` tool bound to one adapter + recorder, for the debug agent's belt.
122
+ * `trail` (when wired by the loop) is the run's shared step trail, so every act —
123
+ * the ones that worked and the ones that threw — lands in the persisted findings.
88
124
  */
89
- export declare function runAct(adapter: Adapter, recorder: StepRecorder, input: ActInput): Promise<ActResult>;
90
- /** Build the `act` tool bound to one adapter + recorder, for the debug agent's belt. */
91
- export declare function createActTool(adapter: Adapter, recorder: StepRecorder): import("ai").Tool<{
92
- action: "type" | "key" | "click" | "scroll" | "navigate" | "wait";
125
+ export declare function createActTool(adapter: Adapter, recorder: StepRecorder, trail?: ActTrail): import("ai").Tool<{
126
+ action: "type" | "key" | "click" | "scroll" | "navigate" | "wait" | "switch_tab";
93
127
  target?: string | undefined;
94
128
  text?: string | undefined;
129
+ clear?: boolean | undefined;
95
130
  key?: string | undefined;
96
131
  direction?: "up" | "down" | "left" | "right" | undefined;
97
132
  amount?: number | undefined;
@@ -10,7 +10,7 @@
10
10
  * - `click` → `find` + `click` (resolve the node, then click it)
11
11
  * - `type` → `find` + `type` (resolve the field, then type into it)
12
12
  * - `navigate` → `open` (go to a URL / window / activity)
13
- * - `wait` → `waitFor` (block on a node / network idle / timeout)
13
+ * - `wait` → `waitFor` (block on a node and/or network idle, capped by timeout)
14
14
  * - `key` → `pressKey` (press a key / chord on the focused element)
15
15
  * - `scroll` → `scroll` (wheel the viewport, or a `target`-scoped region)
16
16
  *
@@ -21,13 +21,24 @@
21
21
  *
22
22
  * After the action it records one step: a line to `logs/agent.log` plus an ordered
23
23
  * post-action frame to `screenshots/` (the replay video). Recording is not
24
- * best-effort — a failed capture surfaces, never a silent fallback.
24
+ * best-effort — a failed capture surfaces, never a silent fallback. Every finished
25
+ * step lands on the run's {@link ActTrail} at act time, `ok: true` with its frame
26
+ * or `ok: false` with the error (then rethrown, so the driver still sees it) — the
27
+ * trail tells the truth about what worked AND what did not.
25
28
  */
26
29
  import { tool } from 'ai';
27
30
  import { z } from 'zod';
28
31
  import { AgentError } from '../../errors.js';
29
- /** The six action verbs `act` routes to the shared contract. */
30
- export const ACT_ACTIONS = ['click', 'type', 'key', 'scroll', 'navigate', 'wait'];
32
+ /** The action verbs `act` routes to the shared contract. */
33
+ export const ACT_ACTIONS = [
34
+ 'click',
35
+ 'type',
36
+ 'key',
37
+ 'scroll',
38
+ 'navigate',
39
+ 'wait',
40
+ 'switch_tab',
41
+ ];
31
42
  /**
32
43
  * `act` input — ONE flat object the driver fills per call: `action` picks the
33
44
  * verb, the rest are its (optional) operands, validated per-action in
@@ -41,12 +52,18 @@ export const ACT_ACTIONS = ['click', 'type', 'key', 'scroll', 'navigate', 'wait'
41
52
  * text" out of the schema and into a loud runtime check.
42
53
  */
43
54
  export const ActInputSchema = z.object({
44
- action: z.enum(ACT_ACTIONS).describe('what to do: click | type | key | scroll | navigate | wait'),
55
+ action: z
56
+ .enum(ACT_ACTIONS)
57
+ .describe('what to do: click | type | key | scroll | navigate | wait | switch_tab'),
45
58
  target: z
46
59
  .string()
47
60
  .optional()
48
- .describe('what to act on — CSS, role+name (button "Save"), or visible text (web); navigate: URL/window/activity; wait: selector to await; scroll: region to scroll within (optional)'),
61
+ .describe('what to act on — CSS, role+name (button "Save"), or visible text (web); navigate: URL/window/activity; wait: selector to await (required unless networkIdle); scroll: region to scroll within (optional); switch_tab: tab index from observe({kind:"tabs"})'),
49
62
  text: z.string().optional().describe('text to type (action=type)'),
63
+ clear: z
64
+ .boolean()
65
+ .optional()
66
+ .describe('replace the field contents instead of appending to them (action=type)'),
50
67
  key: z
51
68
  .string()
52
69
  .optional()
@@ -59,7 +76,7 @@ export const ActInputSchema = z.object({
59
76
  networkIdle: z
60
77
  .boolean()
61
78
  .optional()
62
- .describe('wait until in-flight requests settle (action=wait, web)'),
79
+ .describe('wait until in-flight requests settle (action=wait, web); needed if no target'),
63
80
  timeout: z
64
81
  .number()
65
82
  .int()
@@ -80,14 +97,18 @@ function describeNode(node) {
80
97
  const name = node.name.trim();
81
98
  return name ? `${node.role} ${JSON.stringify(name)}` : node.role;
82
99
  }
83
- /** Describe what a `wait` is blocking on, for the step label. */
100
+ /**
101
+ * Describe what a `wait` is blocking on, for the step label. Never empty — the belt
102
+ * rejects a `wait` with no condition before it gets here.
103
+ */
84
104
  function describeWait(query, networkIdle, timeout) {
85
- const parts = [
105
+ return [
86
106
  query ? JSON.stringify(query) : undefined,
87
107
  networkIdle ? 'network idle' : undefined,
88
108
  timeout ? `${timeout}ms` : undefined,
89
- ].filter((part) => part !== undefined);
90
- return parts.length > 0 ? parts.join(' + ') : 'next frame';
109
+ ]
110
+ .filter((part) => part !== undefined)
111
+ .join(' + ');
91
112
  }
92
113
  /**
93
114
  * Require an operand the flat schema can't enforce per-action; fail loud when
@@ -100,6 +121,31 @@ function required(value, field, action) {
100
121
  }
101
122
  return value;
102
123
  }
124
+ /**
125
+ * The tab index `switch_tab` names. `target` is a string for every other verb, so
126
+ * the index arrives as one — reject anything that is not a whole, non-negative
127
+ * number rather than silently driving tab 0.
128
+ */
129
+ function tabIndex(target) {
130
+ const index = Number(target.trim());
131
+ if (!Number.isInteger(index) || index < 0) {
132
+ throw new AgentError(`act 'switch_tab' needs a tab index as 'target' (e.g. "1"), got ${JSON.stringify(target)} — list them with observe({kind:"tabs"})`);
133
+ }
134
+ return index;
135
+ }
136
+ /**
137
+ * Label an act from its INPUT — the fallback for a step that threw before a
138
+ * target-derived label existed. Never echoes `text` (typed secrets stay out of
139
+ * the trail, as they do out of the success label).
140
+ */
141
+ function describeAttempt(input) {
142
+ const operand = input.action === 'key' ? input.key : input.action === 'scroll' ? input.direction : input.target;
143
+ return operand ? `${input.action} ${operand}` : input.action;
144
+ }
145
+ /** One-line error text for a failed step's `note`. */
146
+ function failureNote(error) {
147
+ return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
148
+ }
103
149
  /** Perform one action against the contract and return its target-derived step label. */
104
150
  async function performAct(adapter, input) {
105
151
  switch (input.action) {
@@ -113,6 +159,23 @@ async function performAct(adapter, input) {
113
159
  // the real `requires 'text'` failure, nor cost an unnecessary `find()`.
114
160
  const text = required(input.text, 'text', 'type');
115
161
  const node = await resolve(adapter, required(input.target, 'target', 'type'));
162
+ if (input.clear === true) {
163
+ // `type` appends by design (it focuses and types, it does not `fill`), so
164
+ // re-typing a field silently produced doubled values like
165
+ // "Finish project reportFinish project report" — which the driver then
166
+ // reported as an app bug.
167
+ //
168
+ // Empty the field FIRST, then type: select-all-then-type would not work,
169
+ // because every `type` focuses its target by clicking, and that click
170
+ // collapses the selection it was meant to overwrite. Deleting instead
171
+ // leaves an empty field, where the re-click's caret position is moot.
172
+ // Built from existing contract verbs, so desktop and android get it too.
173
+ await adapter.type(node, '');
174
+ await adapter.pressKey('Control+a');
175
+ await adapter.pressKey('Delete');
176
+ await adapter.type(node, text);
177
+ return `type ${text.length} chars into ${describeNode(node)} (replacing)`;
178
+ }
116
179
  await adapter.type(node, text);
117
180
  return `type ${text.length} chars into ${describeNode(node)}`;
118
181
  }
@@ -122,6 +185,14 @@ async function performAct(adapter, input) {
122
185
  return `navigate to ${target}`;
123
186
  }
124
187
  case 'wait': {
188
+ // Every adapter needs something to block on — a bare `wait` can only throw
189
+ // (`waitFor requires query and/or networkIdle`). Reject it HERE so the driver
190
+ // gets a steering message from its own tool, and the dead step lands on the
191
+ // trail, instead of an adapter error it has to decode. A `timeout` alone is a
192
+ // sleep, which the loop has no use for.
193
+ if (!input.target && input.networkIdle !== true) {
194
+ throw new AgentError("act 'wait' requires 'target' (a selector to wait for) and/or 'networkIdle': true");
195
+ }
125
196
  await adapter.waitFor({
126
197
  query: input.target,
127
198
  networkIdle: input.networkIdle,
@@ -139,6 +210,14 @@ async function performAct(adapter, input) {
139
210
  await adapter.scroll({ direction, amount: input.amount, within: input.target });
140
211
  return `scroll ${direction}${input.amount !== undefined ? ` ${input.amount}px` : ''}`;
141
212
  }
213
+ case 'switch_tab': {
214
+ if (!adapter.selectTab) {
215
+ throw new AgentError("act 'switch_tab' is not supported on this target (web only)");
216
+ }
217
+ const index = tabIndex(required(input.target, 'target', 'switch_tab'));
218
+ await adapter.selectTab(index);
219
+ return `switch to tab ${index}`;
220
+ }
142
221
  default: {
143
222
  const unreachable = input.action;
144
223
  throw new AgentError(`unknown act action: ${JSON.stringify(unreachable)}`);
@@ -148,20 +227,96 @@ async function performAct(adapter, input) {
148
227
  /**
149
228
  * Route one `act` call through the {@link Adapter}, then record the step. Pure
150
229
  * over the contract + {@link StepRecorder} seams, so it unit-tests against fakes.
230
+ *
231
+ * The step lands on `trail` the moment it finishes — announced through
232
+ * {@link ActTrail.begin} first, so a `report` racing in the SAME step waits for it
233
+ * instead of writing a verdict that never mentions this act. Anything that throws
234
+ * — a missing operand, an unresolved target, a dead adapter, a failed capture — is
235
+ * recorded as an `ok: false` entry and then RETHROWN: the driver still sees the
236
+ * error (and can retry), while the evidence trail keeps the step that did not work
237
+ * instead of silently dropping it.
238
+ */
239
+ export async function runAct(adapter, recorder, input, trail) {
240
+ // Enter the gate BEFORE the first await, so a same-step terminal read sees this
241
+ // act in flight rather than an empty trail.
242
+ const settle = trail?.begin();
243
+ // Label the attempt from the input up front: a throw inside `performAct` yields
244
+ // no target-derived label, and an unlabelled failed step is not evidence.
245
+ let label = describeAttempt(input);
246
+ try {
247
+ label = await performAct(adapter, input);
248
+ const png = await adapter.screenshot();
249
+ const screenshot = await recorder.saveScreenshot(label, png);
250
+ await recorder.appendLog('agent', `act ${label} → ${screenshot}`);
251
+ trail?.record({ step: label, ok: true, screenshot });
252
+ return {
253
+ action: input.action,
254
+ label,
255
+ ok: true,
256
+ screenshot,
257
+ ...(await extraTabs(adapter)),
258
+ };
259
+ }
260
+ catch (error) {
261
+ trail?.record({ step: label, ok: false, note: failureNote(error) });
262
+ throw error;
263
+ }
264
+ finally {
265
+ // After the record on BOTH paths — a waiter released early would read a trail
266
+ // that is missing the very step it waited for.
267
+ settle?.();
268
+ }
269
+ }
270
+ /**
271
+ * The open tabs, but only when there is more than one to report — see
272
+ * {@link ActResult.tabs}. Never fails an otherwise-good act: a target that
273
+ * cannot list tabs, or one that throws mid-teardown, simply reports none.
151
274
  */
152
- export async function runAct(adapter, recorder, input) {
153
- const label = await performAct(adapter, input);
154
- const png = await adapter.screenshot();
155
- const screenshot = await recorder.saveScreenshot(label, png);
156
- await recorder.appendLog('agent', `act ${label} → ${screenshot}`);
157
- return { action: input.action, label, screenshot };
275
+ async function extraTabs(adapter) {
276
+ if (!adapter.tabs)
277
+ return {};
278
+ try {
279
+ const tabs = await adapter.tabs();
280
+ return tabs.length > 1 ? { tabs } : {};
281
+ }
282
+ catch {
283
+ return {};
284
+ }
158
285
  }
159
- /** Build the `act` tool bound to one adapter + recorder, for the debug agent's belt. */
160
- export function createActTool(adapter, recorder) {
286
+ /**
287
+ * Build the `act` tool bound to one adapter + recorder, for the debug agent's belt.
288
+ * `trail` (when wired by the loop) is the run's shared step trail, so every act —
289
+ * the ones that worked and the ones that threw — lands in the persisted findings.
290
+ */
291
+ export function createActTool(adapter, recorder, trail) {
292
+ /**
293
+ * Acts run ONE AT A TIME, however many the driver emits in a step.
294
+ *
295
+ * A model routinely batches independent-looking actions into a single step —
296
+ * `type` the email and `type` the password — and the SDK executes a step's tool
297
+ * calls concurrently. But an act is compound (focus the target, then type into
298
+ * it) and keyboard input is dispatched at the PAGE, not at an element: two acts
299
+ * in flight interleave their keystrokes into whichever field last took focus.
300
+ *
301
+ * Observed end-to-end: a registration typed
302
+ * `tTeessttuPsaesrs1TestPass123!…` into the password field and the app happily
303
+ * created the account. Nothing errored — the run just silently tested something
304
+ * other than what it typed, which is the worst failure mode a debugger can have.
305
+ *
306
+ * Chaining here rather than locking the adapter: the atomic unit is the whole
307
+ * act, not any single contract call it makes.
308
+ */
309
+ let queue = Promise.resolve();
161
310
  return tool({
162
- description: 'Drive the target with one action, chosen by action: click | type | key | scroll | navigate | wait. Resolves target via find, then routes to the adapter (click/type/open/waitFor) and records a step to agent.log plus a post-action screenshot. Use observe to read state before and after.',
311
+ description: 'Drive the target with one action, chosen by action: click | type | key | scroll | navigate | wait | switch_tab. Resolves target via find, then routes to the adapter (click/type/open/waitFor) and records a step to agent.log plus a post-action screenshot. Returns tabs when more than one is open — a click may have opened one. Use observe to read state before and after.',
163
312
  inputSchema: ActInputSchema,
164
- execute: (input) => runAct(adapter, recorder, input),
313
+ execute: (input) => {
314
+ const next = queue.then(() => runAct(adapter, recorder, input, trail));
315
+ // The chain must survive a failed act: swallow the rejection on the QUEUE
316
+ // copy only, so a thrown act still reaches the driver via `next`.
317
+ queue = next.catch(() => undefined);
318
+ return next;
319
+ },
165
320
  });
166
321
  }
167
322
  //# sourceMappingURL=act.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"act.js","sourceRoot":"","sources":["../../../src/agent/belt/act.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,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GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACpC,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -85,7 +85,7 @@ export interface EvidenceRecorder {
85
85
  * Pins the reply to the exact JSON `look` parses, so any competent multimodal
86
86
  * model behaves the same (never relies on a 3rd-party default).
87
87
  */
88
- export declare const VISION_SYSTEM_PROMPT = "You are the vision guy \u2014 the eyes of a blind UI-testing driver.\nYou are given a screenshot of the target UI plus a question and/or an expected look.\nDescribe what you see and judge how it looks: layout, alignment, spacing, colour,\noverlap, cut-off or unreadable text \u2014 anything that looks broken or off.\n\nReply with ONLY a JSON object (no prose, no markdown fences) of this exact shape:\n\n{\n \"description\": \"what you see, answering the question if one was asked\",\n \"matches\": true, // include ONLY when an expected look was given: does it match it?\n \"issues\": [ // visual problems found; [] when there are none\n { \"what\": \"the problem\", \"where\": \"where on screen\", \"severity\": \"low\" | \"medium\" | \"high\" }\n ]\n}\n\nSeverity: high = broken layout / overlap / invisible interactive element;\nmedium = misalignment / bad spacing / contrast issue; low = minor polish.\nBe concrete about \"where\" (e.g. \"top-right header\", \"primary submit button\").\nOutput the JSON object and nothing else.";
88
+ export declare const VISION_SYSTEM_PROMPT = "You are the vision guy \u2014 the eyes of a blind UI-testing driver.\nYou are given a screenshot of the target UI plus a question and/or an expected look.\nDescribe what you see and judge how it looks: layout, alignment, spacing, colour,\noverlap, cut-off or unreadable text \u2014 anything that looks broken or off.\n\nReply with ONLY a JSON object (no prose, no markdown fences) of this exact shape:\n\n{\n \"description\": \"what you see, answering the question if one was asked\",\n \"matches\": true, // include ONLY when an expected look was given: does it match it?\n \"issues\": [ // visual problems found; [] when there are none\n { \"what\": \"the problem\", \"where\": \"where on screen\", \"severity\": \"low\" | \"medium\" | \"high\" }\n ]\n}\n\nSeverity, by user impact: high = a user cannot read or use something (overlap,\ninvisible interactive element, text cut off mid-word, broken layout);\nmedium = it works but looks wrong (misalignment, cramped or uneven spacing, weak\ncontrast); low = polish (a few pixels off, a slightly odd shade, icon sizing).\nBe concrete about \"where\" (e.g. \"top-right header\", \"primary submit button\").\n\n## Report only what is ON this screenshot\n\n- `\"issues\": []` is a normal, useful answer. An empty list is not a failure to\n find something \u2014 a clean screen is a real result. Never pad the list to look thorough.\n- Judge only what is VISIBLE here. This is one viewport, not the whole page:\n content below the fold is not \"missing\", and you cannot see hover, focus,\n animation, other screen sizes, or what happens after a click. Do not report any\n of those.\n- Do not judge whether the CONTENT is correct \u2014 whether a total is right, a name is\n the expected one, a list holds the intended items. You cannot know the intent.\n Report how it LOOKS. If something reads as obviously placeholder (\"lorem ipsum\",\n \"undefined\", \"NaN\", an empty state where data was clearly expected), that IS\n visual and worth flagging.\n- If you are unsure whether something is a defect or the intended design, say so in\n `description` and leave it out of `issues`. A speculative issue costs the driver\n a real investigation.\n\n## If you were asked to read back a value\n\nWhen the question is just \"what does this field contain?\" / \"is the box checked?\" /\n\"what does this text say?\", answer it plainly in `description` \u2014 and add one\nsentence noting the driver can read this structurally from\n`observe({kind:\"tree\"})` (fields `value`, `checked`, `name`), which is exact\nwhere a screenshot is a guess. Reading small text off pixels is the one thing you\nare worst at; say when you are unsure rather than guessing a value.\n\nOutput the JSON object and nothing else.";
89
89
  /** Whether a provider error says the vision model rejected image input (text-only model). */
90
90
  export declare function isImageRejection(message: string): boolean;
91
91
  /** The latched, actionable message the driver gets when the vision model is text-only. */