@developerz.ai/ui-debugger-mcp 1.0.4 → 1.2.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.
- package/README.md +22 -10
- package/dist/adapters/android/adb.d.ts +34 -5
- package/dist/adapters/android/adb.js +74 -20
- package/dist/adapters/android/adb.js.map +1 -1
- package/dist/adapters/android/android-adapter.d.ts +23 -7
- package/dist/adapters/android/android-adapter.js +106 -36
- package/dist/adapters/android/android-adapter.js.map +1 -1
- package/dist/adapters/android/android-adapter.test-helpers.d.ts +52 -0
- package/dist/adapters/android/android-adapter.test-helpers.js +115 -0
- package/dist/adapters/android/android-adapter.test-helpers.js.map +1 -0
- package/dist/adapters/android/commands.d.ts +27 -4
- package/dist/adapters/android/commands.js +66 -4
- package/dist/adapters/android/commands.js.map +1 -1
- package/dist/adapters/android/ports.d.ts +32 -0
- package/dist/adapters/android/ports.js +47 -0
- package/dist/adapters/android/ports.js.map +1 -0
- package/dist/adapters/android/uiautomator.d.ts +10 -2
- package/dist/adapters/android/uiautomator.js +36 -4
- package/dist/adapters/android/uiautomator.js.map +1 -1
- package/dist/adapters/browser/browser-adapter.d.ts +14 -13
- package/dist/adapters/browser/browser-adapter.js +81 -200
- package/dist/adapters/browser/browser-adapter.js.map +1 -1
- package/dist/adapters/browser/cdp.js +18 -11
- package/dist/adapters/browser/cdp.js.map +1 -1
- package/dist/adapters/browser/extractor.d.ts +49 -0
- package/dist/adapters/browser/extractor.js +208 -0
- package/dist/adapters/browser/extractor.js.map +1 -0
- package/dist/adapters/browser/filters.d.ts +15 -0
- package/dist/adapters/browser/filters.js +93 -0
- package/dist/adapters/browser/filters.js.map +1 -0
- package/dist/adapters/browser/launch.d.ts +41 -0
- package/dist/adapters/browser/launch.js +61 -0
- package/dist/adapters/browser/launch.js.map +1 -0
- package/dist/adapters/browser/query.d.ts +3 -2
- package/dist/adapters/browser/query.js +68 -2
- package/dist/adapters/browser/query.js.map +1 -1
- package/dist/adapters/budget.d.ts +16 -0
- package/dist/adapters/budget.js +25 -0
- package/dist/adapters/budget.js.map +1 -0
- package/dist/adapters/contract.d.ts +29 -6
- package/dist/adapters/desktop/atspi.d.ts +15 -0
- package/dist/adapters/desktop/atspi.js +37 -17
- package/dist/adapters/desktop/atspi.js.map +1 -1
- package/dist/adapters/desktop/capture.js +8 -1
- package/dist/adapters/desktop/capture.js.map +1 -1
- package/dist/adapters/desktop/desktop-adapter.d.ts +9 -2
- package/dist/adapters/desktop/desktop-adapter.js +84 -32
- package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
- package/dist/adapters/desktop/input.d.ts +16 -1
- package/dist/adapters/desktop/input.js +30 -0
- package/dist/adapters/desktop/input.js.map +1 -1
- package/dist/adapters/desktop/proc.d.ts +18 -3
- package/dist/adapters/desktop/proc.js +48 -5
- package/dist/adapters/desktop/proc.js.map +1 -1
- package/dist/adapters/factory.d.ts +3 -1
- package/dist/adapters/factory.js +6 -2
- package/dist/adapters/factory.js.map +1 -1
- package/dist/adapters/limit.d.ts +10 -0
- package/dist/adapters/limit.js +19 -0
- package/dist/adapters/limit.js.map +1 -0
- package/dist/agent/belt/act.d.ts +27 -5
- package/dist/agent/belt/act.js +75 -17
- package/dist/agent/belt/act.js.map +1 -1
- package/dist/agent/belt/look.d.ts +37 -0
- package/dist/agent/belt/look.js +96 -4
- package/dist/agent/belt/look.js.map +1 -1
- package/dist/agent/belt/observe.d.ts +35 -9
- package/dist/agent/belt/observe.js +127 -18
- package/dist/agent/belt/observe.js.map +1 -1
- package/dist/agent/belt/report.d.ts +29 -9
- package/dist/agent/belt/report.js +77 -10
- package/dist/agent/belt/report.js.map +1 -1
- package/dist/agent/belt/trail.d.ts +34 -0
- package/dist/agent/belt/trail.js +64 -0
- package/dist/agent/belt/trail.js.map +1 -0
- package/dist/agent/capabilities.d.ts +30 -0
- package/dist/agent/capabilities.js +75 -0
- package/dist/agent/capabilities.js.map +1 -0
- package/dist/agent/loop.d.ts +68 -19
- package/dist/agent/loop.js +195 -51
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/prompts/compose.d.ts +9 -1
- package/dist/agent/prompts/compose.js +5 -4
- package/dist/agent/prompts/compose.js.map +1 -1
- package/dist/agent/prompts/debug-agent.d.ts +13 -1
- package/dist/agent/prompts/debug-agent.js +47 -7
- package/dist/agent/prompts/debug-agent.js.map +1 -1
- package/dist/agent/prompts/desktop-addendum.d.ts +1 -1
- package/dist/agent/prompts/desktop-addendum.js +1 -1
- package/dist/agent/prompts/web-addendum.d.ts +1 -1
- package/dist/agent/prompts/web-addendum.js +45 -17
- package/dist/agent/prompts/web-addendum.js.map +1 -1
- package/dist/agent/provider.d.ts +12 -3
- package/dist/agent/provider.js +13 -8
- package/dist/agent/provider.js.map +1 -1
- package/dist/cli/control.d.ts +3 -1
- package/dist/cli/control.js +26 -40
- package/dist/cli/control.js.map +1 -1
- package/dist/cli/help.d.ts +3 -1
- package/dist/cli/help.js +6 -2
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/init.d.ts +3 -6
- package/dist/cli/init.js +64 -16
- package/dist/cli/init.js.map +1 -1
- package/dist/config/load.js +8 -1
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +12 -5
- package/dist/config/schema.js +17 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/errors.d.ts +22 -2
- package/dist/errors.js +36 -4
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/main.js +38 -11
- package/dist/main.js.map +1 -1
- package/dist/mcp/server.d.ts +16 -1
- package/dist/mcp/server.js +23 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/server.test-helpers.d.ts +23 -0
- package/dist/mcp/server.test-helpers.js +49 -0
- package/dist/mcp/server.test-helpers.js.map +1 -0
- package/dist/mcp/tools/describe.js +5 -0
- package/dist/mcp/tools/describe.js.map +1 -1
- package/dist/mcp/tools/end-session.js +5 -0
- package/dist/mcp/tools/end-session.js.map +1 -1
- package/dist/mcp/tools/get-findings.js +23 -3
- package/dist/mcp/tools/get-findings.js.map +1 -1
- package/dist/mcp/tools/output.d.ts +50 -0
- package/dist/mcp/tools/output.js +55 -0
- package/dist/mcp/tools/output.js.map +1 -0
- package/dist/mcp/tools/result.d.ts +24 -1
- package/dist/mcp/tools/result.js +106 -5
- package/dist/mcp/tools/result.js.map +1 -1
- package/dist/mcp/tools/send-message.js +5 -0
- package/dist/mcp/tools/send-message.js.map +1 -1
- package/dist/mcp/tools/start-debug.js +7 -1
- package/dist/mcp/tools/start-debug.js.map +1 -1
- package/dist/services/debug-service.d.ts +38 -6
- package/dist/services/debug-service.js +122 -13
- package/dist/services/debug-service.js.map +1 -1
- package/dist/services/session-builder.d.ts +26 -3
- package/dist/services/session-builder.js +46 -14
- package/dist/services/session-builder.js.map +1 -1
- package/dist/session/atomic-write.d.ts +24 -0
- package/dist/session/atomic-write.js +39 -0
- package/dist/session/atomic-write.js.map +1 -0
- package/dist/session/findings-store.js +3 -4
- package/dist/session/findings-store.js.map +1 -1
- package/dist/session/process-identity.d.ts +16 -0
- package/dist/session/process-identity.js +29 -0
- package/dist/session/process-identity.js.map +1 -1
- package/dist/session/session.js +10 -2
- package/dist/session/session.js.map +1 -1
- package/dist/session/state-file.d.ts +51 -5
- package/dist/session/state-file.js +60 -8
- package/dist/session/state-file.js.map +1 -1
- package/dist/session/workspace.d.ts +11 -0
- package/dist/session/workspace.js +14 -1
- package/dist/session/workspace.js.map +1 -1
- package/package.json +4 -1
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* carry the real logic and are unit-tested without spawning; {@link Xdotool} is
|
|
11
11
|
* the thin runner that shells out and fails loud as an {@link AdapterError}.
|
|
12
12
|
*/
|
|
13
|
-
import type { Bounds, ScrollDirection } from '../contract.js';
|
|
13
|
+
import type { Bounds, Node, ScrollDirection } from '../contract.js';
|
|
14
14
|
import { type Exec } from './proc.js';
|
|
15
15
|
/**
|
|
16
16
|
* Map a contract key/chord (`'Enter'`, `'Control+a'`, `'Escape'`) onto an
|
|
@@ -24,6 +24,21 @@ export declare function centerOf(bounds: Bounds): {
|
|
|
24
24
|
x: number;
|
|
25
25
|
y: number;
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* The on-screen rectangle of a {@link Node}, or a loud failure when it has none.
|
|
29
|
+
*
|
|
30
|
+
* AT-SPI nodes that expose no `Component` (app roots, toolkit fillers) carry
|
|
31
|
+
* placeholder zero bounds (`atspi.ts` marks them `measured: false`), and a real
|
|
32
|
+
* widget reports `0x0` until it is laid out. Either way the "center" is the screen
|
|
33
|
+
* origin — clicking it would hit the top-left of the desktop and read as success.
|
|
34
|
+
* (The android adapter applies the same rule in `tapPointOf`.)
|
|
35
|
+
*/
|
|
36
|
+
export declare function expectOnScreen(node: Node): Bounds;
|
|
37
|
+
/** Where a `click`/`type` lands on a {@link Node} — its center, zero-size guarded. */
|
|
38
|
+
export declare function clickPointOf(node: Node): {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
};
|
|
27
42
|
/** `mousemove --sync x y click <button>` — move then click in one synced invocation. */
|
|
28
43
|
export declare function clickArgs(x: number, y: number, button?: number): string[];
|
|
29
44
|
/** `mousemove --sync x y` — park the cursor (used to scope a scroll to a region). */
|
|
@@ -95,6 +95,29 @@ export function centerOf(bounds) {
|
|
|
95
95
|
y: Math.round(bounds.y + bounds.height / 2),
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* The on-screen rectangle of a {@link Node}, or a loud failure when it has none.
|
|
100
|
+
*
|
|
101
|
+
* AT-SPI nodes that expose no `Component` (app roots, toolkit fillers) carry
|
|
102
|
+
* placeholder zero bounds (`atspi.ts` marks them `measured: false`), and a real
|
|
103
|
+
* widget reports `0x0` until it is laid out. Either way the "center" is the screen
|
|
104
|
+
* origin — clicking it would hit the top-left of the desktop and read as success.
|
|
105
|
+
* (The android adapter applies the same rule in `tapPointOf`.)
|
|
106
|
+
*/
|
|
107
|
+
export function expectOnScreen(node) {
|
|
108
|
+
const { width, height } = node.bounds;
|
|
109
|
+
if (width <= 0 || height <= 0) {
|
|
110
|
+
const label = node.name === '' ? node.role : `${node.role} "${node.name}"`;
|
|
111
|
+
throw new AdapterError(`desktop: ${label} has zero size (${width}x${height}) — it is not on screen ` +
|
|
112
|
+
'(no AT-SPI Component, or not laid out yet); wait for it to render or scroll it ' +
|
|
113
|
+
'into view, then re-read its bounds');
|
|
114
|
+
}
|
|
115
|
+
return node.bounds;
|
|
116
|
+
}
|
|
117
|
+
/** Where a `click`/`type` lands on a {@link Node} — its center, zero-size guarded. */
|
|
118
|
+
export function clickPointOf(node) {
|
|
119
|
+
return centerOf(expectOnScreen(node));
|
|
120
|
+
}
|
|
98
121
|
/** `mousemove --sync x y click <button>` — move then click in one synced invocation. */
|
|
99
122
|
export function clickArgs(x, y, button = 1) {
|
|
100
123
|
return ['mousemove', '--sync', String(x), String(y), 'click', String(button)];
|
|
@@ -157,6 +180,10 @@ export class Xdotool {
|
|
|
157
180
|
// that means "not up yet", so keep polling. Anything on stderr is a real
|
|
158
181
|
// failure (e.g. `Can't open display`) — fatal, loud. Missing xdotool too.
|
|
159
182
|
const out = await this.#exec(XDOTOOL, args).catch((error) => {
|
|
183
|
+
// An expired per-call cap (`proc.ts`) arrives already loud, with no stderr —
|
|
184
|
+
// never mistake a wedged xdotool for "no window yet" and keep polling.
|
|
185
|
+
if (error instanceof AdapterError)
|
|
186
|
+
throw error;
|
|
160
187
|
if (isEnoent(error)) {
|
|
161
188
|
throw new AdapterError('desktop: `xdotool` not found on PATH (install xdotool)');
|
|
162
189
|
}
|
|
@@ -187,6 +214,9 @@ export class Xdotool {
|
|
|
187
214
|
await this.#exec(XDOTOOL, args);
|
|
188
215
|
}
|
|
189
216
|
catch (error) {
|
|
217
|
+
// Already-loud failures (a per-call timeout) surface verbatim, not re-prefixed.
|
|
218
|
+
if (error instanceof AdapterError)
|
|
219
|
+
throw error;
|
|
190
220
|
if (isEnoent(error)) {
|
|
191
221
|
throw new AdapterError('desktop: `xdotool` not found on PATH (install xdotool)');
|
|
192
222
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/adapters/desktop/input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAa,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAElF,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B,sEAAsE;AACtE,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB,iFAAiF;AACjF,MAAM,WAAW,GAA2B;IAC1C,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,OAAO;IACZ,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,uFAAuF;AACvF,MAAM,WAAW,GAA2B;IAC1C,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,QAAQ;IACb,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;IACV,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,QAAQ;IACb,KAAK,EAAE,OAAO;IACd,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,OAAO;IACnB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,MAAM,EAA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AK,CAAC,IAAI,CAAC;iBACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;iBAC1B,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACnC,IAAI,EAAE,EAAE,CAAC;gBACP,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;gBACjD,OAAO;YACT,CAAC;YACD,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,SAAS,EAAE,CAAC;gBACpC,MAAM,IAAI,YAAY,CACpB,oCAAoC,SAAS,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAC7E,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,0FAA0F;IAC1F,KAAK,CAAC,GAAG,CAAC,IAAc;QACtB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,gFAAgF;YAChF,IAAI,KAAK,YAAY,YAAY;gBAAE,MAAM,KAAK,CAAC;YAC/C,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpB,MAAM,IAAI,YAAY,CAAC,wDAAwD,CAAC,CAAC;YACnF,CAAC;YACD,MAAM,IAAI,YAAY,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,YAAY,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;CACF"}
|
|
@@ -9,8 +9,17 @@
|
|
|
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
|
*/
|
|
15
|
+
/**
|
|
16
|
+
* Default per-invocation wall-clock cap. These tools do wedge in practice — `busctl`
|
|
17
|
+
* against an unresponsive AT-SPI peer, `xdotool --sync` waiting on a window that never
|
|
18
|
+
* settles — and an unbounded `execFile` parks the whole operation behind that one call
|
|
19
|
+
* until the outer session timeout. 10 s is far above any healthy input/a11y round-trip;
|
|
20
|
+
* capture passes its own, longer cap (`capture.ts`).
|
|
21
|
+
*/
|
|
22
|
+
export declare const DEFAULT_EXEC_TIMEOUT_MS = 10000;
|
|
14
23
|
/** Run a CLI tool, resolve its stdout, reject (loud) on a non-zero exit or a missing binary. */
|
|
15
24
|
export type Exec = (cmd: string, args: string[]) => Promise<string>;
|
|
16
25
|
/**
|
|
@@ -20,8 +29,14 @@ export type Exec = (cmd: string, args: string[]) => Promise<string>;
|
|
|
20
29
|
* Wayland session ({@link chooseCaptureTool} checks `WAYLAND_DISPLAY` first).
|
|
21
30
|
*/
|
|
22
31
|
export declare function desktopEnv(display?: string): NodeJS.ProcessEnv;
|
|
23
|
-
/**
|
|
24
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The real {@link Exec}: `execFile` bound to a fixed child env and a wall-clock cap
|
|
34
|
+
* (`timeoutMs`, default {@link DEFAULT_EXEC_TIMEOUT_MS}). Expiry kills the child and
|
|
35
|
+
* rejects as an {@link ExecTimeoutError} naming the cap; every other failure passes through
|
|
36
|
+
* **raw** so callers can still triage the real `execFile` error (ENOENT, exit code,
|
|
37
|
+
* stderr) — `xdotool search` exiting non-zero with empty stderr means "no window yet".
|
|
38
|
+
*/
|
|
39
|
+
export declare function makeExec(env: NodeJS.ProcessEnv, timeoutMs?: number): Exec;
|
|
25
40
|
/** True when an error is a "binary not found on PATH" (`ENOENT`) — for a clear, loud message. */
|
|
26
41
|
export declare function isEnoent(error: unknown): boolean;
|
|
27
42
|
/** Compact message extractor for wrapping a thrown subprocess error. */
|
|
@@ -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
|
-
/**
|
|
34
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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
|
|
1
|
+
{"version":3,"file":"proc.js","sourceRoot":"","sources":["../../../src/adapters/desktop/proc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEtC,sFAAsF;AACtF,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,GAAG,SAAS,CAAC;AAK9B;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC/B,IAAI,OAAO,EAAE,CAAC;QACZ,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,OAAO,GAAG,CAAC,eAAe,CAAC;IAC7B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAsB,EAAE,SAAS,GAAG,uBAAuB;IAClF,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACzB,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE;gBAC5C,GAAG;gBACH,SAAS,EAAE,UAAU;gBACrB,OAAO,EAAE,SAAS;gBAClB,UAAU,EAAE,WAAW;aACxB,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;YACzC,MAAM,IAAI,gBAAgB,CACxB,cAAc,GAAG,sBAAsB,SAAS,OAAO,WAAW,6CAA6C,EAC/G,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;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>;
|
package/dist/adapters/factory.js
CHANGED
|
@@ -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
|
|
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;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAkB,EAClB,MAAc,EACd,UAAkB,EAClB,KAAmC,EACnC,SAAkB;IAElB,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAE1C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,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"}
|
package/dist/agent/belt/act.d.ts
CHANGED
|
@@ -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
|
|
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,11 +21,15 @@
|
|
|
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
30
|
import type { Adapter } from '../../adapters/contract.js';
|
|
28
31
|
import type { LogChannel } from '../../session/findings-store.js';
|
|
32
|
+
import type { ActTrail } from './trail.js';
|
|
29
33
|
/** The six action verbs `act` routes to the shared contract. */
|
|
30
34
|
export declare const ACT_ACTIONS: readonly ["click", "type", "key", "scroll", "navigate", "wait"];
|
|
31
35
|
/**
|
|
@@ -69,6 +73,12 @@ export interface ActResult {
|
|
|
69
73
|
action: ActInput['action'];
|
|
70
74
|
/** Target-derived step label, e.g. `click button "Save"`. */
|
|
71
75
|
label: string;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the step worked — always `true` here, since a failed act throws (and
|
|
78
|
+
* reaches the trail as `ok: false`). Told to the driver so it never has to
|
|
79
|
+
* guess whether an act landed.
|
|
80
|
+
*/
|
|
81
|
+
ok: true;
|
|
72
82
|
/** Path to the post-action screenshot saved as evidence. */
|
|
73
83
|
screenshot: string;
|
|
74
84
|
}
|
|
@@ -85,10 +95,22 @@ export interface StepRecorder {
|
|
|
85
95
|
/**
|
|
86
96
|
* Route one `act` call through the {@link Adapter}, then record the step. Pure
|
|
87
97
|
* over the contract + {@link StepRecorder} seams, so it unit-tests against fakes.
|
|
98
|
+
*
|
|
99
|
+
* The step lands on `trail` the moment it finishes — announced through
|
|
100
|
+
* {@link ActTrail.begin} first, so a `report` racing in the SAME step waits for it
|
|
101
|
+
* instead of writing a verdict that never mentions this act. Anything that throws
|
|
102
|
+
* — a missing operand, an unresolved target, a dead adapter, a failed capture — is
|
|
103
|
+
* recorded as an `ok: false` entry and then RETHROWN: the driver still sees the
|
|
104
|
+
* error (and can retry), while the evidence trail keeps the step that did not work
|
|
105
|
+
* instead of silently dropping it.
|
|
106
|
+
*/
|
|
107
|
+
export declare function runAct(adapter: Adapter, recorder: StepRecorder, input: ActInput, trail?: ActTrail): Promise<ActResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Build the `act` tool bound to one adapter + recorder, for the debug agent's belt.
|
|
110
|
+
* `trail` (when wired by the loop) is the run's shared step trail, so every act —
|
|
111
|
+
* the ones that worked and the ones that threw — lands in the persisted findings.
|
|
88
112
|
*/
|
|
89
|
-
export declare function
|
|
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<{
|
|
113
|
+
export declare function createActTool(adapter: Adapter, recorder: StepRecorder, trail?: ActTrail): import("ai").Tool<{
|
|
92
114
|
action: "type" | "key" | "click" | "scroll" | "navigate" | "wait";
|
|
93
115
|
target?: string | undefined;
|
|
94
116
|
text?: string | undefined;
|
package/dist/agent/belt/act.js
CHANGED
|
@@ -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
|
|
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,7 +21,10 @@
|
|
|
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';
|
|
@@ -45,7 +48,7 @@ export const ActInputSchema = z.object({
|
|
|
45
48
|
target: z
|
|
46
49
|
.string()
|
|
47
50
|
.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)'),
|
|
51
|
+
.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)'),
|
|
49
52
|
text: z.string().optional().describe('text to type (action=type)'),
|
|
50
53
|
key: z
|
|
51
54
|
.string()
|
|
@@ -59,7 +62,7 @@ export const ActInputSchema = z.object({
|
|
|
59
62
|
networkIdle: z
|
|
60
63
|
.boolean()
|
|
61
64
|
.optional()
|
|
62
|
-
.describe('wait until in-flight requests settle (action=wait, web)'),
|
|
65
|
+
.describe('wait until in-flight requests settle (action=wait, web); needed if no target'),
|
|
63
66
|
timeout: z
|
|
64
67
|
.number()
|
|
65
68
|
.int()
|
|
@@ -80,14 +83,18 @@ function describeNode(node) {
|
|
|
80
83
|
const name = node.name.trim();
|
|
81
84
|
return name ? `${node.role} ${JSON.stringify(name)}` : node.role;
|
|
82
85
|
}
|
|
83
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Describe what a `wait` is blocking on, for the step label. Never empty — the belt
|
|
88
|
+
* rejects a `wait` with no condition before it gets here.
|
|
89
|
+
*/
|
|
84
90
|
function describeWait(query, networkIdle, timeout) {
|
|
85
|
-
|
|
91
|
+
return [
|
|
86
92
|
query ? JSON.stringify(query) : undefined,
|
|
87
93
|
networkIdle ? 'network idle' : undefined,
|
|
88
94
|
timeout ? `${timeout}ms` : undefined,
|
|
89
|
-
]
|
|
90
|
-
|
|
95
|
+
]
|
|
96
|
+
.filter((part) => part !== undefined)
|
|
97
|
+
.join(' + ');
|
|
91
98
|
}
|
|
92
99
|
/**
|
|
93
100
|
* Require an operand the flat schema can't enforce per-action; fail loud when
|
|
@@ -100,6 +107,19 @@ function required(value, field, action) {
|
|
|
100
107
|
}
|
|
101
108
|
return value;
|
|
102
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Label an act from its INPUT — the fallback for a step that threw before a
|
|
112
|
+
* target-derived label existed. Never echoes `text` (typed secrets stay out of
|
|
113
|
+
* the trail, as they do out of the success label).
|
|
114
|
+
*/
|
|
115
|
+
function describeAttempt(input) {
|
|
116
|
+
const operand = input.action === 'key' ? input.key : input.action === 'scroll' ? input.direction : input.target;
|
|
117
|
+
return operand ? `${input.action} ${operand}` : input.action;
|
|
118
|
+
}
|
|
119
|
+
/** One-line error text for a failed step's `note`. */
|
|
120
|
+
function failureNote(error) {
|
|
121
|
+
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
122
|
+
}
|
|
103
123
|
/** Perform one action against the contract and return its target-derived step label. */
|
|
104
124
|
async function performAct(adapter, input) {
|
|
105
125
|
switch (input.action) {
|
|
@@ -122,6 +142,14 @@ async function performAct(adapter, input) {
|
|
|
122
142
|
return `navigate to ${target}`;
|
|
123
143
|
}
|
|
124
144
|
case 'wait': {
|
|
145
|
+
// Every adapter needs something to block on — a bare `wait` can only throw
|
|
146
|
+
// (`waitFor requires query and/or networkIdle`). Reject it HERE so the driver
|
|
147
|
+
// gets a steering message from its own tool, and the dead step lands on the
|
|
148
|
+
// trail, instead of an adapter error it has to decode. A `timeout` alone is a
|
|
149
|
+
// sleep, which the loop has no use for.
|
|
150
|
+
if (!input.target && input.networkIdle !== true) {
|
|
151
|
+
throw new AgentError("act 'wait' requires 'target' (a selector to wait for) and/or 'networkIdle': true");
|
|
152
|
+
}
|
|
125
153
|
await adapter.waitFor({
|
|
126
154
|
query: input.target,
|
|
127
155
|
networkIdle: input.networkIdle,
|
|
@@ -148,20 +176,50 @@ async function performAct(adapter, input) {
|
|
|
148
176
|
/**
|
|
149
177
|
* Route one `act` call through the {@link Adapter}, then record the step. Pure
|
|
150
178
|
* over the contract + {@link StepRecorder} seams, so it unit-tests against fakes.
|
|
179
|
+
*
|
|
180
|
+
* The step lands on `trail` the moment it finishes — announced through
|
|
181
|
+
* {@link ActTrail.begin} first, so a `report` racing in the SAME step waits for it
|
|
182
|
+
* instead of writing a verdict that never mentions this act. Anything that throws
|
|
183
|
+
* — a missing operand, an unresolved target, a dead adapter, a failed capture — is
|
|
184
|
+
* recorded as an `ok: false` entry and then RETHROWN: the driver still sees the
|
|
185
|
+
* error (and can retry), while the evidence trail keeps the step that did not work
|
|
186
|
+
* instead of silently dropping it.
|
|
151
187
|
*/
|
|
152
|
-
export async function runAct(adapter, recorder, input) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
188
|
+
export async function runAct(adapter, recorder, input, trail) {
|
|
189
|
+
// Enter the gate BEFORE the first await, so a same-step terminal read sees this
|
|
190
|
+
// act in flight rather than an empty trail.
|
|
191
|
+
const settle = trail?.begin();
|
|
192
|
+
// Label the attempt from the input up front: a throw inside `performAct` yields
|
|
193
|
+
// no target-derived label, and an unlabelled failed step is not evidence.
|
|
194
|
+
let label = describeAttempt(input);
|
|
195
|
+
try {
|
|
196
|
+
label = await performAct(adapter, input);
|
|
197
|
+
const png = await adapter.screenshot();
|
|
198
|
+
const screenshot = await recorder.saveScreenshot(label, png);
|
|
199
|
+
await recorder.appendLog('agent', `act ${label} → ${screenshot}`);
|
|
200
|
+
trail?.record({ step: label, ok: true, screenshot });
|
|
201
|
+
return { action: input.action, label, ok: true, screenshot };
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
trail?.record({ step: label, ok: false, note: failureNote(error) });
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
finally {
|
|
208
|
+
// After the record on BOTH paths — a waiter released early would read a trail
|
|
209
|
+
// that is missing the very step it waited for.
|
|
210
|
+
settle?.();
|
|
211
|
+
}
|
|
158
212
|
}
|
|
159
|
-
/**
|
|
160
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Build the `act` tool bound to one adapter + recorder, for the debug agent's belt.
|
|
215
|
+
* `trail` (when wired by the loop) is the run's shared step trail, so every act —
|
|
216
|
+
* the ones that worked and the ones that threw — lands in the persisted findings.
|
|
217
|
+
*/
|
|
218
|
+
export function createActTool(adapter, recorder, trail) {
|
|
161
219
|
return tool({
|
|
162
220
|
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.',
|
|
163
221
|
inputSchema: ActInputSchema,
|
|
164
|
-
execute: (input) => runAct(adapter, recorder, input),
|
|
222
|
+
execute: (input) => runAct(adapter, recorder, input, trail),
|
|
165
223
|
});
|
|
166
224
|
}
|
|
167
225
|
//# sourceMappingURL=act.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"act.js","sourceRoot":"","sources":["../../../src/agent/belt/act.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"act.js","sourceRoot":"","sources":["../../../src/agent/belt/act.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,E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AAE,CAAC,CAAC;QAClE,KAAK,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QACrD,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACpE,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,8EAA8E;QAC9E,+CAA+C;QAC/C,MAAM,EAAE,EAAE,CAAC;IACb,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAAgB,EAAE,QAAsB,EAAE,KAAgB;IACtF,OAAO,IAAI,CAAC;QACV,WAAW,EACT,8RAA8R;QAChS,WAAW,EAAE,cAAc;QAC3B,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC;KAC5D,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -86,12 +86,49 @@ export interface EvidenceRecorder {
|
|
|
86
86
|
* model behaves the same (never relies on a 3rd-party default).
|
|
87
87
|
*/
|
|
88
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.";
|
|
89
|
+
/** Whether a provider error says the vision model rejected image input (text-only model). */
|
|
90
|
+
export declare function isImageRejection(message: string): boolean;
|
|
91
|
+
/** The latched, actionable message the driver gets when the vision model is text-only. */
|
|
92
|
+
export declare function visionUnavailableMessage(modelId: string, providerMessage: string): string;
|
|
89
93
|
/**
|
|
90
94
|
* Capture the frame, ask the vision guy, attach the evidence. Pure over the
|
|
91
95
|
* {@link Adapter}, {@link VisionGenerate} and {@link EvidenceRecorder} seams, so
|
|
92
96
|
* it unit-tests against fakes with no network.
|
|
93
97
|
*/
|
|
94
98
|
export declare function runLook(adapter: Adapter, generate: VisionGenerate, recorder: EvidenceRecorder, input: LookInput, abortSignal?: AbortSignal): Promise<LookResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Build `look`'s execute closure with the vision-unavailable latch: once a call
|
|
101
|
+
* dies on {@link VisionUnavailableError} (text-only vision model), every later
|
|
102
|
+
* call fails fast with the same guidance — no screenshot, no provider round-trip.
|
|
103
|
+
* Exported apart from the `tool()` wrapper so the latch unit-tests against fakes.
|
|
104
|
+
*/
|
|
105
|
+
export declare function createLookExecute(adapter: Adapter, generate: VisionGenerate, recorder: EvidenceRecorder): (input: LookInput, abortSignal?: AbortSignal) => Promise<LookResult>;
|
|
106
|
+
/** Self-look output: the saved evidence plus the frame itself (base64) for the driver's own eyes. */
|
|
107
|
+
export interface SelfLookResult {
|
|
108
|
+
/** Path to the screenshot saved as evidence. */
|
|
109
|
+
screenshot: string;
|
|
110
|
+
/** Raw frame size in bytes (before base64). */
|
|
111
|
+
bytes: number;
|
|
112
|
+
/** The question/expectation echoed back so the driver judges against it. */
|
|
113
|
+
prompt: string;
|
|
114
|
+
/** Base64 PNG of the frame — mapped to a `file-data` part via `toModelOutput`. */
|
|
115
|
+
frame: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Build `look` for a MULTIMODAL driver (self-look): when control + vision are the
|
|
119
|
+
* SAME model, a second blind vision call wastes a round-trip and drops the run's
|
|
120
|
+
* context — instead the tool returns the frame itself as multimodal tool output
|
|
121
|
+
* (`toModelOutput` → `content` with a `file-data` part), so the driver looks at
|
|
122
|
+
* the screenshot with its own eyes, in full conversation context.
|
|
123
|
+
*
|
|
124
|
+
* Older frames are pruned from the transcript by the loop (`pruneStaleFrames`) so
|
|
125
|
+
* repeated looks never stack images in the re-sent history — only the newest frame
|
|
126
|
+
* stays live.
|
|
127
|
+
*/
|
|
128
|
+
export declare function createSelfLookTool(adapter: Adapter, recorder: EvidenceRecorder): import("ai").Tool<{
|
|
129
|
+
question?: string | undefined;
|
|
130
|
+
expect?: string | undefined;
|
|
131
|
+
}, SelfLookResult>;
|
|
95
132
|
/** Build the `look` tool bound to one adapter + vision model + recorder, for the belt. */
|
|
96
133
|
export declare function createLookTool(adapter: Adapter, vision: LanguageModel, recorder: EvidenceRecorder): import("ai").Tool<{
|
|
97
134
|
question?: string | undefined;
|