@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.
- package/README.md +45 -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 +16 -13
- package/dist/adapters/browser/browser-adapter.js +196 -313
- package/dist/adapters/browser/browser-adapter.js.map +1 -1
- package/dist/adapters/browser/cdp.d.ts +40 -2
- package/dist/adapters/browser/cdp.js +223 -19
- package/dist/adapters/browser/cdp.js.map +1 -1
- package/dist/adapters/browser/extractor.d.ts +53 -0
- package/dist/adapters/browser/extractor.js +224 -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/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 +82 -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 +44 -9
- package/dist/agent/belt/act.js +176 -21
- package/dist/agent/belt/act.js.map +1 -1
- package/dist/agent/belt/look.d.ts +1 -1
- package/dist/agent/belt/look.js +31 -2
- package/dist/agent/belt/look.js.map +1 -1
- package/dist/agent/belt/observe.d.ts +42 -16
- package/dist/agent/belt/observe.js +134 -22
- 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 +4 -4
- package/dist/agent/capabilities.js +41 -13
- package/dist/agent/capabilities.js.map +1 -1
- package/dist/agent/loop.d.ts +70 -21
- package/dist/agent/loop.js +146 -48
- 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 +98 -14
- 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 +84 -16
- package/dist/agent/prompts/web-addendum.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/fingerprint.d.ts +32 -0
- package/dist/config/fingerprint.js +47 -0
- package/dist/config/fingerprint.js.map +1 -0
- package/dist/config/load.d.ts +7 -1
- package/dist/config/load.js +17 -4
- 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 +14 -2
- package/dist/errors.js +24 -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 +26 -8
- 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 +47 -8
- package/dist/services/debug-service.js +185 -14
- package/dist/services/debug-service.js.map +1 -1
- package/dist/services/session-builder.d.ts +20 -3
- package/dist/services/session-builder.js +43 -13
- package/dist/services/session-builder.js.map +1 -1
- package/dist/services/summarize.d.ts +1 -1
- package/dist/services/summarize.js +8 -1
- package/dist/services/summarize.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 +36 -4
- package/dist/session/session.js.map +1 -1
- package/dist/session/state-file.d.ts +64 -5
- package/dist/session/state-file.js +76 -9
- 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
|
@@ -11,6 +11,14 @@ import { FindingsSchema } from '../../findings/schema.js';
|
|
|
11
11
|
import { toToolResult } from './result.js';
|
|
12
12
|
/** Selectable top-level findings keys, derived from the findings schema. */
|
|
13
13
|
const FindingsField = FindingsSchema.keyof();
|
|
14
|
+
/**
|
|
15
|
+
* Declared output: the findings object with every key optional.
|
|
16
|
+
*
|
|
17
|
+
* A `fields` projection returns only the requested keys, so no key can be
|
|
18
|
+
* promised — an all-required schema would make every sparse read fail output
|
|
19
|
+
* validation. Types stay exact per key; only presence is loose.
|
|
20
|
+
*/
|
|
21
|
+
const FindingsOutputSchema = FindingsSchema.partial();
|
|
14
22
|
/** Build the `get_findings` outer tool bound to the debug service. */
|
|
15
23
|
export function getFindingsTool(service) {
|
|
16
24
|
return {
|
|
@@ -20,7 +28,12 @@ export function getFindingsTool(service) {
|
|
|
20
28
|
title: 'Get run findings',
|
|
21
29
|
description: 'Poll the run: status (running|passed|failed) plus structured findings — the step trail, ' +
|
|
22
30
|
'functional bugs, visual/UX feedback, summary, and evidence paths (screenshots, logs). ' +
|
|
23
|
-
'Pass wait (ms) to long-poll until the run settles; pass fields to return only some keys.'
|
|
31
|
+
'Pass wait (ms) to long-poll until the run settles; pass fields to return only some keys. ' +
|
|
32
|
+
'A run that auto-ended (wall-clock timeout or client disconnect) stays readable under its ' +
|
|
33
|
+
'id until end_session or the next start_debug.',
|
|
34
|
+
annotations: {
|
|
35
|
+
readOnlyHint: true,
|
|
36
|
+
},
|
|
24
37
|
inputSchema: {
|
|
25
38
|
session_id: z.string().min(1).describe('The id returned by start_debug.'),
|
|
26
39
|
wait: z
|
|
@@ -32,10 +45,17 @@ export function getFindingsTool(service) {
|
|
|
32
45
|
.describe('Long-poll up to this many ms for a terminal verdict before reading. Omit/0 to read now.'),
|
|
33
46
|
fields: z
|
|
34
47
|
.array(FindingsField)
|
|
48
|
+
.min(1)
|
|
35
49
|
.optional()
|
|
36
|
-
.describe('Project a subset of findings keys (e.g. ["status","bugs"]). Omit for the whole
|
|
50
|
+
.describe('Project a subset of findings keys (e.g. ["status","bugs"]). Omit for the whole ' +
|
|
51
|
+
'object, whose lists are capped at 20 items; a projected read returns them in full.'),
|
|
37
52
|
},
|
|
38
|
-
|
|
53
|
+
outputSchema: FindingsOutputSchema,
|
|
54
|
+
},
|
|
55
|
+
// Cap the lists only on a whole-object read: the steering note points back
|
|
56
|
+
// at `fields=[...]`, so a projected read must come back complete or the
|
|
57
|
+
// recovery path it names would be a lie.
|
|
58
|
+
async (args) => toToolResult(await service.getFindings(args), { capLists: args.fields === undefined }));
|
|
39
59
|
},
|
|
40
60
|
};
|
|
41
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-findings.js","sourceRoot":"","sources":["../../../src/mcp/tools/get-findings.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,4EAA4E;AAC5E,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC;AAE7C,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,OAAiB;IAC/C,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,QAAQ,CAAC,MAAM;YACb,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;gBACE,KAAK,EAAE,kBAAkB;gBACzB,WAAW,EACT,0FAA0F;oBAC1F,wFAAwF;oBACxF,
|
|
1
|
+
{"version":3,"file":"get-findings.js","sourceRoot":"","sources":["../../../src/mcp/tools/get-findings.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,4EAA4E;AAC5E,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC;AAEtD,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,OAAiB;IAC/C,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,QAAQ,CAAC,MAAM;YACb,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;gBACE,KAAK,EAAE,kBAAkB;gBACzB,WAAW,EACT,0FAA0F;oBAC1F,wFAAwF;oBACxF,2FAA2F;oBAC3F,2FAA2F;oBAC3F,+CAA+C;gBACjD,WAAW,EAAE;oBACX,YAAY,EAAE,IAAI;iBACnB;gBACD,WAAW,EAAE;oBACX,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,iCAAiC,CAAC;oBACzE,IAAI,EAAE,CAAC;yBACJ,MAAM,EAAE;yBACR,GAAG,EAAE;yBACL,GAAG,CAAC,CAAC,CAAC;yBACN,GAAG,CAAC,OAAO,CAAC;yBACZ,QAAQ,EAAE;yBACV,QAAQ,CACP,yFAAyF,CAC1F;oBACH,MAAM,EAAE,CAAC;yBACN,KAAK,CAAC,aAAa,CAAC;yBACpB,GAAG,CAAC,CAAC,CAAC;yBACN,QAAQ,EAAE;yBACV,QAAQ,CACP,iFAAiF;wBAC/E,oFAAoF,CACvF;iBACJ;gBACD,YAAY,EAAE,oBAAoB;aACnC;YACD,2EAA2E;YAC3E,wEAAwE;YACxE,yCAAyC;YACzC,KAAK,EAAE,IAAI,EAAE,EAAE,CACb,YAAY,CAAC,MAAM,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC,CACzF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output schemas for the outer tools — the typed half of every tool result.
|
|
3
|
+
*
|
|
4
|
+
* {@link toToolResult} returns each service value BOTH as pretty text and as
|
|
5
|
+
* `structuredContent`; the SDK validates that structured half against the
|
|
6
|
+
* `outputSchema` a tool declares, and clients compile it to type the payload
|
|
7
|
+
* they receive. Declaring them here keeps "Zod at every boundary" true on the
|
|
8
|
+
* way *out* too: a service shape that drifts fails loud at the boundary instead
|
|
9
|
+
* of reaching the caller unchecked.
|
|
10
|
+
*
|
|
11
|
+
* Each schema is pinned to its service interface with `satisfies`, so a rename
|
|
12
|
+
* in `debug-service.ts` that this file misses fails typecheck.
|
|
13
|
+
*
|
|
14
|
+
* `get_findings` declares its own (the findings schema, projected) — see
|
|
15
|
+
* `get-findings.ts`.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
/** `start_debug` output — the id every later call is keyed by. */
|
|
19
|
+
export declare const StartResultSchema: z.ZodObject<{
|
|
20
|
+
session_id: z.ZodString;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
/** `send_message` / `end_session` output — a plain acknowledgement. */
|
|
23
|
+
export declare const AckSchema: z.ZodObject<{
|
|
24
|
+
ok: z.ZodLiteral<true>;
|
|
25
|
+
session_id: z.ZodString;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
/** `describe` output — the target catalog plus the resolved models + workspace. */
|
|
28
|
+
export declare const DescribeResultSchema: z.ZodObject<{
|
|
29
|
+
targets: z.ZodArray<z.ZodObject<{
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
adapter: z.ZodEnum<{
|
|
32
|
+
browser: "browser";
|
|
33
|
+
desktop: "desktop";
|
|
34
|
+
android: "android";
|
|
35
|
+
}>;
|
|
36
|
+
mode: z.ZodEnum<{
|
|
37
|
+
managed: "managed";
|
|
38
|
+
attach: "attach";
|
|
39
|
+
}>;
|
|
40
|
+
operational: z.ZodBoolean;
|
|
41
|
+
url: z.ZodOptional<z.ZodString>;
|
|
42
|
+
headless: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
models: z.ZodObject<{
|
|
45
|
+
driver: z.ZodString;
|
|
46
|
+
vision: z.ZodString;
|
|
47
|
+
summary: z.ZodString;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
workspace: z.ZodString;
|
|
50
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output schemas for the outer tools — the typed half of every tool result.
|
|
3
|
+
*
|
|
4
|
+
* {@link toToolResult} returns each service value BOTH as pretty text and as
|
|
5
|
+
* `structuredContent`; the SDK validates that structured half against the
|
|
6
|
+
* `outputSchema` a tool declares, and clients compile it to type the payload
|
|
7
|
+
* they receive. Declaring them here keeps "Zod at every boundary" true on the
|
|
8
|
+
* way *out* too: a service shape that drifts fails loud at the boundary instead
|
|
9
|
+
* of reaching the caller unchecked.
|
|
10
|
+
*
|
|
11
|
+
* Each schema is pinned to its service interface with `satisfies`, so a rename
|
|
12
|
+
* in `debug-service.ts` that this file misses fails typecheck.
|
|
13
|
+
*
|
|
14
|
+
* `get_findings` declares its own (the findings schema, projected) — see
|
|
15
|
+
* `get-findings.ts`.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
/** `start_debug` output — the id every later call is keyed by. */
|
|
19
|
+
export const StartResultSchema = z.object({
|
|
20
|
+
session_id: z
|
|
21
|
+
.string()
|
|
22
|
+
.min(1)
|
|
23
|
+
.describe('Pass this to get_findings, send_message and end_session.'),
|
|
24
|
+
});
|
|
25
|
+
/** `send_message` / `end_session` output — a plain acknowledgement. */
|
|
26
|
+
export const AckSchema = z.object({
|
|
27
|
+
ok: z
|
|
28
|
+
.literal(true)
|
|
29
|
+
.describe('The call was accepted; a failure arrives as an error result instead.'),
|
|
30
|
+
session_id: z.string().min(1).describe('The run this ack is for.'),
|
|
31
|
+
});
|
|
32
|
+
/** One configured target's public shape — secrets (api keys, profiles) stay out. */
|
|
33
|
+
const TargetInfoSchema = z.object({
|
|
34
|
+
name: z.string().describe('Target name to pass to start_debug.'),
|
|
35
|
+
adapter: z.enum(['browser', 'desktop', 'android']).describe('Which adapter drives this target.'),
|
|
36
|
+
mode: z
|
|
37
|
+
.enum(['managed', 'attach'])
|
|
38
|
+
.describe('managed = the server launches and owns it; attach = it connects to a running one.'),
|
|
39
|
+
operational: z.boolean().describe('Whether this adapter is wired and usable.'),
|
|
40
|
+
url: z.string().optional().describe('Entry url (web targets only).'),
|
|
41
|
+
headless: z.boolean().optional().describe('Headless flag (web targets only).'),
|
|
42
|
+
});
|
|
43
|
+
/** `describe` output — the target catalog plus the resolved models + workspace. */
|
|
44
|
+
export const DescribeResultSchema = z.object({
|
|
45
|
+
targets: z.array(TargetInfoSchema).describe('Targets configured for this project.'),
|
|
46
|
+
models: z
|
|
47
|
+
.object({
|
|
48
|
+
driver: z.string().describe('Fast guy — drives the target (text-only).'),
|
|
49
|
+
vision: z.string().describe('Vision guy — judges screenshots.'),
|
|
50
|
+
summary: z.string().describe('Compresses findings for the caller.'),
|
|
51
|
+
})
|
|
52
|
+
.describe('Resolved per-role model ids.'),
|
|
53
|
+
workspace: z.string().describe('Per-project workspace path; evidence lands under it.'),
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../../src/mcp/tools/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,kEAAkE;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,0DAA0D,CAAC;CACxE,CAAkC,CAAC;AAEpC,uEAAuE;AACvE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,EAAE,EAAE,CAAC;SACF,OAAO,CAAC,IAAI,CAAC;SACb,QAAQ,CAAC,sEAAsE,CAAC;IACnF,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,C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CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sDAAsD,CAAC;CACvF,CAAqC,CAAC"}
|
|
@@ -4,7 +4,30 @@
|
|
|
4
4
|
* back BOTH as pretty-printed `text` (human/log readable) and as
|
|
5
5
|
* `structuredContent` (the typed channel MCP clients parse). Keeps the five tool
|
|
6
6
|
* handlers a single `toToolResult(await service.x(args))` line each.
|
|
7
|
+
*
|
|
8
|
+
* Two spec-alignment behaviors live here too, so no tool handler has to think
|
|
9
|
+
* about them:
|
|
10
|
+
* - **Truncation steering** (opt-in, see {@link ToolResultOptions.capLists}):
|
|
11
|
+
* a list over {@link MAX_LIST_ITEMS} gets capped and a trailing text block
|
|
12
|
+
* names the retrieval that returns it whole. Never capped without one — a
|
|
13
|
+
* dropped entry the caller cannot ask for again is silent data loss.
|
|
14
|
+
* - **`resource_link`s**: evidence paths (screenshots, `replay.mp4`, logs) ride
|
|
15
|
+
* as `resource_link` content items (file:// URIs) alongside the text block —
|
|
16
|
+
* the spec-blessed form, not inline path strings the caller has to notice.
|
|
7
17
|
*/
|
|
8
18
|
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
19
|
+
/** Per-call switches for {@link toToolResult}. */
|
|
20
|
+
export interface ToolResultOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Cap over-long top-level arrays and append {@link steeringNote}.
|
|
23
|
+
*
|
|
24
|
+
* Opt-in, because the note has to name a retrieval that really returns the
|
|
25
|
+
* dropped items. Only `get_findings` has one — and only for an unprojected
|
|
26
|
+
* read, since `fields=[...]` comes back uncapped. Everything else stays whole:
|
|
27
|
+
* `describe.targets` is the configured catalog, there is no page 2, so a
|
|
28
|
+
* capped entry would be undiscoverable.
|
|
29
|
+
*/
|
|
30
|
+
capLists?: boolean;
|
|
31
|
+
}
|
|
9
32
|
/** Wrap a service result as a tool response: pretty `text` plus `structuredContent` for records. */
|
|
10
|
-
export declare function toToolResult(data: unknown): CallToolResult;
|
|
33
|
+
export declare function toToolResult(data: unknown, options?: ToolResultOptions): CallToolResult;
|
package/dist/mcp/tools/result.js
CHANGED
|
@@ -4,17 +4,118 @@
|
|
|
4
4
|
* back BOTH as pretty-printed `text` (human/log readable) and as
|
|
5
5
|
* `structuredContent` (the typed channel MCP clients parse). Keeps the five tool
|
|
6
6
|
* handlers a single `toToolResult(await service.x(args))` line each.
|
|
7
|
+
*
|
|
8
|
+
* Two spec-alignment behaviors live here too, so no tool handler has to think
|
|
9
|
+
* about them:
|
|
10
|
+
* - **Truncation steering** (opt-in, see {@link ToolResultOptions.capLists}):
|
|
11
|
+
* a list over {@link MAX_LIST_ITEMS} gets capped and a trailing text block
|
|
12
|
+
* names the retrieval that returns it whole. Never capped without one — a
|
|
13
|
+
* dropped entry the caller cannot ask for again is silent data loss.
|
|
14
|
+
* - **`resource_link`s**: evidence paths (screenshots, `replay.mp4`, logs) ride
|
|
15
|
+
* as `resource_link` content items (file:// URIs) alongside the text block —
|
|
16
|
+
* the spec-blessed form, not inline path strings the caller has to notice.
|
|
7
17
|
*/
|
|
8
18
|
/** A plain object value (not an array) — what every outer tool returns. */
|
|
9
19
|
function isRecord(value) {
|
|
10
20
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
11
21
|
}
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
/** Cap on a top-level array field before it gets truncated for the response. */
|
|
23
|
+
const MAX_LIST_ITEMS = 20;
|
|
24
|
+
/** Keys whose string value — when an absolute path — is evidence worth linking. */
|
|
25
|
+
const EVIDENCE_KEYS = new Set(['screenshot', 'evidence']);
|
|
26
|
+
/** Guess a MIME type from an evidence path's extension; omit when unknown. */
|
|
27
|
+
function mimeTypeFor(path) {
|
|
28
|
+
if (path.endsWith('.png'))
|
|
29
|
+
return 'image/png';
|
|
30
|
+
if (path.endsWith('.jpg') || path.endsWith('.jpeg'))
|
|
31
|
+
return 'image/jpeg';
|
|
32
|
+
if (path.endsWith('.mp4'))
|
|
33
|
+
return 'video/mp4';
|
|
34
|
+
if (path.endsWith('.log'))
|
|
35
|
+
return 'text/plain';
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
/** Build one `resource_link` content item for an absolute evidence path. */
|
|
39
|
+
function resourceLink(path) {
|
|
40
|
+
const mimeType = mimeTypeFor(path);
|
|
15
41
|
return {
|
|
16
|
-
|
|
17
|
-
|
|
42
|
+
type: 'resource_link',
|
|
43
|
+
uri: new URL(path, 'file://').href,
|
|
44
|
+
name: path.split('/').pop() ?? path,
|
|
45
|
+
...(mimeType !== undefined && { mimeType }),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Walk a (findings-shaped) value collecting `resource_link`s for every absolute
|
|
50
|
+
* path under an evidence-ish key. Only absolute paths qualify — `bugs[].evidence`
|
|
51
|
+
* doubles as free-text ("line 42"), so a relative-looking string is left as text,
|
|
52
|
+
* not linked. Dedupes by path (a replay path can be both `findings.evidence` and
|
|
53
|
+
* on a step).
|
|
54
|
+
*/
|
|
55
|
+
function collectResourceLinks(value) {
|
|
56
|
+
const links = [];
|
|
57
|
+
const seen = new Set();
|
|
58
|
+
const walk = (node) => {
|
|
59
|
+
if (Array.isArray(node)) {
|
|
60
|
+
for (const item of node)
|
|
61
|
+
walk(item);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!isRecord(node))
|
|
65
|
+
return;
|
|
66
|
+
for (const [key, val] of Object.entries(node)) {
|
|
67
|
+
if (typeof val === 'string' && EVIDENCE_KEYS.has(key) && val.startsWith('/')) {
|
|
68
|
+
if (!seen.has(val)) {
|
|
69
|
+
seen.add(val);
|
|
70
|
+
links.push(resourceLink(val));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
walk(val);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
18
77
|
};
|
|
78
|
+
walk(value);
|
|
79
|
+
return links;
|
|
80
|
+
}
|
|
81
|
+
/** Cap any top-level array field over {@link MAX_LIST_ITEMS}; report which ones. */
|
|
82
|
+
function capLists(data) {
|
|
83
|
+
const truncated = [];
|
|
84
|
+
const capped = {};
|
|
85
|
+
for (const [key, value] of Object.entries(data)) {
|
|
86
|
+
if (Array.isArray(value) && value.length > MAX_LIST_ITEMS) {
|
|
87
|
+
capped[key] = value.slice(0, MAX_LIST_ITEMS);
|
|
88
|
+
truncated.push(key);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
capped[key] = value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return { capped, truncated };
|
|
95
|
+
}
|
|
96
|
+
/** Steering text appended when one or more lists got capped. */
|
|
97
|
+
function steeringNote(truncated) {
|
|
98
|
+
const fields = truncated.map((f) => `"${f}"`).join(', ');
|
|
99
|
+
return (`Truncated ${truncated.join(', ')} to the first ${MAX_LIST_ITEMS} items. ` +
|
|
100
|
+
`Call get_findings with fields=[${fields}] to read those arrays in full — ` +
|
|
101
|
+
'a projected read is never truncated. The complete run also sits on disk: ' +
|
|
102
|
+
'findings.json / replay.mp4 / the logs under the session workspace.');
|
|
103
|
+
}
|
|
104
|
+
/** Wrap a service result as a tool response: pretty `text` plus `structuredContent` for records. */
|
|
105
|
+
export function toToolResult(data, options = {}) {
|
|
106
|
+
if (!isRecord(data)) {
|
|
107
|
+
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
108
|
+
}
|
|
109
|
+
const { capped, truncated } = options.capLists
|
|
110
|
+
? capLists(data)
|
|
111
|
+
: { capped: data, truncated: [] };
|
|
112
|
+
const content = [
|
|
113
|
+
{ type: 'text', text: JSON.stringify(capped, null, 2) },
|
|
114
|
+
];
|
|
115
|
+
if (truncated.length > 0) {
|
|
116
|
+
content.push({ type: 'text', text: steeringNote(truncated) });
|
|
117
|
+
}
|
|
118
|
+
content.push(...collectResourceLinks(capped));
|
|
119
|
+
return { content, structuredContent: capped };
|
|
19
120
|
}
|
|
20
121
|
//# sourceMappingURL=result.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../src/mcp/tools/result.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../src/mcp/tools/result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,2EAA2E;AAC3E,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,gFAAgF;AAChF,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,mFAAmF;AACnF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC;AAI1D,8EAA8E;AAC9E,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,WAAW,CAAC;IAC9C,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,YAAY,CAAC;IACzE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,WAAW,CAAC;IAC9C,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,YAAY,CAAC;IAC/C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,4EAA4E;AAC5E,SAAS,YAAY,CAAC,IAAY;IAChC,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,GAAG,EAAE,IAAI,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,IAAI;QAClC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IA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AAC,IAAI,CAAC;QAChB,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAc,EAAE,CAAC;IAChD,MAAM,OAAO,GAA8B;QACzC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;KACxD,CAAC;IACF,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;IAE9C,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* {@link DebugApi.send}, ack.
|
|
7
7
|
*/
|
|
8
8
|
import { z } from 'zod';
|
|
9
|
+
import { AckSchema } from './output.js';
|
|
9
10
|
import { toToolResult } from './result.js';
|
|
10
11
|
/** Build the `send_message` outer tool bound to the debug service. */
|
|
11
12
|
export function sendMessageTool(service) {
|
|
@@ -17,6 +18,9 @@ export function sendMessageTool(service) {
|
|
|
17
18
|
description: 'Talk to the small driver agent mid-run: add work, redirect it, or answer a question. ' +
|
|
18
19
|
'The message is folded into the conversation before the next step — the run keeps going, ' +
|
|
19
20
|
'no restart. Use get_findings to see the effect.',
|
|
21
|
+
annotations: {
|
|
22
|
+
destructiveHint: false,
|
|
23
|
+
},
|
|
20
24
|
inputSchema: {
|
|
21
25
|
session_id: z.string().min(1).describe('The id returned by start_debug.'),
|
|
22
26
|
message: z
|
|
@@ -24,6 +28,7 @@ export function sendMessageTool(service) {
|
|
|
24
28
|
.min(1)
|
|
25
29
|
.describe('The instruction for the driver, in plain language (e.g. "skip checkout, the bug is the login form").'),
|
|
26
30
|
},
|
|
31
|
+
outputSchema: AckSchema,
|
|
27
32
|
}, (args) => toToolResult(service.send(args)));
|
|
28
33
|
},
|
|
29
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-message.js","sourceRoot":"","sources":["../../../src/mcp/tools/send-message.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,OAAiB;IAC/C,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,QAAQ,CAAC,MAAM;YACb,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;gBACE,KAAK,EAAE,yBAAyB;gBAChC,WAAW,EACT,uFAAuF;oBACvF,0FAA0F;oBAC1F,iDAAiD;gBACnD,WAAW,EAAE;oBACX,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,iCAAiC,CAAC;oBACzE,OAAO,EAAE,CAAC;yBACP,MAAM,EAAE;yBACR,GAAG,CAAC,CAAC,CAAC;yBACN,QAAQ,CACP,sGAAsG,CACvG;iBACJ;
|
|
1
|
+
{"version":3,"file":"send-message.js","sourceRoot":"","sources":["../../../src/mcp/tools/send-message.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,OAAiB;IAC/C,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,QAAQ,CAAC,MAAM;YACb,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;gBACE,KAAK,EAAE,yBAAyB;gBAChC,WAAW,EACT,uFAAuF;oBACvF,0FAA0F;oBAC1F,iDAAiD;gBACnD,WAAW,EAAE;oBACX,eAAe,EAAE,KAAK;iBACvB;gBACD,WAAW,EAAE;oBACX,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,iCAAiC,CAAC;oBACzE,OAAO,EAAE,CAAC;yBACP,MAAM,EAAE;yBACR,GAAG,CAAC,CAAC,CAAC;yBACN,QAAQ,CACP,sGAAsG,CACvG;iBACJ;gBACD,YAAY,EAAE,SAAS;aACxB,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAC3C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* `{ session_id }` result.
|
|
8
8
|
*/
|
|
9
9
|
import { z } from 'zod';
|
|
10
|
+
import { StartResultSchema } from './output.js';
|
|
10
11
|
import { toToolResult } from './result.js';
|
|
11
12
|
/** Build the `start_debug` outer tool bound to the debug service. */
|
|
12
13
|
export function startDebugTool(service) {
|
|
@@ -19,6 +20,10 @@ export function startDebugTool(service) {
|
|
|
19
20
|
'(e.g. "web"). It drives the UI autonomously and gathers findings (functional bugs + ' +
|
|
20
21
|
'visual feedback). One run per project at a time. Returns { session_id }; then poll ' +
|
|
21
22
|
'get_findings, steer with send_message, and close with end_session.',
|
|
23
|
+
annotations: {
|
|
24
|
+
destructiveHint: false,
|
|
25
|
+
openWorldHint: true,
|
|
26
|
+
},
|
|
22
27
|
inputSchema: {
|
|
23
28
|
target: z
|
|
24
29
|
.string()
|
|
@@ -42,8 +47,9 @@ export function startDebugTool(service) {
|
|
|
42
47
|
.positive()
|
|
43
48
|
.max(2_147_483)
|
|
44
49
|
.optional()
|
|
45
|
-
.describe('Wall-clock cap in SECONDS before the run auto-ends (frees the browser/profile). Omit for the default (300s). Max 2_147_483 (Node timer ceiling once × 1000).'),
|
|
50
|
+
.describe('Wall-clock cap in SECONDS before the run auto-ends (frees the browser/profile), counted from this call — launching the browser and the first navigation spend it too. Omit for the default (300s). Max 2_147_483 (Node timer ceiling once × 1000).'),
|
|
46
51
|
},
|
|
52
|
+
outputSchema: StartResultSchema,
|
|
47
53
|
}, async ({ timeout, ...rest }) => toToolResult(await service.start({
|
|
48
54
|
...rest,
|
|
49
55
|
...(timeout !== undefined && { timeoutMs: timeout * 1000 }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-debug.js","sourceRoot":"","sources":["../../../src/mcp/tools/start-debug.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,qEAAqE;AACrE,MAAM,UAAU,cAAc,CAAC,OAAiB;IAC9C,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,QAAQ,CAAC,MAAM;YACb,MAAM,CAAC,YAAY,CACjB,aAAa,EACb;gBACE,KAAK,EAAE,mBAAmB;gBAC1B,WAAW,EACT,mFAAmF;oBACnF,sFAAsF;oBACtF,qFAAqF;oBACrF,oEAAoE;gBACtE,WAAW,EAAE;oBACX,MAAM,EAAE,CAAC;yBACN,MAAM,EAAE;yBACR,GAAG,CAAC,CAAC,CAAC;yBACN,QAAQ,CACP,4FAA4F,CAC7F;oBACH,IAAI,EAAE,CAAC;yBACJ,MAAM,EAAE;yBACR,GAAG,CAAC,CAAC,CAAC;yBACN,QAAQ,CACP,8FAA8F,CAC/F;oBACH,GAAG,EAAE,CAAC;yBACH,GAAG,EAAE;yBACL,QAAQ,EAAE;yBACV,QAAQ,CACP,qOAAqO,CACtO;oBACH,QAAQ,EAAE,CAAC;yBACR,MAAM,EAAE;yBACR,QAAQ,EAAE;yBACV,QAAQ,CACP,+EAA+E,CAChF;oBACH,OAAO,EAAE,CAAC;yBACP,MAAM,EAAE;yBACR,GAAG,EAAE;yBACL,QAAQ,EAAE;yBACV,GAAG,CAAC,SAAS,CAAC;yBACd,QAAQ,EAAE;yBACV,QAAQ,CACP,
|
|
1
|
+
{"version":3,"file":"start-debug.js","sourceRoot":"","sources":["../../../src/mcp/tools/start-debug.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,qEAAqE;AACrE,MAAM,UAAU,cAAc,CAAC,OAAiB;IAC9C,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,QAAQ,CAAC,MAAM;YACb,MAAM,CAAC,YAAY,CACjB,aAAa,EACb;gBACE,KAAK,EAAE,mBAAmB;gBAC1B,WAAW,EACT,mFAAmF;oBACnF,sFAAsF;oBACtF,qFAAqF;oBACrF,oEAAoE;gBACtE,WAAW,EAAE;oBACX,eAAe,EAAE,KAAK;oBACtB,aAAa,EAAE,IAAI;iBACpB;gBACD,WAAW,EAAE;oBACX,MAAM,EAAE,CAAC;yBACN,MAAM,EAAE;yBACR,GAAG,CAAC,CAAC,CAAC;yBACN,QAAQ,CACP,4FAA4F,CAC7F;oBACH,IAAI,EAAE,CAAC;yBACJ,MAAM,EAAE;yBACR,GAAG,CAAC,CAAC,CAAC;yBACN,QAAQ,CACP,8FAA8F,CAC/F;oBACH,GAAG,EAAE,CAAC;yBACH,GAAG,EAAE;yBACL,QAAQ,EAAE;yBACV,QAAQ,CACP,qOAAqO,CACtO;oBACH,QAAQ,EAAE,CAAC;yBACR,MAAM,EAAE;yBACR,QAAQ,EAAE;yBACV,QAAQ,CACP,+EAA+E,CAChF;oBACH,OAAO,EAAE,CAAC;yBACP,MAAM,EAAE;yBACR,GAAG,EAAE;yBACL,QAAQ,EAAE;yBACV,GAAG,CAAC,SAAS,CAAC;yBACd,QAAQ,EAAE;yBACV,QAAQ,CACP,oPAAoP,CACrP;iBACJ;gBACD,YAAY,EAAE,iBAAiB;aAChC,EACD,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAC7B,YAAY,CACV,MAAM,OAAO,CAAC,KAAK,CAAC;gBAClB,GAAG,IAAI;gBACP,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI,EAAE,CAAC;aAC5D,CAAC,CACH,CACJ,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -8,14 +8,26 @@
|
|
|
8
8
|
* seam — so the orchestration here unit-tests with no browser or network. The MCP
|
|
9
9
|
* handlers stay thin: validate input, call straight through to a method here.
|
|
10
10
|
*
|
|
11
|
+
* One run per project holds *across processes* too: the manager only knows this
|
|
12
|
+
* server's memory, so `start` also consults the `state.json` breadcrumb and
|
|
13
|
+
* refuses when another live server already owns a run here (a dead owner's stale
|
|
14
|
+
* breadcrumb never blocks).
|
|
15
|
+
*
|
|
11
16
|
* Sessions are keyed by cwd, but the tools speak `session_id`. Every id-bearing
|
|
12
17
|
* call resolves the active session for the cwd and fails loud
|
|
13
18
|
* ({@link SessionNotFoundError}) when the id does not match, so a stale id never
|
|
14
19
|
* silently drives the wrong run.
|
|
20
|
+
*
|
|
21
|
+
* A run that ends *without* the caller asking (wall-clock timeout, SIGTERM, the
|
|
22
|
+
* MCP client dying) leaves the manager, but its findings must not vanish with it:
|
|
23
|
+
* the settled session is retained so `get_findings` keeps serving its terminal
|
|
24
|
+
* snapshot. `end_session` is the explicit forget; the next `start_debug`
|
|
25
|
+
* supersedes it. The retained snapshot holds no target resources (the adapter is
|
|
26
|
+
* already closed) and never participates in the one-run gate.
|
|
15
27
|
*/
|
|
16
|
-
import type
|
|
28
|
+
import { type ResolvedConfig } from '../config/load.js';
|
|
17
29
|
import type { Target } from '../config/schema.js';
|
|
18
|
-
import type
|
|
30
|
+
import { type Findings } from '../findings/schema.js';
|
|
19
31
|
import type { SessionManager } from '../session/manager.js';
|
|
20
32
|
import type { Session, SnapshotField } from '../session/session.js';
|
|
21
33
|
import { type StatePort } from '../session/state-file.js';
|
|
@@ -29,7 +41,11 @@ export interface StartInput {
|
|
|
29
41
|
criteria?: string;
|
|
30
42
|
/** Per-run URL the caller points the driver at (web); overrides the target's configured url. */
|
|
31
43
|
url?: string;
|
|
32
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Wall-clock cap (ms) before the run auto-ends, counted from THIS call — assembly,
|
|
46
|
+
* launch and the first navigation spend it too. Defaults to
|
|
47
|
+
* {@link DEFAULT_SESSION_TIMEOUT_MS}.
|
|
48
|
+
*/
|
|
33
49
|
timeoutMs?: number;
|
|
34
50
|
}
|
|
35
51
|
/** `start_debug` output — the id to poll/redirect/end the run by. */
|
|
@@ -105,8 +121,15 @@ export interface DebugServiceDeps {
|
|
|
105
121
|
state?: StatePort;
|
|
106
122
|
/** Default wall-clock cap (ms) for a run; defaults to {@link DEFAULT_SESSION_TIMEOUT_MS}. */
|
|
107
123
|
defaultTimeoutMs?: number;
|
|
108
|
-
/** Injected clock (epoch ms) for session ids; defaults to `Date.now`. */
|
|
124
|
+
/** Injected clock (epoch ms) for session ids + the run deadline; defaults to `Date.now`. */
|
|
109
125
|
now?: () => number;
|
|
126
|
+
/**
|
|
127
|
+
* Has `.ui-debugger-mcp.json` changed since boot? Config is resolved once and
|
|
128
|
+
* wired into long-lived objects, so a changed file means every later run would
|
|
129
|
+
* silently use the OLD settings — see `config/fingerprint.ts`. Defaults to
|
|
130
|
+
* "never changed" (unit tests hold no file).
|
|
131
|
+
*/
|
|
132
|
+
configChanged?: () => boolean;
|
|
110
133
|
}
|
|
111
134
|
export declare class DebugService implements DebugApi {
|
|
112
135
|
#private;
|
|
@@ -114,8 +137,14 @@ export declare class DebugService implements DebugApi {
|
|
|
114
137
|
/**
|
|
115
138
|
* Open a run: assemble the session, take the profile lock, point the adapter at
|
|
116
139
|
* the target, and kick the loop off in the background. Fails loud if a run is
|
|
117
|
-
* already active for this cwd ({@link SessionBusyError})
|
|
118
|
-
*
|
|
140
|
+
* already active for this cwd ({@link SessionBusyError}) — whether it belongs to
|
|
141
|
+
* this server (the manager / in-flight guard) or to another live one (the
|
|
142
|
+
* `state.json` breadcrumb); never leaks a launched browser — a lost lock race or
|
|
143
|
+
* a failed `open` tears the session back down.
|
|
144
|
+
*
|
|
145
|
+
* `timeout` is wall-clock from HERE: the deadline is fixed on entry and the
|
|
146
|
+
* remaining budget is threaded into the build and the first navigation, so a slow
|
|
147
|
+
* Chrome launch spends the caller's cap instead of sitting outside it.
|
|
119
148
|
*/
|
|
120
149
|
start({ target, goal, criteria, url, timeoutMs }: StartInput): Promise<StartResult>;
|
|
121
150
|
/**
|
|
@@ -124,11 +153,21 @@ export declare class DebugService implements DebugApi {
|
|
|
124
153
|
* drains the inbox, so an ack then would silently drop the message.
|
|
125
154
|
*/
|
|
126
155
|
send({ session_id, message }: SendInput): Ack;
|
|
127
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* Snapshot the run's findings — optionally long-poll (`wait`) and/or project a
|
|
158
|
+
* subset (`fields`). Serves the retained terminal snapshot once the run has
|
|
159
|
+
* auto-ended, so a timed-out run's partial findings stay reachable (the
|
|
160
|
+
* long-poll returns at once: a settled run has nothing left to wait for).
|
|
161
|
+
*/
|
|
128
162
|
getFindings({ session_id, wait, fields, }: GetFindingsInput): Promise<Findings | Partial<Findings>>;
|
|
129
163
|
/** List configured targets (the whole catalog, or one when named) plus resolved models/workspace. */
|
|
130
164
|
describe({ target }: DescribeInput): DescribeResult;
|
|
131
|
-
/**
|
|
165
|
+
/**
|
|
166
|
+
* End the active run: abort the loop, close the adapter, free the profile lock.
|
|
167
|
+
* Ending a run that already auto-ended (timeout / client death) is not an error
|
|
168
|
+
* — it just forgets the retained snapshot, so `end_session` reads the same
|
|
169
|
+
* either way and stays the one explicit forget.
|
|
170
|
+
*/
|
|
132
171
|
end({ session_id }: EndInput): Promise<Ack>;
|
|
133
172
|
/**
|
|
134
173
|
* End whatever run is active for this cwd, if any — the graceful-shutdown path
|