@agimon-ai/browse-tool 0.2.0 → 0.2.2
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 +69 -0
- package/dist/cli.cjs +24 -23
- package/dist/cli.mjs +23 -23
- package/dist/extension/background.js +1039 -339
- package/dist/extension/background.js.map +1 -1
- package/dist/extension/content.js +45 -4
- package/dist/extension/content.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -2
- package/dist/playwright-test-BwI7HgW7.mjs +1 -2
- package/dist/{playwright-test-CnsuVfC9.cjs → playwright-test-DTw_9rvK.cjs} +1 -1
- package/dist/stdio-DKou0TqY.cjs +10 -0
- package/dist/stdio-ELROpCD_.mjs +9 -0
- package/dist/stubs/playwright-test.cjs +1 -1
- package/package.json +12 -2
- package/dist/cli.d.cts +0 -1
- package/dist/cli.d.mts +0 -2
- package/dist/cli.mjs.map +0 -1
- package/dist/index.d.cts +0 -309
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -310
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/playwright-test-BwI7HgW7.mjs.map +0 -1
- package/dist/stdio-BP3yiSxK.mjs +0 -9
- package/dist/stdio-BP3yiSxK.mjs.map +0 -1
- package/dist/stdio-ynNFGBY4.cjs +0 -9
- package/dist/stubs/playwright-test.d.cts +0 -111
- package/dist/stubs/playwright-test.d.cts.map +0 -1
- package/dist/stubs/playwright-test.d.mts +0 -111
- package/dist/stubs/playwright-test.d.mts.map +0 -1
package/dist/index.d.cts
DELETED
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { Container } from "inversify";
|
|
2
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
-
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
//#region src/constants/playwright-types.d.ts
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* InversifyJS DI container binding tokens.
|
|
10
|
-
* Maps service names to unique Symbol identifiers for dependency injection.
|
|
11
|
-
*
|
|
12
|
-
* DESIGN PATTERNS:
|
|
13
|
-
* - Token map pattern for IoC container bindings
|
|
14
|
-
* - Uses named constants from service-ids to avoid magic strings
|
|
15
|
-
* - Frozen object (as const) to prevent runtime modification
|
|
16
|
-
*
|
|
17
|
-
* CODING STANDARDS:
|
|
18
|
-
* - Import service ID constants instead of using inline strings
|
|
19
|
-
* - Keep in sync with container module registrations
|
|
20
|
-
* - Use Symbol.for() for cross-module symbol sharing
|
|
21
|
-
*
|
|
22
|
-
* AVOID:
|
|
23
|
-
* - Adding entries without corresponding container bindings
|
|
24
|
-
* - Using Symbol() instead of Symbol.for() (breaks cross-module resolution)
|
|
25
|
-
*/
|
|
26
|
-
declare const PLAYWRIGHT_TYPES: {
|
|
27
|
-
readonly ProfileService: symbol;
|
|
28
|
-
readonly PageRegistry: symbol;
|
|
29
|
-
readonly BrowserService: symbol;
|
|
30
|
-
readonly ElementLocatorService: symbol;
|
|
31
|
-
readonly PageMonitorService: symbol;
|
|
32
|
-
readonly PauseController: symbol;
|
|
33
|
-
readonly AutomationRunner: symbol;
|
|
34
|
-
readonly SpecRunner: symbol;
|
|
35
|
-
readonly SpecBundlerService: symbol;
|
|
36
|
-
readonly SpecDiscoveryService: symbol;
|
|
37
|
-
readonly SpecMetadataService: symbol;
|
|
38
|
-
readonly SetupRunner: symbol;
|
|
39
|
-
readonly WebServerManager: symbol;
|
|
40
|
-
readonly Logger: symbol;
|
|
41
|
-
readonly HttpServerHealthCheck: symbol;
|
|
42
|
-
readonly HttpServerManager: symbol;
|
|
43
|
-
readonly HttpBrowserClient: symbol;
|
|
44
|
-
readonly RemoteToolExecutor: symbol;
|
|
45
|
-
readonly ExtensionTaskQueue: symbol;
|
|
46
|
-
readonly ExtensionToolDelegator: symbol;
|
|
47
|
-
readonly ToolExecutor: symbol;
|
|
48
|
-
readonly StealthLauncher: symbol;
|
|
49
|
-
readonly BrowserLockManager: symbol;
|
|
50
|
-
readonly ExtensionSessionRegistry: symbol;
|
|
51
|
-
readonly ExtensionPageProxy: symbol;
|
|
52
|
-
readonly ExtensionSpecRunner: symbol;
|
|
53
|
-
readonly McpSessionTracker: symbol;
|
|
54
|
-
readonly ChromeForTestingService: symbol;
|
|
55
|
-
readonly WebSocketHub: symbol;
|
|
56
|
-
readonly IdleCleanupService: symbol;
|
|
57
|
-
readonly PortRegistryService: symbol;
|
|
58
|
-
readonly Tool: symbol;
|
|
59
|
-
};
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region src/container/index.d.ts
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @deprecated Use createMcpContainer() or createHttpContainer() instead.
|
|
65
|
-
*/
|
|
66
|
-
declare const container: Container;
|
|
67
|
-
/**
|
|
68
|
-
* @deprecated Use createMcpContainer() or createHttpContainer() instead.
|
|
69
|
-
*/
|
|
70
|
-
declare function createContainer(): Container;
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/server/index.d.ts
|
|
73
|
-
|
|
74
|
-
/** Logger interface for dependency injection */
|
|
75
|
-
interface Logger {
|
|
76
|
-
debug(message: string, context?: Record<string, unknown>): void;
|
|
77
|
-
info(message: string, context?: Record<string, unknown>): void;
|
|
78
|
-
warn(message: string, context?: Record<string, unknown>): void;
|
|
79
|
-
error(message: string, context?: Record<string, unknown>): void;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Error thrown when an unknown tool is requested.
|
|
83
|
-
* Provides error code, recovery suggestion, and available tools list.
|
|
84
|
-
*/
|
|
85
|
-
declare class UnknownToolError extends Error {
|
|
86
|
-
readonly code = "UNKNOWN_TOOL";
|
|
87
|
-
readonly recovery = "Use ListTools to see available tools.";
|
|
88
|
-
readonly availableTools: string[];
|
|
89
|
-
constructor(toolName: string, availableTools: string[], options?: ErrorOptions);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Error thrown when tool execution fails.
|
|
93
|
-
* Provides error code, tool name context, and recovery suggestion.
|
|
94
|
-
*/
|
|
95
|
-
declare class ToolExecutionError extends Error {
|
|
96
|
-
readonly code = "TOOL_EXECUTION_ERROR";
|
|
97
|
-
readonly recovery: string;
|
|
98
|
-
readonly toolName: string;
|
|
99
|
-
constructor(toolName: string, message: string, options?: ErrorOptions & {
|
|
100
|
-
recovery?: string;
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Configuration options for the MCP server.
|
|
105
|
-
*/
|
|
106
|
-
interface ServerConfig {
|
|
107
|
-
/** Optional IoC container (defaults to the shared container) */
|
|
108
|
-
container?: Container;
|
|
109
|
-
/** Optional logger for debugging and error tracking */
|
|
110
|
-
logger?: Logger;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Creates a new MCP server instance with tools from the IoC container.
|
|
114
|
-
* @param config - Optional server configuration
|
|
115
|
-
* @returns Configured MCP Server instance
|
|
116
|
-
*/
|
|
117
|
-
declare function createServer(config?: ServerConfig): Server;
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region src/transports/stdio.d.ts
|
|
120
|
-
/**
|
|
121
|
-
* Stdio transport handler for MCP server
|
|
122
|
-
* Used for command-line and direct integrations
|
|
123
|
-
*/
|
|
124
|
-
declare class StdioTransportHandler {
|
|
125
|
-
private server;
|
|
126
|
-
private transport;
|
|
127
|
-
constructor(server: Server);
|
|
128
|
-
start(): Promise<void>;
|
|
129
|
-
stop(): Promise<void>;
|
|
130
|
-
}
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/validation/tool-definition.d.ts
|
|
133
|
-
declare const JSON_SCHEMA_TYPES: readonly ["object", "string", "number", "boolean", "array", "integer", "null"];
|
|
134
|
-
declare const ToolDefinitionSchema: z.ZodObject<{
|
|
135
|
-
name: z.ZodString;
|
|
136
|
-
description: z.ZodString;
|
|
137
|
-
inputSchema: z.ZodObject<{
|
|
138
|
-
type: z.ZodEnum<{
|
|
139
|
-
string: "string";
|
|
140
|
-
number: "number";
|
|
141
|
-
boolean: "boolean";
|
|
142
|
-
object: "object";
|
|
143
|
-
array: "array";
|
|
144
|
-
integer: "integer";
|
|
145
|
-
null: "null";
|
|
146
|
-
}>;
|
|
147
|
-
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
148
|
-
required: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
149
|
-
additionalProperties: z.ZodOptional<z.ZodBoolean>;
|
|
150
|
-
}, z.core.$strip>;
|
|
151
|
-
}, z.core.$strip>;
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/types/spec.d.ts
|
|
154
|
-
/**
|
|
155
|
-
* Spec Types - Type definitions for enhanced spec execution
|
|
156
|
-
*
|
|
157
|
-
* DESIGN PATTERNS:
|
|
158
|
-
* - Interface-based type definitions for type safety
|
|
159
|
-
* - Separation of concerns: metadata, config, filtering, project info
|
|
160
|
-
*
|
|
161
|
-
* CODING STANDARDS:
|
|
162
|
-
* - All interfaces have JSDoc documentation
|
|
163
|
-
* - Types use 'interface' for object shapes
|
|
164
|
-
* - Optional properties marked with '?'
|
|
165
|
-
*
|
|
166
|
-
* AVOID:
|
|
167
|
-
* - Using 'type' for object shapes (prefer interface)
|
|
168
|
-
* - Using 'any' type
|
|
169
|
-
*/
|
|
170
|
-
/**
|
|
171
|
-
* Generic schema interface for argument validation.
|
|
172
|
-
* Compatible with Zod schemas - uses parse method for validation.
|
|
173
|
-
*/
|
|
174
|
-
interface ArgsSchema {
|
|
175
|
-
/** Parse and validate input data, throws on invalid input */
|
|
176
|
-
parse(data: unknown): Record<string, unknown>;
|
|
177
|
-
/** Safe parse that returns success/error result */
|
|
178
|
-
safeParse?(data: unknown): {
|
|
179
|
-
success: boolean;
|
|
180
|
-
data?: Record<string, unknown>;
|
|
181
|
-
error?: unknown;
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Metadata extracted from a spec file.
|
|
186
|
-
* Contains information about dynamic arguments and environment prefix.
|
|
187
|
-
*/
|
|
188
|
-
interface SpecMetadata {
|
|
189
|
-
/** Schema for spec arguments validation (compatible with Zod) */
|
|
190
|
-
argsSchema: ArgsSchema | null;
|
|
191
|
-
/** Environment variable prefix for argument parsing (e.g., 'SPEC_LOGIN_') */
|
|
192
|
-
envPrefix: string | null;
|
|
193
|
-
/** Whether the spec has dynamic arguments */
|
|
194
|
-
hasDynamicArgs: boolean;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Web server configuration for starting a dev server before running specs.
|
|
198
|
-
* Compatible with Playwright's webServer config.
|
|
199
|
-
*/
|
|
200
|
-
interface WebServerConfig {
|
|
201
|
-
/** Command to start the server (e.g., 'npm run dev') */
|
|
202
|
-
command: string;
|
|
203
|
-
/** URL to wait for before running tests */
|
|
204
|
-
url: string;
|
|
205
|
-
/** Whether to reuse an existing server if one is running */
|
|
206
|
-
reuseExistingServer?: boolean;
|
|
207
|
-
/** Timeout in milliseconds to wait for the server to start */
|
|
208
|
-
timeout?: number;
|
|
209
|
-
/** Working directory for the server command */
|
|
210
|
-
cwd?: string;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Playwright MCP configuration extracted from playwright.config.ts.
|
|
214
|
-
* Contains MCP-specific settings for spec execution.
|
|
215
|
-
*/
|
|
216
|
-
interface PlaywrightMcpConfig {
|
|
217
|
-
/** Base URL for relative navigation */
|
|
218
|
-
baseURL?: string;
|
|
219
|
-
/** Path to setup file to run before specs */
|
|
220
|
-
setupFile?: string;
|
|
221
|
-
/** Export name in setup file (default: 'default') */
|
|
222
|
-
setupExport?: string;
|
|
223
|
-
/** Web server configuration */
|
|
224
|
-
webServer?: WebServerConfig;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Filter options for selecting which tests to run.
|
|
228
|
-
* Multiple filters are combined with AND logic.
|
|
229
|
-
*/
|
|
230
|
-
interface TestFilter {
|
|
231
|
-
/** Filter by exact test name */
|
|
232
|
-
testName?: string;
|
|
233
|
-
/** Filter by regex pattern on full test title */
|
|
234
|
-
testPattern?: string;
|
|
235
|
-
/** Run only tests marked with test.only() */
|
|
236
|
-
onlyMarked?: boolean;
|
|
237
|
-
/** Filter by describe block name pattern */
|
|
238
|
-
describeFilter?: string;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* E2E project configuration for multi-project test setups.
|
|
242
|
-
* Represents a logical grouping of specs within a project.
|
|
243
|
-
*/
|
|
244
|
-
interface E2EProject {
|
|
245
|
-
/** Project name (e.g., 'desktop', 'mobile') */
|
|
246
|
-
name: string;
|
|
247
|
-
/** Project root path */
|
|
248
|
-
path: string;
|
|
249
|
-
/** Path to playwright.config.ts */
|
|
250
|
-
configPath?: string;
|
|
251
|
-
/** Test directory relative to project path */
|
|
252
|
-
testDir?: string;
|
|
253
|
-
/** List of spec files in this project */
|
|
254
|
-
specs: SpecInfo[];
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Information about a single spec file.
|
|
258
|
-
* Used for listing and selecting specs to run.
|
|
259
|
-
*/
|
|
260
|
-
interface SpecInfo {
|
|
261
|
-
/** Spec file name without path */
|
|
262
|
-
name: string;
|
|
263
|
-
/** Absolute path to the spec file */
|
|
264
|
-
path: string;
|
|
265
|
-
/** Path relative to project root */
|
|
266
|
-
relativePath: string;
|
|
267
|
-
/** Whether the spec exports an argsSchema */
|
|
268
|
-
hasArgsSchema: boolean;
|
|
269
|
-
/** Number of tests in the spec */
|
|
270
|
-
testCount: number;
|
|
271
|
-
}
|
|
272
|
-
//#endregion
|
|
273
|
-
//#region src/types/index.d.ts
|
|
274
|
-
/**
|
|
275
|
-
* JSON Schema type values supported in tool input schemas
|
|
276
|
-
*/
|
|
277
|
-
type JsonSchemaType = (typeof JSON_SCHEMA_TYPES)[number];
|
|
278
|
-
/**
|
|
279
|
-
* Tool definition for MCP, derived from Zod schema
|
|
280
|
-
*/
|
|
281
|
-
type ToolDefinition = z.infer<typeof ToolDefinitionSchema>;
|
|
282
|
-
/**
|
|
283
|
-
* Structured success result from tool execution
|
|
284
|
-
*/
|
|
285
|
-
interface ToolSuccessResult extends CallToolResult {
|
|
286
|
-
isError: false;
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Structured failure result from tool execution
|
|
290
|
-
*/
|
|
291
|
-
interface ToolFailureResult extends CallToolResult {
|
|
292
|
-
isError: true;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Discriminated union for tool execution outcomes
|
|
296
|
-
*/
|
|
297
|
-
type ToolResult = ToolSuccessResult | ToolFailureResult;
|
|
298
|
-
/**
|
|
299
|
-
* Base tool interface following MCP SDK patterns.
|
|
300
|
-
* Returns CallToolResult for SDK compatibility.
|
|
301
|
-
* Use ToolResult to narrow success/failure when isError is set.
|
|
302
|
-
*/
|
|
303
|
-
interface Tool<TInput = unknown> {
|
|
304
|
-
getDefinition(): ToolDefinition;
|
|
305
|
-
execute(input: TInput): Promise<CallToolResult>;
|
|
306
|
-
}
|
|
307
|
-
//#endregion
|
|
308
|
-
export { type ArgsSchema, type E2EProject, JsonSchemaType, type Logger, PLAYWRIGHT_TYPES, type PlaywrightMcpConfig, type ServerConfig, type SpecInfo, type SpecMetadata, StdioTransportHandler, type TestFilter, Tool, ToolDefinition, ToolExecutionError, ToolFailureResult, ToolResult, ToolSuccessResult, UnknownToolError, type WebServerConfig, container, createContainer, createServer };
|
|
309
|
-
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/constants/playwright-types.ts","../src/container/index.ts","../src/server/index.ts","../src/transports/stdio.ts","../src/validation/tool-definition.ts","../src/types/spec.ts","../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAsDA;;;;AC6PA;AASA;;;;AC7RA;;;AAGkC,cFoBrB,gBEpBqB,EAAA;EACC,SAAA,c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;;;;;;;UDwChB,UAAA;;;;;;;;;;SAUR;;;;;;UAOQ,QAAA;;;;;;;;;;;;;;;;ALvDjB;KMnCY,cAAA,WAAyB;;;ALgSrC;AASgB,KKpSJ,cAAA,GAAiB,CAAA,CAAE,KLoSI,CAAA,OKpSS,oBLoSA,CAAA;;;;AC7R3B,UIFA,iBAAA,SAA0B,cJEpB,CAAA;EACY,OAAA,EAAA,KAAA;;;;;AAuBtB,UInBI,iBAAA,SAA0B,cJmBA,CAAA;EAmB9B,OAAA,EAAA,IAAA;AAoBb;AAuDA;;;KI1GY,UAAA,GAAa,oBAAoB;AHN7C;;;;;UGaiB;mBACE;iBACF,SAAS,QAAQ;AF/BlC"}
|
package/dist/index.d.mts
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import "reflect-metadata/lite";
|
|
2
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
-
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
-
import { Container, ContainerModule } from "inversify";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
|
|
7
|
-
//#region src/constants/playwright-types.d.ts
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* InversifyJS DI container binding tokens.
|
|
11
|
-
* Maps service names to unique Symbol identifiers for dependency injection.
|
|
12
|
-
*
|
|
13
|
-
* DESIGN PATTERNS:
|
|
14
|
-
* - Token map pattern for IoC container bindings
|
|
15
|
-
* - Uses named constants from service-ids to avoid magic strings
|
|
16
|
-
* - Frozen object (as const) to prevent runtime modification
|
|
17
|
-
*
|
|
18
|
-
* CODING STANDARDS:
|
|
19
|
-
* - Import service ID constants instead of using inline strings
|
|
20
|
-
* - Keep in sync with container module registrations
|
|
21
|
-
* - Use Symbol.for() for cross-module symbol sharing
|
|
22
|
-
*
|
|
23
|
-
* AVOID:
|
|
24
|
-
* - Adding entries without corresponding container bindings
|
|
25
|
-
* - Using Symbol() instead of Symbol.for() (breaks cross-module resolution)
|
|
26
|
-
*/
|
|
27
|
-
declare const PLAYWRIGHT_TYPES: {
|
|
28
|
-
readonly ProfileService: symbol;
|
|
29
|
-
readonly PageRegistry: symbol;
|
|
30
|
-
readonly BrowserService: symbol;
|
|
31
|
-
readonly ElementLocatorService: symbol;
|
|
32
|
-
readonly PageMonitorService: symbol;
|
|
33
|
-
readonly PauseController: symbol;
|
|
34
|
-
readonly AutomationRunner: symbol;
|
|
35
|
-
readonly SpecRunner: symbol;
|
|
36
|
-
readonly SpecBundlerService: symbol;
|
|
37
|
-
readonly SpecDiscoveryService: symbol;
|
|
38
|
-
readonly SpecMetadataService: symbol;
|
|
39
|
-
readonly SetupRunner: symbol;
|
|
40
|
-
readonly WebServerManager: symbol;
|
|
41
|
-
readonly Logger: symbol;
|
|
42
|
-
readonly HttpServerHealthCheck: symbol;
|
|
43
|
-
readonly HttpServerManager: symbol;
|
|
44
|
-
readonly HttpBrowserClient: symbol;
|
|
45
|
-
readonly RemoteToolExecutor: symbol;
|
|
46
|
-
readonly ExtensionTaskQueue: symbol;
|
|
47
|
-
readonly ExtensionToolDelegator: symbol;
|
|
48
|
-
readonly ToolExecutor: symbol;
|
|
49
|
-
readonly StealthLauncher: symbol;
|
|
50
|
-
readonly BrowserLockManager: symbol;
|
|
51
|
-
readonly ExtensionSessionRegistry: symbol;
|
|
52
|
-
readonly ExtensionPageProxy: symbol;
|
|
53
|
-
readonly ExtensionSpecRunner: symbol;
|
|
54
|
-
readonly McpSessionTracker: symbol;
|
|
55
|
-
readonly ChromeForTestingService: symbol;
|
|
56
|
-
readonly WebSocketHub: symbol;
|
|
57
|
-
readonly IdleCleanupService: symbol;
|
|
58
|
-
readonly PortRegistryService: symbol;
|
|
59
|
-
readonly Tool: symbol;
|
|
60
|
-
};
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/container/index.d.ts
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated Use createMcpContainer() or createHttpContainer() instead.
|
|
66
|
-
*/
|
|
67
|
-
declare const container: Container;
|
|
68
|
-
/**
|
|
69
|
-
* @deprecated Use createMcpContainer() or createHttpContainer() instead.
|
|
70
|
-
*/
|
|
71
|
-
declare function createContainer(): Container;
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/server/index.d.ts
|
|
74
|
-
|
|
75
|
-
/** Logger interface for dependency injection */
|
|
76
|
-
interface Logger {
|
|
77
|
-
debug(message: string, context?: Record<string, unknown>): void;
|
|
78
|
-
info(message: string, context?: Record<string, unknown>): void;
|
|
79
|
-
warn(message: string, context?: Record<string, unknown>): void;
|
|
80
|
-
error(message: string, context?: Record<string, unknown>): void;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Error thrown when an unknown tool is requested.
|
|
84
|
-
* Provides error code, recovery suggestion, and available tools list.
|
|
85
|
-
*/
|
|
86
|
-
declare class UnknownToolError extends Error {
|
|
87
|
-
readonly code = "UNKNOWN_TOOL";
|
|
88
|
-
readonly recovery = "Use ListTools to see available tools.";
|
|
89
|
-
readonly availableTools: string[];
|
|
90
|
-
constructor(toolName: string, availableTools: string[], options?: ErrorOptions);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Error thrown when tool execution fails.
|
|
94
|
-
* Provides error code, tool name context, and recovery suggestion.
|
|
95
|
-
*/
|
|
96
|
-
declare class ToolExecutionError extends Error {
|
|
97
|
-
readonly code = "TOOL_EXECUTION_ERROR";
|
|
98
|
-
readonly recovery: string;
|
|
99
|
-
readonly toolName: string;
|
|
100
|
-
constructor(toolName: string, message: string, options?: ErrorOptions & {
|
|
101
|
-
recovery?: string;
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Configuration options for the MCP server.
|
|
106
|
-
*/
|
|
107
|
-
interface ServerConfig {
|
|
108
|
-
/** Optional IoC container (defaults to the shared container) */
|
|
109
|
-
container?: Container;
|
|
110
|
-
/** Optional logger for debugging and error tracking */
|
|
111
|
-
logger?: Logger;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Creates a new MCP server instance with tools from the IoC container.
|
|
115
|
-
* @param config - Optional server configuration
|
|
116
|
-
* @returns Configured MCP Server instance
|
|
117
|
-
*/
|
|
118
|
-
declare function createServer(config?: ServerConfig): Server;
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/transports/stdio.d.ts
|
|
121
|
-
/**
|
|
122
|
-
* Stdio transport handler for MCP server
|
|
123
|
-
* Used for command-line and direct integrations
|
|
124
|
-
*/
|
|
125
|
-
declare class StdioTransportHandler {
|
|
126
|
-
private server;
|
|
127
|
-
private transport;
|
|
128
|
-
constructor(server: Server);
|
|
129
|
-
start(): Promise<void>;
|
|
130
|
-
stop(): Promise<void>;
|
|
131
|
-
}
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/validation/tool-definition.d.ts
|
|
134
|
-
declare const JSON_SCHEMA_TYPES: readonly ["object", "string", "number", "boolean", "array", "integer", "null"];
|
|
135
|
-
declare const ToolDefinitionSchema: z.ZodObject<{
|
|
136
|
-
name: z.ZodString;
|
|
137
|
-
description: z.ZodString;
|
|
138
|
-
inputSchema: z.ZodObject<{
|
|
139
|
-
type: z.ZodEnum<{
|
|
140
|
-
string: "string";
|
|
141
|
-
number: "number";
|
|
142
|
-
boolean: "boolean";
|
|
143
|
-
object: "object";
|
|
144
|
-
array: "array";
|
|
145
|
-
integer: "integer";
|
|
146
|
-
null: "null";
|
|
147
|
-
}>;
|
|
148
|
-
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
149
|
-
required: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
150
|
-
additionalProperties: z.ZodOptional<z.ZodBoolean>;
|
|
151
|
-
}, z.core.$strip>;
|
|
152
|
-
}, z.core.$strip>;
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/types/spec.d.ts
|
|
155
|
-
/**
|
|
156
|
-
* Spec Types - Type definitions for enhanced spec execution
|
|
157
|
-
*
|
|
158
|
-
* DESIGN PATTERNS:
|
|
159
|
-
* - Interface-based type definitions for type safety
|
|
160
|
-
* - Separation of concerns: metadata, config, filtering, project info
|
|
161
|
-
*
|
|
162
|
-
* CODING STANDARDS:
|
|
163
|
-
* - All interfaces have JSDoc documentation
|
|
164
|
-
* - Types use 'interface' for object shapes
|
|
165
|
-
* - Optional properties marked with '?'
|
|
166
|
-
*
|
|
167
|
-
* AVOID:
|
|
168
|
-
* - Using 'type' for object shapes (prefer interface)
|
|
169
|
-
* - Using 'any' type
|
|
170
|
-
*/
|
|
171
|
-
/**
|
|
172
|
-
* Generic schema interface for argument validation.
|
|
173
|
-
* Compatible with Zod schemas - uses parse method for validation.
|
|
174
|
-
*/
|
|
175
|
-
interface ArgsSchema {
|
|
176
|
-
/** Parse and validate input data, throws on invalid input */
|
|
177
|
-
parse(data: unknown): Record<string, unknown>;
|
|
178
|
-
/** Safe parse that returns success/error result */
|
|
179
|
-
safeParse?(data: unknown): {
|
|
180
|
-
success: boolean;
|
|
181
|
-
data?: Record<string, unknown>;
|
|
182
|
-
error?: unknown;
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Metadata extracted from a spec file.
|
|
187
|
-
* Contains information about dynamic arguments and environment prefix.
|
|
188
|
-
*/
|
|
189
|
-
interface SpecMetadata {
|
|
190
|
-
/** Schema for spec arguments validation (compatible with Zod) */
|
|
191
|
-
argsSchema: ArgsSchema | null;
|
|
192
|
-
/** Environment variable prefix for argument parsing (e.g., 'SPEC_LOGIN_') */
|
|
193
|
-
envPrefix: string | null;
|
|
194
|
-
/** Whether the spec has dynamic arguments */
|
|
195
|
-
hasDynamicArgs: boolean;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Web server configuration for starting a dev server before running specs.
|
|
199
|
-
* Compatible with Playwright's webServer config.
|
|
200
|
-
*/
|
|
201
|
-
interface WebServerConfig {
|
|
202
|
-
/** Command to start the server (e.g., 'npm run dev') */
|
|
203
|
-
command: string;
|
|
204
|
-
/** URL to wait for before running tests */
|
|
205
|
-
url: string;
|
|
206
|
-
/** Whether to reuse an existing server if one is running */
|
|
207
|
-
reuseExistingServer?: boolean;
|
|
208
|
-
/** Timeout in milliseconds to wait for the server to start */
|
|
209
|
-
timeout?: number;
|
|
210
|
-
/** Working directory for the server command */
|
|
211
|
-
cwd?: string;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Playwright MCP configuration extracted from playwright.config.ts.
|
|
215
|
-
* Contains MCP-specific settings for spec execution.
|
|
216
|
-
*/
|
|
217
|
-
interface PlaywrightMcpConfig {
|
|
218
|
-
/** Base URL for relative navigation */
|
|
219
|
-
baseURL?: string;
|
|
220
|
-
/** Path to setup file to run before specs */
|
|
221
|
-
setupFile?: string;
|
|
222
|
-
/** Export name in setup file (default: 'default') */
|
|
223
|
-
setupExport?: string;
|
|
224
|
-
/** Web server configuration */
|
|
225
|
-
webServer?: WebServerConfig;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Filter options for selecting which tests to run.
|
|
229
|
-
* Multiple filters are combined with AND logic.
|
|
230
|
-
*/
|
|
231
|
-
interface TestFilter {
|
|
232
|
-
/** Filter by exact test name */
|
|
233
|
-
testName?: string;
|
|
234
|
-
/** Filter by regex pattern on full test title */
|
|
235
|
-
testPattern?: string;
|
|
236
|
-
/** Run only tests marked with test.only() */
|
|
237
|
-
onlyMarked?: boolean;
|
|
238
|
-
/** Filter by describe block name pattern */
|
|
239
|
-
describeFilter?: string;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* E2E project configuration for multi-project test setups.
|
|
243
|
-
* Represents a logical grouping of specs within a project.
|
|
244
|
-
*/
|
|
245
|
-
interface E2EProject {
|
|
246
|
-
/** Project name (e.g., 'desktop', 'mobile') */
|
|
247
|
-
name: string;
|
|
248
|
-
/** Project root path */
|
|
249
|
-
path: string;
|
|
250
|
-
/** Path to playwright.config.ts */
|
|
251
|
-
configPath?: string;
|
|
252
|
-
/** Test directory relative to project path */
|
|
253
|
-
testDir?: string;
|
|
254
|
-
/** List of spec files in this project */
|
|
255
|
-
specs: SpecInfo[];
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Information about a single spec file.
|
|
259
|
-
* Used for listing and selecting specs to run.
|
|
260
|
-
*/
|
|
261
|
-
interface SpecInfo {
|
|
262
|
-
/** Spec file name without path */
|
|
263
|
-
name: string;
|
|
264
|
-
/** Absolute path to the spec file */
|
|
265
|
-
path: string;
|
|
266
|
-
/** Path relative to project root */
|
|
267
|
-
relativePath: string;
|
|
268
|
-
/** Whether the spec exports an argsSchema */
|
|
269
|
-
hasArgsSchema: boolean;
|
|
270
|
-
/** Number of tests in the spec */
|
|
271
|
-
testCount: number;
|
|
272
|
-
}
|
|
273
|
-
//#endregion
|
|
274
|
-
//#region src/types/index.d.ts
|
|
275
|
-
/**
|
|
276
|
-
* JSON Schema type values supported in tool input schemas
|
|
277
|
-
*/
|
|
278
|
-
type JsonSchemaType = (typeof JSON_SCHEMA_TYPES)[number];
|
|
279
|
-
/**
|
|
280
|
-
* Tool definition for MCP, derived from Zod schema
|
|
281
|
-
*/
|
|
282
|
-
type ToolDefinition = z.infer<typeof ToolDefinitionSchema>;
|
|
283
|
-
/**
|
|
284
|
-
* Structured success result from tool execution
|
|
285
|
-
*/
|
|
286
|
-
interface ToolSuccessResult extends CallToolResult {
|
|
287
|
-
isError: false;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Structured failure result from tool execution
|
|
291
|
-
*/
|
|
292
|
-
interface ToolFailureResult extends CallToolResult {
|
|
293
|
-
isError: true;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Discriminated union for tool execution outcomes
|
|
297
|
-
*/
|
|
298
|
-
type ToolResult = ToolSuccessResult | ToolFailureResult;
|
|
299
|
-
/**
|
|
300
|
-
* Base tool interface following MCP SDK patterns.
|
|
301
|
-
* Returns CallToolResult for SDK compatibility.
|
|
302
|
-
* Use ToolResult to narrow success/failure when isError is set.
|
|
303
|
-
*/
|
|
304
|
-
interface Tool<TInput = unknown> {
|
|
305
|
-
getDefinition(): ToolDefinition;
|
|
306
|
-
execute(input: TInput): Promise<CallToolResult>;
|
|
307
|
-
}
|
|
308
|
-
//#endregion
|
|
309
|
-
export { type ArgsSchema, type E2EProject, JsonSchemaType, type Logger, PLAYWRIGHT_TYPES, type PlaywrightMcpConfig, type ServerConfig, type SpecInfo, type SpecMetadata, StdioTransportHandler, type TestFilter, Tool, ToolDefinition, ToolExecutionError, ToolFailureResult, ToolResult, ToolSuccessResult, UnknownToolError, type WebServerConfig, container, createContainer, createServer };
|
|
310
|
-
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/constants/playwright-types.ts","../src/container/index.ts","../src/server/index.ts","../src/transports/stdio.ts","../src/validation/tool-definition.ts","../src/types/spec.ts","../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;AAsDA;;;;AC6PA;AASA;;;;AC7RA;;AAEkC,cFqBrB,gBErBqB,EAAA;EACA,SAAA,cAAA,EAAA,MAAA;EACC,SAAA,YAAA,EAAA,MAAA;EAAM,SAAA,cAAA,EAAA,MAAA;EAoB5B,SAAA,qBAAiB,EAKsC,MAAA;EAcvD,SAAA,kBAAmB,EAAA,MAK2B;EAe1C,SAAA,eAAY,EAAA,MAEf;EAqDE,SAAA,gBAAY,EAAU,MAAA;;;;EChHzB,SAAA,mBAAqB,EAAA,MAAA;EAIZ,SAAA,WAAA,EAAA,MAAA;EAIL,SAAA,gBAAA,EAAA,MAAA;EAqBD,SAAA,MAAA,EAAA,MAAA;EAAO,SAAA,qBAAA,EAAA,MAAA;;;;EC7CV,SAAA,kBAAkG,EAAA,MAAA;EAElG,SAAA,sBASX,EAAA,MAAA;;;;;;;;;;;;;;;;;AC6CF;AAeA;AAiBA;cJsMa,WAAS;;;AKh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,cAAA,GAAiB,CAAA,CAAE,KL2RT,CAAA,OK3RsB,oBL6R1C,CAAA;AAOF;;;UK/RiB,iBAAA,SAA0B;EJE1B,OAAA,EAAM,KAAA;;;;;AAIkB,UICxB,iBAAA,SAA0B,cJDF,CAAA;EAoB5B,OAAA,EAAA,IAAA;AAmBb;AAoBA;AAuDA;;KI1GY,UAAA,GAAa,oBAAoB;;AHN7C;;;;AA6BuB,UGhBN,IHgBM,CAAA,SAAA,OAAA,CAAA,CAAA;mBGfJ;iBACF,SAAS,QAAQ"}
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["defaultContainer"],"sources":["../src/server/index.ts"],"sourcesContent":["/**\n * MCP Server Setup\n *\n * DESIGN PATTERNS:\n * - Factory pattern for server creation with IoC container\n * - Tool registry pattern for fast lookup\n * - Structured error handling with custom error classes\n *\n * CODING STANDARDS:\n * - Tools are loaded from IoC container on server creation\n * - Proper error handling in all request handlers with custom error classes\n * - Errors include codes, recovery suggestions, and available tools list\n *\n * AVOID:\n * - Hardcoded tool lists (use IoC container)\n * - Missing error handling in handlers\n * - Generic error messages without recovery suggestions\n */\n\nimport { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';\nimport type { Container } from 'inversify';\nimport { PLAYWRIGHT_TYPES, container as defaultContainer } from '../container/index.js';\nimport type { Tool } from '../types/index.js';\n\n// ============================================================================\n// Logger Interface\n// ============================================================================\n\n/** Logger interface for dependency injection */\nexport interface Logger {\n debug(message: string, context?: Record<string, unknown>): void;\n info(message: string, context?: Record<string, unknown>): void;\n warn(message: string, context?: Record<string, unknown>): void;\n error(message: string, context?: Record<string, unknown>): void;\n}\n\n/**\n * Creates a no-op logger for silent operation.\n * @returns A logger implementation that discards all messages\n */\nfunction createNoopLogger(): Logger {\n const noop = (): void => undefined;\n return { debug: noop, info: noop, warn: noop, error: noop };\n}\n\n// ============================================================================\n// Error Classes\n// ============================================================================\n\n/**\n * Error thrown when an unknown tool is requested.\n * Provides error code, recovery suggestion, and available tools list.\n */\nexport class UnknownToolError extends Error {\n readonly code = 'UNKNOWN_TOOL';\n readonly recovery = 'Use ListTools to see available tools.';\n readonly availableTools: string[];\n\n constructor(toolName: string, availableTools: string[], options?: ErrorOptions) {\n super(\n `Unknown tool: ${toolName}. Available tools: ${availableTools.slice(0, 5).join(', ')}${availableTools.length > 5 ? `, ... (${availableTools.length} total)` : ''}. Use ListTools to see all available tools.`,\n options,\n );\n this.name = 'UnknownToolError';\n this.availableTools = availableTools;\n }\n}\n\n/**\n * Error thrown when tool execution fails.\n * Provides error code, tool name context, and recovery suggestion.\n */\nexport class ToolExecutionError extends Error {\n readonly code = 'TOOL_EXECUTION_ERROR';\n readonly recovery: string;\n readonly toolName: string;\n\n constructor(toolName: string, message: string, options?: ErrorOptions & { recovery?: string }) {\n super(`Tool execution failed for '${toolName}': ${message}`, options);\n this.name = 'ToolExecutionError';\n this.toolName = toolName;\n this.recovery = options?.recovery ?? 'Check tool inputs and try again.';\n }\n}\n\n// ============================================================================\n// Server Configuration\n// ============================================================================\n\n/**\n * Configuration options for the MCP server.\n */\nexport interface ServerConfig {\n /** Optional IoC container (defaults to the shared container) */\n container?: Container;\n /** Optional logger for debugging and error tracking */\n logger?: Logger;\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Creates a structured error response following MCP conventions.\n * Includes error codes, recovery suggestions, and context metadata.\n * @param error - The error that occurred\n * @param toolName - Name of the tool that failed\n * @returns CallToolResult with isError flag and structured error content\n */\nfunction createErrorResponse(error: unknown, toolName: string): CallToolResult {\n const message = error instanceof Error ? error.message : 'Unknown error occurred';\n const code = error instanceof Error && 'code' in error ? (error as { code: string }).code : 'TOOL_EXECUTION_ERROR';\n const recovery =\n error instanceof Error && 'recovery' in error\n ? (error as { recovery: string }).recovery\n : 'Check tool inputs and try again.';\n\n const errorResponse = {\n error: {\n code,\n message,\n toolName,\n recovery,\n },\n };\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(errorResponse, null, 2),\n },\n ],\n isError: true,\n };\n}\n\n// ============================================================================\n// Server Factory\n// ============================================================================\n\n/**\n * Creates a new MCP server instance with tools from the IoC container.\n * @param config - Optional server configuration\n * @returns Configured MCP Server instance\n */\nexport function createServer(config?: ServerConfig): Server {\n const iocContainer = config?.container ?? defaultContainer;\n const logger = config?.logger ?? createNoopLogger();\n\n const server = new Server(\n {\n name: 'browse-tool',\n version: '0.1.0',\n },\n {\n capabilities: {\n tools: {},\n },\n },\n );\n\n // Get all tools from the container\n const tools = iocContainer.getAll<Tool>(PLAYWRIGHT_TYPES.Tool);\n\n // Build tool map for fast lookup\n const toolMap = new Map<string, Tool>();\n for (const tool of tools) {\n const def = tool.getDefinition();\n toolMap.set(def.name, tool);\n }\n\n logger.info('MCP server initialized', { toolCount: tools.length });\n\n // List all available tools\n server.setRequestHandler(ListToolsRequestSchema, async () => {\n logger.debug('ListTools request received');\n return {\n tools: tools.map((tool) => tool.getDefinition()),\n };\n });\n\n // Execute tool by name\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n logger.debug('Tool call received', { toolName: name, timestamp: new Date().toISOString() });\n\n const tool = toolMap.get(name);\n\n if (!tool) {\n const availableTools = Array.from(toolMap.keys());\n logger.warn('Unknown tool requested', { toolName: name, availableTools, timestamp: new Date().toISOString() });\n throw new UnknownToolError(name, availableTools);\n }\n\n try {\n return await tool.execute(args);\n } catch (error) {\n // Wrap in ToolExecutionError for consistent error handling\n const toolError =\n error instanceof ToolExecutionError\n ? error\n : new ToolExecutionError(name, error instanceof Error ? error.message : String(error), { cause: error });\n\n logger.error('Tool execution failed', {\n toolName: name,\n error: toolError.message,\n code: toolError.code,\n timestamp: new Date().toISOString(),\n });\n return createErrorResponse(toolError, name);\n }\n });\n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