testchimp-runner-core 0.0.1

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.
Files changed (74) hide show
  1. package/dist/auth-config.d.ts +33 -0
  2. package/dist/auth-config.d.ts.map +1 -0
  3. package/dist/auth-config.js +69 -0
  4. package/dist/auth-config.js.map +1 -0
  5. package/dist/env-loader.d.ts +20 -0
  6. package/dist/env-loader.d.ts.map +1 -0
  7. package/dist/env-loader.js +83 -0
  8. package/dist/env-loader.js.map +1 -0
  9. package/dist/execution-service.d.ts +61 -0
  10. package/dist/execution-service.d.ts.map +1 -0
  11. package/dist/execution-service.js +822 -0
  12. package/dist/execution-service.js.map +1 -0
  13. package/dist/file-handler.d.ts +59 -0
  14. package/dist/file-handler.d.ts.map +1 -0
  15. package/dist/file-handler.js +75 -0
  16. package/dist/file-handler.js.map +1 -0
  17. package/dist/index.d.ts +46 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +196 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/llm-facade.d.ts +101 -0
  22. package/dist/llm-facade.d.ts.map +1 -0
  23. package/dist/llm-facade.js +289 -0
  24. package/dist/llm-facade.js.map +1 -0
  25. package/dist/playwright-mcp-service.d.ts +42 -0
  26. package/dist/playwright-mcp-service.d.ts.map +1 -0
  27. package/dist/playwright-mcp-service.js +167 -0
  28. package/dist/playwright-mcp-service.js.map +1 -0
  29. package/dist/prompts.d.ts +34 -0
  30. package/dist/prompts.d.ts.map +1 -0
  31. package/dist/prompts.js +237 -0
  32. package/dist/prompts.js.map +1 -0
  33. package/dist/scenario-service.d.ts +25 -0
  34. package/dist/scenario-service.d.ts.map +1 -0
  35. package/dist/scenario-service.js +119 -0
  36. package/dist/scenario-service.js.map +1 -0
  37. package/dist/scenario-worker-class.d.ts +30 -0
  38. package/dist/scenario-worker-class.d.ts.map +1 -0
  39. package/dist/scenario-worker-class.js +263 -0
  40. package/dist/scenario-worker-class.js.map +1 -0
  41. package/dist/script-utils.d.ts +44 -0
  42. package/dist/script-utils.d.ts.map +1 -0
  43. package/dist/script-utils.js +100 -0
  44. package/dist/script-utils.js.map +1 -0
  45. package/dist/types.d.ts +171 -0
  46. package/dist/types.d.ts.map +1 -0
  47. package/dist/types.js +28 -0
  48. package/dist/types.js.map +1 -0
  49. package/dist/utils/browser-utils.d.ts +13 -0
  50. package/dist/utils/browser-utils.d.ts.map +1 -0
  51. package/dist/utils/browser-utils.js +269 -0
  52. package/dist/utils/browser-utils.js.map +1 -0
  53. package/dist/utils/page-info-utils.d.ts +16 -0
  54. package/dist/utils/page-info-utils.d.ts.map +1 -0
  55. package/dist/utils/page-info-utils.js +77 -0
  56. package/dist/utils/page-info-utils.js.map +1 -0
  57. package/env.prod +1 -0
  58. package/env.staging +1 -0
  59. package/package.json +38 -0
  60. package/src/auth-config.ts +84 -0
  61. package/src/env-loader.ts +91 -0
  62. package/src/execution-service.ts +999 -0
  63. package/src/file-handler.ts +104 -0
  64. package/src/index.ts +205 -0
  65. package/src/llm-facade.ts +413 -0
  66. package/src/playwright-mcp-service.ts +203 -0
  67. package/src/prompts.ts +247 -0
  68. package/src/scenario-service.ts +138 -0
  69. package/src/scenario-worker-class.ts +330 -0
  70. package/src/script-utils.ts +109 -0
  71. package/src/types.ts +202 -0
  72. package/src/utils/browser-utils.ts +272 -0
  73. package/src/utils/page-info-utils.ts +93 -0
  74. package/tsconfig.json +19 -0
