@developerz.ai/ui-debugger-mcp 1.0.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/LICENSE +21 -0
- package/README.md +295 -0
- package/dist/adapters/android/adb.d.ts +38 -0
- package/dist/adapters/android/adb.js +72 -0
- package/dist/adapters/android/adb.js.map +1 -0
- package/dist/adapters/android/android-adapter.d.ts +63 -0
- package/dist/adapters/android/android-adapter.js +306 -0
- package/dist/adapters/android/android-adapter.js.map +1 -0
- package/dist/adapters/android/commands.d.ts +59 -0
- package/dist/adapters/android/commands.js +178 -0
- package/dist/adapters/android/commands.js.map +1 -0
- package/dist/adapters/android/uiautomator.d.ts +81 -0
- package/dist/adapters/android/uiautomator.js +296 -0
- package/dist/adapters/android/uiautomator.js.map +1 -0
- package/dist/adapters/browser/browser-adapter.d.ts +72 -0
- package/dist/adapters/browser/browser-adapter.js +434 -0
- package/dist/adapters/browser/browser-adapter.js.map +1 -0
- package/dist/adapters/browser/cdp.d.ts +83 -0
- package/dist/adapters/browser/cdp.js +308 -0
- package/dist/adapters/browser/cdp.js.map +1 -0
- package/dist/adapters/browser/query.d.ts +25 -0
- package/dist/adapters/browser/query.js +85 -0
- package/dist/adapters/browser/query.js.map +1 -0
- package/dist/adapters/contract.d.ts +159 -0
- package/dist/adapters/contract.js +22 -0
- package/dist/adapters/contract.js.map +1 -0
- package/dist/adapters/desktop/atspi.d.ts +95 -0
- package/dist/adapters/desktop/atspi.js +359 -0
- package/dist/adapters/desktop/atspi.js.map +1 -0
- package/dist/adapters/desktop/capture.d.ts +35 -0
- package/dist/adapters/desktop/capture.js +67 -0
- package/dist/adapters/desktop/capture.js.map +1 -0
- package/dist/adapters/desktop/desktop-adapter.d.ts +60 -0
- package/dist/adapters/desktop/desktop-adapter.js +215 -0
- package/dist/adapters/desktop/desktop-adapter.js.map +1 -0
- package/dist/adapters/desktop/input.d.ts +67 -0
- package/dist/adapters/desktop/input.js +191 -0
- package/dist/adapters/desktop/input.js.map +1 -0
- package/dist/adapters/desktop/proc.d.ts +23 -0
- package/dist/adapters/desktop/proc.js +38 -0
- package/dist/adapters/desktop/proc.js.map +1 -0
- package/dist/adapters/factory.d.ts +23 -0
- package/dist/adapters/factory.js +45 -0
- package/dist/adapters/factory.js.map +1 -0
- package/dist/agent/belt/act.d.ts +100 -0
- package/dist/agent/belt/act.js +166 -0
- package/dist/agent/belt/act.js.map +1 -0
- package/dist/agent/belt/look.d.ts +98 -0
- package/dist/agent/belt/look.js +160 -0
- package/dist/agent/belt/look.js.map +1 -0
- package/dist/agent/belt/observe.d.ts +102 -0
- package/dist/agent/belt/observe.js +185 -0
- package/dist/agent/belt/observe.js.map +1 -0
- package/dist/agent/belt/report.d.ts +133 -0
- package/dist/agent/belt/report.js +112 -0
- package/dist/agent/belt/report.js.map +1 -0
- package/dist/agent/loop.d.ts +136 -0
- package/dist/agent/loop.js +173 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/models.d.ts +26 -0
- package/dist/agent/models.js +22 -0
- package/dist/agent/models.js.map +1 -0
- package/dist/agent/prompts/android-addendum.d.ts +12 -0
- package/dist/agent/prompts/android-addendum.js +76 -0
- package/dist/agent/prompts/android-addendum.js.map +1 -0
- package/dist/agent/prompts/compose.d.ts +30 -0
- package/dist/agent/prompts/compose.js +52 -0
- package/dist/agent/prompts/compose.js.map +1 -0
- package/dist/agent/prompts/debug-agent.d.ts +9 -0
- package/dist/agent/prompts/debug-agent.js +102 -0
- package/dist/agent/prompts/debug-agent.js.map +1 -0
- package/dist/agent/prompts/desktop-addendum.d.ts +10 -0
- package/dist/agent/prompts/desktop-addendum.js +66 -0
- package/dist/agent/prompts/desktop-addendum.js.map +1 -0
- package/dist/agent/prompts/web-addendum.d.ts +9 -0
- package/dist/agent/prompts/web-addendum.js +70 -0
- package/dist/agent/prompts/web-addendum.js.map +1 -0
- package/dist/agent/provider.d.ts +17 -0
- package/dist/agent/provider.js +29 -0
- package/dist/agent/provider.js.map +1 -0
- package/dist/cli/control.d.ts +19 -0
- package/dist/cli/control.js +152 -0
- package/dist/cli/control.js.map +1 -0
- package/dist/cli/help.d.ts +9 -0
- package/dist/cli/help.js +41 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/init.d.ts +20 -0
- package/dist/cli/init.js +119 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/config/load.d.ts +64 -0
- package/dist/config/load.js +105 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/schema.d.ts +105 -0
- package/dist/config/schema.js +62 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/errors.d.ts +41 -0
- package/dist/errors.js +90 -0
- package/dist/errors.js.map +1 -0
- package/dist/findings/schema.d.ts +64 -0
- package/dist/findings/schema.js +27 -0
- package/dist/findings/schema.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +95 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp/server.d.ts +25 -0
- package/dist/mcp/server.js +31 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/describe.d.ts +12 -0
- package/dist/mcp/tools/describe.js +32 -0
- package/dist/mcp/tools/describe.js.map +1 -0
- package/dist/mcp/tools/end-session.d.ts +11 -0
- package/dist/mcp/tools/end-session.js +27 -0
- package/dist/mcp/tools/end-session.js.map +1 -0
- package/dist/mcp/tools/get-findings.d.ts +12 -0
- package/dist/mcp/tools/get-findings.js +42 -0
- package/dist/mcp/tools/get-findings.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +17 -0
- package/dist/mcp/tools/index.js +24 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/result.d.ts +10 -0
- package/dist/mcp/tools/result.js +20 -0
- package/dist/mcp/tools/result.js.map +1 -0
- package/dist/mcp/tools/send-message.d.ts +11 -0
- package/dist/mcp/tools/send-message.js +31 -0
- package/dist/mcp/tools/send-message.js.map +1 -0
- package/dist/mcp/tools/start-debug.d.ts +12 -0
- package/dist/mcp/tools/start-debug.js +50 -0
- package/dist/mcp/tools/start-debug.js.map +1 -0
- package/dist/services/debug-service.d.ts +133 -0
- package/dist/services/debug-service.js +163 -0
- package/dist/services/debug-service.js.map +1 -0
- package/dist/services/replay.d.ts +102 -0
- package/dist/services/replay.js +184 -0
- package/dist/services/replay.js.map +1 -0
- package/dist/services/session-builder.d.ts +65 -0
- package/dist/services/session-builder.js +198 -0
- package/dist/services/session-builder.js.map +1 -0
- package/dist/services/summarize.d.ts +59 -0
- package/dist/services/summarize.js +93 -0
- package/dist/services/summarize.js.map +1 -0
- package/dist/session/findings-store.d.ts +52 -0
- package/dist/session/findings-store.js +176 -0
- package/dist/session/findings-store.js.map +1 -0
- package/dist/session/manager.d.ts +47 -0
- package/dist/session/manager.js +66 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/session/process-identity.d.ts +45 -0
- package/dist/session/process-identity.js +81 -0
- package/dist/session/process-identity.js.map +1 -0
- package/dist/session/session.d.ts +156 -0
- package/dist/session/session.js +309 -0
- package/dist/session/session.js.map +1 -0
- package/dist/session/state-file.d.ts +72 -0
- package/dist/session/state-file.js +104 -0
- package/dist/session/state-file.js.map +1 -0
- package/dist/session/workspace.d.ts +60 -0
- package/dist/session/workspace.js +75 -0
- package/dist/session/workspace.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
/**
|
|
3
|
+
* A self-registering outer MCP tool.
|
|
4
|
+
*
|
|
5
|
+
* Boot (this file) owns the server lifecycle + transport; each tool owns its own
|
|
6
|
+
* config and handler and attaches itself via {@link register}. The registrar
|
|
7
|
+
* stays tool-blind: the five outer tools (`start_debug`, `send_message`,
|
|
8
|
+
* `get_findings`, `describe`, `end_session`) are injected, never hardcoded here.
|
|
9
|
+
*/
|
|
10
|
+
export interface McpTool {
|
|
11
|
+
/** Tool name exposed to MCP clients (e.g. `start_debug`). */
|
|
12
|
+
readonly name: string;
|
|
13
|
+
/** Attach this tool's config + handler to the given server. */
|
|
14
|
+
readonly register: (server: McpServer) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build an {@link McpServer} and register every provided tool.
|
|
18
|
+
* Fails fast on a duplicate tool name so collisions surface loud.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createMcpServer(tools: readonly McpTool[]): McpServer;
|
|
21
|
+
/**
|
|
22
|
+
* Boot the stdio MCP server: register the tools, connect the stdio transport,
|
|
23
|
+
* and return the live server. Callers wire dependencies into the tools.
|
|
24
|
+
*/
|
|
25
|
+
export declare function startStdioServer(tools: readonly McpTool[]): Promise<McpServer>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { McpServerError } from '../errors.js';
|
|
4
|
+
import { NAME, VERSION } from '../index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Build an {@link McpServer} and register every provided tool.
|
|
7
|
+
* Fails fast on a duplicate tool name so collisions surface loud.
|
|
8
|
+
*/
|
|
9
|
+
export function createMcpServer(tools) {
|
|
10
|
+
const server = new McpServer({ name: NAME, version: VERSION });
|
|
11
|
+
const registered = new Set();
|
|
12
|
+
for (const tool of tools) {
|
|
13
|
+
if (registered.has(tool.name)) {
|
|
14
|
+
throw new McpServerError(`duplicate MCP tool registration: '${tool.name}'`);
|
|
15
|
+
}
|
|
16
|
+
registered.add(tool.name);
|
|
17
|
+
tool.register(server);
|
|
18
|
+
}
|
|
19
|
+
return server;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Boot the stdio MCP server: register the tools, connect the stdio transport,
|
|
23
|
+
* and return the live server. Callers wire dependencies into the tools.
|
|
24
|
+
*/
|
|
25
|
+
export async function startStdioServer(tools) {
|
|
26
|
+
const server = createMcpServer(tools);
|
|
27
|
+
const transport = new StdioServerTransport();
|
|
28
|
+
await server.connect(transport);
|
|
29
|
+
return server;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAiB5C;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAyB;IACvD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/D,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,cAAc,CAAC,qCAAqC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC9E,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAyB;IAC9D,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `describe` — list this project's debug targets + resolved models/workspace.
|
|
3
|
+
*
|
|
4
|
+
* The smart agent's lazy catalog: what targets are configured (and which are
|
|
5
|
+
* wired), so it knows valid `target` values for `start_debug` without reading the
|
|
6
|
+
* config file. Pass `target` to narrow to one. Thin handler: Zod-validate, call
|
|
7
|
+
* {@link DebugApi.describe}.
|
|
8
|
+
*/
|
|
9
|
+
import type { DebugApi } from '../../services/debug-service.js';
|
|
10
|
+
import type { McpTool } from '../server.js';
|
|
11
|
+
/** Build the `describe` outer tool bound to the debug service. */
|
|
12
|
+
export declare function describeTool(service: DebugApi): McpTool;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `describe` — list this project's debug targets + resolved models/workspace.
|
|
3
|
+
*
|
|
4
|
+
* The smart agent's lazy catalog: what targets are configured (and which are
|
|
5
|
+
* wired), so it knows valid `target` values for `start_debug` without reading the
|
|
6
|
+
* config file. Pass `target` to narrow to one. Thin handler: Zod-validate, call
|
|
7
|
+
* {@link DebugApi.describe}.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { toToolResult } from './result.js';
|
|
11
|
+
/** Build the `describe` outer tool bound to the debug service. */
|
|
12
|
+
export function describeTool(service) {
|
|
13
|
+
return {
|
|
14
|
+
name: 'describe',
|
|
15
|
+
register(server) {
|
|
16
|
+
server.registerTool('describe', {
|
|
17
|
+
title: 'Describe debug targets',
|
|
18
|
+
description: 'List the configured targets for this project (name, adapter, managed|attach, whether wired, ' +
|
|
19
|
+
'and web url/headless) plus the resolved per-role models and workspace. Call this first to pick ' +
|
|
20
|
+
'a valid target for start_debug. Pass target to narrow to one.',
|
|
21
|
+
inputSchema: {
|
|
22
|
+
target: z
|
|
23
|
+
.string()
|
|
24
|
+
.min(1)
|
|
25
|
+
.optional()
|
|
26
|
+
.describe('Optional target name to narrow the catalog to a single entry.'),
|
|
27
|
+
},
|
|
28
|
+
}, (args) => toToolResult(service.describe(args)));
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=describe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../../src/mcp/tools/describe.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,kEAAkE;AAClE,MAAM,UAAU,YAAY,CAAC,OAAiB;IAC5C,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,QAAQ,CAAC,MAAM;YACb,MAAM,CAAC,YAAY,CACjB,UAAU,EACV;gBACE,KAAK,EAAE,wBAAwB;gBAC/B,WAAW,EACT,8FAA8F;oBAC9F,iGAAiG;oBACjG,+DAA+D;gBACjE,WAAW,EAAE;oBACX,MAAM,EAAE,CAAC;yBACN,MAAM,EAAE;yBACR,GAAG,CAAC,CAAC,CAAC;yBACN,QAAQ,EAAE;yBACV,QAAQ,CAAC,+DAA+D,CAAC;iBAC7E;aACF,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAC/C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `end_session` — stop and tear down the active run.
|
|
3
|
+
*
|
|
4
|
+
* Aborts the loop, closes the target adapter (managed: stops Chrome; attach:
|
|
5
|
+
* disconnects only), and frees the project's profile lock. Thin handler:
|
|
6
|
+
* Zod-validate, call {@link DebugApi.end}, ack.
|
|
7
|
+
*/
|
|
8
|
+
import type { DebugApi } from '../../services/debug-service.js';
|
|
9
|
+
import type { McpTool } from '../server.js';
|
|
10
|
+
/** Build the `end_session` outer tool bound to the debug service. */
|
|
11
|
+
export declare function endSessionTool(service: DebugApi): McpTool;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `end_session` — stop and tear down the active run.
|
|
3
|
+
*
|
|
4
|
+
* Aborts the loop, closes the target adapter (managed: stops Chrome; attach:
|
|
5
|
+
* disconnects only), and frees the project's profile lock. Thin handler:
|
|
6
|
+
* Zod-validate, call {@link DebugApi.end}, ack.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { toToolResult } from './result.js';
|
|
10
|
+
/** Build the `end_session` outer tool bound to the debug service. */
|
|
11
|
+
export function endSessionTool(service) {
|
|
12
|
+
return {
|
|
13
|
+
name: 'end_session',
|
|
14
|
+
register(server) {
|
|
15
|
+
server.registerTool('end_session', {
|
|
16
|
+
title: 'End the debug run',
|
|
17
|
+
description: 'Close the active run: abort the loop, release the target (managed Chrome is stopped; an ' +
|
|
18
|
+
'attached browser is only disconnected), and free the project lock so a new start_debug can ' +
|
|
19
|
+
'run. The last get_findings snapshot remains on disk.',
|
|
20
|
+
inputSchema: {
|
|
21
|
+
session_id: z.string().min(1).describe('The id returned by start_debug.'),
|
|
22
|
+
},
|
|
23
|
+
}, async (args) => toToolResult(await service.end(args)));
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=end-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"end-session.js","sourceRoot":"","sources":["../../../src/mcp/tools/end-session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;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,0FAA0F;oBAC1F,6FAA6F;oBAC7F,sDAAsD;gBACxD,WAAW,EAAE;oBACX,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,iCAAiC,CAAC;iBAC1E;aACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CACtD,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `get_findings` — poll a run's status + structured findings + evidence.
|
|
3
|
+
*
|
|
4
|
+
* Reads the live snapshot the loop flushes incrementally. `wait` long-polls until
|
|
5
|
+
* the run settles a verdict (or the timeout elapses); `fields` projects a subset
|
|
6
|
+
* to keep the payload small. Thin handler: Zod-validate, call
|
|
7
|
+
* {@link DebugApi.getFindings}.
|
|
8
|
+
*/
|
|
9
|
+
import type { DebugApi } from '../../services/debug-service.js';
|
|
10
|
+
import type { McpTool } from '../server.js';
|
|
11
|
+
/** Build the `get_findings` outer tool bound to the debug service. */
|
|
12
|
+
export declare function getFindingsTool(service: DebugApi): McpTool;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `get_findings` — poll a run's status + structured findings + evidence.
|
|
3
|
+
*
|
|
4
|
+
* Reads the live snapshot the loop flushes incrementally. `wait` long-polls until
|
|
5
|
+
* the run settles a verdict (or the timeout elapses); `fields` projects a subset
|
|
6
|
+
* to keep the payload small. Thin handler: Zod-validate, call
|
|
7
|
+
* {@link DebugApi.getFindings}.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { FindingsSchema } from '../../findings/schema.js';
|
|
11
|
+
import { toToolResult } from './result.js';
|
|
12
|
+
/** Selectable top-level findings keys, derived from the findings schema. */
|
|
13
|
+
const FindingsField = FindingsSchema.keyof();
|
|
14
|
+
/** Build the `get_findings` outer tool bound to the debug service. */
|
|
15
|
+
export function getFindingsTool(service) {
|
|
16
|
+
return {
|
|
17
|
+
name: 'get_findings',
|
|
18
|
+
register(server) {
|
|
19
|
+
server.registerTool('get_findings', {
|
|
20
|
+
title: 'Get run findings',
|
|
21
|
+
description: 'Poll the run: status (running|passed|failed) plus structured findings — the step trail, ' +
|
|
22
|
+
'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.',
|
|
24
|
+
inputSchema: {
|
|
25
|
+
session_id: z.string().min(1).describe('The id returned by start_debug.'),
|
|
26
|
+
wait: z
|
|
27
|
+
.number()
|
|
28
|
+
.int()
|
|
29
|
+
.min(0)
|
|
30
|
+
.max(120_000)
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('Long-poll up to this many ms for a terminal verdict before reading. Omit/0 to read now.'),
|
|
33
|
+
fields: z
|
|
34
|
+
.array(FindingsField)
|
|
35
|
+
.optional()
|
|
36
|
+
.describe('Project a subset of findings keys (e.g. ["status","bugs"]). Omit for the whole object.'),
|
|
37
|
+
},
|
|
38
|
+
}, async (args) => toToolResult(await service.getFindings(args)));
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=get-findings.js.map
|
|
@@ -0,0 +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,0FAA0F;gBAC5F,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,QAAQ,EAAE;yBACV,QAAQ,CACP,wFAAwF,CACzF;iBACJ;aACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAC9D,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The five outer conversational tools, assembled over one {@link DebugApi}.
|
|
3
|
+
*
|
|
4
|
+
* Boot calls {@link outerTools} and hands the list to `startStdioServer`. The
|
|
5
|
+
* server stays tool-blind; this is the single place the catalog is enumerated —
|
|
6
|
+
* `start_debug`, `send_message`, `get_findings`, `describe`, `end_session`.
|
|
7
|
+
*/
|
|
8
|
+
import type { DebugApi } from '../../services/debug-service.js';
|
|
9
|
+
import type { McpTool } from '../server.js';
|
|
10
|
+
import { describeTool } from './describe.js';
|
|
11
|
+
import { endSessionTool } from './end-session.js';
|
|
12
|
+
import { getFindingsTool } from './get-findings.js';
|
|
13
|
+
import { sendMessageTool } from './send-message.js';
|
|
14
|
+
import { startDebugTool } from './start-debug.js';
|
|
15
|
+
/** Build all five outer tools bound to the debug service, in catalog order. */
|
|
16
|
+
export declare function outerTools(service: DebugApi): McpTool[];
|
|
17
|
+
export { describeTool, endSessionTool, getFindingsTool, sendMessageTool, startDebugTool };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The five outer conversational tools, assembled over one {@link DebugApi}.
|
|
3
|
+
*
|
|
4
|
+
* Boot calls {@link outerTools} and hands the list to `startStdioServer`. The
|
|
5
|
+
* server stays tool-blind; this is the single place the catalog is enumerated —
|
|
6
|
+
* `start_debug`, `send_message`, `get_findings`, `describe`, `end_session`.
|
|
7
|
+
*/
|
|
8
|
+
import { describeTool } from './describe.js';
|
|
9
|
+
import { endSessionTool } from './end-session.js';
|
|
10
|
+
import { getFindingsTool } from './get-findings.js';
|
|
11
|
+
import { sendMessageTool } from './send-message.js';
|
|
12
|
+
import { startDebugTool } from './start-debug.js';
|
|
13
|
+
/** Build all five outer tools bound to the debug service, in catalog order. */
|
|
14
|
+
export function outerTools(service) {
|
|
15
|
+
return [
|
|
16
|
+
startDebugTool(service),
|
|
17
|
+
sendMessageTool(service),
|
|
18
|
+
getFindingsTool(service),
|
|
19
|
+
describeTool(service),
|
|
20
|
+
endSessionTool(service),
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
export { describeTool, endSessionTool, getFindingsTool, sendMessageTool, startDebugTool };
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,OAAiB;IAC1C,OAAO;QACL,cAAc,CAAC,OAAO,CAAC;QACvB,eAAe,CAAC,OAAO,CAAC;QACxB,eAAe,CAAC,OAAO,CAAC;QACxB,YAAY,CAAC,OAAO,CAAC;QACrB,cAAc,CAAC,OAAO,CAAC;KACxB,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outer-tool result shaping — the one place a service value becomes a
|
|
3
|
+
* {@link CallToolResult}. Every outer tool returns a record, so the value rides
|
|
4
|
+
* back BOTH as pretty-printed `text` (human/log readable) and as
|
|
5
|
+
* `structuredContent` (the typed channel MCP clients parse). Keeps the five tool
|
|
6
|
+
* handlers a single `toToolResult(await service.x(args))` line each.
|
|
7
|
+
*/
|
|
8
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
9
|
+
/** Wrap a service result as a tool response: pretty `text` plus `structuredContent` for records. */
|
|
10
|
+
export declare function toToolResult(data: unknown): CallToolResult;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outer-tool result shaping — the one place a service value becomes a
|
|
3
|
+
* {@link CallToolResult}. Every outer tool returns a record, so the value rides
|
|
4
|
+
* back BOTH as pretty-printed `text` (human/log readable) and as
|
|
5
|
+
* `structuredContent` (the typed channel MCP clients parse). Keeps the five tool
|
|
6
|
+
* handlers a single `toToolResult(await service.x(args))` line each.
|
|
7
|
+
*/
|
|
8
|
+
/** A plain object value (not an array) — what every outer tool returns. */
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
/** Wrap a service result as a tool response: pretty `text` plus `structuredContent` for records. */
|
|
13
|
+
export function toToolResult(data) {
|
|
14
|
+
const text = JSON.stringify(data, null, 2);
|
|
15
|
+
return {
|
|
16
|
+
content: [{ type: 'text', text }],
|
|
17
|
+
...(isRecord(data) ? { structuredContent: data } : {}),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../src/mcp/tools/result.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;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,oGAAoG;AACpG,MAAM,UAAU,YAAY,CAAC,IAAa;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3C,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACjC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `send_message` — talk to the running driver mid-run.
|
|
3
|
+
*
|
|
4
|
+
* Injects an instruction the loop folds in before its next step (add work,
|
|
5
|
+
* redirect, answer a question). Thin handler: Zod-validate, call
|
|
6
|
+
* {@link DebugApi.send}, ack.
|
|
7
|
+
*/
|
|
8
|
+
import type { DebugApi } from '../../services/debug-service.js';
|
|
9
|
+
import type { McpTool } from '../server.js';
|
|
10
|
+
/** Build the `send_message` outer tool bound to the debug service. */
|
|
11
|
+
export declare function sendMessageTool(service: DebugApi): McpTool;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `send_message` — talk to the running driver mid-run.
|
|
3
|
+
*
|
|
4
|
+
* Injects an instruction the loop folds in before its next step (add work,
|
|
5
|
+
* redirect, answer a question). Thin handler: Zod-validate, call
|
|
6
|
+
* {@link DebugApi.send}, ack.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { toToolResult } from './result.js';
|
|
10
|
+
/** Build the `send_message` outer tool bound to the debug service. */
|
|
11
|
+
export function sendMessageTool(service) {
|
|
12
|
+
return {
|
|
13
|
+
name: 'send_message',
|
|
14
|
+
register(server) {
|
|
15
|
+
server.registerTool('send_message', {
|
|
16
|
+
title: 'Message the running run',
|
|
17
|
+
description: 'Talk to the small driver agent mid-run: add work, redirect it, or answer a question. ' +
|
|
18
|
+
'The message is folded into the conversation before the next step — the run keeps going, ' +
|
|
19
|
+
'no restart. Use get_findings to see the effect.',
|
|
20
|
+
inputSchema: {
|
|
21
|
+
session_id: z.string().min(1).describe('The id returned by start_debug.'),
|
|
22
|
+
message: z
|
|
23
|
+
.string()
|
|
24
|
+
.min(1)
|
|
25
|
+
.describe('The instruction for the driver, in plain language (e.g. "skip checkout, the bug is the login form").'),
|
|
26
|
+
},
|
|
27
|
+
}, (args) => toToolResult(service.send(args)));
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=send-message.js.map
|
|
@@ -0,0 +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;aACF,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAC3C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `start_debug` — open a debug session for a configured target.
|
|
3
|
+
*
|
|
4
|
+
* Hands the small driver agent a goal (the "story"); it drives the UI
|
|
5
|
+
* autonomously and reports findings. One run per project (cwd) at a time. Thin
|
|
6
|
+
* handler: Zod-validate the raw shape, call {@link DebugApi.start}, shape the
|
|
7
|
+
* `{ session_id }` result.
|
|
8
|
+
*/
|
|
9
|
+
import type { DebugApi } from '../../services/debug-service.js';
|
|
10
|
+
import type { McpTool } from '../server.js';
|
|
11
|
+
/** Build the `start_debug` outer tool bound to the debug service. */
|
|
12
|
+
export declare function startDebugTool(service: DebugApi): McpTool;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `start_debug` — open a debug session for a configured target.
|
|
3
|
+
*
|
|
4
|
+
* Hands the small driver agent a goal (the "story"); it drives the UI
|
|
5
|
+
* autonomously and reports findings. One run per project (cwd) at a time. Thin
|
|
6
|
+
* handler: Zod-validate the raw shape, call {@link DebugApi.start}, shape the
|
|
7
|
+
* `{ session_id }` result.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { toToolResult } from './result.js';
|
|
11
|
+
/** Build the `start_debug` outer tool bound to the debug service. */
|
|
12
|
+
export function startDebugTool(service) {
|
|
13
|
+
return {
|
|
14
|
+
name: 'start_debug',
|
|
15
|
+
register(server) {
|
|
16
|
+
server.registerTool('start_debug', {
|
|
17
|
+
title: 'Start a debug run',
|
|
18
|
+
description: 'Open a debug session: hand the small driver agent a goal for a configured target ' +
|
|
19
|
+
'(e.g. "web"). It drives the UI autonomously and gathers findings (functional bugs + ' +
|
|
20
|
+
'visual feedback). One run per project at a time. Returns { session_id }; then poll ' +
|
|
21
|
+
'get_findings, steer with send_message, and close with end_session.',
|
|
22
|
+
inputSchema: {
|
|
23
|
+
target: z
|
|
24
|
+
.string()
|
|
25
|
+
.min(1)
|
|
26
|
+
.describe('Configured target name (a key in .ui-debugger-mcp.json targets, e.g. "web"). See describe.'),
|
|
27
|
+
goal: z
|
|
28
|
+
.string()
|
|
29
|
+
.min(1)
|
|
30
|
+
.describe('The story: what to accomplish, in plain language (e.g. "log in and add item 3 to the cart").'),
|
|
31
|
+
criteria: z
|
|
32
|
+
.string()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe('Optional explicit pass/fail rules, one per line. Omit to let the agent judge.'),
|
|
35
|
+
timeout: z
|
|
36
|
+
.number()
|
|
37
|
+
.int()
|
|
38
|
+
.positive()
|
|
39
|
+
.max(2_147_483)
|
|
40
|
+
.optional()
|
|
41
|
+
.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).'),
|
|
42
|
+
},
|
|
43
|
+
}, async ({ timeout, ...rest }) => toToolResult(await service.start({
|
|
44
|
+
...rest,
|
|
45
|
+
...(timeout !== undefined && { timeoutMs: timeout * 1000 }),
|
|
46
|
+
})));
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=start-debug.js.map
|
|
@@ -0,0 +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,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,8JAA8J,CAC/J;iBACJ;aACF,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"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug service — the business logic behind the five outer MCP tools.
|
|
3
|
+
*
|
|
4
|
+
* One conversational surface over one project (cwd): start a run, talk to it
|
|
5
|
+
* mid-flight, poll its findings, list targets, end it. Holds the cwd-keyed
|
|
6
|
+
* {@link SessionManager} (the one-run-per-project gate) and the resolved config,
|
|
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. The MCP
|
|
9
|
+
* handlers stay thin: validate input, call straight through to a method here.
|
|
10
|
+
*
|
|
11
|
+
* Sessions are keyed by cwd, but the tools speak `session_id`. Every id-bearing
|
|
12
|
+
* call resolves the active session for the cwd and fails loud
|
|
13
|
+
* ({@link SessionNotFoundError}) when the id does not match, so a stale id never
|
|
14
|
+
* silently drives the wrong run.
|
|
15
|
+
*/
|
|
16
|
+
import type { ResolvedConfig } from '../config/load.js';
|
|
17
|
+
import type { Target } from '../config/schema.js';
|
|
18
|
+
import type { Findings } from '../findings/schema.js';
|
|
19
|
+
import type { SessionManager } from '../session/manager.js';
|
|
20
|
+
import type { Session, SnapshotField } from '../session/session.js';
|
|
21
|
+
import { type StatePort } from '../session/state-file.js';
|
|
22
|
+
import type { SessionBuilder } from './session-builder.js';
|
|
23
|
+
/** Default wall-clock cap on a debug run before it auto-ends (overridable per run). */
|
|
24
|
+
export declare const DEFAULT_SESSION_TIMEOUT_MS = 300000;
|
|
25
|
+
/** `start_debug` input — open a run for a configured target. */
|
|
26
|
+
export interface StartInput {
|
|
27
|
+
target: string;
|
|
28
|
+
goal: string;
|
|
29
|
+
criteria?: string;
|
|
30
|
+
/** Wall-clock cap (ms) before the run auto-ends; defaults to {@link DEFAULT_SESSION_TIMEOUT_MS}. */
|
|
31
|
+
timeoutMs?: number;
|
|
32
|
+
}
|
|
33
|
+
/** `start_debug` output — the id to poll/redirect/end the run by. */
|
|
34
|
+
export interface StartResult {
|
|
35
|
+
session_id: string;
|
|
36
|
+
}
|
|
37
|
+
/** `send_message` input — inject a mid-run instruction. */
|
|
38
|
+
export interface SendInput {
|
|
39
|
+
session_id: string;
|
|
40
|
+
message: string;
|
|
41
|
+
}
|
|
42
|
+
/** `send_message` / `end_session` acknowledgement. */
|
|
43
|
+
export interface Ack {
|
|
44
|
+
ok: true;
|
|
45
|
+
session_id: string;
|
|
46
|
+
}
|
|
47
|
+
/** `get_findings` input — snapshot (optionally long-poll / project a subset). */
|
|
48
|
+
export interface GetFindingsInput {
|
|
49
|
+
session_id: string;
|
|
50
|
+
wait?: number;
|
|
51
|
+
fields?: SnapshotField[];
|
|
52
|
+
}
|
|
53
|
+
/** `describe` input — the whole catalog, or one target when named. */
|
|
54
|
+
export interface DescribeInput {
|
|
55
|
+
target?: string;
|
|
56
|
+
}
|
|
57
|
+
/** One target's public shape in the catalog (secrets stay out). */
|
|
58
|
+
export interface TargetInfo {
|
|
59
|
+
name: string;
|
|
60
|
+
adapter: Target['adapter'];
|
|
61
|
+
/** `managed` = the server launches/owns it; `attach` = it connects to a running one. */
|
|
62
|
+
mode: 'managed' | 'attach';
|
|
63
|
+
/** Whether this adapter is wired yet (only `browser` today). */
|
|
64
|
+
operational: boolean;
|
|
65
|
+
/** Web target entry url, when applicable. */
|
|
66
|
+
url?: string;
|
|
67
|
+
/** Web headless flag, when applicable. */
|
|
68
|
+
headless?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** `describe` output — configured targets plus the resolved models + workspace. */
|
|
71
|
+
export interface DescribeResult {
|
|
72
|
+
targets: TargetInfo[];
|
|
73
|
+
models: {
|
|
74
|
+
driver: string;
|
|
75
|
+
vision: string;
|
|
76
|
+
summary: string;
|
|
77
|
+
};
|
|
78
|
+
workspace: string;
|
|
79
|
+
}
|
|
80
|
+
/** The surface the outer MCP tools call. Implemented by {@link DebugService}. */
|
|
81
|
+
export interface DebugApi {
|
|
82
|
+
start(input: StartInput): Promise<StartResult>;
|
|
83
|
+
send(input: SendInput): Ack;
|
|
84
|
+
getFindings(input: GetFindingsInput): Promise<Findings | Partial<Findings>>;
|
|
85
|
+
describe(input: DescribeInput): DescribeResult;
|
|
86
|
+
end(input: EndInput): Promise<Ack>;
|
|
87
|
+
}
|
|
88
|
+
/** `end_session` input. */
|
|
89
|
+
export interface EndInput {
|
|
90
|
+
session_id: string;
|
|
91
|
+
}
|
|
92
|
+
/** Everything the service needs, wired at boot. */
|
|
93
|
+
export interface DebugServiceDeps {
|
|
94
|
+
/** The cwd-keyed registry (one run per project). */
|
|
95
|
+
manager: SessionManager<Session>;
|
|
96
|
+
/** Resolved project config — backs `describe` + target validation. */
|
|
97
|
+
config: ResolvedConfig;
|
|
98
|
+
/** This project's session key (one project = one cwd = one session). */
|
|
99
|
+
cwd: string;
|
|
100
|
+
/** Seam to the heavy session assembly; injected so `start` stays testable. */
|
|
101
|
+
build: SessionBuilder;
|
|
102
|
+
/** Cross-process run breadcrumb (`state.json`) for the CLI; defaults to a no-op. */
|
|
103
|
+
state?: StatePort;
|
|
104
|
+
/** Default wall-clock cap (ms) for a run; defaults to {@link DEFAULT_SESSION_TIMEOUT_MS}. */
|
|
105
|
+
defaultTimeoutMs?: number;
|
|
106
|
+
/** Injected clock (epoch ms) for session ids; defaults to `Date.now`. */
|
|
107
|
+
now?: () => number;
|
|
108
|
+
}
|
|
109
|
+
export declare class DebugService implements DebugApi {
|
|
110
|
+
#private;
|
|
111
|
+
constructor(deps: DebugServiceDeps);
|
|
112
|
+
/**
|
|
113
|
+
* Open a run: assemble the session, take the profile lock, point the adapter at
|
|
114
|
+
* the target, and kick the loop off in the background. Fails loud if a run is
|
|
115
|
+
* already active for this cwd ({@link SessionBusyError}); never leaks a launched
|
|
116
|
+
* browser — a lost lock race or a failed `open` tears the session back down.
|
|
117
|
+
*/
|
|
118
|
+
start({ target, goal, criteria, timeoutMs }: StartInput): Promise<StartResult>;
|
|
119
|
+
/** Queue a mid-run instruction for the active run's driver. */
|
|
120
|
+
send({ session_id, message }: SendInput): Ack;
|
|
121
|
+
/** Snapshot the run's findings — optionally long-poll (`wait`) and/or project a subset (`fields`). */
|
|
122
|
+
getFindings({ session_id, wait, fields, }: GetFindingsInput): Promise<Findings | Partial<Findings>>;
|
|
123
|
+
/** List configured targets (the whole catalog, or one when named) plus resolved models/workspace. */
|
|
124
|
+
describe({ target }: DescribeInput): DescribeResult;
|
|
125
|
+
/** End the active run: abort the loop, close the adapter, free the profile lock. */
|
|
126
|
+
end({ session_id }: EndInput): Promise<Ack>;
|
|
127
|
+
/**
|
|
128
|
+
* End whatever run is active for this cwd, if any — the graceful-shutdown path
|
|
129
|
+
* for a SIGTERM/SIGINT, a CLI `stop`, or the wall-clock timeout firing. No-op
|
|
130
|
+
* when nothing is running.
|
|
131
|
+
*/
|
|
132
|
+
endActive(): Promise<void>;
|
|
133
|
+
}
|