@superblocksteam/vite-plugin-file-sync 2.0.67-next.1 → 2.0.68-next.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/dist/ai-service/agent/tools/apis/analysis.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/analysis.js +4 -0
- package/dist/ai-service/agent/tools/apis/analysis.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-executor.d.ts +9 -1
- package/dist/ai-service/agent/tools/apis/api-executor.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-executor.js +4 -1
- package/dist/ai-service/agent/tools/apis/api-executor.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.d.ts +1 -0
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js +1 -1
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/test-api.d.ts +5 -0
- package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/test-api.js +9 -1
- package/dist/ai-service/agent/tools/apis/test-api.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/read.d.ts +1 -1
- package/dist/ai-service/index.d.ts +23 -2
- package/dist/ai-service/index.d.ts.map +1 -1
- package/dist/ai-service/index.js +99 -0
- package/dist/ai-service/index.js.map +1 -1
- package/dist/ai-service/judge/debug-browser.d.ts +8 -0
- package/dist/ai-service/judge/debug-browser.d.ts.map +1 -0
- package/dist/ai-service/judge/debug-browser.js +79 -0
- package/dist/ai-service/judge/debug-browser.js.map +1 -0
- package/dist/ai-service/judge/index.d.ts +12 -0
- package/dist/ai-service/judge/index.d.ts.map +1 -0
- package/dist/ai-service/judge/index.js +11 -0
- package/dist/ai-service/judge/index.js.map +1 -0
- package/dist/ai-service/judge/integration/mcp-client.d.ts +82 -0
- package/dist/ai-service/judge/integration/mcp-client.d.ts.map +1 -0
- package/dist/ai-service/judge/integration/mcp-client.js +276 -0
- package/dist/ai-service/judge/integration/mcp-client.js.map +1 -0
- package/dist/ai-service/judge/integration/playwright-bridge.d.ts +142 -0
- package/dist/ai-service/judge/integration/playwright-bridge.d.ts.map +1 -0
- package/dist/ai-service/judge/integration/playwright-bridge.js +217 -0
- package/dist/ai-service/judge/integration/playwright-bridge.js.map +1 -0
- package/dist/ai-service/judge/judge-eval-http.d.ts +3 -0
- package/dist/ai-service/judge/judge-eval-http.d.ts.map +1 -0
- package/dist/ai-service/judge/judge-eval-http.js +541 -0
- package/dist/ai-service/judge/judge-eval-http.js.map +1 -0
- package/dist/ai-service/judge/judge-eval-service-runner.d.ts +35 -0
- package/dist/ai-service/judge/judge-eval-service-runner.d.ts.map +1 -0
- package/dist/ai-service/judge/judge-eval-service-runner.js +124 -0
- package/dist/ai-service/judge/judge-eval-service-runner.js.map +1 -0
- package/dist/ai-service/judge/judge-executor.d.ts +65 -0
- package/dist/ai-service/judge/judge-executor.d.ts.map +1 -0
- package/dist/ai-service/judge/judge-executor.js +334 -0
- package/dist/ai-service/judge/judge-executor.js.map +1 -0
- package/dist/ai-service/judge/judge-service.d.ts +161 -0
- package/dist/ai-service/judge/judge-service.d.ts.map +1 -0
- package/dist/ai-service/judge/judge-service.js +241 -0
- package/dist/ai-service/judge/judge-service.js.map +1 -0
- package/dist/ai-service/judge/prompts/evaluation-criteria.d.ts +37 -0
- package/dist/ai-service/judge/prompts/evaluation-criteria.d.ts.map +1 -0
- package/dist/ai-service/judge/prompts/evaluation-criteria.js +283 -0
- package/dist/ai-service/judge/prompts/evaluation-criteria.js.map +1 -0
- package/dist/ai-service/judge/prompts/system-prompt.d.ts +30 -0
- package/dist/ai-service/judge/prompts/system-prompt.d.ts.map +1 -0
- package/dist/ai-service/judge/prompts/system-prompt.js +212 -0
- package/dist/ai-service/judge/prompts/system-prompt.js.map +1 -0
- package/dist/ai-service/judge/storage/csv-storage.d.ts +99 -0
- package/dist/ai-service/judge/storage/csv-storage.d.ts.map +1 -0
- package/dist/ai-service/judge/storage/csv-storage.js +274 -0
- package/dist/ai-service/judge/storage/csv-storage.js.map +1 -0
- package/dist/ai-service/judge/storage/index.d.ts +9 -0
- package/dist/ai-service/judge/storage/index.d.ts.map +1 -0
- package/dist/ai-service/judge/storage/index.js +7 -0
- package/dist/ai-service/judge/storage/index.js.map +1 -0
- package/dist/ai-service/judge/storage/interface.d.ts +51 -0
- package/dist/ai-service/judge/storage/interface.d.ts.map +1 -0
- package/dist/ai-service/judge/storage/interface.js +8 -0
- package/dist/ai-service/judge/storage/interface.js.map +1 -0
- package/dist/ai-service/judge/storage/types.d.ts +54 -0
- package/dist/ai-service/judge/storage/types.d.ts.map +1 -0
- package/dist/ai-service/judge/storage/types.js +7 -0
- package/dist/ai-service/judge/storage/types.js.map +1 -0
- package/dist/ai-service/judge/tools/index.d.ts +22 -0
- package/dist/ai-service/judge/tools/index.d.ts.map +1 -0
- package/dist/ai-service/judge/tools/index.js +29 -0
- package/dist/ai-service/judge/tools/index.js.map +1 -0
- package/dist/ai-service/judge/tools/playwright-action.d.ts +18 -0
- package/dist/ai-service/judge/tools/playwright-action.d.ts.map +1 -0
- package/dist/ai-service/judge/tools/playwright-action.js +171 -0
- package/dist/ai-service/judge/tools/playwright-action.js.map +1 -0
- package/dist/ai-service/judge/tools/submit-feedback.d.ts +41 -0
- package/dist/ai-service/judge/tools/submit-feedback.d.ts.map +1 -0
- package/dist/ai-service/judge/tools/submit-feedback.js +150 -0
- package/dist/ai-service/judge/tools/submit-feedback.js.map +1 -0
- package/dist/ai-service/judge/types.d.ts +169 -0
- package/dist/ai-service/judge/types.d.ts.map +1 -0
- package/dist/ai-service/judge/types.js +8 -0
- package/dist/ai-service/judge/types.js.map +1 -0
- package/dist/ai-service/llm/interaction/adapters/vercel.d.ts.map +1 -1
- package/dist/ai-service/llm/interaction/adapters/vercel.js.map +1 -1
- package/dist/ai-service/llm/interaction/provider.d.ts +10 -9
- package/dist/ai-service/llm/interaction/provider.d.ts.map +1 -1
- package/dist/ai-service/llmobs/middleware/stream-text.d.ts +8 -8
- package/dist/ai-service/llmobs/middleware/stream-text.d.ts.map +1 -1
- package/dist/ai-service/llmobs/middleware/stream-text.js.map +1 -1
- package/dist/ai-service/llmobs/tracer.d.ts.map +1 -1
- package/dist/ai-service/llmobs/tracer.js +2 -1
- package/dist/ai-service/llmobs/tracer.js.map +1 -1
- package/dist/ai-service/mcp/embedded-playwright-mcp-server.d.ts +53 -0
- package/dist/ai-service/mcp/embedded-playwright-mcp-server.d.ts.map +1 -0
- package/dist/ai-service/mcp/embedded-playwright-mcp-server.js +541 -0
- package/dist/ai-service/mcp/embedded-playwright-mcp-server.js.map +1 -0
- package/dist/ai-service/mcp/playwright-server.d.ts +114 -0
- package/dist/ai-service/mcp/playwright-server.d.ts.map +1 -0
- package/dist/ai-service/mcp/playwright-server.js +109 -0
- package/dist/ai-service/mcp/playwright-server.js.map +1 -0
- package/dist/server-rpc/client.js +1 -1
- package/dist/server-rpc/client.js.map +1 -1
- package/dist/socket-manager.d.ts.map +1 -1
- package/dist/socket-manager.js +8 -0
- package/dist/socket-manager.js.map +1 -1
- package/package.json +7 -6
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge between judge system and Playwright MCP server.
|
|
3
|
+
*
|
|
4
|
+
* Provides a high-level interface for browser automation
|
|
5
|
+
* through the MCP protocol.
|
|
6
|
+
*/
|
|
7
|
+
import type { Logger } from "../../../util/logger.js";
|
|
8
|
+
import type { PlaywrightActionParams, PlaywrightActionResult } from "../types.js";
|
|
9
|
+
/**
|
|
10
|
+
* High-level Playwright action parameters.
|
|
11
|
+
*/
|
|
12
|
+
export interface PlaywrightAction {
|
|
13
|
+
navigate?: {
|
|
14
|
+
url: string;
|
|
15
|
+
};
|
|
16
|
+
click?: {
|
|
17
|
+
selector: string;
|
|
18
|
+
};
|
|
19
|
+
fill?: {
|
|
20
|
+
selector: string;
|
|
21
|
+
value: string;
|
|
22
|
+
};
|
|
23
|
+
screenshot?: {
|
|
24
|
+
fullPage?: boolean;
|
|
25
|
+
};
|
|
26
|
+
getText?: {
|
|
27
|
+
selector: string;
|
|
28
|
+
};
|
|
29
|
+
waitForSelector?: {
|
|
30
|
+
selector: string;
|
|
31
|
+
timeout?: number;
|
|
32
|
+
};
|
|
33
|
+
evaluate?: {
|
|
34
|
+
script: string;
|
|
35
|
+
};
|
|
36
|
+
getUrl?: Record<string, never>;
|
|
37
|
+
reload?: Record<string, never>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Bridge to Playwright MCP server for browser automation.
|
|
41
|
+
*
|
|
42
|
+
* Provides a simplified interface for common browser
|
|
43
|
+
* automation tasks used by the judge system.
|
|
44
|
+
*/
|
|
45
|
+
export declare class PlaywrightBridge {
|
|
46
|
+
private logger;
|
|
47
|
+
private mcpClient;
|
|
48
|
+
constructor(serverUrl: string, logger: Logger);
|
|
49
|
+
/**
|
|
50
|
+
* Initializes the bridge connection.
|
|
51
|
+
*/
|
|
52
|
+
initialize(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Navigates to a URL.
|
|
55
|
+
*
|
|
56
|
+
* @param url - Target URL
|
|
57
|
+
* @returns Navigation result
|
|
58
|
+
*/
|
|
59
|
+
navigate(url: string): Promise<PlaywrightActionResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Clicks an element.
|
|
62
|
+
*
|
|
63
|
+
* @param selector - Element selector
|
|
64
|
+
* @returns Click result
|
|
65
|
+
*/
|
|
66
|
+
click(selector: string): Promise<PlaywrightActionResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Fills an input field.
|
|
69
|
+
*
|
|
70
|
+
* @param selector - Input selector
|
|
71
|
+
* @param value - Value to fill
|
|
72
|
+
* @returns Fill result
|
|
73
|
+
*/
|
|
74
|
+
fill(selector: string, value: string): Promise<PlaywrightActionResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Captures a screenshot.
|
|
77
|
+
*
|
|
78
|
+
* @param fullPage - Whether to capture full page
|
|
79
|
+
* @returns Screenshot result with base64 data
|
|
80
|
+
*/
|
|
81
|
+
screenshot(fullPage?: boolean): Promise<PlaywrightActionResult>;
|
|
82
|
+
/**
|
|
83
|
+
* Gets text content from an element.
|
|
84
|
+
*
|
|
85
|
+
* @param selector - Element selector
|
|
86
|
+
* @returns Text content
|
|
87
|
+
*/
|
|
88
|
+
getText(selector: string): Promise<PlaywrightActionResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Waits for a selector to appear.
|
|
91
|
+
*
|
|
92
|
+
* @param selector - Element selector
|
|
93
|
+
* @param timeout - Wait timeout in milliseconds
|
|
94
|
+
* @returns Wait result
|
|
95
|
+
*/
|
|
96
|
+
waitForSelector(selector: string, timeout?: number): Promise<PlaywrightActionResult>;
|
|
97
|
+
/**
|
|
98
|
+
* Evaluates JavaScript in the page context.
|
|
99
|
+
*
|
|
100
|
+
* @param script - JavaScript to execute
|
|
101
|
+
* @returns Evaluation result
|
|
102
|
+
*/
|
|
103
|
+
evaluate(script: string): Promise<PlaywrightActionResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Gets the current page URL.
|
|
106
|
+
*
|
|
107
|
+
* @returns Current URL
|
|
108
|
+
*/
|
|
109
|
+
getUrl(): Promise<PlaywrightActionResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Reloads the current page.
|
|
112
|
+
*
|
|
113
|
+
* @returns Reload result
|
|
114
|
+
*/
|
|
115
|
+
reload(): Promise<PlaywrightActionResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Executes a generic Playwright action.
|
|
118
|
+
*
|
|
119
|
+
* @param action - Action name
|
|
120
|
+
* @param params - Action parameters
|
|
121
|
+
* @returns Action result
|
|
122
|
+
*/
|
|
123
|
+
executeAction(action: PlaywrightActionParams["action"], params: Record<string, any>): Promise<PlaywrightActionResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Executes multiple actions in sequence.
|
|
126
|
+
*
|
|
127
|
+
* @param actions - Array of actions to execute
|
|
128
|
+
* @returns Results of all actions
|
|
129
|
+
*/
|
|
130
|
+
executeSequence(actions: PlaywrightAction[]): Promise<PlaywrightActionResult[]>;
|
|
131
|
+
/**
|
|
132
|
+
* Cleans up the bridge connection.
|
|
133
|
+
*/
|
|
134
|
+
cleanup(): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Checks if the bridge is connected.
|
|
137
|
+
*
|
|
138
|
+
* @returns True if connected
|
|
139
|
+
*/
|
|
140
|
+
isConnected(): boolean;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=playwright-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright-bridge.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/judge/integration/playwright-bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3B,KAAK,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7B,IAAI,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,UAAU,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACpC,OAAO,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,eAAe,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,QAAQ,CAA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ACxC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,OAAO,CAAC,sBAAsB,CAAC;IA2BlC;;;;;OAKG;IACG,eAAe,CACnB,OAAO,EAAE,gBAAgB,EAAE,GAC1B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IA6CpC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B;;;;OAIG;IACH,WAAW,IAAI,OAAO;CAGvB"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge between judge system and Playwright MCP server.
|
|
3
|
+
*
|
|
4
|
+
* Provides a high-level interface for browser automation
|
|
5
|
+
* through the MCP protocol.
|
|
6
|
+
*/
|
|
7
|
+
import { MCPClient } from "./mcp-client.js";
|
|
8
|
+
/**
|
|
9
|
+
* Bridge to Playwright MCP server for browser automation.
|
|
10
|
+
*
|
|
11
|
+
* Provides a simplified interface for common browser
|
|
12
|
+
* automation tasks used by the judge system.
|
|
13
|
+
*/
|
|
14
|
+
export class PlaywrightBridge {
|
|
15
|
+
logger;
|
|
16
|
+
mcpClient;
|
|
17
|
+
constructor(serverUrl, logger) {
|
|
18
|
+
this.logger = logger;
|
|
19
|
+
this.mcpClient = new MCPClient(serverUrl, logger);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Initializes the bridge connection.
|
|
23
|
+
*/
|
|
24
|
+
async initialize() {
|
|
25
|
+
await this.mcpClient.connect();
|
|
26
|
+
this.logger.info("Playwright bridge initialized");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Navigates to a URL.
|
|
30
|
+
*
|
|
31
|
+
* @param url - Target URL
|
|
32
|
+
* @returns Navigation result
|
|
33
|
+
*/
|
|
34
|
+
async navigate(url) {
|
|
35
|
+
return this.executeAction("navigate", { url });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Clicks an element.
|
|
39
|
+
*
|
|
40
|
+
* @param selector - Element selector
|
|
41
|
+
* @returns Click result
|
|
42
|
+
*/
|
|
43
|
+
async click(selector) {
|
|
44
|
+
return this.executeAction("click", { selector });
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fills an input field.
|
|
48
|
+
*
|
|
49
|
+
* @param selector - Input selector
|
|
50
|
+
* @param value - Value to fill
|
|
51
|
+
* @returns Fill result
|
|
52
|
+
*/
|
|
53
|
+
async fill(selector, value) {
|
|
54
|
+
return this.executeAction("fill", { selector, value });
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Captures a screenshot.
|
|
58
|
+
*
|
|
59
|
+
* @param fullPage - Whether to capture full page
|
|
60
|
+
* @returns Screenshot result with base64 data
|
|
61
|
+
*/
|
|
62
|
+
async screenshot(fullPage = false) {
|
|
63
|
+
return this.executeAction("screenshot", { fullPage });
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Gets text content from an element.
|
|
67
|
+
*
|
|
68
|
+
* @param selector - Element selector
|
|
69
|
+
* @returns Text content
|
|
70
|
+
*/
|
|
71
|
+
async getText(selector) {
|
|
72
|
+
return this.executeAction("getText", { selector });
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Waits for a selector to appear.
|
|
76
|
+
*
|
|
77
|
+
* @param selector - Element selector
|
|
78
|
+
* @param timeout - Wait timeout in milliseconds
|
|
79
|
+
* @returns Wait result
|
|
80
|
+
*/
|
|
81
|
+
async waitForSelector(selector, timeout = 30000) {
|
|
82
|
+
return this.executeAction("waitForSelector", { selector, timeout });
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Evaluates JavaScript in the page context.
|
|
86
|
+
*
|
|
87
|
+
* @param script - JavaScript to execute
|
|
88
|
+
* @returns Evaluation result
|
|
89
|
+
*/
|
|
90
|
+
async evaluate(script) {
|
|
91
|
+
this.logger.info(`Evaluate called - length: ${script.length}, preview: ${script.substring(0, 100)}`);
|
|
92
|
+
// Validate script doesn't contain module syntax
|
|
93
|
+
if (script.includes("import ") ||
|
|
94
|
+
script.includes("export ") ||
|
|
95
|
+
script.includes("require(")) {
|
|
96
|
+
this.logger.warn("Script contains module syntax", `Script preview: ${script.substring(0, 200)}`);
|
|
97
|
+
// Return error to the model instead of throwing
|
|
98
|
+
return {
|
|
99
|
+
success: false,
|
|
100
|
+
error: "Cannot use import/export/require statements in browser evaluate context. Use plain JavaScript only. For example, use 'document.querySelector' instead of importing libraries.",
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
this.logger.info("Script validation passed, executing action");
|
|
104
|
+
return this.executeAction("evaluate", { script });
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Gets the current page URL.
|
|
108
|
+
*
|
|
109
|
+
* @returns Current URL
|
|
110
|
+
*/
|
|
111
|
+
async getUrl() {
|
|
112
|
+
return this.executeAction("getUrl", {});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Reloads the current page.
|
|
116
|
+
*
|
|
117
|
+
* @returns Reload result
|
|
118
|
+
*/
|
|
119
|
+
async reload() {
|
|
120
|
+
return this.executeAction("reload", {});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Executes a generic Playwright action.
|
|
124
|
+
*
|
|
125
|
+
* @param action - Action name
|
|
126
|
+
* @param params - Action parameters
|
|
127
|
+
* @returns Action result
|
|
128
|
+
*/
|
|
129
|
+
async executeAction(action, params) {
|
|
130
|
+
this.logger.info(`Executing action: ${action}, params: ${Object.keys(params).join(", ")}`);
|
|
131
|
+
const actionParams = {
|
|
132
|
+
action,
|
|
133
|
+
params,
|
|
134
|
+
};
|
|
135
|
+
this.logger.info("Calling MCP client");
|
|
136
|
+
const result = await this.mcpClient.executePlaywrightAction(actionParams);
|
|
137
|
+
if (!result.success) {
|
|
138
|
+
this.logger.error("Action failed", {
|
|
139
|
+
error: {
|
|
140
|
+
kind: "PlaywrightActionError",
|
|
141
|
+
message: `Action ${action} failed: ${result.error || "Unknown error"}`,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
this.logger.info(`Action succeeded: ${action}`);
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Executes multiple actions in sequence.
|
|
152
|
+
*
|
|
153
|
+
* @param actions - Array of actions to execute
|
|
154
|
+
* @returns Results of all actions
|
|
155
|
+
*/
|
|
156
|
+
async executeSequence(actions) {
|
|
157
|
+
const results = [];
|
|
158
|
+
for (const action of actions) {
|
|
159
|
+
let result;
|
|
160
|
+
if (action.navigate) {
|
|
161
|
+
result = await this.navigate(action.navigate.url);
|
|
162
|
+
}
|
|
163
|
+
else if (action.click) {
|
|
164
|
+
result = await this.click(action.click.selector);
|
|
165
|
+
}
|
|
166
|
+
else if (action.fill) {
|
|
167
|
+
result = await this.fill(action.fill.selector, action.fill.value);
|
|
168
|
+
}
|
|
169
|
+
else if (action.screenshot) {
|
|
170
|
+
result = await this.screenshot(action.screenshot.fullPage);
|
|
171
|
+
}
|
|
172
|
+
else if (action.getText) {
|
|
173
|
+
result = await this.getText(action.getText.selector);
|
|
174
|
+
}
|
|
175
|
+
else if (action.waitForSelector) {
|
|
176
|
+
result = await this.waitForSelector(action.waitForSelector.selector, action.waitForSelector.timeout);
|
|
177
|
+
}
|
|
178
|
+
else if (action.evaluate) {
|
|
179
|
+
result = await this.evaluate(action.evaluate.script);
|
|
180
|
+
}
|
|
181
|
+
else if (action.getUrl) {
|
|
182
|
+
result = await this.getUrl();
|
|
183
|
+
}
|
|
184
|
+
else if (action.reload) {
|
|
185
|
+
result = await this.reload();
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
result = {
|
|
189
|
+
success: false,
|
|
190
|
+
error: "Unknown action type",
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
results.push(result);
|
|
194
|
+
// Stop sequence on failure
|
|
195
|
+
if (!result.success) {
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return results;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Cleans up the bridge connection.
|
|
203
|
+
*/
|
|
204
|
+
async cleanup() {
|
|
205
|
+
await this.mcpClient.disconnect();
|
|
206
|
+
this.logger.info("Playwright bridge cleaned up");
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Checks if the bridge is connected.
|
|
210
|
+
*
|
|
211
|
+
* @returns True if connected
|
|
212
|
+
*/
|
|
213
|
+
isConnected() {
|
|
214
|
+
return this.mcpClient.isConnected();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=playwright-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright-bridge.js","sourceRoot":"","sources":["../../../../src/ai-service/judge/integration/playwright-bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAsB5C;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAKjB;IAJF,SAAS,CAAY;IAE7B,YACE,SAAiB,EACT,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAEtB,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IACpD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,GAAW;QACxB,OAAO,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK,CAAC,QAAgB;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC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