@empiricalrun/test-gen 0.78.1 → 0.78.3
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/CHANGELOG.md +15 -0
- package/dist/agent/base/index.d.ts.map +1 -1
- package/dist/agent/base/index.js +1 -0
- package/dist/agent/chat/exports.d.ts +0 -1
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +1 -3
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +2 -0
- package/dist/agent/cua/index.d.ts.map +1 -1
- package/dist/agent/cua/index.js +11 -8
- package/dist/agent/cua/pw-codegen/factory.d.ts +15 -0
- package/dist/agent/cua/pw-codegen/factory.d.ts.map +1 -0
- package/dist/agent/cua/pw-codegen/factory.js +59 -0
- package/dist/agent/cua/pw-codegen/index.d.ts +7 -0
- package/dist/agent/cua/pw-codegen/index.d.ts.map +1 -0
- package/dist/agent/cua/pw-codegen/index.js +14 -0
- package/dist/agent/cua/pw-codegen/pw-event-sink/index.d.ts +43 -0
- package/dist/agent/cua/pw-codegen/pw-event-sink/index.d.ts.map +1 -0
- package/dist/agent/cua/pw-codegen/pw-event-sink/index.js +250 -0
- package/dist/agent/cua/pw-codegen/pw-pause/index.d.ts +1 -1
- package/dist/agent/cua/pw-codegen/pw-pause/index.d.ts.map +1 -1
- package/dist/agent/cua/pw-codegen/pw-pause/index.js +6 -2
- package/dist/agent/cua/pw-codegen/pw-pause/patch.d.ts +15 -3
- package/dist/agent/cua/pw-codegen/pw-pause/patch.d.ts.map +1 -1
- package/dist/agent/cua/pw-codegen/pw-pause/patch.js +38 -10
- package/dist/agent/cua/pw-codegen/version.d.ts +25 -0
- package/dist/agent/cua/pw-codegen/version.d.ts.map +1 -0
- package/dist/agent/cua/pw-codegen/version.js +86 -0
- package/dist/agent/triage/index.d.ts.map +1 -1
- package/dist/agent/triage/index.js +2 -0
- package/dist/dashboard/client.d.ts +5 -0
- package/dist/dashboard/client.d.ts.map +1 -1
- package/dist/dashboard/client.js +28 -21
- package/dist/recorder/index.d.ts.map +1 -1
- package/dist/recorder/index.js +7 -2
- package/dist/tools/create-pull-request/utils.d.ts +1 -1
- package/dist/tools/definitions/analyse-video.d.ts +2 -24
- package/dist/tools/definitions/analyse-video.d.ts.map +1 -1
- package/dist/tools/definitions/delete-file.d.ts +1 -5
- package/dist/tools/definitions/delete-file.d.ts.map +1 -1
- package/dist/tools/definitions/download-build.d.ts +1 -5
- package/dist/tools/definitions/download-build.d.ts.map +1 -1
- package/dist/tools/definitions/list-tests-and-projects.d.ts +1 -5
- package/dist/tools/definitions/list-tests-and-projects.d.ts.map +1 -1
- package/dist/tools/definitions/run-test.d.ts +2 -14
- package/dist/tools/definitions/run-test.d.ts.map +1 -1
- package/dist/tools/definitions/safe-bash.d.ts +8 -0
- package/dist/tools/definitions/safe-bash.d.ts.map +1 -0
- package/dist/tools/definitions/safe-bash.js +32 -0
- package/dist/tools/definitions/test-gen-browser.d.ts +2 -14
- package/dist/tools/definitions/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/definitions/upgrade-packages.d.ts +3 -25
- package/dist/tools/definitions/upgrade-packages.d.ts.map +1 -1
- package/dist/tools/definitions/utils.d.ts +2 -10
- package/dist/tools/definitions/utils.d.ts.map +1 -1
- package/dist/tools/executor/index.d.ts.map +1 -1
- package/dist/tools/executor/index.js +2 -0
- package/dist/tools/fetch-file/index.d.ts +1 -5
- package/dist/tools/fetch-file/index.d.ts.map +1 -1
- package/dist/tools/firecrawl-scrape/index.d.ts +9 -0
- package/dist/tools/firecrawl-scrape/index.d.ts.map +1 -0
- package/dist/tools/firecrawl-scrape/index.js +107 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +9 -1
- package/dist/tools/issues-v2/create-issue.d.ts.map +1 -1
- package/dist/tools/issues-v2/create-issue.js +2 -6
- package/dist/tools/issues-v2/set-issue-description.d.ts +3 -0
- package/dist/tools/issues-v2/set-issue-description.d.ts.map +1 -0
- package/dist/tools/issues-v2/set-issue-description.js +59 -0
- package/dist/tools/issues-v2/update-issue.d.ts.map +1 -1
- package/dist/tools/issues-v2/update-issue.js +7 -9
- package/dist/tools/safe-bash/index.d.ts +3 -0
- package/dist/tools/safe-bash/index.d.ts.map +1 -0
- package/dist/tools/safe-bash/index.js +128 -0
- package/dist/tools/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/test-gen-browser.js +12 -5
- package/dist/tools/utils/validate-schema.d.ts.map +1 -1
- package/dist/tools/utils/validate-schema.js +9 -4
- package/dist/utils/model.d.ts.map +1 -1
- package/dist/utils/model.js +3 -8
- package/dist/utils/slug.d.ts +0 -1
- package/dist/utils/slug.d.ts.map +1 -1
- package/dist/utils/slug.js +1 -15
- package/package.json +6 -6
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.78.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [a94a7f7]
|
|
8
|
+
- @empiricalrun/r2-uploader@0.5.0
|
|
9
|
+
|
|
10
|
+
## 0.78.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [25962dc]
|
|
15
|
+
- @empiricalrun/llm@0.25.1
|
|
16
|
+
- videostil@0.3.3
|
|
17
|
+
|
|
3
18
|
## 0.78.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,iBAAiB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,CAAC;IAElB,IAAI,QAAQ,IAAI,gBAAgB,EAAE,CAEjC;IAED,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,IAAI,SAAS,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAKnC;IAED,eAAe,CACb,KAAK,EAAE,KAAK,CAAC,eAAe,GAAG,8BAA8B,CAAC,GAC7D,gBAAgB,CAAC,CAAC,CAAC;IAKtB,YAAY,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAQ3C,IAAI,IAAI,gBAAgB,CAAC,CAAC,CAAC;IA6B3B,kBAAkB,CAChB,SAAS,EAAE,eAAe,EAAE,EAC5B,WAAW,EAAE,UAAU,EAAE,EACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,GACnC,SAAS,GAAG,SAAS;IA4BlB,eAAe,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAW5D,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC;IAsBxC,6BAA6B,IACzB;QACE,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,GACD,SAAS;CAGd"}
|
package/dist/agent/base/index.js
CHANGED
|
@@ -108,6 +108,7 @@ class BaseAgent {
|
|
|
108
108
|
if (!systemPrompt) {
|
|
109
109
|
if (this.repoInfoBuilder) {
|
|
110
110
|
systemPrompt = await this.buildSystemPrompt(this.repoInfoBuilder);
|
|
111
|
+
this.systemPrompt = systemPrompt;
|
|
111
112
|
}
|
|
112
113
|
else {
|
|
113
114
|
throw new Error("Repo info builder is required.");
|
|
@@ -7,7 +7,6 @@ export { BaseAgent } from "../base";
|
|
|
7
7
|
export type { CodeReviewResultV0, CodeReviewResultV1, CodeReviewResultV2, CodeReviewVersionedResult, } from "../code-review";
|
|
8
8
|
export { TriageAgent } from "../triage";
|
|
9
9
|
export { ChatAgent } from "./index";
|
|
10
|
-
export { resolveChatModelBasedOnInput } from "./models";
|
|
11
10
|
export { fetchToolCallFromId, getLatestDownloadBuildUrl, LATEST_CHAT_STATE_VERSION, } from "./state";
|
|
12
11
|
export { extractAttachments } from "./utils";
|
|
13
12
|
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/exports.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/exports.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractAttachments = exports.LATEST_CHAT_STATE_VERSION = exports.getLatestDownloadBuildUrl = exports.fetchToolCallFromId = exports.
|
|
3
|
+
exports.extractAttachments = exports.LATEST_CHAT_STATE_VERSION = exports.getLatestDownloadBuildUrl = exports.fetchToolCallFromId = exports.ChatAgent = exports.TriageAgent = exports.BaseAgent = exports.viewFileUsingGitHub = exports.getFileInfoFromGitHub = exports.SUPPORTED_CHAT_MODELS = exports.createChatModel = void 0;
|
|
4
4
|
var chat_1 = require("@empiricalrun/llm/chat");
|
|
5
5
|
Object.defineProperty(exports, "createChatModel", { enumerable: true, get: function () { return chat_1.createChatModel; } });
|
|
6
6
|
var constants_1 = require("@empiricalrun/llm/chat/constants");
|
|
@@ -14,8 +14,6 @@ var triage_1 = require("../triage");
|
|
|
14
14
|
Object.defineProperty(exports, "TriageAgent", { enumerable: true, get: function () { return triage_1.TriageAgent; } });
|
|
15
15
|
var index_1 = require("./index");
|
|
16
16
|
Object.defineProperty(exports, "ChatAgent", { enumerable: true, get: function () { return index_1.ChatAgent; } });
|
|
17
|
-
var models_1 = require("./models");
|
|
18
|
-
Object.defineProperty(exports, "resolveChatModelBasedOnInput", { enumerable: true, get: function () { return models_1.resolveChatModelBasedOnInput; } });
|
|
19
17
|
var state_1 = require("./state");
|
|
20
18
|
Object.defineProperty(exports, "fetchToolCallFromId", { enumerable: true, get: function () { return state_1.fetchToolCallFromId; } });
|
|
21
19
|
Object.defineProperty(exports, "getLatestDownloadBuildUrl", { enumerable: true, get: function () { return state_1.getLatestDownloadBuildUrl; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAapE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKpC,qBAAa,SAAS,CAAC,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IAC5C,SAAS,CAAC,QAAQ,IAAI,WAAW;IAiB3B,iBAAiB,CACrB,eAAe,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,GACvC,OAAO,CAAC,MAAM,CAAC;CAsGnB"}
|
package/dist/agent/chat/index.js
CHANGED
|
@@ -18,6 +18,8 @@ class ChatAgent extends base_1.BaseAgent {
|
|
|
18
18
|
test_run_fetcher_1.fetchTestRunDetailsTool,
|
|
19
19
|
diagnosis_fetcher_1.fetchDiagnosisReportTool,
|
|
20
20
|
...(0, tools_1.textEditorToolsForModel)(this.selectedModel),
|
|
21
|
+
...(this.featureFlags.includes("useSafeBash") ? [tools_1.safeBashTool] : []),
|
|
22
|
+
...(this.featureFlags.includes("useScrapeHtml") ? [tools_1.scrapeHtmlTool] : []),
|
|
21
23
|
];
|
|
22
24
|
return {
|
|
23
25
|
custom,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/cua/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,iBAAiB,EACjB,KAAK,EACN,MAAM,uCAAuC,CAAC;AAS/C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/cua/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,iBAAiB,EACjB,KAAK,EACN,MAAM,uCAAuC,CAAC;AAS/C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAmElC,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAClC;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,iBAAiB,CAAC;CAC/B,CACJ,CAAC;AAEF,wBAAsB,+BAA+B,CAAC,EACpD,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,8BAAsC,GACvC,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C,GAAG,OAAO,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC,CAuND"}
|
package/dist/agent/cua/index.js
CHANGED
|
@@ -6,20 +6,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createTestUsingComputerUseAgent = createTestUsingComputerUseAgent;
|
|
7
7
|
const llm_1 = require("@empiricalrun/llm");
|
|
8
8
|
const openai_1 = __importDefault(require("openai"));
|
|
9
|
+
const logger_1 = require("../../logger");
|
|
9
10
|
const computer_1 = require("./computer");
|
|
10
11
|
const model_1 = require("./model");
|
|
11
12
|
const element_from_point_1 = require("./pw-codegen/element-from-point");
|
|
12
|
-
const
|
|
13
|
+
const factory_1 = require("./pw-codegen/factory");
|
|
13
14
|
const MAX_ITERATIONS = 10;
|
|
14
15
|
async function getCodegenInstance(prefersElementFromPoint) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
console.log("[getCodegen] using PlaywrightPauseCodegen");
|
|
19
|
-
return new pw_pause_1.PlaywrightPauseCodegen();
|
|
16
|
+
if (prefersElementFromPoint) {
|
|
17
|
+
logger_1.logger.debug("[getCodegen] using ElementFromPointCodegen (preferred)");
|
|
18
|
+
return new element_from_point_1.ElementFromPointCodegen();
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const repoDir = process.cwd();
|
|
21
|
+
const { codegen, approach, version } = await (0, factory_1.createPlaywrightCodegen)(repoDir);
|
|
22
|
+
logger_1.logger.debug(`[getCodegen] using ${approach} codegen for Playwright ${version.full}`);
|
|
23
|
+
// Prepare if needed (patch-based approach requires file modifications)
|
|
24
|
+
await (0, factory_1.prepareCodegenIfNeeded)(repoDir, approach);
|
|
25
|
+
return codegen;
|
|
23
26
|
}
|
|
24
27
|
function artifact(screenshot, name) {
|
|
25
28
|
return {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory for creating the appropriate Playwright codegen implementation
|
|
3
|
+
* based on the installed Playwright version.
|
|
4
|
+
*/
|
|
5
|
+
import type { BasePlaywrightCodegen } from "./types";
|
|
6
|
+
import { type CodegenApproach, type PlaywrightVersion } from "./version";
|
|
7
|
+
export type CodegenFactoryResult = {
|
|
8
|
+
codegen: BasePlaywrightCodegen;
|
|
9
|
+
approach: CodegenApproach;
|
|
10
|
+
version: PlaywrightVersion;
|
|
11
|
+
};
|
|
12
|
+
export declare function createPlaywrightCodegen(repoDir: string): Promise<CodegenFactoryResult>;
|
|
13
|
+
export declare function prepareCodegenIfNeeded(repoDir: string, approach: CodegenApproach): Promise<void>;
|
|
14
|
+
export { type CodegenApproach, type PlaywrightVersion };
|
|
15
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../src/agent/cua/pw-codegen/factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EACL,KAAK,eAAe,EAGpB,KAAK,iBAAiB,EACvB,MAAM,WAAW,CAAC;AAEnB,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,qBAAqB,CAAC;IAC/B,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AAEF,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CAoD/B;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,IAAI,CAAC,CAQf;AAED,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPlaywrightCodegen = createPlaywrightCodegen;
|
|
4
|
+
exports.prepareCodegenIfNeeded = prepareCodegenIfNeeded;
|
|
5
|
+
/**
|
|
6
|
+
* Factory for creating the appropriate Playwright codegen implementation
|
|
7
|
+
* based on the installed Playwright version.
|
|
8
|
+
*/
|
|
9
|
+
const logger_1 = require("../../../logger");
|
|
10
|
+
const pw_event_sink_1 = require("./pw-event-sink");
|
|
11
|
+
const pw_pause_1 = require("./pw-pause");
|
|
12
|
+
const version_1 = require("./version");
|
|
13
|
+
async function createPlaywrightCodegen(repoDir) {
|
|
14
|
+
const version = await (0, version_1.detectPlaywrightVersion)(repoDir);
|
|
15
|
+
if (!version) {
|
|
16
|
+
throw new Error("Could not detect Playwright version. Make sure @playwright/test is installed.");
|
|
17
|
+
}
|
|
18
|
+
const approach = (0, version_1.getCodegenApproach)(version);
|
|
19
|
+
logger_1.logger.info(`Detected Playwright ${version.full}, using "${approach}" codegen approach`);
|
|
20
|
+
switch (approach) {
|
|
21
|
+
case "event-sink": {
|
|
22
|
+
const canUse = await (0, pw_event_sink_1.canUseEventSinkCodegen)();
|
|
23
|
+
if (!canUse) {
|
|
24
|
+
throw new Error("Cannot use event-sink codegen. Check that RUN_PLAYWRIGHT_HEADED=true.");
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
codegen: new pw_event_sink_1.PlaywrightEventSinkCodegen(),
|
|
28
|
+
approach,
|
|
29
|
+
version,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
case "patch": {
|
|
33
|
+
const canUse = await (0, pw_pause_1.canUsePauseCodegen)(repoDir);
|
|
34
|
+
if (!canUse) {
|
|
35
|
+
throw new Error("Cannot use patch-based codegen. Check requirements: " +
|
|
36
|
+
"RUN_PLAYWRIGHT_HEADED=true, PW_CODEGEN_NO_INSPECTOR=true, and patched recorder.");
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
codegen: new pw_pause_1.PlaywrightPauseCodegen(),
|
|
40
|
+
approach,
|
|
41
|
+
version,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
case "unsupported":
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Unsupported Playwright version: ${version.full}. ` +
|
|
47
|
+
"Supported versions: 1.47.x, 1.53.x (patch), 1.57.0+ (event-sink).");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function prepareCodegenIfNeeded(repoDir, approach) {
|
|
51
|
+
if (approach === "patch") {
|
|
52
|
+
logger_1.logger.info("Preparing Playwright for patch-based codegen...");
|
|
53
|
+
await (0, pw_pause_1.preparePatchCodegen)(repoDir);
|
|
54
|
+
}
|
|
55
|
+
else if (approach === "event-sink") {
|
|
56
|
+
logger_1.logger.info("Preparing Playwright for event-sink codegen...");
|
|
57
|
+
await (0, pw_event_sink_1.prepareEventSinkCodegen)(repoDir);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright Codegen - exports for external use
|
|
3
|
+
*/
|
|
4
|
+
export { type CodegenApproach, type CodegenFactoryResult, createPlaywrightCodegen, type PlaywrightVersion, prepareCodegenIfNeeded, } from "./factory";
|
|
5
|
+
export type { BasePlaywrightCodegen } from "./types";
|
|
6
|
+
export { detectPlaywrightVersion, getCodegenApproach, getPlaywrightVersionFromNpmList, parseVersion, } from "./version";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agent/cua/pw-codegen/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,uBAAuB,EACvB,KAAK,iBAAiB,EACtB,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,+BAA+B,EAC/B,YAAY,GACb,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseVersion = exports.getPlaywrightVersionFromNpmList = exports.getCodegenApproach = exports.detectPlaywrightVersion = exports.prepareCodegenIfNeeded = exports.createPlaywrightCodegen = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Playwright Codegen - exports for external use
|
|
6
|
+
*/
|
|
7
|
+
var factory_1 = require("./factory");
|
|
8
|
+
Object.defineProperty(exports, "createPlaywrightCodegen", { enumerable: true, get: function () { return factory_1.createPlaywrightCodegen; } });
|
|
9
|
+
Object.defineProperty(exports, "prepareCodegenIfNeeded", { enumerable: true, get: function () { return factory_1.prepareCodegenIfNeeded; } });
|
|
10
|
+
var version_1 = require("./version");
|
|
11
|
+
Object.defineProperty(exports, "detectPlaywrightVersion", { enumerable: true, get: function () { return version_1.detectPlaywrightVersion; } });
|
|
12
|
+
Object.defineProperty(exports, "getCodegenApproach", { enumerable: true, get: function () { return version_1.getCodegenApproach; } });
|
|
13
|
+
Object.defineProperty(exports, "getPlaywrightVersionFromNpmList", { enumerable: true, get: function () { return version_1.getPlaywrightVersionFromNpmList; } });
|
|
14
|
+
Object.defineProperty(exports, "parseVersion", { enumerable: true, get: function () { return version_1.parseVersion; } });
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright Codegen using RecorderEventSink API (Playwright 1.57.0+)
|
|
3
|
+
*
|
|
4
|
+
* This implementation uses Playwright's internal RecorderEventSink interface
|
|
5
|
+
* to capture generated code without patching any files.
|
|
6
|
+
*
|
|
7
|
+
* How it works:
|
|
8
|
+
* 1. Call _enableRecorder() with mode: 'recording' and recorderMode: 'api'
|
|
9
|
+
* 2. Playwright's Recorder captures all user actions
|
|
10
|
+
* 3. Events flow to our eventSink callbacks with generated code
|
|
11
|
+
* 4. No inspector UI opens (recorderMode: 'api' skips UI)
|
|
12
|
+
*
|
|
13
|
+
* Requirements:
|
|
14
|
+
* - Playwright 1.57.0 or higher
|
|
15
|
+
* - RUN_PLAYWRIGHT_HEADED=true (recorder needs headed mode)
|
|
16
|
+
* - A small patch to recorderApp.js to allow recorderMode: 'api' with PW_CODEGEN_NO_INSPECTOR
|
|
17
|
+
*/
|
|
18
|
+
import type { BrowserContext, Page } from "playwright";
|
|
19
|
+
import type { BasePlaywrightCodegen } from "../types";
|
|
20
|
+
/**
|
|
21
|
+
* Prepares Playwright 1.57+ for event-sink codegen by patching recorderApp.js
|
|
22
|
+
* to allow recorderMode: 'api' even when PW_CODEGEN_NO_INSPECTOR is set.
|
|
23
|
+
*/
|
|
24
|
+
export declare function prepareEventSinkCodegen(repoDir: string): Promise<void>;
|
|
25
|
+
export declare function canUseEventSinkCodegen(): Promise<boolean>;
|
|
26
|
+
export declare function hasEventSinkSupport(context: BrowserContext): boolean;
|
|
27
|
+
export declare class PlaywrightEventSinkCodegen implements BasePlaywrightCodegen {
|
|
28
|
+
private page;
|
|
29
|
+
private codeBuffer;
|
|
30
|
+
private lastActionPromise;
|
|
31
|
+
private resolveLastAction;
|
|
32
|
+
private lastReturnedEntry;
|
|
33
|
+
private isGettingLastAction;
|
|
34
|
+
private eventSink;
|
|
35
|
+
private notifyActionReceived;
|
|
36
|
+
private waitForNextAction;
|
|
37
|
+
initialize(page: Page): Promise<void>;
|
|
38
|
+
recordAction(): Promise<void>;
|
|
39
|
+
getCodeForLastAction(): Promise<string>;
|
|
40
|
+
private waitForPendingSignals;
|
|
41
|
+
private wrapCodeWithSignals;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-event-sink/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AASvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAItD;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoC5E;AA8CD,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,OAAO,CAAC,CAa/D;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAEpE;AAQD,qBAAa,0BAA2B,YAAW,qBAAqB;IACtE,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,iBAAiB,CAA4B;IACrD,OAAO,CAAC,iBAAiB,CAA2B;IACpD,OAAO,CAAC,iBAAiB,CAA2B;IACpD,OAAO,CAAC,mBAAmB,CAAS;IAEpC,OAAO,CAAC,SAAS,CAkDf;IAEF,OAAO,CAAC,oBAAoB;IAQ5B,OAAO,CAAC,iBAAiB;IASnB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BrC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAK7B,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;YAuD/B,qBAAqB;IAOnC,OAAO,CAAC,mBAAmB;CA0D5B"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PlaywrightEventSinkCodegen = void 0;
|
|
7
|
+
exports.prepareEventSinkCodegen = prepareEventSinkCodegen;
|
|
8
|
+
exports.canUseEventSinkCodegen = canUseEventSinkCodegen;
|
|
9
|
+
exports.hasEventSinkSupport = hasEventSinkSupport;
|
|
10
|
+
/**
|
|
11
|
+
* Playwright Codegen using RecorderEventSink API (Playwright 1.57.0+)
|
|
12
|
+
*
|
|
13
|
+
* This implementation uses Playwright's internal RecorderEventSink interface
|
|
14
|
+
* to capture generated code without patching any files.
|
|
15
|
+
*
|
|
16
|
+
* How it works:
|
|
17
|
+
* 1. Call _enableRecorder() with mode: 'recording' and recorderMode: 'api'
|
|
18
|
+
* 2. Playwright's Recorder captures all user actions
|
|
19
|
+
* 3. Events flow to our eventSink callbacks with generated code
|
|
20
|
+
* 4. No inspector UI opens (recorderMode: 'api' skips UI)
|
|
21
|
+
*
|
|
22
|
+
* Requirements:
|
|
23
|
+
* - Playwright 1.57.0 or higher
|
|
24
|
+
* - RUN_PLAYWRIGHT_HEADED=true (recorder needs headed mode)
|
|
25
|
+
* - A small patch to recorderApp.js to allow recorderMode: 'api' with PW_CODEGEN_NO_INSPECTOR
|
|
26
|
+
*/
|
|
27
|
+
const fs_1 = __importDefault(require("fs"));
|
|
28
|
+
const logger_1 = require("../../../../logger");
|
|
29
|
+
const patch_1 = require("../pw-pause/patch");
|
|
30
|
+
const CUSTOM_PATCH_COMMENT = `// Custom patch code set by @empiricalrun/test-gen`;
|
|
31
|
+
/**
|
|
32
|
+
* Prepares Playwright 1.57+ for event-sink codegen by patching recorderApp.js
|
|
33
|
+
* to allow recorderMode: 'api' even when PW_CODEGEN_NO_INSPECTOR is set.
|
|
34
|
+
*/
|
|
35
|
+
async function prepareEventSinkCodegen(repoDir) {
|
|
36
|
+
const npmListOutput = await (0, patch_1.runNpmList)(repoDir);
|
|
37
|
+
if (!npmListOutput) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const pwCorePath = (0, patch_1.getPlaywrightCorePath)(npmListOutput);
|
|
41
|
+
const pathToRecorderApp = await (0, patch_1.getPathToRecorderApp)(pwCorePath);
|
|
42
|
+
const currentFileContents = fs_1.default.readFileSync(pathToRecorderApp, "utf-8");
|
|
43
|
+
// Check if already patched
|
|
44
|
+
if (currentFileContents.includes(CUSTOM_PATCH_COMMENT)) {
|
|
45
|
+
logger_1.logger.debug("Playwright recorder app already patched for event-sink");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// Patch RecorderApp.show() to allow recorderMode: 'api' with PW_CODEGEN_NO_INSPECTOR
|
|
49
|
+
const original = `if (process.env.PW_CODEGEN_NO_INSPECTOR)
|
|
50
|
+
return;`;
|
|
51
|
+
const replacement = `${CUSTOM_PATCH_COMMENT}
|
|
52
|
+
if (process.env.PW_CODEGEN_NO_INSPECTOR && params.recorderMode !== 'api')
|
|
53
|
+
return;`;
|
|
54
|
+
if (!currentFileContents.includes(original)) {
|
|
55
|
+
throw new Error("Could not find expected code pattern in recorderApp.js for 1.57+");
|
|
56
|
+
}
|
|
57
|
+
await (0, patch_1.createFileBackup)(pathToRecorderApp);
|
|
58
|
+
const newCode = currentFileContents.replace(original, replacement);
|
|
59
|
+
fs_1.default.writeFileSync(pathToRecorderApp, newCode);
|
|
60
|
+
logger_1.logger.debug(`Patched Playwright recorder app for event-sink at ${pathToRecorderApp}`);
|
|
61
|
+
}
|
|
62
|
+
async function canUseEventSinkCodegen() {
|
|
63
|
+
const isRunningHeaded = process.env.RUN_PLAYWRIGHT_HEADED &&
|
|
64
|
+
process.env.RUN_PLAYWRIGHT_HEADED === "true";
|
|
65
|
+
if (!isRunningHeaded) {
|
|
66
|
+
logger_1.logger.error("Cannot use event sink codegen because RUN_PLAYWRIGHT_HEADED is not true");
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
function hasEventSinkSupport(context) {
|
|
72
|
+
return typeof context._enableRecorder === "function";
|
|
73
|
+
}
|
|
74
|
+
class PlaywrightEventSinkCodegen {
|
|
75
|
+
page;
|
|
76
|
+
codeBuffer = [];
|
|
77
|
+
lastActionPromise;
|
|
78
|
+
resolveLastAction;
|
|
79
|
+
lastReturnedEntry;
|
|
80
|
+
isGettingLastAction = false;
|
|
81
|
+
eventSink = {
|
|
82
|
+
actionAdded: (_page, _action, code) => {
|
|
83
|
+
const actionData = _action;
|
|
84
|
+
const pageAlias = actionData.frame?.pageAlias || "page";
|
|
85
|
+
console.log(`[PlaywrightEventSinkCodegen] Received code from Playwright: ${code}`);
|
|
86
|
+
this.codeBuffer.push({ code, pageAlias, pendingSignals: [] });
|
|
87
|
+
this.notifyActionReceived();
|
|
88
|
+
},
|
|
89
|
+
actionUpdated: (_page, _action, code) => {
|
|
90
|
+
const actionData = _action;
|
|
91
|
+
const pageAlias = actionData.frame?.pageAlias || "page";
|
|
92
|
+
console.log(`[PlaywrightEventSinkCodegen] Updated code from Playwright: ${code}`);
|
|
93
|
+
const lastEntry = this.codeBuffer[this.codeBuffer.length - 1];
|
|
94
|
+
if (lastEntry) {
|
|
95
|
+
lastEntry.code = code;
|
|
96
|
+
lastEntry.pageAlias = pageAlias;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
this.codeBuffer.push({ code, pageAlias, pendingSignals: [] });
|
|
100
|
+
}
|
|
101
|
+
this.notifyActionReceived();
|
|
102
|
+
},
|
|
103
|
+
signalAdded: (_page, signalContext) => {
|
|
104
|
+
const { signal, frame } = signalContext;
|
|
105
|
+
console.log(`[PlaywrightEventSinkCodegen] Signal: ${signal.name}`);
|
|
106
|
+
if (signal.name === "popup" ||
|
|
107
|
+
signal.name === "download" ||
|
|
108
|
+
signal.name === "dialog") {
|
|
109
|
+
const signalPageAlias = frame.pageAlias;
|
|
110
|
+
// Find most recent action with matching pageAlias
|
|
111
|
+
const targetEntry = [...this.codeBuffer]
|
|
112
|
+
.reverse()
|
|
113
|
+
.find((e) => e.pageAlias === signalPageAlias) ||
|
|
114
|
+
(this.lastReturnedEntry?.pageAlias === signalPageAlias
|
|
115
|
+
? this.lastReturnedEntry
|
|
116
|
+
: undefined);
|
|
117
|
+
if (targetEntry) {
|
|
118
|
+
targetEntry.pendingSignals.push(signal);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
notifyActionReceived() {
|
|
124
|
+
if (this.resolveLastAction) {
|
|
125
|
+
this.resolveLastAction();
|
|
126
|
+
this.resolveLastAction = undefined;
|
|
127
|
+
this.lastActionPromise = undefined;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
waitForNextAction() {
|
|
131
|
+
if (!this.lastActionPromise) {
|
|
132
|
+
this.lastActionPromise = new Promise((resolve) => {
|
|
133
|
+
this.resolveLastAction = resolve;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return this.lastActionPromise;
|
|
137
|
+
}
|
|
138
|
+
async initialize(page) {
|
|
139
|
+
this.page = page;
|
|
140
|
+
this.codeBuffer = [];
|
|
141
|
+
const context = page.context();
|
|
142
|
+
if (!hasEventSinkSupport(context)) {
|
|
143
|
+
throw new Error("Playwright version does not support _enableRecorder API. " +
|
|
144
|
+
"This codegen requires Playwright 1.57.0 or higher.");
|
|
145
|
+
}
|
|
146
|
+
logger_1.logger.debug("[EventSinkCodegen] Enabling recorder with event sink");
|
|
147
|
+
await context._enableRecorder({
|
|
148
|
+
mode: "recording",
|
|
149
|
+
recorderMode: "api",
|
|
150
|
+
language: "javascript",
|
|
151
|
+
}, this.eventSink);
|
|
152
|
+
logger_1.logger.debug("[EventSinkCodegen] Recorder enabled, ready to capture actions");
|
|
153
|
+
}
|
|
154
|
+
async recordAction() {
|
|
155
|
+
// No-op: Playwright's recorder automatically captures actions
|
|
156
|
+
// when they are performed on the page
|
|
157
|
+
}
|
|
158
|
+
async getCodeForLastAction() {
|
|
159
|
+
// Guard against concurrent calls
|
|
160
|
+
if (this.isGettingLastAction) {
|
|
161
|
+
throw new Error("getCodeForLastAction must not be called concurrently");
|
|
162
|
+
}
|
|
163
|
+
this.isGettingLastAction = true;
|
|
164
|
+
try {
|
|
165
|
+
// If we already have code buffered, wait briefly for any signals that may arrive
|
|
166
|
+
if (this.codeBuffer.length > 0) {
|
|
167
|
+
const entry = this.codeBuffer.pop();
|
|
168
|
+
this.lastReturnedEntry = entry;
|
|
169
|
+
await this.waitForPendingSignals();
|
|
170
|
+
this.lastReturnedEntry = undefined;
|
|
171
|
+
const finalCode = this.wrapCodeWithSignals(entry);
|
|
172
|
+
console.log(`[PlaywrightEventSinkCodegen] Generated code:\n${finalCode}`);
|
|
173
|
+
return finalCode;
|
|
174
|
+
}
|
|
175
|
+
// Wait for an action to be recorded, with timeout
|
|
176
|
+
const timeoutMs = 5000;
|
|
177
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
178
|
+
setTimeout(() => reject(new Error("Timeout waiting for recorded action")), timeoutMs);
|
|
179
|
+
});
|
|
180
|
+
try {
|
|
181
|
+
await Promise.race([this.waitForNextAction(), timeoutPromise]);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
throw new Error("No code for last action: " + error.message);
|
|
185
|
+
}
|
|
186
|
+
if (this.codeBuffer.length === 0) {
|
|
187
|
+
throw new Error("No code for last action");
|
|
188
|
+
}
|
|
189
|
+
const entry = this.codeBuffer.pop();
|
|
190
|
+
this.lastReturnedEntry = entry;
|
|
191
|
+
// Wait briefly for signals that may arrive after the action
|
|
192
|
+
await this.waitForPendingSignals();
|
|
193
|
+
this.lastReturnedEntry = undefined;
|
|
194
|
+
const finalCode = this.wrapCodeWithSignals(entry);
|
|
195
|
+
console.log(`[PlaywrightEventSinkCodegen] Generated code:\n${finalCode}`);
|
|
196
|
+
return finalCode;
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
this.isGettingLastAction = false;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async waitForPendingSignals() {
|
|
203
|
+
// Wait a fixed time window to capture signals that arrive after the action
|
|
204
|
+
// Signals typically arrive within a few hundred ms
|
|
205
|
+
const timeoutMs = 500;
|
|
206
|
+
await new Promise((resolve) => setTimeout(resolve, timeoutMs));
|
|
207
|
+
}
|
|
208
|
+
wrapCodeWithSignals(entry) {
|
|
209
|
+
const { code, pageAlias, pendingSignals } = entry;
|
|
210
|
+
if (pendingSignals.length === 0) {
|
|
211
|
+
return code;
|
|
212
|
+
}
|
|
213
|
+
const lines = [];
|
|
214
|
+
let popup;
|
|
215
|
+
let download;
|
|
216
|
+
let dialog;
|
|
217
|
+
for (const signal of pendingSignals) {
|
|
218
|
+
if (signal.name === "popup") {
|
|
219
|
+
popup = signal;
|
|
220
|
+
}
|
|
221
|
+
else if (signal.name === "download") {
|
|
222
|
+
download = signal;
|
|
223
|
+
}
|
|
224
|
+
else if (signal.name === "dialog") {
|
|
225
|
+
dialog = signal;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (dialog) {
|
|
229
|
+
lines.push(` ${pageAlias}.once('dialog', dialog => {
|
|
230
|
+
console.log(\`Dialog message: \${dialog.message()}\`);
|
|
231
|
+
dialog.dismiss().catch(() => {});
|
|
232
|
+
});`);
|
|
233
|
+
}
|
|
234
|
+
if (popup) {
|
|
235
|
+
lines.push(`const ${popup.popupAlias}Promise = ${pageAlias}.waitForEvent('popup');`);
|
|
236
|
+
}
|
|
237
|
+
if (download) {
|
|
238
|
+
lines.push(`const download${download.downloadAlias}Promise = ${pageAlias}.waitForEvent('download');`);
|
|
239
|
+
}
|
|
240
|
+
lines.push(code);
|
|
241
|
+
if (popup) {
|
|
242
|
+
lines.push(`const ${popup.popupAlias} = await ${popup.popupAlias}Promise;`);
|
|
243
|
+
}
|
|
244
|
+
if (download) {
|
|
245
|
+
lines.push(`const download${download.downloadAlias} = await download${download.downloadAlias}Promise;`);
|
|
246
|
+
}
|
|
247
|
+
return lines.join("\n");
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
exports.PlaywrightEventSinkCodegen = PlaywrightEventSinkCodegen;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Page } from "playwright";
|
|
2
2
|
import { BasePlaywrightCodegen } from "../types";
|
|
3
|
-
export {
|
|
3
|
+
export { createFileBackup, getPathToRecorderApp, getPlaywrightCorePath, preparePatchCodegen, revertToOriginalPwCode, runNpmList, } from "./patch";
|
|
4
4
|
export declare function canUsePauseCodegen(repoDir: string): Promise<boolean>;
|
|
5
5
|
export declare class PlaywrightPauseCodegen implements BasePlaywrightCodegen {
|
|
6
6
|
private port;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAMjD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAMjD,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,oBAwCvD;AAED,qBAAa,sBAAuB,YAAW,qBAAqB;IAClE,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,iBAAiB,CAAqB;;YAMhC,QAAQ;IAUhB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBrC,sBAAsB,CAAC,IAAI,EAAE,IAAI;IAqBjC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CAU9C"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PlaywrightPauseCodegen = exports.revertToOriginalPwCode = exports.
|
|
6
|
+
exports.PlaywrightPauseCodegen = exports.runNpmList = exports.revertToOriginalPwCode = exports.preparePatchCodegen = exports.getPlaywrightCorePath = exports.getPathToRecorderApp = exports.createFileBackup = void 0;
|
|
7
7
|
exports.canUsePauseCodegen = canUsePauseCodegen;
|
|
8
8
|
const express_1 = __importDefault(require("express"));
|
|
9
9
|
const logger_1 = require("../../../../logger");
|
|
@@ -11,8 +11,12 @@ const ipc_1 = require("./ipc");
|
|
|
11
11
|
const patch_1 = require("./patch");
|
|
12
12
|
const utils_1 = require("./utils");
|
|
13
13
|
var patch_2 = require("./patch");
|
|
14
|
-
Object.defineProperty(exports, "
|
|
14
|
+
Object.defineProperty(exports, "createFileBackup", { enumerable: true, get: function () { return patch_2.createFileBackup; } });
|
|
15
|
+
Object.defineProperty(exports, "getPathToRecorderApp", { enumerable: true, get: function () { return patch_2.getPathToRecorderApp; } });
|
|
16
|
+
Object.defineProperty(exports, "getPlaywrightCorePath", { enumerable: true, get: function () { return patch_2.getPlaywrightCorePath; } });
|
|
17
|
+
Object.defineProperty(exports, "preparePatchCodegen", { enumerable: true, get: function () { return patch_2.preparePatchCodegen; } });
|
|
15
18
|
Object.defineProperty(exports, "revertToOriginalPwCode", { enumerable: true, get: function () { return patch_2.revertToOriginalPwCode; } });
|
|
19
|
+
Object.defineProperty(exports, "runNpmList", { enumerable: true, get: function () { return patch_2.runNpmList; } });
|
|
16
20
|
async function canUsePauseCodegen(repoDir) {
|
|
17
21
|
const hasPatchedPwCode = await (0, patch_1.hasPatchedRecorderApp)(repoDir);
|
|
18
22
|
if (!hasPatchedPwCode) {
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Prepares Playwright 1.47/1.53 for patch-based codegen by patching
|
|
3
|
+
* setSources() to POST generated code to a local HTTP server.
|
|
4
|
+
*/
|
|
5
|
+
export declare function preparePatchCodegen(repoDir: string): Promise<void>;
|
|
2
6
|
export declare function getPathToRecorderApp(pwCorePath: string): Promise<string>;
|
|
3
7
|
export declare function runNpmList(repoDir: string): Promise<string | undefined>;
|
|
8
|
+
export type PatchableVersion = "1.47" | "1.53";
|
|
9
|
+
/**
|
|
10
|
+
* Gets the path to playwright-core from npm list output.
|
|
11
|
+
* This is used by event-sink codegen which doesn't need version validation.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getPlaywrightCorePath(output: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Gets the path and version for patch-based codegen (1.47/1.53 only).
|
|
16
|
+
*/
|
|
4
17
|
export declare function getPlaywrightCoreFromNpmList(output: string): {
|
|
5
18
|
path: string;
|
|
6
|
-
version:
|
|
19
|
+
version: PatchableVersion;
|
|
7
20
|
};
|
|
8
21
|
export declare function hasPatchedRecorderApp(repoDir: string): Promise<boolean | undefined>;
|
|
9
22
|
export declare function revertToOriginalPwCode(repoDir: string): Promise<void>;
|
|
10
23
|
export declare function createFileBackup(pathToFile: string): Promise<void>;
|
|
11
|
-
export declare function patchPwCode(pwVersion: "1.47" | "1.53", pathToRecorderApp: string, port: number): Promise<void>;
|
|
12
24
|
//# sourceMappingURL=patch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/patch.ts"],"names":[],"mappings":"AAoBA,wBAAsB,
|
|
1
|
+
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/patch.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,iBAexD;AAED,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,mBAgB5D;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,+BAgB/C;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAe5D;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,gBAAgB,CAAC;CAC3B,CAuBA;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,gCAkB1D;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,iBAuB3D;AAED,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,iBAGxD"}
|