@developerz.ai/ui-debugger-mcp 1.8.0 → 1.10.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 +70 -52
- package/dist/adapters/android/adb.d.ts +19 -7
- package/dist/adapters/android/adb.js +50 -13
- package/dist/adapters/android/adb.js.map +1 -1
- package/dist/adapters/android/android-adapter.d.ts +42 -2
- package/dist/adapters/android/android-adapter.js +366 -36
- package/dist/adapters/android/android-adapter.js.map +1 -1
- package/dist/adapters/android/commands.js.map +1 -1
- package/dist/adapters/android/ports.js.map +1 -1
- package/dist/adapters/android/sdk.d.ts +65 -0
- package/dist/adapters/android/sdk.js +107 -0
- package/dist/adapters/android/sdk.js.map +1 -0
- package/dist/adapters/android/uiautomator.d.ts +23 -7
- package/dist/adapters/android/uiautomator.js +31 -7
- package/dist/adapters/android/uiautomator.js.map +1 -1
- package/dist/adapters/availability.d.ts +39 -0
- package/dist/adapters/availability.js +62 -0
- package/dist/adapters/availability.js.map +1 -0
- package/dist/adapters/browser/browser-adapter.d.ts +12 -22
- package/dist/adapters/browser/browser-adapter.js +133 -67
- package/dist/adapters/browser/browser-adapter.js.map +1 -1
- package/dist/adapters/browser/cdp.d.ts +15 -7
- package/dist/adapters/browser/cdp.js +25 -3
- package/dist/adapters/browser/cdp.js.map +1 -1
- package/dist/adapters/browser/filters.d.ts +1 -1
- package/dist/adapters/browser/filters.js.map +1 -1
- package/dist/adapters/browser/geometry.js.map +1 -1
- package/dist/adapters/browser/launch.d.ts +14 -5
- package/dist/adapters/browser/launch.js +14 -5
- package/dist/adapters/browser/launch.js.map +1 -1
- package/dist/adapters/browser/lifecycle.d.ts +58 -0
- package/dist/adapters/browser/lifecycle.js +98 -0
- package/dist/adapters/browser/lifecycle.js.map +1 -0
- package/dist/adapters/browser/log-filters.d.ts +2 -2
- package/dist/adapters/browser/log-filters.js.map +1 -1
- package/dist/adapters/browser/log-format.d.ts +14 -23
- package/dist/adapters/browser/log-format.js +16 -55
- package/dist/adapters/browser/log-format.js.map +1 -1
- package/dist/adapters/browser/tab-context.d.ts +30 -0
- package/dist/adapters/browser/tab-context.js +41 -0
- package/dist/adapters/browser/tab-context.js.map +1 -0
- package/dist/adapters/contract.d.ts +111 -5
- package/dist/adapters/contract.js +7 -2
- package/dist/adapters/contract.js.map +1 -1
- package/dist/adapters/desktop/atspi-busctl.d.ts +26 -0
- package/dist/adapters/desktop/atspi-busctl.js +330 -0
- package/dist/adapters/desktop/atspi-busctl.js.map +1 -0
- package/dist/adapters/desktop/atspi-parse.d.ts +39 -0
- package/dist/adapters/desktop/atspi-parse.js +155 -0
- package/dist/adapters/desktop/atspi-parse.js.map +1 -0
- package/dist/adapters/desktop/atspi.d.ts +75 -50
- package/dist/adapters/desktop/atspi.js +64 -285
- package/dist/adapters/desktop/atspi.js.map +1 -1
- package/dist/adapters/desktop/capture.d.ts +11 -20
- package/dist/adapters/desktop/capture.js +68 -37
- package/dist/adapters/desktop/capture.js.map +1 -1
- package/dist/adapters/desktop/desktop-adapter.d.ts +20 -2
- package/dist/adapters/desktop/desktop-adapter.js +91 -9
- package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
- package/dist/adapters/desktop/input.d.ts +18 -4
- package/dist/adapters/desktop/input.js +15 -10
- package/dist/adapters/desktop/input.js.map +1 -1
- package/dist/adapters/desktop/proc.d.ts +32 -4
- package/dist/adapters/desktop/proc.js +33 -6
- package/dist/adapters/desktop/proc.js.map +1 -1
- package/dist/adapters/factory.d.ts +12 -5
- package/dist/adapters/factory.js +29 -3
- package/dist/adapters/factory.js.map +1 -1
- package/dist/adapters/log-format.d.ts +32 -0
- package/dist/adapters/log-format.js +39 -0
- package/dist/adapters/log-format.js.map +1 -0
- package/dist/agent/belt/act.d.ts +440 -21
- package/dist/agent/belt/act.js +43 -6
- package/dist/agent/belt/act.js.map +1 -1
- package/dist/agent/belt/look.d.ts +471 -14
- package/dist/agent/belt/look.js +74 -12
- package/dist/agent/belt/look.js.map +1 -1
- package/dist/agent/belt/observe.d.ts +663 -42
- package/dist/agent/belt/observe.js +76 -12
- package/dist/agent/belt/observe.js.map +1 -1
- package/dist/agent/belt/report.d.ts +754 -48
- package/dist/agent/belt/report.js +121 -38
- package/dist/agent/belt/report.js.map +1 -1
- package/dist/agent/belt/trail.d.ts +44 -16
- package/dist/agent/belt/trail.js +46 -11
- package/dist/agent/belt/trail.js.map +1 -1
- package/dist/agent/capabilities.js.map +1 -1
- package/dist/agent/fallback.d.ts +33 -0
- package/dist/agent/fallback.js +84 -0
- package/dist/agent/fallback.js.map +1 -0
- package/dist/agent/loop.d.ts +54 -52
- package/dist/agent/loop.js +173 -176
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/models.d.ts +10 -6
- package/dist/agent/models.js +15 -9
- package/dist/agent/models.js.map +1 -1
- package/dist/agent/prompts/compose.d.ts +1 -1
- package/dist/agent/prompts/debug-agent.js +45 -8
- package/dist/agent/prompts/debug-agent.js.map +1 -1
- package/dist/agent/prompts/web-addendum.d.ts +1 -1
- package/dist/agent/prompts/web-addendum.js +15 -3
- package/dist/agent/prompts/web-addendum.js.map +1 -1
- package/dist/agent/provider.d.ts +38 -0
- package/dist/agent/provider.js +55 -3
- package/dist/agent/provider.js.map +1 -1
- package/dist/boot.d.ts +64 -0
- package/dist/boot.js +145 -0
- package/dist/boot.js.map +1 -0
- package/dist/cli/chromium-libs.d.ts +262 -0
- package/dist/cli/chromium-libs.js +522 -0
- package/dist/cli/chromium-libs.js.map +1 -0
- package/dist/cli/control.js +51 -9
- package/dist/cli/control.js.map +1 -1
- package/dist/cli/help.js +1 -1
- package/dist/cli/init.d.ts +54 -3
- package/dist/cli/init.js +89 -24
- package/dist/cli/init.js.map +1 -1
- package/dist/config/fingerprint.d.ts +6 -1
- package/dist/config/fingerprint.js +8 -4
- package/dist/config/fingerprint.js.map +1 -1
- package/dist/config/load.d.ts +50 -10
- package/dist/config/load.js +93 -27
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +18 -6
- package/dist/config/schema.js +22 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +18 -0
- package/dist/errors.js.map +1 -1
- package/dist/findings/schema.d.ts +44 -6
- package/dist/findings/schema.js +39 -3
- package/dist/findings/schema.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +4 -76
- package/dist/main.js.map +1 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/describe.d.ts +5 -4
- package/dist/mcp/tools/describe.js +14 -10
- package/dist/mcp/tools/describe.js.map +1 -1
- package/dist/mcp/tools/end-session.d.ts +3 -1
- package/dist/mcp/tools/end-session.js +7 -3
- package/dist/mcp/tools/end-session.js.map +1 -1
- package/dist/mcp/tools/output.d.ts +5 -4
- package/dist/mcp/tools/output.js +10 -2
- package/dist/mcp/tools/output.js.map +1 -1
- package/dist/mcp/tools/result.d.ts +10 -1
- package/dist/mcp/tools/result.js +8 -6
- package/dist/mcp/tools/result.js.map +1 -1
- package/dist/mcp/tools/start-debug.js +7 -5
- package/dist/mcp/tools/start-debug.js.map +1 -1
- package/dist/redact.d.ts +28 -0
- package/dist/redact.js +51 -0
- package/dist/redact.js.map +1 -0
- package/dist/services/catalog.d.ts +28 -0
- package/dist/services/catalog.js +65 -0
- package/dist/services/catalog.js.map +1 -0
- package/dist/services/debug-api.d.ts +172 -0
- package/dist/services/debug-api.js +9 -0
- package/dist/services/debug-api.js.map +1 -0
- package/dist/services/debug-service.d.ts +25 -173
- package/dist/services/debug-service.js +108 -175
- package/dist/services/debug-service.js.map +1 -1
- package/dist/services/login.d.ts +7 -2
- package/dist/services/login.js +210 -10
- package/dist/services/login.js.map +1 -1
- package/dist/services/retained-snapshot.d.ts +36 -0
- package/dist/services/retained-snapshot.js +63 -0
- package/dist/services/retained-snapshot.js.map +1 -0
- package/dist/services/session-builder.d.ts +26 -0
- package/dist/services/session-builder.js +46 -19
- package/dist/services/session-builder.js.map +1 -1
- package/dist/services/start-guards.d.ts +32 -0
- package/dist/services/start-guards.js +50 -0
- package/dist/services/start-guards.js.map +1 -0
- package/dist/services/summarize.d.ts +12 -3
- package/dist/services/summarize.js +13 -5
- package/dist/services/summarize.js.map +1 -1
- package/dist/session/cleanup.js.map +1 -1
- package/dist/session/findings-store.d.ts +2 -1
- package/dist/session/findings-store.js +30 -2
- package/dist/session/findings-store.js.map +1 -1
- package/dist/session/live-pointer.d.ts +19 -0
- package/dist/session/live-pointer.js +41 -0
- package/dist/session/live-pointer.js.map +1 -0
- package/dist/session/manager.d.ts +11 -1
- package/dist/session/manager.js +46 -2
- package/dist/session/manager.js.map +1 -1
- package/dist/session/owner-lock.d.ts +208 -0
- package/dist/session/owner-lock.js +499 -0
- package/dist/session/owner-lock.js.map +1 -0
- package/dist/session/process-identity.js.map +1 -1
- package/dist/session/session.js +61 -7
- package/dist/session/session.js.map +1 -1
- package/dist/session/state-file.d.ts +74 -14
- package/dist/session/state-file.js +203 -21
- package/dist/session/state-file.js.map +1 -1
- package/package.json +7 -7
- package/dist/adapters/android/android-adapter.test-helpers.d.ts +0 -52
- package/dist/adapters/android/android-adapter.test-helpers.js +0 -115
- package/dist/adapters/android/android-adapter.test-helpers.js.map +0 -1
- package/dist/mcp/server.test-helpers.d.ts +0 -23
- package/dist/mcp/server.test-helpers.js +0 -49
- package/dist/mcp/server.test-helpers.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The target catalog behind `describe` — the projection of configured targets
|
|
3
|
+
* onto their public, secret-free shape.
|
|
4
|
+
*
|
|
5
|
+
* Split out of `debug-service.ts` to keep that file under the 500-LOC cap. This
|
|
6
|
+
* half is PURE: no session, no manager, no fs — a target's config in, its
|
|
7
|
+
* public entry out. `managed` vs `attach` is DERIVED from the target itself (a
|
|
8
|
+
* `cdpUrl` / `adbSerial` means "connect to a running one", never start/stop it),
|
|
9
|
+
* `operational` from the host platform, and the persona NAMES are the only half
|
|
10
|
+
* of the auth block that ever leaves the config.
|
|
11
|
+
*/
|
|
12
|
+
import { isAdapterOperational } from '../adapters/availability.js';
|
|
13
|
+
import { TargetNotFoundError } from '../errors.js';
|
|
14
|
+
/** Whether a target is in attach mode (connects to a running instance, never start/stop). */
|
|
15
|
+
export function isAttach(target) {
|
|
16
|
+
if (target.adapter === 'browser')
|
|
17
|
+
return target.cdpUrl != null;
|
|
18
|
+
if (target.adapter === 'android')
|
|
19
|
+
return target.adbSerial != null;
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Project one configured target onto its public {@link TargetInfo} (no secrets).
|
|
24
|
+
*
|
|
25
|
+
* `operational` is DERIVED, never hardcoded: the adapter kind must be wired in
|
|
26
|
+
* this build AND supported on the host platform (see `adapters/availability.ts`).
|
|
27
|
+
*/
|
|
28
|
+
export function describeTarget(name, target, platform) {
|
|
29
|
+
const base = {
|
|
30
|
+
name,
|
|
31
|
+
adapter: target.adapter,
|
|
32
|
+
mode: isAttach(target) ? 'attach' : 'managed',
|
|
33
|
+
operational: isAdapterOperational(target.adapter, platform),
|
|
34
|
+
// What the project declares is EXPECTED of this app — the driver already gets
|
|
35
|
+
// it in its prompt; the caller sees it here so "the table is empty" coming back
|
|
36
|
+
// as a non-finding is explainable without opening the config file.
|
|
37
|
+
...(target.notes !== undefined && { notes: target.notes }),
|
|
38
|
+
};
|
|
39
|
+
if (target.adapter === 'browser') {
|
|
40
|
+
// Persona NAMES are the discoverable half — a caller can pick a valid `as`
|
|
41
|
+
// without opening the config file, and never sees the values.
|
|
42
|
+
const personas = Object.keys(target.auth ?? {});
|
|
43
|
+
return {
|
|
44
|
+
...base,
|
|
45
|
+
url: target.url,
|
|
46
|
+
headless: target.headless,
|
|
47
|
+
...(personas.length > 0 && { personas }),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return base;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The catalog `describe` reports — every configured target, or just the one
|
|
54
|
+
* named. An unknown name fails loud: a silently empty list would read as "this
|
|
55
|
+
* project has no targets" and send the caller looking for the wrong bug.
|
|
56
|
+
*/
|
|
57
|
+
export function selectTargets(targets, named, platform) {
|
|
58
|
+
const entries = Object.entries(targets);
|
|
59
|
+
const selected = named === undefined ? entries : entries.filter(([name]) => name === named);
|
|
60
|
+
if (named !== undefined && selected.length === 0) {
|
|
61
|
+
throw new TargetNotFoundError(`target '${named}' not found in config.targets`);
|
|
62
|
+
}
|
|
63
|
+
return selected.map(([name, config]) => describeTarget(name, config, platform));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/services/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,6FAA6F;AAC7F,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC;IAC/D,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC;IAClE,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,MAAc,EACd,QAAyB;IAEzB,MAAM,IAAI,GAAe;QACvB,IAAI;QACJ,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;QAC7C,WAAW,EAAE,oBAAoB,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC;QAC3D,8EAA8E;QAC9E,gFAAgF;QAChF,mEAAmE;QACnE,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;KAC3D,CAAC;IACF,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,2EAA2E;QAC3E,8DAA8D;QAC9D,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAChD,OAAO;YACL,GAAG,IAAI;YACP,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC;SACzC,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,OAA+B,EAC/B,KAAyB,EACzB,QAAyB;IAEzB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC;IAC5F,IAAI,KAAK,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,mBAAmB,CAAC,WAAW,KAAK,+BAA+B,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The debug service's public contract — the types the outer MCP tools speak.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `debug-service.ts` to keep that file under the 500-LOC cap: this
|
|
5
|
+
* is a dozen TYPE declarations with no runtime behaviour of their own. The
|
|
6
|
+
* service re-exports every name it exports today, so no importer changes.
|
|
7
|
+
*/
|
|
8
|
+
import type { ResolvedConfig } from '../config/load.js';
|
|
9
|
+
import type { Target } from '../config/schema.js';
|
|
10
|
+
import type { Findings } from '../findings/schema.js';
|
|
11
|
+
import type { SessionManager } from '../session/manager.js';
|
|
12
|
+
import type { Session, SessionStatus, SnapshotField } from '../session/session.js';
|
|
13
|
+
import type { StatePort } from '../session/state-file.js';
|
|
14
|
+
import type { SessionBuilder } from './session-builder.js';
|
|
15
|
+
/** `start_debug` input — open a run for a configured target. */
|
|
16
|
+
export interface StartInput {
|
|
17
|
+
target: string;
|
|
18
|
+
goal: string;
|
|
19
|
+
criteria?: string;
|
|
20
|
+
/** Per-run URL the caller points the driver at (web); overrides the target's configured url. */
|
|
21
|
+
url?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Named auth persona to open the run as — a key in the target's `auth` map. The
|
|
24
|
+
* run signs in out-of-band before the driver's first step; an unknown key fails
|
|
25
|
+
* loud rather than running the goal signed out.
|
|
26
|
+
*/
|
|
27
|
+
as?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Take the project over instead of being refused when a run is already active
|
|
30
|
+
* here: end that run first (through the `end_session` path), then start.
|
|
31
|
+
*
|
|
32
|
+
* OFF by default, and it must stay off by default — a silent takeover kills a
|
|
33
|
+
* healthy run its own caller is still watching. Opt in when the active run is
|
|
34
|
+
* yours and you lost its id (a compacted context, a crashed client) or it is
|
|
35
|
+
* stuck. Only ever replaces a run THIS server owns; one held by another live
|
|
36
|
+
* server is still refused ({@link SessionBusyError}), since its browser is not
|
|
37
|
+
* ours to close.
|
|
38
|
+
*/
|
|
39
|
+
replace?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Wall-clock cap (ms) before the run auto-ends, counted from THIS call — assembly,
|
|
42
|
+
* launch and the first navigation spend it too. Defaults to
|
|
43
|
+
* {@link DEFAULT_SESSION_TIMEOUT_MS}.
|
|
44
|
+
*/
|
|
45
|
+
timeoutMs?: number;
|
|
46
|
+
}
|
|
47
|
+
/** `start_debug` output — the id to poll/redirect/end the run by. */
|
|
48
|
+
export interface StartResult {
|
|
49
|
+
session_id: string;
|
|
50
|
+
}
|
|
51
|
+
/** `send_message` input — inject a mid-run instruction. */
|
|
52
|
+
export interface SendInput {
|
|
53
|
+
session_id: string;
|
|
54
|
+
message: string;
|
|
55
|
+
}
|
|
56
|
+
/** `send_message` / `end_session` acknowledgement. */
|
|
57
|
+
export interface Ack {
|
|
58
|
+
ok: true;
|
|
59
|
+
session_id: string;
|
|
60
|
+
}
|
|
61
|
+
/** `get_findings` input — snapshot (optionally long-poll / project a subset). */
|
|
62
|
+
export interface GetFindingsInput {
|
|
63
|
+
session_id: string;
|
|
64
|
+
wait?: number;
|
|
65
|
+
fields?: SnapshotField[];
|
|
66
|
+
}
|
|
67
|
+
/** `describe` input — the whole catalog, or one target when named. */
|
|
68
|
+
export interface DescribeInput {
|
|
69
|
+
target?: string;
|
|
70
|
+
}
|
|
71
|
+
/** One target's public shape in the catalog (secrets stay out). */
|
|
72
|
+
export interface TargetInfo {
|
|
73
|
+
name: string;
|
|
74
|
+
adapter: Target['adapter'];
|
|
75
|
+
/** `managed` = the server launches/owns it; `attach` = it connects to a running one. */
|
|
76
|
+
mode: 'managed' | 'attach';
|
|
77
|
+
/**
|
|
78
|
+
* Whether this adapter kind is available HERE: wired in this build AND
|
|
79
|
+
* supported on the host platform. It is NOT a launch promise — the target may
|
|
80
|
+
* be down, or its browser/emulator/device missing or disconnected; that fails
|
|
81
|
+
* loud at launch.
|
|
82
|
+
*/
|
|
83
|
+
operational: boolean;
|
|
84
|
+
/** Web target entry url, when applicable. */
|
|
85
|
+
url?: string;
|
|
86
|
+
/** Web headless flag, when applicable. */
|
|
87
|
+
headless?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Named auth personas configured for this target — the valid `start_debug({as})`
|
|
90
|
+
* values. NAMES ONLY; the credentials never leave `.ui-debugger-mcp.json`.
|
|
91
|
+
* Absent when the target has no `auth` block.
|
|
92
|
+
*/
|
|
93
|
+
personas?: string[];
|
|
94
|
+
/**
|
|
95
|
+
* The target's standing `notes` — what is EXPECTED of this app (seeded data,
|
|
96
|
+
* onboarding modals, dark mode), verbatim from config. Also composed into the
|
|
97
|
+
* driver's prompt; surfaced here so a caller can see what the run was told.
|
|
98
|
+
*/
|
|
99
|
+
notes?: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The run this server holds for the project, as `describe` reports it — the way
|
|
103
|
+
* back in-band for a caller that lost its `session_id` (a compacted context, a
|
|
104
|
+
* client restart). Without it the only recovery was the out-of-band CLI.
|
|
105
|
+
*/
|
|
106
|
+
export interface RunInfo {
|
|
107
|
+
/** Pass to `get_findings` / `send_message` / `end_session`. */
|
|
108
|
+
id: string;
|
|
109
|
+
/** `running`, or the verdict it settled on (still readable, still holding the slot). */
|
|
110
|
+
status: SessionStatus;
|
|
111
|
+
/** The goal this run was started with — enough to tell whose run it is. */
|
|
112
|
+
goal: string;
|
|
113
|
+
}
|
|
114
|
+
/** `describe` output — configured targets plus the resolved models + workspace. */
|
|
115
|
+
export interface DescribeResult {
|
|
116
|
+
targets: TargetInfo[];
|
|
117
|
+
models: {
|
|
118
|
+
driver: string;
|
|
119
|
+
vision: string;
|
|
120
|
+
summary: string;
|
|
121
|
+
};
|
|
122
|
+
/** Resolved per-project workspace root (`<base>/<project>`) — where evidence lands. */
|
|
123
|
+
workspace: string;
|
|
124
|
+
/**
|
|
125
|
+
* The active run for this project (or the retained snapshot of the last one that
|
|
126
|
+
* auto-ended). Absent when this server holds no run. A run another live server
|
|
127
|
+
* owns is NOT reported here — `start_debug` names that one in its refusal.
|
|
128
|
+
*/
|
|
129
|
+
session?: RunInfo;
|
|
130
|
+
}
|
|
131
|
+
/** The surface the outer MCP tools call. Implemented by {@link DebugService}. */
|
|
132
|
+
export interface DebugApi {
|
|
133
|
+
start(input: StartInput): Promise<StartResult>;
|
|
134
|
+
send(input: SendInput): Ack;
|
|
135
|
+
getFindings(input: GetFindingsInput): Promise<Findings | Partial<Findings>>;
|
|
136
|
+
describe(input: DescribeInput): DescribeResult;
|
|
137
|
+
end(input: EndInput): Promise<Ack>;
|
|
138
|
+
}
|
|
139
|
+
/** `end_session` input. */
|
|
140
|
+
export interface EndInput {
|
|
141
|
+
session_id: string;
|
|
142
|
+
}
|
|
143
|
+
/** Everything the service needs, wired at boot. */
|
|
144
|
+
export interface DebugServiceDeps {
|
|
145
|
+
/** The cwd-keyed registry (one run per project). */
|
|
146
|
+
manager: SessionManager<Session>;
|
|
147
|
+
/** Resolved project config — backs `describe` + target validation. */
|
|
148
|
+
config: ResolvedConfig;
|
|
149
|
+
/** This project's session key (one project = one cwd = one session). */
|
|
150
|
+
cwd: string;
|
|
151
|
+
/** Seam to the heavy session assembly; injected so `start` stays testable. */
|
|
152
|
+
build: SessionBuilder;
|
|
153
|
+
/** Cross-process run breadcrumb (`state.json`) for the CLI; defaults to a no-op. */
|
|
154
|
+
state?: StatePort;
|
|
155
|
+
/** Default wall-clock cap (ms) for a run; defaults to {@link DEFAULT_SESSION_TIMEOUT_MS}. */
|
|
156
|
+
defaultTimeoutMs?: number;
|
|
157
|
+
/** Injected clock (epoch ms) for session ids + the run deadline; defaults to `Date.now`. */
|
|
158
|
+
now?: () => number;
|
|
159
|
+
/**
|
|
160
|
+
* The host platform the adapter-availability rule is evaluated against;
|
|
161
|
+
* defaults to `process.platform`. Injected so `describe` reports the same
|
|
162
|
+
* fact on every host (the tests pin it).
|
|
163
|
+
*/
|
|
164
|
+
platform?: NodeJS.Platform;
|
|
165
|
+
/**
|
|
166
|
+
* Has `.ui-debugger-mcp.json` changed since boot? Config is resolved once and
|
|
167
|
+
* wired into long-lived objects, so a changed file means every later run would
|
|
168
|
+
* silently use the OLD settings — see `config/fingerprint.ts`. Defaults to
|
|
169
|
+
* "never changed" (unit tests hold no file).
|
|
170
|
+
*/
|
|
171
|
+
configChanged?: () => boolean;
|
|
172
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The debug service's public contract — the types the outer MCP tools speak.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `debug-service.ts` to keep that file under the 500-LOC cap: this
|
|
5
|
+
* is a dozen TYPE declarations with no runtime behaviour of their own. The
|
|
6
|
+
* service re-exports every name it exports today, so no importer changes.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=debug-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-api.js","sourceRoot":"","sources":["../../src/services/debug-api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -5,13 +5,16 @@
|
|
|
5
5
|
* mid-flight, poll its findings, list targets, end it. Holds the cwd-keyed
|
|
6
6
|
* {@link SessionManager} (the one-run-per-project gate) and the resolved config,
|
|
7
7
|
* and delegates the heavy session assembly to an injected {@link SessionBuilder}
|
|
8
|
-
* seam — so the orchestration here unit-tests with no browser or network.
|
|
9
|
-
* handlers stay thin: validate input, call straight through to a method here.
|
|
8
|
+
* seam — so the orchestration here unit-tests with no browser or network.
|
|
10
9
|
*
|
|
11
10
|
* One run per project holds *across processes* too: the manager only knows this
|
|
12
11
|
* server's memory, so `start` also consults the `state.json` breadcrumb and
|
|
13
12
|
* refuses when another live server already owns a run here (a dead owner's stale
|
|
14
|
-
* breadcrumb never blocks).
|
|
13
|
+
* breadcrumb never blocks). That read is the FRIENDLY early refusal; the
|
|
14
|
+
* AUTHORITY is the workspace's exclusive ownership claim, taken atomically by
|
|
15
|
+
* {@link FileStatePort.record} — two servers starting in the same window both
|
|
16
|
+
* read "no foreign run", and only the claim admits one of them
|
|
17
|
+
* ({@link SessionBusyError}, before a browser is launched).
|
|
15
18
|
*
|
|
16
19
|
* Sessions are keyed by cwd, but the tools speak `session_id`. Every id-bearing
|
|
17
20
|
* call resolves the active session for the cwd and fails loud
|
|
@@ -22,165 +25,18 @@
|
|
|
22
25
|
* MCP client dying) leaves the manager, but its findings must not vanish with it:
|
|
23
26
|
* the settled session is retained so `get_findings` keeps serving its terminal
|
|
24
27
|
* snapshot. `end_session` is the explicit forget; the next `start_debug`
|
|
25
|
-
* supersedes it. The
|
|
26
|
-
*
|
|
28
|
+
* supersedes it. The snapshot holds no target resources and never gates a start.
|
|
29
|
+
*
|
|
30
|
+
* The pieces around this orchestration live in their own modules: the contract
|
|
31
|
+
* types in `debug-api.ts` (re-exported here, so no importer changes), the catalog
|
|
32
|
+
* projection in `catalog.ts`, the retained snapshot in `retained-snapshot.ts`
|
|
33
|
+
* and the start-time refusals in `start-guards.ts`.
|
|
27
34
|
*/
|
|
28
|
-
import { type ResolvedConfig } from '../config/load.js';
|
|
29
|
-
import type { Target } from '../config/schema.js';
|
|
30
35
|
import { type Findings } from '../findings/schema.js';
|
|
31
|
-
import type {
|
|
32
|
-
|
|
33
|
-
import { type StatePort } from '../session/state-file.js';
|
|
34
|
-
import type { SessionBuilder } from './session-builder.js';
|
|
36
|
+
import type { Ack, DebugApi, DebugServiceDeps, DescribeInput, DescribeResult, EndInput, GetFindingsInput, SendInput, StartInput, StartResult } from './debug-api.js';
|
|
37
|
+
export type { Ack, DebugApi, DebugServiceDeps, DescribeInput, DescribeResult, EndInput, GetFindingsInput, RunInfo, SendInput, StartInput, StartResult, TargetInfo, } from './debug-api.js';
|
|
35
38
|
/** Default wall-clock cap on a debug run before it auto-ends (overridable per run). */
|
|
36
39
|
export declare const DEFAULT_SESSION_TIMEOUT_MS = 300000;
|
|
37
|
-
/** `start_debug` input — open a run for a configured target. */
|
|
38
|
-
export interface StartInput {
|
|
39
|
-
target: string;
|
|
40
|
-
goal: string;
|
|
41
|
-
criteria?: string;
|
|
42
|
-
/** Per-run URL the caller points the driver at (web); overrides the target's configured url. */
|
|
43
|
-
url?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Named auth persona to open the run as — a key in the target's `auth` map. The
|
|
46
|
-
* run signs in out-of-band before the driver's first step; an unknown key fails
|
|
47
|
-
* loud rather than running the goal signed out.
|
|
48
|
-
*/
|
|
49
|
-
as?: string;
|
|
50
|
-
/**
|
|
51
|
-
* Take the project over instead of being refused when a run is already active
|
|
52
|
-
* here: end that run first (through the `end_session` path), then start.
|
|
53
|
-
*
|
|
54
|
-
* OFF by default, and it must stay off by default — a silent takeover kills a
|
|
55
|
-
* healthy run its own caller is still watching. Opt in when the active run is
|
|
56
|
-
* yours and you lost its id (a compacted context, a crashed client) or it is
|
|
57
|
-
* stuck. Only ever replaces a run THIS server owns; one held by another live
|
|
58
|
-
* server is still refused ({@link SessionBusyError}), since its browser is not
|
|
59
|
-
* ours to close.
|
|
60
|
-
*/
|
|
61
|
-
replace?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Wall-clock cap (ms) before the run auto-ends, counted from THIS call — assembly,
|
|
64
|
-
* launch and the first navigation spend it too. Defaults to
|
|
65
|
-
* {@link DEFAULT_SESSION_TIMEOUT_MS}.
|
|
66
|
-
*/
|
|
67
|
-
timeoutMs?: number;
|
|
68
|
-
}
|
|
69
|
-
/** `start_debug` output — the id to poll/redirect/end the run by. */
|
|
70
|
-
export interface StartResult {
|
|
71
|
-
session_id: string;
|
|
72
|
-
}
|
|
73
|
-
/** `send_message` input — inject a mid-run instruction. */
|
|
74
|
-
export interface SendInput {
|
|
75
|
-
session_id: string;
|
|
76
|
-
message: string;
|
|
77
|
-
}
|
|
78
|
-
/** `send_message` / `end_session` acknowledgement. */
|
|
79
|
-
export interface Ack {
|
|
80
|
-
ok: true;
|
|
81
|
-
session_id: string;
|
|
82
|
-
}
|
|
83
|
-
/** `get_findings` input — snapshot (optionally long-poll / project a subset). */
|
|
84
|
-
export interface GetFindingsInput {
|
|
85
|
-
session_id: string;
|
|
86
|
-
wait?: number;
|
|
87
|
-
fields?: SnapshotField[];
|
|
88
|
-
}
|
|
89
|
-
/** `describe` input — the whole catalog, or one target when named. */
|
|
90
|
-
export interface DescribeInput {
|
|
91
|
-
target?: string;
|
|
92
|
-
}
|
|
93
|
-
/** One target's public shape in the catalog (secrets stay out). */
|
|
94
|
-
export interface TargetInfo {
|
|
95
|
-
name: string;
|
|
96
|
-
adapter: Target['adapter'];
|
|
97
|
-
/** `managed` = the server launches/owns it; `attach` = it connects to a running one. */
|
|
98
|
-
mode: 'managed' | 'attach';
|
|
99
|
-
/** Whether this adapter is wired. All three (browser/desktop/android) are shipped. */
|
|
100
|
-
operational: boolean;
|
|
101
|
-
/** Web target entry url, when applicable. */
|
|
102
|
-
url?: string;
|
|
103
|
-
/** Web headless flag, when applicable. */
|
|
104
|
-
headless?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Named auth personas configured for this target — the valid `start_debug({as})`
|
|
107
|
-
* values. NAMES ONLY; the credentials never leave `.ui-debugger-mcp.json`.
|
|
108
|
-
* Absent when the target has no `auth` block.
|
|
109
|
-
*/
|
|
110
|
-
personas?: string[];
|
|
111
|
-
/**
|
|
112
|
-
* The target's standing `notes` — what is EXPECTED of this app (seeded data,
|
|
113
|
-
* onboarding modals, dark mode), verbatim from config. Also composed into the
|
|
114
|
-
* driver's prompt; surfaced here so a caller can see what the run was told.
|
|
115
|
-
*/
|
|
116
|
-
notes?: string;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* The run this server holds for the project, as `describe` reports it — the way
|
|
120
|
-
* back in-band for a caller that lost its `session_id` (a compacted context, a
|
|
121
|
-
* client restart). Without it the only recovery was the out-of-band CLI.
|
|
122
|
-
*/
|
|
123
|
-
export interface RunInfo {
|
|
124
|
-
/** Pass to `get_findings` / `send_message` / `end_session`. */
|
|
125
|
-
id: string;
|
|
126
|
-
/** `running`, or the verdict it settled on (still readable, still holding the slot). */
|
|
127
|
-
status: SessionStatus;
|
|
128
|
-
/** The goal this run was started with — enough to tell whose run it is. */
|
|
129
|
-
goal: string;
|
|
130
|
-
}
|
|
131
|
-
/** `describe` output — configured targets plus the resolved models + workspace. */
|
|
132
|
-
export interface DescribeResult {
|
|
133
|
-
targets: TargetInfo[];
|
|
134
|
-
models: {
|
|
135
|
-
driver: string;
|
|
136
|
-
vision: string;
|
|
137
|
-
summary: string;
|
|
138
|
-
};
|
|
139
|
-
/** Resolved per-project workspace root (`<base>/<project>`) — where evidence lands. */
|
|
140
|
-
workspace: string;
|
|
141
|
-
/**
|
|
142
|
-
* The active run for this project (or the retained snapshot of the last one that
|
|
143
|
-
* auto-ended). Absent when this server holds no run. A run another live server
|
|
144
|
-
* owns is NOT reported here — `start_debug` names that one in its refusal.
|
|
145
|
-
*/
|
|
146
|
-
session?: RunInfo;
|
|
147
|
-
}
|
|
148
|
-
/** The surface the outer MCP tools call. Implemented by {@link DebugService}. */
|
|
149
|
-
export interface DebugApi {
|
|
150
|
-
start(input: StartInput): Promise<StartResult>;
|
|
151
|
-
send(input: SendInput): Ack;
|
|
152
|
-
getFindings(input: GetFindingsInput): Promise<Findings | Partial<Findings>>;
|
|
153
|
-
describe(input: DescribeInput): DescribeResult;
|
|
154
|
-
end(input: EndInput): Promise<Ack>;
|
|
155
|
-
}
|
|
156
|
-
/** `end_session` input. */
|
|
157
|
-
export interface EndInput {
|
|
158
|
-
session_id: string;
|
|
159
|
-
}
|
|
160
|
-
/** Everything the service needs, wired at boot. */
|
|
161
|
-
export interface DebugServiceDeps {
|
|
162
|
-
/** The cwd-keyed registry (one run per project). */
|
|
163
|
-
manager: SessionManager<Session>;
|
|
164
|
-
/** Resolved project config — backs `describe` + target validation. */
|
|
165
|
-
config: ResolvedConfig;
|
|
166
|
-
/** This project's session key (one project = one cwd = one session). */
|
|
167
|
-
cwd: string;
|
|
168
|
-
/** Seam to the heavy session assembly; injected so `start` stays testable. */
|
|
169
|
-
build: SessionBuilder;
|
|
170
|
-
/** Cross-process run breadcrumb (`state.json`) for the CLI; defaults to a no-op. */
|
|
171
|
-
state?: StatePort;
|
|
172
|
-
/** Default wall-clock cap (ms) for a run; defaults to {@link DEFAULT_SESSION_TIMEOUT_MS}. */
|
|
173
|
-
defaultTimeoutMs?: number;
|
|
174
|
-
/** Injected clock (epoch ms) for session ids + the run deadline; defaults to `Date.now`. */
|
|
175
|
-
now?: () => number;
|
|
176
|
-
/**
|
|
177
|
-
* Has `.ui-debugger-mcp.json` changed since boot? Config is resolved once and
|
|
178
|
-
* wired into long-lived objects, so a changed file means every later run would
|
|
179
|
-
* silently use the OLD settings — see `config/fingerprint.ts`. Defaults to
|
|
180
|
-
* "never changed" (unit tests hold no file).
|
|
181
|
-
*/
|
|
182
|
-
configChanged?: () => boolean;
|
|
183
|
-
}
|
|
184
40
|
export declare class DebugService implements DebugApi {
|
|
185
41
|
#private;
|
|
186
42
|
constructor(deps: DebugServiceDeps);
|
|
@@ -189,46 +45,42 @@ export declare class DebugService implements DebugApi {
|
|
|
189
45
|
* the target, and kick the loop off in the background. Fails loud if a run is
|
|
190
46
|
* already active for this cwd ({@link SessionBusyError}) — whether it belongs to
|
|
191
47
|
* this server (the manager / in-flight guard) or to another live one (the
|
|
192
|
-
* `state.json` breadcrumb
|
|
193
|
-
* a failed `open` tears
|
|
48
|
+
* `state.json` breadcrumb read, and then the workspace's ownership claim);
|
|
49
|
+
* never leaks a launched browser — a lost lock race or a failed `open` tears
|
|
50
|
+
* the session back down.
|
|
194
51
|
*
|
|
195
52
|
* `timeout` is wall-clock from HERE: the deadline is fixed on entry and the
|
|
196
53
|
* remaining budget is threaded into the build and the first navigation, so a slow
|
|
197
54
|
* Chrome launch spends the caller's cap instead of sitting outside it.
|
|
198
55
|
*
|
|
199
|
-
* The refusal is the default
|
|
200
|
-
*
|
|
201
|
-
* the
|
|
202
|
-
* replace it, and `describe` reports that id at any time — so a lost session id
|
|
203
|
-
* is a detour, not the dead end that used to need the out-of-band CLI.
|
|
56
|
+
* The refusal is the default; `replace: true` is the caller's explicit takeover.
|
|
57
|
+
* Either way the caller has a way forward: the refusal names the active id and
|
|
58
|
+
* the calls that read, close or replace it, and `describe` reports that id.
|
|
204
59
|
*/
|
|
205
60
|
start(input: StartInput): Promise<StartResult>;
|
|
206
61
|
/**
|
|
207
62
|
* Queue a mid-run instruction for the active run's driver. Fails loud
|
|
208
63
|
* ({@link SessionSettledError}) once the run has settled — the loop no longer
|
|
209
|
-
* drains the inbox, so an ack then would
|
|
64
|
+
* drains the inbox, so an ack then would drop the message.
|
|
210
65
|
*/
|
|
211
66
|
send({ session_id, message }: SendInput): Ack;
|
|
212
67
|
/**
|
|
213
68
|
* Snapshot the run's findings — optionally long-poll (`wait`) and/or project a
|
|
214
69
|
* subset (`fields`). Serves the retained terminal snapshot once the run has
|
|
215
|
-
* auto-ended, so a timed-out run's
|
|
216
|
-
* long-poll returns at once: a settled run has nothing left to wait for).
|
|
70
|
+
* auto-ended, so a timed-out run's findings stay reachable.
|
|
217
71
|
*/
|
|
218
72
|
getFindings({ session_id, wait, fields, }: GetFindingsInput): Promise<Findings | Partial<Findings>>;
|
|
219
73
|
/** List configured targets (the whole catalog, or one when named) plus resolved models/workspace. */
|
|
220
74
|
describe({ target }: DescribeInput): DescribeResult;
|
|
221
75
|
/**
|
|
222
76
|
* End the active run: abort the loop, close the adapter, free the profile lock.
|
|
223
|
-
* Ending a run that already auto-ended
|
|
224
|
-
*
|
|
225
|
-
* either way and stays the one explicit forget.
|
|
77
|
+
* Ending a run that already auto-ended is not an error — it just forgets the
|
|
78
|
+
* retained snapshot, so `end_session` stays the one explicit forget.
|
|
226
79
|
*/
|
|
227
80
|
end({ session_id }: EndInput): Promise<Ack>;
|
|
228
81
|
/**
|
|
229
82
|
* End whatever run is active for this cwd, if any — the graceful-shutdown path
|
|
230
|
-
* for a SIGTERM/SIGINT, a CLI `stop`, or the wall-clock timeout firing.
|
|
231
|
-
* when nothing is running.
|
|
83
|
+
* for a SIGTERM/SIGINT, a CLI `stop`, or the wall-clock timeout firing.
|
|
232
84
|
*/
|
|
233
85
|
endActive(): Promise<void>;
|
|
234
86
|
}
|