@@ -0,0 +1,263 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScenarioWorker = void 0;
4
+ const page_info_utils_1 = require("./utils/page-info-utils");
5
+ const browser_utils_1 = require("./utils/browser-utils");
6
+ const llm_facade_1 = require("./llm-facade");
7
+ const script_utils_1 = require("./script-utils");
8
+ const MAX_RETRIES_PER_STEP = 2;
9
+ class ScenarioWorker {
10
+ constructor(fileHandler, authConfig, outputChannel) {
11
+ this.initialized = false;
12
+ this.sessionId = null;
13
+ this.llmFacade = new llm_facade_1.LLMFacade(authConfig);
14
+ this.fileHandler = fileHandler;
15
+ this.outputChannel = outputChannel;
16
+ }
17
+ log(message) {
18
+ console.log(message);
19
+ if (this.outputChannel) {
20
+ this.outputChannel.appendLine(`[ScenarioWorker] ${message}`);
21
+ }
22
+ }
23
+ logError(message) {
24
+ console.error(message);
25
+ if (this.outputChannel) {
26
+ this.outputChannel.appendLine(`[ScenarioWorker] ERROR: ${message}`);
27
+ }
28
+ }
29
+ async initialize() {
30
+ try {
31
+ this.log('Initializing Scenario worker...');
32
+ this.sessionId = `scenario_worker_${Date.now()}`;
33
+ this.initialized = true;
34
+ this.log(`Scenario worker initialized with session: ${this.sessionId}`);
35
+ }
36
+ catch (error) {
37
+ this.logError(`Scenario worker initialization error: ${error}`);
38
+ throw error;
39
+ }
40
+ }
41
+ async processScenarioJob(job) {
42
+ if (!this.initialized) {
43
+ throw new Error('Scenario worker not initialized');
44
+ }
45
+ const startTime = Date.now();
46
+ const steps = [];
47
+ let generatedScript = '';
48
+ let scriptPath;
49
+ let browser;
50
+ let context;
51
+ let page;
52
+ let overallSuccess = true;
53
+ try {
54
+ // 1. Break down scenario into steps using LLM
55
+ const scenarioSteps = await this.llmFacade.breakdownScenario(job.scenario, job.model);
56
+ steps.push(...scenarioSteps);
57
+ // 2. Start a new browser session using centralized utility
58
+ // Default to headed mode (headless: false) for better debugging
59
+ const browserInstance = await (0, browser_utils_1.initializeBrowser)(job.playwrightConfig, false);
60
+ browser = browserInstance.browser;
61
+ context = browserInstance.context;
62
+ page = browserInstance.page;
63
+ // Set reasonable timeout for all operations
64
+ page.setDefaultTimeout(5000); // 5 seconds
65
+ let previousSteps = [];
66
+ let lastError;
67
+ // 3. Execute each step
68
+ for (let i = 0; i < steps.length; i++) {
69
+ const step = steps[i];
70
+ step.stepNumber = i + 1;
71
+ step.retryCount = 0;
72
+ let stepSuccess = false;
73
+ let stepOutput = '';
74
+ let stepError;
75
+ for (let attempt = 0; attempt <= MAX_RETRIES_PER_STEP; attempt++) {
76
+ let currentAttemptCommand;
77
+ let currentAttemptSuccess = false;
78
+ let currentAttemptError;
79
+ const attemptTimestamp = Date.now();
80
+ try {
81
+ this.log(`Attempt ${attempt + 1} for step: ${step.description}`);
82
+ // Get current page state using Playwright's accessibility tree
83
+ const domSnapshot = {
84
+ url: page.url(),
85
+ title: await page.title(),
86
+ accessibilityTree: await page.accessibility.snapshot()
87
+ };
88
+ // Generate Playwright command using LLM
89
+ const pageInfo = await (0, page_info_utils_1.getEnhancedPageInfo)(domSnapshot);
90
+ const command = await this.llmFacade.generatePlaywrightCommand(step.description, pageInfo, previousSteps, lastError, step, job.model);
91
+ if (!command) {
92
+ throw new Error('LLM failed to generate a Playwright command.');
93
+ }
94
+ step.playwrightCommand = command;
95
+ currentAttemptCommand = command;
96
+ this.log(` Command: ${command}`);
97
+ // Execute the command
98
+ await this.executePlaywrightCommand(page, browser, context, command);
99
+ stepSuccess = true;
100
+ currentAttemptSuccess = true;
101
+ stepOutput = `Executed: ${command}`;
102
+ stepError = undefined;
103
+ this.log(` ✅ SUCCESS: ${command}`);
104
+ break; // Step successful, move to next scenario step
105
+ }
106
+ catch (error) {
107
+ stepError = error instanceof Error ? error.message : String(error);
108
+ currentAttemptError = stepError;
109
+ console.error(` ❌ FAILED (attempt ${attempt + 1}): ${stepError}`);
110
+ console.error(` Command attempted: ${currentAttemptCommand || 'N/A'}`);
111
+ step.retryCount++;
112
+ // Only update lastError if this is the final attempt
113
+ if (attempt === MAX_RETRIES_PER_STEP) {
114
+ lastError = stepError;
115
+ }
116
+ // If this is the last attempt, mark as failed and move on
117
+ if (attempt === MAX_RETRIES_PER_STEP) {
118
+ stepSuccess = false;
119
+ stepOutput = `Failed after ${MAX_RETRIES_PER_STEP + 1} attempts.`;
120
+ overallSuccess = false;
121
+ console.error(` 🚫 STEP FAILED after ${MAX_RETRIES_PER_STEP + 1} attempts`);
122
+ break; // Exit retry loop
123
+ }
124
+ }
125
+ finally {
126
+ if (!step.attempts) {
127
+ step.attempts = [];
128
+ }
129
+ step.attempts.push({
130
+ attemptNumber: attempt + 1,
131
+ command: currentAttemptCommand,
132
+ success: currentAttemptSuccess,
133
+ error: currentAttemptError,
134
+ timestamp: attemptTimestamp
135
+ });
136
+ }
137
+ }
138
+ step.success = stepSuccess;
139
+ step.error = stepError;
140
+ previousSteps.push(step);
141
+ }
142
+ // Generate test name if not provided
143
+ const testName = job.testName || await this.llmFacade.generateTestName(job.scenario, job.model);
144
+ // Generate preferred filename
145
+ let preferredFileName;
146
+ if (testName && testName !== 'test') {
147
+ // Use the generated test name
148
+ const sanitizedName = testName
149
+ .replace(/[^a-zA-Z0-9\s-_]/g, '') // Remove special characters except spaces, hyphens, underscores
150
+ .replace(/\s+/g, '_') // Replace spaces with underscores
151
+ .replace(/_+/g, '_') // Replace multiple underscores with single underscore
152
+ .replace(/^_|_$/g, '') // Remove leading/trailing underscores
153
+ .toLowerCase();
154
+ preferredFileName = `${sanitizedName}.spec.js`;
155
+ }
156
+ else {
157
+ // Use scenario file name if no meaningful test name was generated
158
+ const scenarioFileName = job.scenarioFileName || 'scenario';
159
+ const baseName = scenarioFileName.replace(/\.[^/.]+$/, ''); // Remove extension
160
+ const sanitizedName = baseName
161
+ .replace(/[^a-zA-Z0-9\s-_]/g, '') // Remove special characters except spaces, hyphens, underscores
162
+ .replace(/\s+/g, '_') // Replace spaces with underscores
163
+ .replace(/_+/g, '_') // Replace multiple underscores with single underscore
164
+ .replace(/^_|_$/g, '') // Remove leading/trailing underscores
165
+ .toLowerCase();
166
+ preferredFileName = `${sanitizedName}.spec.js`;
167
+ }
168
+ // Generate clean script with TestChimp comment and code
169
+ generatedScript = (0, script_utils_1.generateTestScript)(testName, steps);
170
+ // Generate detailed execution log
171
+ const logLines = [];
172
+ logLines.push(`# Scenario Execution Log`);
173
+ logLines.push(`Job ID: ${job.id}`);
174
+ logLines.push(`Scenario: ${job.scenario}`);
175
+ logLines.push(`Start Time: ${new Date(startTime).toISOString()}`);
176
+ logLines.push(`End Time: ${new Date().toISOString()}`);
177
+ logLines.push(`Total Execution Time: ${Date.now() - startTime}ms`);
178
+ logLines.push(`Overall Success: ${overallSuccess ? 'YES' : 'NO'}`);
179
+ logLines.push(``);
180
+ for (const step of steps) {
181
+ logLines.push(`## Step ${step.stepNumber}: ${step.description}`);
182
+ logLines.push(`Status: ${step.success ? 'SUCCESS' : 'FAILED'}`);
183
+ logLines.push(`Retry Count: ${step.retryCount || 0}`);
184
+ if (step.playwrightCommand) {
185
+ logLines.push(`Final Command: ${step.playwrightCommand}`);
186
+ }
187
+ if (step.error) {
188
+ logLines.push(`Final Error: ${step.error}`);
189
+ }
190
+ if (step.attempts && step.attempts.length > 0) {
191
+ logLines.push(`### Attempts:`);
192
+ for (const attempt of step.attempts) {
193
+ logLines.push(`- Attempt ${attempt.attemptNumber}:`);
194
+ logLines.push(` Command: ${attempt.command || 'N/A'}`);
195
+ logLines.push(` Success: ${attempt.success ? 'YES' : 'NO'}`);
196
+ if (attempt.error) {
197
+ logLines.push(` Error: ${attempt.error}`);
198
+ }
199
+ logLines.push(` Timestamp: ${new Date(attempt.timestamp).toISOString()}`);
200
+ }
201
+ }
202
+ logLines.push(``);
203
+ }
204
+ const executionLog = logLines.join('\n');
205
+ return {
206
+ success: overallSuccess,
207
+ steps,
208
+ generatedScript,
209
+ executionLog,
210
+ executionTime: Date.now() - startTime,
211
+ testName,
212
+ preferredFileName
213
+ };
214
+ }
215
+ catch (error) {
216
+ overallSuccess = false;
217
+ console.error('Overall scenario processing error:', error);
218
+ return {
219
+ success: false,
220
+ steps,
221
+ generatedScript,
222
+ executionLog: `# Scenario Execution Log\nJob ID: ${job.id}\nScenario: ${job.scenario}\nError: ${error instanceof Error ? error.message : 'Unknown error during scenario processing'}`,
223
+ executionTime: Date.now() - startTime,
224
+ testName: job.testName || 'test',
225
+ preferredFileName: 'test.spec.js',
226
+ error: error instanceof Error ? error.message : 'Unknown error during scenario processing'
227
+ };
228
+ }
229
+ finally {
230
+ if (browser) {
231
+ await browser.close();
232
+ }
233
+ }
234
+ }
235
+ async executePlaywrightCommand(page, browser, context, command) {
236
+ // Set reasonable timeouts
237
+ page.setDefaultTimeout(5000); // 5 seconds
238
+ try {
239
+ // Execute command directly without validation
240
+ const commandFunction = new Function('page', 'browser', 'context', 'expect', `
241
+ return (async () => {
242
+ try {
243
+ ${command}
244
+ } catch (error) {
245
+ console.error('Command execution error:', error);
246
+ throw error;
247
+ }
248
+ })();
249
+ `);
250
+ await commandFunction(page, browser, context, require('@playwright/test').expect);
251
+ }
252
+ finally {
253
+ // Reset to default timeout
254
+ page.setDefaultTimeout(10000); // Reset to default 10 seconds
255
+ }
256
+ }
257
+ async cleanup() {
258
+ this.initialized = false;
259
+ this.sessionId = null;
260
+ }
261
+ }
262
+ exports.ScenarioWorker = ScenarioWorker;
263
+ //# sourceMappingURL=scenario-worker-class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenario-worker-class.js","sourceRoot":"","sources":["../src/scenario-worker-class.ts"],"names":[],"mappings":";;;AAGA,6DAA8D;AAC9D,yDAA0D;AAC1D,6CAAyC;AAIzC,iDAAoD;AAkBpD,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B,MAAa,cAAc;IAOzB,YAAY,WAAyB,EAAE,UAAuB,EAAE,aAA6B;QANrF,gBAAW,GAAG,KAAK,CAAC;QACpB,cAAS,GAAkB,IAAI,CAAC;QAMtC,IAAI,CAAC,SAAS,GAAG,IAAI,sBAAS,CAAC,UAAU,CAAC,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAEO,GAAG,CAAC,OAAe;QACzB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;Q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K,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF;AA5SD,wCA4SC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Script Generation Utilities
3
+ *
4
+ * This module provides utilities for generating and formatting test scripts
5
+ * with TestChimp-specific markers and comments.
6
+ */
7
+ /**
8
+ * TestChimp managed test comment that should be added to all generated scripts
9
+ */
10
+ export declare const TESTCHIMP_MANAGED_COMMENT = "/*\n\nThis is a TestChimp Managed Test.\n\n*/";
11
+ /**
12
+ * Generates TestChimp managed test comment with optional repair advice
13
+ * @param repairAdvice Optional repair advice to include in the comment
14
+ * @returns The complete comment block
15
+ */
16
+ export declare function generateTestChimpComment(repairAdvice?: string): string;
17
+ /**
18
+ * Adds the TestChimp managed test comment to the beginning of a script
19
+ * @param script The original script content
20
+ * @param repairAdvice Optional repair advice to include in the comment
21
+ * @returns The script with TestChimp comment prepended
22
+ */
23
+ export declare function addTestChimpComment(script: string, repairAdvice?: string): string;
24
+ /**
25
+ * Generates a complete test script with TestChimp comment, imports, and test structure
26
+ * @param testName The name of the test
27
+ * @param steps Array of test steps with descriptions and commands
28
+ * @param includeTestChimpComment Whether to include the TestChimp managed test comment
29
+ * @param repairAdvice Optional repair advice to include in the comment
30
+ * @returns The complete test script
31
+ */
32
+ export declare function generateTestScript(testName: string, steps: Array<{
33
+ stepNumber: number;
34
+ description: string;
35
+ playwrightCommand?: string;
36
+ success?: boolean;
37
+ }>, includeTestChimpComment?: boolean, repairAdvice?: string): string;
38
+ /**
39
+ * Checks if a script is a TestChimp managed test
40
+ * @param script The script content to check
41
+ * @returns True if the script contains the TestChimp managed test comment
42
+ */
43
+ export declare function isTestChimpManagedTest(script: string): boolean;
44
+ //# sourceMappingURL=script-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script-utils.d.ts","sourceRoot":"","sources":["../src/script-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,yBAAyB,kDAInC,CAAC;AAEJ;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAYtE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAejF;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,KAAK,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,EACxG,uBAAuB,GAAE,OAAc,EACvC,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CA4BR;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE9D"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /**
3
+ * Script Generation Utilities
4
+ *
5
+ * This module provides utilities for generating and formatting test scripts
6
+ * with TestChimp-specific markers and comments.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.TESTCHIMP_MANAGED_COMMENT = void 0;
10
+ exports.generateTestChimpComment = generateTestChimpComment;
11
+ exports.addTestChimpComment = addTestChimpComment;
12
+ exports.generateTestScript = generateTestScript;
13
+ exports.isTestChimpManagedTest = isTestChimpManagedTest;
14
+ /**
15
+ * TestChimp managed test comment that should be added to all generated scripts
16
+ */
17
+ exports.TESTCHIMP_MANAGED_COMMENT = `/*
18
+
19
+ This is a TestChimp Managed Test.
20
+
21
+ */`;
22
+ /**
23
+ * Generates TestChimp managed test comment with optional repair advice
24
+ * @param repairAdvice Optional repair advice to include in the comment
25
+ * @returns The complete comment block
26
+ */
27
+ function generateTestChimpComment(repairAdvice) {
28
+ if (repairAdvice) {
29
+ return `/*
30
+
31
+ This is a TestChimp Managed Test.
32
+
33
+ Repair Advice:
34
+ ${repairAdvice}
35
+
36
+ */`;
37
+ }
38
+ return exports.TESTCHIMP_MANAGED_COMMENT;
39
+ }
40
+ /**
41
+ * Adds the TestChimp managed test comment to the beginning of a script
42
+ * @param script The original script content
43
+ * @param repairAdvice Optional repair advice to include in the comment
44
+ * @returns The script with TestChimp comment prepended
45
+ */
46
+ function addTestChimpComment(script, repairAdvice) {
47
+ // If the script already has the TestChimp comment, update it with repair advice if provided
48
+ if (script.includes('This is a TestChimp Managed Test')) {
49
+ if (repairAdvice) {
50
+ // Replace existing comment with new one that includes repair advice
51
+ const commentRegex = /\/\*[\s\S]*?This is a TestChimp Managed Test\.[\s\S]*?\*\//;
52
+ const newComment = generateTestChimpComment(repairAdvice);
53
+ return script.replace(commentRegex, newComment);
54
+ }
55
+ return script;
56
+ }
57
+ // Add the comment at the beginning of the script
58
+ const comment = generateTestChimpComment(repairAdvice);
59
+ return `${comment}\n\n${script}`;
60
+ }
61
+ /**
62
+ * Generates a complete test script with TestChimp comment, imports, and test structure
63
+ * @param testName The name of the test
64
+ * @param steps Array of test steps with descriptions and commands
65
+ * @param includeTestChimpComment Whether to include the TestChimp managed test comment
66
+ * @param repairAdvice Optional repair advice to include in the comment
67
+ * @returns The complete test script
68
+ */
69
+ function generateTestScript(testName, steps, includeTestChimpComment = true, repairAdvice) {
70
+ const scriptLines = [];
71
+ // Add TestChimp comment if requested
72
+ if (includeTestChimpComment) {
73
+ const comment = generateTestChimpComment(repairAdvice);
74
+ scriptLines.push(comment);
75
+ scriptLines.push('');
76
+ }
77
+ // Add imports
78
+ scriptLines.push(`import { test, expect } from '@playwright/test';`);
79
+ // Add test structure
80
+ scriptLines.push(`test('${testName.replace(/'/g, "\\'")}', async ({ page, browser, context }) => {`);
81
+ // Add steps
82
+ for (const step of steps) {
83
+ const status = step.success === false ? ' [FAILED]' : '';
84
+ scriptLines.push(` // Step ${step.stepNumber}: ${step.description}${status}`);
85
+ if (step.playwrightCommand && step.success !== false) {
86
+ scriptLines.push(` ${step.playwrightCommand}`);
87
+ }
88
+ }
89
+ scriptLines.push(`});`);
90
+ return scriptLines.join('\n');
91
+ }
92
+ /**
93
+ * Checks if a script is a TestChimp managed test
94
+ * @param script The script content to check
95
+ * @returns True if the script contains the TestChimp managed test comment
96
+ */
97
+ function isTestChimpManagedTest(script) {
98
+ return script.includes('This is a TestChimp Managed Test');
99
+ }
100
+ //# sourceMappingURL=script-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script-utils.js","sourceRoot":"","sources":["../src/script-utils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAgBH,4DAYC;AAQD,kDAeC;AAUD,gDAiCC;AAOD,wDAEC;AArGD;;GAEG;AACU,QAAA,yBAAyB,GAAG;;;;GAItC,CAAC;AAEJ;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,YAAqB;IAC5D,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO;;;;;EAKT,YAAY;;GAEX,CAAC;IACF,CAAC;IACD,OAAO,iCAAyB,CAAC;AACnC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,MAAc,EAAE,YAAqB;IACvE,4FAA4F;IAC5F,IAAI,MAAM,CAAC,QAAQ,CAAC,kCAAkC,CAAC,EAAE,CAAC;QACxD,IAAI,YAAY,EAAE,CAAC;YACjB,oEAAoE;YACpE,MAAM,YAAY,GAAG,4DAA4D,CAAC;YAClF,MAAM,UAAU,GAAG,wBAAwB,CAAC,YAAY,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iDAAiD;IACjD,MAAM,OAAO,GAAG,wBAAwB,CAAC,YAAY,CAAC,CAAC;IACvD,OAAO,GAAG,OAAO,OAAO,MAAM,EAAE,CAAC;AACnC,CAAC;AAED;;;;;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+ /**
2
+ * Playwright MCP configuration - JavaScript config file content (playwright.config.js)
3
+ */
4
+ export type PlaywrightConfig = string;
5
+ /**
6
+ * Request structure for the Playwright script executor
7
+ */
8
+ export interface PlaywrightExecutionRequest {
9
+ /** Main Playwright script content */
10
+ script: string;
11
+ /** Optional pre-script to run before the main script */
12
+ prescript?: string;
13
+ /** Optional post-script to run after the main script */
14
+ postscript?: string;
15
+ /** Playwright configuration file content */
16
+ playwrightConfig: string;
17
+ /** Optional GPT model to use for AI operations */
18
+ model?: string;
19
+ }
20
+ /**
21
+ * Response structure for the Playwright script executor
22
+ */
23
+ export interface PlaywrightExecutionResponse {
24
+ /** Whether the execution was successful */
25
+ success: boolean;
26
+ /** Execution results from each script phase */
27
+ results: {
28
+ prescript?: ScriptResult;
29
+ script: ScriptResult;
30
+ postscript?: ScriptResult;
31
+ };
32
+ /** Overall execution time in milliseconds */
33
+ executionTime: number;
34
+ /** Any errors that occurred during execution */
35
+ error?: string;
36
+ }
37
+ /**
38
+ * Individual script execution result
39
+ */
40
+ export interface ScriptResult {
41
+ /** Whether this specific script executed successfully */
42
+ success: boolean;
43
+ /** Output from the script execution */
44
+ output: string;
45
+ /** Any errors from this script */
46
+ error?: string;
47
+ /** Execution time for this script in milliseconds */
48
+ executionTime: number;
49
+ }
50
+ /**
51
+ * Scenario execution request
52
+ */
53
+ export interface ScenarioRequest {
54
+ scenario: string;
55
+ testName?: string;
56
+ playwrightConfig?: PlaywrightConfig;
57
+ model?: string;
58
+ }
59
+ /**
60
+ * Scenario execution job for worker queue
61
+ */
62
+ export interface ScenarioRunJob {
63
+ id: string;
64
+ scenario: string;
65
+ testName?: string;
66
+ playwrightConfig?: PlaywrightConfig;
67
+ model?: string;
68
+ scenarioFileName?: string;
69
+ }
70
+ /**
71
+ * Scenario execution response
72
+ */
73
+ export interface ScenarioResponse {
74
+ success: boolean;
75
+ steps: ScenarioStep[];
76
+ generatedScript: string;
77
+ executionLog: string;
78
+ executionTime: number;
79
+ testName?: string;
80
+ preferredFileName?: string;
81
+ error?: string;
82
+ }
83
+ /**
84
+ * Individual scenario step
85
+ */
86
+ export interface ScenarioStep {
87
+ stepNumber: number;
88
+ description: string;
89
+ playwrightCommand?: string;
90
+ success?: boolean;
91
+ error?: string;
92
+ retryCount?: number;
93
+ attempts?: Array<{
94
+ attemptNumber: number;
95
+ command?: string;
96
+ success: boolean;
97
+ error?: string;
98
+ timestamp: number;
99
+ }>;
100
+ }
101
+ /**
102
+ * Legacy scenario job interface (for backward compatibility)
103
+ */
104
+ export interface ScenarioJob {
105
+ id: string;
106
+ scenario: string;
107
+ config?: PlaywrightConfig;
108
+ resolve: (result: ScenarioResponse) => void;
109
+ reject: (error: Error) => void;
110
+ }
111
+ /**
112
+ * Execution mode for script execution
113
+ */
114
+ export declare enum ExecutionMode {
115
+ RUN_EXACTLY = "RUN_EXACTLY",
116
+ RUN_WITH_AI_REPAIR = "RUN_WITH_AI_REPAIR"
117
+ }
118
+ /**
119
+ * Script execution request with AI repair capabilities
120
+ */
121
+ export interface ScriptExecutionRequest {
122
+ script?: string;
123
+ scriptFilePath?: string;
124
+ mode: ExecutionMode;
125
+ repair_flexibility?: number;
126
+ playwrightConfig?: PlaywrightConfig;
127
+ playwrightConfigFilePath?: string;
128
+ model?: string;
129
+ headless?: boolean;
130
+ deflake_run_count?: number;
131
+ }
132
+ /**
133
+ * Script execution response with repair information
134
+ */
135
+ export interface ScriptExecutionResponse {
136
+ run_status: 'success' | 'failed';
137
+ repair_status?: 'success' | 'failed' | 'partial';
138
+ repair_confidence?: number;
139
+ repair_advice?: string;
140
+ updated_script?: string;
141
+ executionTime: number;
142
+ num_deflake_runs?: number;
143
+ error?: string;
144
+ }
145
+ /**
146
+ * Individual script step for AI repair
147
+ */
148
+ export interface ScriptStep {
149
+ description: string;
150
+ code: string;
151
+ success?: boolean;
152
+ error?: string;
153
+ }
154
+ /**
155
+ * Step operation types for AI repair
156
+ */
157
+ export declare enum StepOperation {
158
+ MODIFY = "MODIFY",
159
+ INSERT = "INSERT",
160
+ REMOVE = "REMOVE"
161
+ }
162
+ /**
163
+ * Step repair action
164
+ */
165
+ export interface StepRepairAction {
166
+ operation: StepOperation;
167
+ stepIndex?: number;
168
+ newStep?: ScriptStep;
169
+ insertAfterIndex?: number;
170
+ }
171
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAMtC;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,gBAAgB,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,2CAA2C;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,+CAA+C;IAC/C,OAAO,EAAE;QACP,SAAS,CAAC,EAAE,YAAY,CAAC;QACzB,MAAM,EAAE,YAAY,CAAC;QACrB,UAAU,CAAC,EAAE,YAAY,CAAC;KAC3B,CAAC;IACF,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,yDAAyD;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,aAAa,EAAE,MAAM,CAAC;CACvB;AAMD;;GAEG;AACH,MAAM,WAAW,eAAe;IA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oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,aAAa,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"}
package/dist/types.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // CORE TYPES
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StepOperation = exports.ExecutionMode = void 0;
7
+ // ============================================================================
8
+ // AI REPAIR TYPES
9
+ // ============================================================================
10
+ /**
11
+ * Execution mode for script execution
12
+ */
13
+ var ExecutionMode;
14
+ (function (ExecutionMode) {
15
+ ExecutionMode["RUN_EXACTLY"] = "RUN_EXACTLY";
16
+ ExecutionMode["RUN_WITH_AI_REPAIR"] = "RUN_WITH_AI_REPAIR";
17
+ })(ExecutionMode || (exports.ExecutionMode = ExecutionMode = {}));
18
+ /**
19
+ * Step operation types for AI repair
20
+ */
21
+ var StepOperation;
22
+ (function (StepOperation) {
23
+ StepOperation["MODIFY"] = "MODIFY";
24
+ StepOperation["INSERT"] = "INSERT";
25
+ StepOperation["REMOVE"] = "REMOVE";
26
+ })(StepOperation || (exports.StepOperation = StepOperation = {}));
27
+ // Repair suggestion and confidence interfaces are now in llm-facade.ts
28
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;;;AAiI/E,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;GAEG;AACH,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,4CAA2B,CAAA;IAC3B,0DAAyC,CAAA;AAC3C,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAyCD;;GAEG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;AACnB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAYD,uEAAuE"}
@@ -0,0 +1,13 @@
1
+ import { Browser, BrowserContext, Page } from 'playwright';
2
+ /**
3
+ * Initialize browser with Playwright configuration
4
+ * @param playwrightConfig - JavaScript config file content (playwright.config.js)
5
+ * @param headless - Override headless mode (optional)
6
+ * @returns Browser, context, and page instances
7
+ */
8
+ export declare function initializeBrowser(playwrightConfigContent?: string, headless?: boolean, playwrightConfigFilePath?: string): Promise<{
9
+ browser: Browser;
10
+ context: BrowserContext;
11
+ page: Page;
12
+ }>;
13
+ //# sourceMappingURL=browser-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-utils.d.ts","sourceRoot":"","sources":["../../src/utils/browser-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAMtF;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,uBAAuB,CAAC,EAAE,MAAM,EAChC,QAAQ,CAAC,EAAE,OAAO,EAClB,wBAAwB,CAAC,EAAE,MAAM,GAChC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CA+PpE"}