@empiricalrun/test-gen 0.71.1 → 0.71.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +0 -6
- package/dist/agent/browsing/index.d.ts.map +1 -1
- package/dist/agent/browsing/index.js +6 -14
- package/dist/agent/codegen/repo-edit.d.ts.map +1 -1
- package/dist/agent/codegen/repo-edit.js +0 -4
- package/dist/agent/codegen/run.d.ts.map +1 -1
- package/dist/agent/codegen/run.js +0 -4
- package/dist/agent/codegen/utils.d.ts +1 -3
- package/dist/agent/codegen/utils.d.ts.map +1 -1
- package/dist/agent/codegen/utils.js +1 -2
- package/dist/agent/cua/index.d.ts +2 -1
- package/dist/agent/cua/index.d.ts.map +1 -1
- package/dist/agent/cua/index.js +4 -4
- package/dist/agent/master/execute-browser-action.d.ts.map +1 -1
- package/dist/agent/master/execute-browser-action.js +1 -4
- package/dist/agent/master/run.d.ts.map +1 -1
- package/dist/agent/master/run.js +0 -19
- package/dist/agent/master/scroller.d.ts.map +1 -1
- package/dist/agent/master/scroller.js +0 -4
- package/dist/bin/index.js +1 -35
- package/dist/bin/logger/index.d.ts +0 -1
- package/dist/bin/logger/index.d.ts.map +1 -1
- package/dist/bin/logger/index.js +0 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -6
- package/dist/tool-call-service/index.js +2 -2
- package/dist/tools/{test-run.d.ts → run-test.d.ts} +1 -1
- package/dist/tools/run-test.d.ts.map +1 -0
- package/dist/tools/{test-run.js → run-test.js} +3 -1
- package/package.json +5 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/reporter/index.d.ts +0 -26
- package/dist/reporter/index.d.ts.map +0 -1
- package/dist/reporter/index.js +0 -149
- package/dist/reporter/lib.d.ts +0 -31
- package/dist/reporter/lib.d.ts.map +0 -1
- package/dist/reporter/lib.js +0 -71
- package/dist/tools/test-run.d.ts.map +0 -1
- package/dist/uploader/index.d.ts +0 -26
- package/dist/uploader/index.d.ts.map +0 -1
- package/dist/uploader/index.js +0 -103
- package/dist/uploader/utils.d.ts +0 -8
- package/dist/uploader/utils.d.ts.map +0 -1
- package/dist/uploader/utils.js +0 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.71.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d7f9025: chore: remove old session reporter which is no longer used
|
|
8
|
+
- f44505a: fix: smaller responses from run-test tool
|
|
9
|
+
- 001b324: fix: enforce codegen approach for overlay dismissals
|
|
10
|
+
- Updated dependencies [f44505a]
|
|
11
|
+
- @empiricalrun/test-run@0.10.8
|
|
12
|
+
- @empiricalrun/llm@0.19.4
|
|
13
|
+
|
|
3
14
|
## 0.71.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAEL,UAAU,EACV,YAAY,EAEb,MAAM,UAAU,CAAC;AAWlB,qBAAa,iBAAiB;IAQ1B,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,cAAc;IARxB,OAAO,CAAC,gBAAgB,CAAwC;IAChE,OAAO,CAAC,eAAe,CAInB;gBAEM,IAAI,EAAE,WAAW,EACjB,cAAc,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAgB5C,aAAa,CACjB,IAAI,EAAE,MAAM,YAAK,EACjB,IAAI,EAAE,UAAU,EAChB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAqD9B,wBAAwB,IAAI,YAAY,EAAE;IAoB1C,sBAAsB,IAAI,YAAY,EAAE;IAWxC,YAAY,IAAI;QACd,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,EAAE,CAAC;KACvB;IAUD,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAK9B;;;;;;OAMG;IACH,aAAa,IAAI,OAAO;IAQxB,UAAU;IAWV,iBAAiB;IAIjB,iBAAiB,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAItD"}
|
package/dist/actions/index.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PlaywrightActions = void 0;
|
|
4
4
|
const logger_1 = require("../bin/logger");
|
|
5
5
|
const errors_1 = require("../errors");
|
|
6
|
-
const reporter_1 = require("../reporter");
|
|
7
6
|
const assert_1 = require("./assert");
|
|
8
7
|
const click_1 = require("./click");
|
|
9
8
|
const done_1 = require("./done");
|
|
@@ -45,7 +44,6 @@ class PlaywrightActions {
|
|
|
45
44
|
throw Error(`No action registered for action: ${name}`);
|
|
46
45
|
}
|
|
47
46
|
const logger = new logger_1.CustomLogger({ useReporter: false });
|
|
48
|
-
const testgenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
|
|
49
47
|
logger.logEmptyLine();
|
|
50
48
|
const actionSpan = trace?.span({
|
|
51
49
|
name: "execute-action",
|
|
@@ -69,10 +67,6 @@ class PlaywrightActions {
|
|
|
69
67
|
},
|
|
70
68
|
});
|
|
71
69
|
this.recordedActions.push({ name, code, importPath });
|
|
72
|
-
if (code) {
|
|
73
|
-
logger.log(`action: ${name} \ncode: ${code} \nreason: ${args.reason}`);
|
|
74
|
-
void testgenUpdatesReporter.sendMessage("```ts\n" + code + "\n```");
|
|
75
|
-
}
|
|
76
70
|
return code;
|
|
77
71
|
}
|
|
78
72
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAKlD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF,wBAAsB,6BAA6B,CAAC,EAClD,MAAM,EACN,IAAI,EACJ,OAAO,EACP,GAAG,EACH,KAAK,GACN,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,iBAAiB,CAAC;IAC3B,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAwD1C"}
|
|
@@ -4,12 +4,10 @@ exports.executeTaskUsingBrowsingAgent = executeTaskUsingBrowsingAgent;
|
|
|
4
4
|
const llm_1 = require("@empiricalrun/llm");
|
|
5
5
|
const constants_1 = require("../../constants");
|
|
6
6
|
const promptTemplate_0 = "{{#section \"system\"}}\nYou are a browser automation agent who is given a task to generate code for navigation and assertion. This task is your\ngoal and you must achieve it.\n\nYou will be provided with already executed actions and basis that you need to pick the next step to achieve the task.\nRemember that the goal must be achieved.\n\nYou will be provided with the web page snapshot in the form of Document Object Model. Based on the goal and available\ntool calls you need to pick the appropriate tool call.\n\nInstructions:\n- Take actions one at a time. Do not try to take multiple actions\n- You can respond with multiple assertions in one shot\n- Do not repeat the same actions again otherwise your response will be marked INVALID\n- Avoid repeating errors which we got while executing the last action\n- Stick to the task provided to you and mark the task done once the task is complete\n- Do not execute any action which is not mentioned in the task\n- Do not repeat actions which are already executed more than twice otherwise your response will be marked INVALID\n- Always refer to \"Executed actions\" before deciding your next action for completion of the task.\n- End the task done if all actions required for task are executed\n{{/section}}\n\n{{#section \"user\"}}\nTask:\n{{task}}\n\nCurrent page snapshot:\n{{pageSnapshot}}\n{{/section}}";
|
|
7
|
-
const reporter_1 = require("../../reporter");
|
|
8
7
|
const html_1 = require("../../utils/html");
|
|
9
8
|
async function executeTaskUsingBrowsingAgent({ action, page, actions, llm, trace, }) {
|
|
10
9
|
let generatedCodeSteps;
|
|
11
10
|
const tools = actions.getBrowsingActionSchemas();
|
|
12
|
-
const testgenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
|
|
13
11
|
const browsingAgentSpan = trace?.span({
|
|
14
12
|
name: `browsing-agent`,
|
|
15
13
|
input: {
|
|
@@ -48,18 +46,12 @@ async function executeTaskUsingBrowsingAgent({ action, page, actions, llm, trace
|
|
|
48
46
|
for (const i in toolCalls) {
|
|
49
47
|
const toolCall = toolCalls[i];
|
|
50
48
|
const args = JSON.parse(toolCall.function.arguments);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
void testgenUpdatesReporter.sendMessage(e.message);
|
|
61
|
-
throw e;
|
|
62
|
-
}
|
|
49
|
+
const code = await actions.executeAction(toolCall.function.name, JSON.parse(toolCall.function.arguments), toolCallsSpan);
|
|
50
|
+
generatedCodeSteps = {
|
|
51
|
+
// Passing reason as action, in order to pass the correct action that took place to runtime planner
|
|
52
|
+
action: args.reason,
|
|
53
|
+
code,
|
|
54
|
+
};
|
|
63
55
|
}
|
|
64
56
|
toolCallsSpan?.end({ output: { toolCalls, generatedCodeSteps } });
|
|
65
57
|
return generatedCodeSteps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo-edit.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/repo-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"repo-edit.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/repo-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,KAAK,EACL,SAAS,EAET,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC,CA6CD;AAED,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,IAAI,EACJ,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC,CA8BD"}
|
|
@@ -8,7 +8,6 @@ exports.repoEditAgent = repoEditAgent;
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const context_1 = require("../../bin/utils/context");
|
|
10
10
|
const web_1 = require("../../bin/utils/platform/web");
|
|
11
|
-
const reporter_1 = require("../../reporter");
|
|
12
11
|
const generate_code_apply_changes_1 = require("./generate-code-apply-changes");
|
|
13
12
|
const utils_1 = require("./utils");
|
|
14
13
|
async function generateCodeUsingRepoAgent({ task, trace, repoFiles, logger, }) {
|
|
@@ -56,8 +55,6 @@ If all the changes are done, respond with "exit" tool call otherwise respond wit
|
|
|
56
55
|
};
|
|
57
56
|
}
|
|
58
57
|
async function repoEditAgent({ trace, task, logger, }) {
|
|
59
|
-
const testgenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
|
|
60
|
-
void testgenUpdatesReporter.sendMessage(`Updating test code as per the task. \n View [trace](${trace?.getTraceUrl()})`);
|
|
61
58
|
logger?.log(`Starting repo agent: [trace](${trace?.getTraceUrl()})`);
|
|
62
59
|
const { prompt: repoFiles } = await (0, context_1.generateTxtForRepository)();
|
|
63
60
|
const repoAgentOutput = await generateCodeUsingRepoAgent({
|
|
@@ -80,6 +77,5 @@ async function repoEditAgent({ trace, task, logger, }) {
|
|
|
80
77
|
}
|
|
81
78
|
})();
|
|
82
79
|
}));
|
|
83
|
-
await testgenUpdatesReporter.sendMessage(`Successfully generated code for the given task. \n View [trace](${trace?.getTraceUrl()})`);
|
|
84
80
|
return repoAgentOutput;
|
|
85
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,MAAM,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAa5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAQ/C,wBAAsB,uBAAuB,CAAC,EAC5C,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,0BAA0B,EAAE,CAAC;IAC7D,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC,CAAC,CAyDD;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,QAAQ,EACR,IAAI,EACJ,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CA2D7B"}
|
|
@@ -12,7 +12,6 @@ const context_1 = require("../../bin/utils/context");
|
|
|
12
12
|
const web_1 = require("../../bin/utils/platform/web");
|
|
13
13
|
const constants_1 = require("../../constants");
|
|
14
14
|
const promptTemplate_0 = "{{#section \"system\"}}\nYou are a software test engineer who is given a task to write test cases in a Playwright test repository.\nYou will be provided with current test files, fixtures and page object models for you to use and update code as per the\ntask provided to you.\nYou need to respond with file path, the new test code block to be updated in the file and the reason for the change.\n\nHere is the list of files:\n\n{{repoFiles}}\n{{/section}}\n\n{{#section \"user\"}}\nTask: {{task}}\n\n## Follow these instructions before responding with output:\n- Scan the file '{{testFilePath}}' and check whether test case with name '{{testCaseName}}' exists in the file\n- If it exists do not update the file\n- else respond with <file_path></file_path>, <code_block></code_block> and <change></change> as xml tags\n- Only respond with single code_block in the response containing only the test code block to be updated\n{{/section}}";
|
|
15
|
-
const reporter_1 = require("../../reporter");
|
|
16
15
|
const update_flow_1 = require("./update-flow");
|
|
17
16
|
const utils_1 = require("./utils");
|
|
18
17
|
async function createTestWithCodeAgent({ testCase, file, repoFiles, trace, }) {
|
|
@@ -88,8 +87,6 @@ async function generateTestWithCodegen({ testCase, file, trace, }) {
|
|
|
88
87
|
trace,
|
|
89
88
|
});
|
|
90
89
|
}
|
|
91
|
-
const testgenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
|
|
92
|
-
void testgenUpdatesReporter.sendMessage(`Updating test code as per the task. \n View [trace](${trace?.getTraceUrl()})`);
|
|
93
90
|
logger?.log(`Creating a new test case '${testCase.name}': [trace](${trace?.getTraceUrl()})`);
|
|
94
91
|
// Create the test if it doesn't exist
|
|
95
92
|
const { prompt: repoFiles } = await (0, context_1.generateTxtForRepository)();
|
|
@@ -102,7 +99,6 @@ async function generateTestWithCodegen({ testCase, file, trace, }) {
|
|
|
102
99
|
await (0, utils_1.applyFileChangesForCreateTest)({
|
|
103
100
|
trace,
|
|
104
101
|
fileChanges: updates.fileChanges,
|
|
105
|
-
testgenUpdatesReporter,
|
|
106
102
|
});
|
|
107
103
|
await (0, utils_1.validateTypesAndFormatCode)({
|
|
108
104
|
validateTypes: true,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TraceClient } from "@empiricalrun/llm";
|
|
2
2
|
import type { TestCase } from "@empiricalrun/shared-types";
|
|
3
3
|
import { CustomLogger } from "../../bin/logger";
|
|
4
|
-
import { TestGenUpdatesReporter } from "../../reporter";
|
|
5
4
|
import { CodeUpdate, CreateTestCodeUpdate, FileUpdateResponse } from "./types";
|
|
6
5
|
/**
|
|
7
6
|
*
|
|
@@ -71,10 +70,9 @@ export declare function applyFileChangesUsingStrReplace({ trace, fileChanges, lo
|
|
|
71
70
|
fileChanges: CodeUpdate[];
|
|
72
71
|
logger?: CustomLogger;
|
|
73
72
|
}): Promise<FileUpdateResponse[]>;
|
|
74
|
-
export declare function applyFileChangesForCreateTest({ trace, fileChanges,
|
|
73
|
+
export declare function applyFileChangesForCreateTest({ trace, fileChanges, }: {
|
|
75
74
|
trace?: TraceClient;
|
|
76
75
|
fileChanges: CreateTestCodeUpdate[];
|
|
77
|
-
testgenUpdatesReporter?: TestGenUpdatesReporter;
|
|
78
76
|
}): Promise<void>;
|
|
79
77
|
export declare function searchAndReplaceCode({ logger, fileChange, }: {
|
|
80
78
|
fileChange: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAI3D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAI3D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE/E;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,CAiB9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,GACZ,oBAAoB,EAAE,CAgBxB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG;IACvD,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,EAAE,CA8BF;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,EAAE,CAqCF;AAED,wBAAsB,0BAA0B,CAAC,EAC/C,aAAoB,EACpB,KAAK,EACL,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,EACT,iBAAiB,GAClB,EAAE;IACD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAClC,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,iBAyBA;AAED,wBAAsB,+BAA+B,CAAC,EACpD,KAAK,EACL,WAAW,EACX,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA6ChC;AAED,wBAAsB,6BAA6B,CAAC,EAClD,KAAK,EACL,WAAW,GACZ,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC,iBAiDA;AAED,wBAAsB,oBAAoB,CAAC,EACzC,MAAM,EACN,UAAU,GACX,EAAE;IACD,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,CAAC;IACF,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC,CA8BD;AAED,wBAAsB,gBAAgB,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,WAAW,EACX,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE;QACX,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,EAAE,CAAC;IACJ,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAkIxE"}
|
|
@@ -199,7 +199,7 @@ async function applyFileChangesUsingStrReplace({ trace, fileChanges, logger, })
|
|
|
199
199
|
}
|
|
200
200
|
return results;
|
|
201
201
|
}
|
|
202
|
-
async function applyFileChangesForCreateTest({ trace, fileChanges,
|
|
202
|
+
async function applyFileChangesForCreateTest({ trace, fileChanges, }) {
|
|
203
203
|
const repoEditFileChangesSpan = trace?.span({
|
|
204
204
|
name: "create-test-file-changes",
|
|
205
205
|
});
|
|
@@ -235,7 +235,6 @@ async function applyFileChangesForCreateTest({ trace, fileChanges, testgenUpdate
|
|
|
235
235
|
error: e,
|
|
236
236
|
},
|
|
237
237
|
});
|
|
238
|
-
void testgenUpdatesReporter?.sendMessage(`Error while applying changes to file ${fileChange.filePath}, error: ${e}`);
|
|
239
238
|
console.error(`Error while applying changes to file ${fileChange.filePath}`, e);
|
|
240
239
|
}
|
|
241
240
|
}
|
|
@@ -8,10 +8,11 @@ export type BrowserAgentResult = Array<{
|
|
|
8
8
|
type: "screenshot";
|
|
9
9
|
screenshot: ArtifactInputData;
|
|
10
10
|
}>;
|
|
11
|
-
export declare function createTestUsingComputerUseAgent({ page, task, trace, }: {
|
|
11
|
+
export declare function createTestUsingComputerUseAgent({ page, task, trace, prefersElementFromPointCodegen, }: {
|
|
12
12
|
page: Page;
|
|
13
13
|
task: string;
|
|
14
14
|
trace?: TraceClient;
|
|
15
|
+
prefersElementFromPointCodegen?: boolean;
|
|
15
16
|
}): Promise<{
|
|
16
17
|
code: string;
|
|
17
18
|
importPaths: string[];
|
|
@@ -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,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAStE,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,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAStE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAmClC,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
|
@@ -11,9 +11,9 @@ const model_1 = require("./model");
|
|
|
11
11
|
const element_from_point_1 = require("./pw-codegen/element-from-point");
|
|
12
12
|
const pw_pause_1 = require("./pw-codegen/pw-pause");
|
|
13
13
|
const MAX_ITERATIONS = 15;
|
|
14
|
-
async function getCodegenInstance() {
|
|
14
|
+
async function getCodegenInstance(prefersElementFromPoint) {
|
|
15
15
|
const repoDir = process.cwd();
|
|
16
|
-
const canUsePwPause = await (0, pw_pause_1.canUsePauseCodegen)(repoDir);
|
|
16
|
+
const canUsePwPause = !prefersElementFromPoint && (await (0, pw_pause_1.canUsePauseCodegen)(repoDir));
|
|
17
17
|
if (canUsePwPause) {
|
|
18
18
|
console.log("[getCodegen] using PlaywrightPauseCodegen");
|
|
19
19
|
return new pw_pause_1.PlaywrightPauseCodegen();
|
|
@@ -28,8 +28,8 @@ function artifact(screenshot, name) {
|
|
|
28
28
|
data: Buffer.from(screenshot, "base64"),
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
async function createTestUsingComputerUseAgent({ page, task, trace, }) {
|
|
32
|
-
const codegen = await getCodegenInstance();
|
|
31
|
+
async function createTestUsingComputerUseAgent({ page, task, trace, prefersElementFromPointCodegen = false, }) {
|
|
32
|
+
const codegen = await getCodegenInstance(prefersElementFromPointCodegen);
|
|
33
33
|
await codegen.initialize(page);
|
|
34
34
|
const screenshot = await (0, computer_1.getScreenshot)(page);
|
|
35
35
|
const initialArtifact = artifact(screenshot, "Initial screen");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-browser-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/execute-browser-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"execute-browser-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/execute-browser-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAUlD,wBAAsB,oBAAoB,CAAC,EACzC,IAAI,EACJ,UAAU,EACV,KAAK,EACL,OAAO,EACP,GAAG,EACH,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,KAAK,EAAE;QACL,4BAA4B,EAAE,OAAO,CAAC;KACvC,CAAC;IACF,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,GAAG,EAAE,GAAG,CAAC;CACV;;;gBAIW,MAAM;gBACN,MAAM;4BACM,MAAM;;GA8H7B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeBrowserAction = executeBrowserAction;
|
|
4
|
-
const reporter_1 = require("../../reporter");
|
|
5
4
|
const browsing_1 = require("../browsing");
|
|
6
5
|
const action_tool_calls_1 = require("./action-tool-calls");
|
|
7
6
|
const element_annotation_1 = require("./element-annotation");
|
|
@@ -39,7 +38,7 @@ async function executeBrowserAction({ page, nextAction, flags, actions, llm, tra
|
|
|
39
38
|
};
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
|
-
let { annotationKeys, annotatedPageScreenshot
|
|
41
|
+
let { annotationKeys, annotatedPageScreenshot } = await (0, element_annotation_1.getAnnotationKeys)({
|
|
43
42
|
page,
|
|
44
43
|
preference,
|
|
45
44
|
trace,
|
|
@@ -61,8 +60,6 @@ async function executeBrowserAction({ page, nextAction, flags, actions, llm, tra
|
|
|
61
60
|
});
|
|
62
61
|
output.elementAnnotation = elementAnnotation;
|
|
63
62
|
console.log("Output: ", output);
|
|
64
|
-
const testGenReporter = new reporter_1.TestGenUpdatesReporter();
|
|
65
|
-
await testGenReporter.sendCurrentView(annotationBuffer);
|
|
66
63
|
const triggerHintsFlowSpan = trace?.span({
|
|
67
64
|
name: "trigger-hints-flow",
|
|
68
65
|
input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAclC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAUxC,OAAO,EAAE,+BAA+B,EAAE,MAAM,QAAQ,CAAC;AAKzD,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAqB9C,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;GA4PA"}
|
package/dist/agent/master/run.js
CHANGED
|
@@ -10,7 +10,6 @@ const logger_1 = require("../../bin/logger");
|
|
|
10
10
|
const constants_1 = require("../../constants");
|
|
11
11
|
const errors_1 = require("../../errors");
|
|
12
12
|
const page_1 = require("../../page");
|
|
13
|
-
const reporter_1 = require("../../reporter");
|
|
14
13
|
const session_1 = require("../../session");
|
|
15
14
|
const utils_2 = require("../browsing/utils");
|
|
16
15
|
const skills_retriever_1 = require("../codegen/skills-retriever");
|
|
@@ -41,7 +40,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
41
40
|
const useActionSpecificAnnotations = options?.useActionSpecificAnnotations || false;
|
|
42
41
|
const usePlannerInMaster = options?.usePlannerInMaster || false;
|
|
43
42
|
const logger = new logger_1.CustomLogger({ useReporter: false });
|
|
44
|
-
const testgenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
|
|
45
43
|
const session = (0, session_1.getSessionDetails)();
|
|
46
44
|
const testGenPage = new page_1.TestGenPage(page, (0, utils_1.getPageVarName)());
|
|
47
45
|
const trace = llm_1.langfuseInstance?.trace({
|
|
@@ -58,11 +56,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
58
56
|
options.metadata?.environment,
|
|
59
57
|
].filter((s) => !!s),
|
|
60
58
|
});
|
|
61
|
-
if (trace) {
|
|
62
|
-
void testgenUpdatesReporter.sendMessage(`Starting master agent. [view trace](${trace?.getTraceUrl()})`);
|
|
63
|
-
logger.log(`Starting master agent: ${trace?.getTraceUrl()}`);
|
|
64
|
-
void testgenUpdatesReporter.sendAgentTraceUrl(trace.getTraceUrl());
|
|
65
|
-
}
|
|
66
59
|
const llm = new llm_1.LLM({
|
|
67
60
|
trace,
|
|
68
61
|
provider: options.modelProvider || constants_1.DEFAULT_MODEL_PROVIDER,
|
|
@@ -82,14 +75,12 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
82
75
|
}
|
|
83
76
|
skill_1.testCaseSkills.updateSkills(skills);
|
|
84
77
|
if (usePlannerInMaster && testCase && specPath) {
|
|
85
|
-
void testgenUpdatesReporter.sendMessage(`Planner is working on task: ${task}`);
|
|
86
78
|
logger.log(`Planner is working on task: ${task}`);
|
|
87
79
|
const plan = await (0, run_1.planTask)({
|
|
88
80
|
task,
|
|
89
81
|
specPath,
|
|
90
82
|
trace,
|
|
91
83
|
});
|
|
92
|
-
void testgenUpdatesReporter.sendMessage(`Here is the plan:\n${plan}`);
|
|
93
84
|
logger.log(`Here is the plan:\n${plan}`);
|
|
94
85
|
// Will assume this is the task hereon
|
|
95
86
|
task = plan;
|
|
@@ -123,7 +114,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
123
114
|
});
|
|
124
115
|
isGivenTaskDone = plannerResp.isDone;
|
|
125
116
|
if (isGivenTaskDone) {
|
|
126
|
-
await testgenUpdatesReporter.sendMessage(`${plannerResp.reason} Marking the task as done.`);
|
|
127
117
|
break;
|
|
128
118
|
}
|
|
129
119
|
if (actions.getStateVariables()[plannerResp.pageName]) {
|
|
@@ -135,8 +125,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
135
125
|
// inject scripts in the page
|
|
136
126
|
await (0, utils_2.injectPwLocatorGenerator)(testGenPage.pwPageInstance);
|
|
137
127
|
const buffer = await page.screenshot();
|
|
138
|
-
const testGenReporter = new reporter_1.TestGenUpdatesReporter();
|
|
139
|
-
await testGenReporter.sendCurrentView(buffer);
|
|
140
128
|
const pageScreenshot = buffer.toString("base64");
|
|
141
129
|
let output;
|
|
142
130
|
let generatedCodeSteps = [];
|
|
@@ -163,7 +151,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
163
151
|
if (nextAction) {
|
|
164
152
|
if (nextAction.actionType === action_tool_calls_1.ActionType.UNKNOWN) {
|
|
165
153
|
logger.error("Agent is not able to figure out next action since element is not visible on screen.");
|
|
166
|
-
await testgenUpdatesReporter.sendMessage("Agent is not able to figure out next action since element is not visible on screen.");
|
|
167
154
|
break;
|
|
168
155
|
}
|
|
169
156
|
const args = JSON.parse(nextAction.toolCallArgs);
|
|
@@ -175,7 +162,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
175
162
|
reason: args.reason,
|
|
176
163
|
};
|
|
177
164
|
try {
|
|
178
|
-
void testGenReporter.sendMessage(output.reason);
|
|
179
165
|
logger.log(`Next Action: ${output.action}`);
|
|
180
166
|
switch (nextAction.actionType) {
|
|
181
167
|
case skill_1.SKILL_USAGE: {
|
|
@@ -248,7 +234,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
248
234
|
if (failedActions.length >= MAX_ERROR_COUNT) {
|
|
249
235
|
const error = "Agent is not able to figure out next action, marking task as done";
|
|
250
236
|
logger.error(error);
|
|
251
|
-
await testgenUpdatesReporter.sendMessage(error);
|
|
252
237
|
break;
|
|
253
238
|
}
|
|
254
239
|
}
|
|
@@ -265,11 +250,7 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
265
250
|
}
|
|
266
251
|
const { code, importPaths } = actions.generateCode();
|
|
267
252
|
trace?.update({ input: { task }, output: { code } });
|
|
268
|
-
await new reporter_1.TestGenUpdatesReporter().sendCurrentView(await page.screenshot());
|
|
269
253
|
logger.success("Successfully generated code for the given task");
|
|
270
|
-
if (trace) {
|
|
271
|
-
await testgenUpdatesReporter.sendMessage(`Successfully generated code for the given task. \n View [trace](${trace.getTraceUrl()})`);
|
|
272
|
-
}
|
|
273
254
|
return {
|
|
274
255
|
code,
|
|
275
256
|
importPaths,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroller.d.ts","sourceRoot":"","sources":["../../../src/agent/master/scroller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"scroller.d.ts","sourceRoot":"","sources":["../../../src/agent/master/scroller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAYhD,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAoZF,wBAAsB,QAAQ,CAAC,EAC7B,kBAAkB,EAClB,IAAI,EACJ,KAAK,EACL,cAAc,EACd,MAAM,GACP,EAAE;IACD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CA6D5B"}
|
|
@@ -4,7 +4,6 @@ exports.scroller = scroller;
|
|
|
4
4
|
const llm_1 = require("@empiricalrun/llm");
|
|
5
5
|
const vision_1 = require("@empiricalrun/llm/vision");
|
|
6
6
|
const constants_1 = require("../../constants");
|
|
7
|
-
const reporter_1 = require("../../reporter");
|
|
8
7
|
const action_tool_calls_1 = require("./action-tool-calls");
|
|
9
8
|
const element_annotation_1 = require("./element-annotation");
|
|
10
9
|
let usedAnnotations = [];
|
|
@@ -43,9 +42,7 @@ async function isScrollable({ scrollDirection, page, divAnnotation, }) {
|
|
|
43
42
|
// If the div annotation is undefined, we scroll the page
|
|
44
43
|
// else we scroll the element
|
|
45
44
|
async function scroll({ scrollBy, page, direction, divAnnotation, logger, }) {
|
|
46
|
-
const testGenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
|
|
47
45
|
if (divAnnotation) {
|
|
48
|
-
await testGenUpdatesReporter.sendMessage("Scrolling the div since element is not in view");
|
|
49
46
|
logger?.log("Scrolling the div since element is not in view");
|
|
50
47
|
return await page.evaluate(({ scrollBy, direction, divAnnotation }) => {
|
|
51
48
|
if (
|
|
@@ -60,7 +57,6 @@ async function scroll({ scrollBy, page, direction, divAnnotation, logger, }) {
|
|
|
60
57
|
return 0;
|
|
61
58
|
}, { scrollBy, direction, divAnnotation });
|
|
62
59
|
}
|
|
63
|
-
await testGenUpdatesReporter.sendMessage("Scrolling the page since element is not in view");
|
|
64
60
|
logger?.log("Scrolling the page since element is not in view");
|
|
65
61
|
return await page.evaluate(({ scrollBy, direction }) => {
|
|
66
62
|
let scrollHeight = scrollBy || window.innerHeight;
|
package/dist/bin/index.js
CHANGED
|
@@ -21,7 +21,6 @@ const auth_1 = require("../auth");
|
|
|
21
21
|
const api_client_1 = require("../auth/api-client");
|
|
22
22
|
const recorder_1 = require("../recorder");
|
|
23
23
|
const validation_1 = require("../recorder/validation");
|
|
24
|
-
const reporter_1 = require("../reporter");
|
|
25
24
|
const session_1 = require("../session");
|
|
26
25
|
const test_build_1 = require("../test-build");
|
|
27
26
|
const environments_1 = require("./environments");
|
|
@@ -57,14 +56,6 @@ async function runChatAgent({ modelInput, useDiskForChatState, initialPromptPath
|
|
|
57
56
|
async function runAgentsWorkflow(testGenConfig, testGenToken) {
|
|
58
57
|
const logger = new logger_1.CustomLogger();
|
|
59
58
|
const { specPath, testCase } = testGenConfig;
|
|
60
|
-
if (process.env.LOG_URL) {
|
|
61
|
-
try {
|
|
62
|
-
void new reporter_1.TestGenUpdatesReporter().sendLogUrl(process.env.LOG_URL);
|
|
63
|
-
}
|
|
64
|
-
catch (e) {
|
|
65
|
-
console.warn("Failed to send log url to test gen update", e);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
59
|
const session = (0, session_1.getSessionDetails)();
|
|
69
60
|
const trace = llm_1.langfuseInstance?.trace({
|
|
70
61
|
name: "generate-test",
|
|
@@ -87,14 +78,6 @@ async function runAgentsWorkflow(testGenConfig, testGenToken) {
|
|
|
87
78
|
testUrl: session.testUrl,
|
|
88
79
|
},
|
|
89
80
|
});
|
|
90
|
-
if (trace) {
|
|
91
|
-
try {
|
|
92
|
-
void new reporter_1.TestGenUpdatesReporter().sendAgentTraceUrl(trace.getTraceUrl());
|
|
93
|
-
}
|
|
94
|
-
catch (e) {
|
|
95
|
-
console.warn("Failed to send trace url as test gen update", e);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
81
|
// assuming if there is no test case specific test name, we need to update the test case name
|
|
99
82
|
if (!testCase.name) {
|
|
100
83
|
logger.success(`Generating code for the provided task. ${process.env.LOG_URL ? `[view log](${process.env.LOG_URL})` : ""}`);
|
|
@@ -147,7 +130,6 @@ async function runAgentsWorkflow(testGenConfig, testGenToken) {
|
|
|
147
130
|
});
|
|
148
131
|
new logger_1.CustomLogger({ useReporter: false }).log("Generated Plan:");
|
|
149
132
|
console.log(plan);
|
|
150
|
-
await new reporter_1.TestGenUpdatesReporter().sendMessage(plan);
|
|
151
133
|
}
|
|
152
134
|
else if (agent === "code") {
|
|
153
135
|
await (0, run_2.generateTestWithCodegen)({
|
|
@@ -396,11 +378,6 @@ async function main() {
|
|
|
396
378
|
const testGenToken = options.token
|
|
397
379
|
? options.token
|
|
398
380
|
: (0, scenarios_1.buildTokenFromOptions)(options);
|
|
399
|
-
(0, reporter_1.setReporterConfig)({
|
|
400
|
-
projectRepoName: testGenConfig.options?.metadata.projectRepoName,
|
|
401
|
-
testSessionId: testGenConfig.options?.metadata.testSessionId,
|
|
402
|
-
generationId: testGenConfig.options?.metadata.generationId,
|
|
403
|
-
});
|
|
404
381
|
(0, session_1.setSessionDetails)({
|
|
405
382
|
testCaseId: testGenConfig.testCase.id,
|
|
406
383
|
sessionId: testGenConfig.options?.metadata.testSessionId,
|
|
@@ -414,25 +391,14 @@ async function main() {
|
|
|
414
391
|
repoPath: process.cwd(),
|
|
415
392
|
});
|
|
416
393
|
}
|
|
417
|
-
let agentUsed;
|
|
418
394
|
let testGenFailed = false;
|
|
419
395
|
try {
|
|
420
|
-
|
|
396
|
+
await runAgentsWorkflow(testGenConfig, testGenToken);
|
|
421
397
|
}
|
|
422
398
|
catch (e) {
|
|
423
399
|
testGenFailed = true;
|
|
424
400
|
new logger_1.CustomLogger().error(`Failed to generate test for the scenario. ${process.env.LOG_URL ? `[view log](${process.env.LOG_URL})` : ""}`, e?.message, e?.stack);
|
|
425
401
|
}
|
|
426
|
-
if (agentUsed &&
|
|
427
|
-
agentUsed !== "code" &&
|
|
428
|
-
agentUsed !== "plan" &&
|
|
429
|
-
testGenConfig.testCase.name &&
|
|
430
|
-
testGenConfig.options) {
|
|
431
|
-
await new reporter_1.TestGenUpdatesReporter().reportGenAssets({
|
|
432
|
-
projectRepoName: testGenConfig.options.metadata.projectRepoName,
|
|
433
|
-
testName: testGenConfig.testCase.name,
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
402
|
await (0, llm_1.flushAllTraces)();
|
|
437
403
|
await (0, logger_1.waitForLogsToFlush)();
|
|
438
404
|
await (0, session_1.endSession)();
|
|
@@ -3,7 +3,6 @@ export declare class CustomLogger {
|
|
|
3
3
|
constructor({ useReporter }?: {
|
|
4
4
|
useReporter?: boolean | undefined;
|
|
5
5
|
});
|
|
6
|
-
private logToReporter;
|
|
7
6
|
log(message?: string, ...optionalParams: any[]): void;
|
|
8
7
|
warn(message?: string, ...optionalParams: any[]): void;
|
|
9
8
|
success(message?: string, ...optionalParams: any[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/logger/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/logger/index.ts"],"names":[],"mappings":"AAIA,qBAAa,YAAY;IACvB,OAAO,CAAC,WAAW,CAAkB;gBACzB,EAAE,WAAkB,EAAE;;KAAK;IAIvC,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE;IAI9C,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE;IAI/C,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE;IAIlD,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE;IAIhD,YAAY;CAGb;AAED,wBAAsB,kBAAkB,kBAWvC"}
|
package/dist/bin/logger/index.js
CHANGED
|
@@ -3,39 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CustomLogger = void 0;
|
|
4
4
|
exports.waitForLogsToFlush = waitForLogsToFlush;
|
|
5
5
|
const picocolors_1 = require("picocolors");
|
|
6
|
-
const reporter_1 = require("../../reporter");
|
|
7
|
-
const lib_1 = require("../../reporter/lib");
|
|
8
6
|
let queuedReporterMessages = [];
|
|
9
7
|
class CustomLogger {
|
|
10
8
|
useReporter = false;
|
|
11
9
|
constructor({ useReporter = true } = {}) {
|
|
12
10
|
this.useReporter = useReporter;
|
|
13
11
|
}
|
|
14
|
-
logToReporter(message) {
|
|
15
|
-
if (this.useReporter) {
|
|
16
|
-
(() => {
|
|
17
|
-
const promise = (0, reporter_1.getReporter)()?.report(new lib_1.MessageBuilder({ type: "message", message: message }));
|
|
18
|
-
if (promise) {
|
|
19
|
-
queuedReporterMessages.push(promise);
|
|
20
|
-
}
|
|
21
|
-
})();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
12
|
log(message, ...optionalParams) {
|
|
25
13
|
console.log("🪵", (0, picocolors_1.cyan)(message), ...optionalParams);
|
|
26
|
-
this.logToReporter(message);
|
|
27
14
|
}
|
|
28
15
|
warn(message, ...optionalParams) {
|
|
29
16
|
console.log("🟡", (0, picocolors_1.yellow)(message), ...optionalParams);
|
|
30
|
-
this.logToReporter(message);
|
|
31
17
|
}
|
|
32
18
|
success(message, ...optionalParams) {
|
|
33
19
|
console.log("✅", (0, picocolors_1.green)(message), ...optionalParams);
|
|
34
|
-
this.logToReporter(message);
|
|
35
20
|
}
|
|
36
21
|
error(message, ...optionalParams) {
|
|
37
22
|
console.error("🚨", (0, picocolors_1.red)(message), ...optionalParams);
|
|
38
|
-
this.logToReporter(message);
|
|
39
23
|
}
|
|
40
24
|
logEmptyLine() {
|
|
41
25
|
console.log("\n\n");
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAahD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAsB7C,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,IAAI,GAAG,YAAY,EAC5B,KAAK,CAAC,EAAE,SAAS,iBAmElB;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,IAAI,iBAY7C"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,6 @@ const run_1 = require("./agent/master/run");
|
|
|
14
14
|
const scenarios_1 = require("./bin/utils/scenarios");
|
|
15
15
|
const client_1 = __importDefault(require("./file/client"));
|
|
16
16
|
const logger_1 = require("./logger");
|
|
17
|
-
const reporter_1 = require("./reporter");
|
|
18
17
|
const session_1 = require("./session");
|
|
19
18
|
var test_build_1 = require("./test-build");
|
|
20
19
|
Object.defineProperty(exports, "downloadBuild", { enumerable: true, get: function () { return test_build_1.downloadBuild; } });
|
|
@@ -47,11 +46,6 @@ async function createTest(task, pageRef, scope) {
|
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
if (testGenConfig.options && testGenConfig.options.metadata) {
|
|
50
|
-
(0, reporter_1.setReporterConfig)({
|
|
51
|
-
projectRepoName: testGenConfig.options?.metadata.projectRepoName,
|
|
52
|
-
testSessionId: testGenConfig.options?.metadata.testSessionId,
|
|
53
|
-
generationId: testGenConfig.options?.metadata.generationId,
|
|
54
|
-
});
|
|
55
49
|
(0, session_1.setSessionDetails)({
|
|
56
50
|
sessionId: testGenConfig.options?.metadata.testSessionId,
|
|
57
51
|
generationId: testGenConfig.options?.metadata.generationId,
|
|
@@ -8,9 +8,9 @@ const diagnosis_fetcher_1 = require("../tools/diagnosis-fetcher");
|
|
|
8
8
|
const download_build_1 = require("../tools/download-build");
|
|
9
9
|
const grep_1 = require("../tools/grep");
|
|
10
10
|
const list_environments_1 = require("../tools/list-environments");
|
|
11
|
+
const run_test_1 = require("../tools/run-test");
|
|
11
12
|
const str_replace_editor_1 = require("../tools/str_replace_editor");
|
|
12
13
|
const test_gen_browser_1 = require("../tools/test-gen-browser");
|
|
13
|
-
const test_run_1 = require("../tools/test-run");
|
|
14
14
|
const test_run_fetcher_1 = require("../tools/test-run-fetcher");
|
|
15
15
|
const upgrade_packages_1 = require("../tools/upgrade-packages");
|
|
16
16
|
const checkpoint_1 = require("../utils/checkpoint");
|
|
@@ -37,7 +37,7 @@ class ToolCallService {
|
|
|
37
37
|
this.environmentOverrides = environmentOverrides;
|
|
38
38
|
this.tools = [
|
|
39
39
|
grep_1.grepTool,
|
|
40
|
-
|
|
40
|
+
run_test_1.runTestTool,
|
|
41
41
|
test_run_fetcher_1.fetchTestRunReportTool,
|
|
42
42
|
diagnosis_fetcher_1.fetchDiagnosisReportTool,
|
|
43
43
|
test_gen_browser_1.generateTestWithBrowserAgent,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-test.d.ts","sourceRoot":"","sources":["../../src/tools/run-test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AA2DnE,eAAO,MAAM,WAAW,EAAE,IAqFzB,CAAC"}
|
|
@@ -31,7 +31,9 @@ function buildReportUrl(projectName, testRunId) {
|
|
|
31
31
|
return `https://reports.empirical.run/${projectName}/${testRunId}/index.html`;
|
|
32
32
|
}
|
|
33
33
|
function buildResult({ hasTestPassed, summaryJson, reportUrl, }) {
|
|
34
|
-
const
|
|
34
|
+
const summaryWithoutConfig = { ...summaryJson, config: undefined };
|
|
35
|
+
delete summaryWithoutConfig["config"];
|
|
36
|
+
const truncatedSummaryJson = (0, utils_2.truncateJsonValues)(summaryWithoutConfig);
|
|
35
37
|
return `
|
|
36
38
|
Test run is complete. Result: ${hasTestPassed ? "Passed" : "Failed"}
|
|
37
39
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
"zod": "^3.23.8",
|
|
67
67
|
"@empiricalrun/llm": "^0.19.4",
|
|
68
68
|
"@empiricalrun/r2-uploader": "^0.3.9",
|
|
69
|
-
"@empiricalrun/test-run": "^0.10.
|
|
69
|
+
"@empiricalrun/test-run": "^0.10.8"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@playwright/test": "1.53.
|
|
72
|
+
"@playwright/test": "1.53.2",
|
|
73
73
|
"@types/async-retry": "^1.4.8",
|
|
74
74
|
"@types/console-log-level": "^1.4.5",
|
|
75
75
|
"@types/detect-port": "^1.3.5",
|
|
@@ -79,10 +79,10 @@
|
|
|
79
79
|
"@types/mime": "3.0.0",
|
|
80
80
|
"@types/serve-handler": "^6.1.4",
|
|
81
81
|
"js-levenshtein": "^1.1.6",
|
|
82
|
-
"playwright": "1.53.
|
|
82
|
+
"playwright": "1.53.2",
|
|
83
83
|
"serve-handler": "^6.1.6",
|
|
84
84
|
"ts-patch": "^3.3.0",
|
|
85
|
-
"@empiricalrun/shared-types": "0.6.
|
|
85
|
+
"@empiricalrun/shared-types": "0.6.4"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"dev": "tspc --build --watch",
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/index.ts","./src/logger.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/skill.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/browsing/index.ts","./src/agent/browsing/run.ts","./src/agent/browsing/utils.ts","./src/agent/chat/agent-loop.ts","./src/agent/chat/exports.ts","./src/agent/chat/index.ts","./src/agent/chat/models.ts","./src/agent/chat/state.ts","./src/agent/chat/types.ts","./src/agent/chat/utils.ts","./src/agent/chat/prompt/index.ts","./src/agent/chat/prompt/pw-utils-docs.ts","./src/agent/chat/prompt/repo.ts","./src/agent/codegen/create-test-block.ts","./src/agent/codegen/fix-ts-errors.ts","./src/agent/codegen/generate-code-apply-changes.ts","./src/agent/codegen/lexical-scoped-vars.ts","./src/agent/codegen/repo-edit.ts","./src/agent/codegen/run.ts","./src/agent/codegen/skills-retriever.ts","./src/agent/codegen/test-update-feedback.ts","./src/agent/codegen/types.ts","./src/agent/codegen/update-flow.ts","./src/agent/codegen/use-skill.ts","./src/agent/codegen/utils.ts","./src/agent/cua/computer.ts","./src/agent/cua/index.ts","./src/agent/cua/model.ts","./src/agent/cua/pw-codegen/element-from-point.ts","./src/agent/cua/pw-codegen/types.ts","./src/agent/cua/pw-codegen/pw-pause/for-recorder.ts","./src/agent/cua/pw-codegen/pw-pause/index.ts","./src/agent/cua/pw-codegen/pw-pause/ipc.ts","./src/agent/cua/pw-codegen/pw-pause/patch.ts","./src/agent/cua/pw-codegen/pw-pause/types.ts","./src/agent/cua/pw-codegen/pw-pause/utils.ts","./src/agent/diagnosis-agent/index.ts","./src/agent/diagnosis-agent/strict-mode-violation.ts","./src/agent/enrich-prompt/index.ts","./src/agent/enrich-prompt/utils.ts","./src/agent/infer-agent/index.ts","./src/agent/master/action-tool-calls.ts","./src/agent/master/element-annotation.ts","./src/agent/master/execute-browser-action.ts","./src/agent/master/execute-skill-action.ts","./src/agent/master/next-action.ts","./src/agent/master/planner.ts","./src/agent/master/run.ts","./src/agent/master/scroller.ts","./src/agent/master/with-hints.ts","./src/agent/master/browser-tests/cua.spec.ts","./src/agent/master/browser-tests/fixtures.ts","./src/agent/master/browser-tests/index.spec.ts","./src/agent/master/browser-tests/skills.spec.ts","./src/agent/master/icon-descriptor/index.ts","./src/agent/master/icon-descriptor/normalize-svg.ts","./src/agent/planner/run-time-planner.ts","./src/agent/planner/run.ts","./src/artifacts/index.ts","./src/artifacts/utils.ts","./src/auth/api-client.ts","./src/auth/cli-auth.ts","./src/auth/index.ts","./src/auth/token-store.ts","./src/bin/environments.ts","./src/bin/index.ts","./src/bin/setup.ts","./src/bin/logger/index.ts","./src/bin/utils/context.ts","./src/bin/utils/index.ts","./src/bin/utils/fs/index.ts","./src/bin/utils/platform/web/index.ts","./src/bin/utils/platform/web/test-files/ts-path-import-validate.ts","./src/bin/utils/scenarios/index.ts","./src/browser-injected-scripts/annotate-elements.spec.ts","./src/constants/index.ts","./src/errors/index.ts","./src/evals/add-scenario-agent.evals.ts","./src/evals/append-create-test-agent.evals.ts","./src/evals/fetch-pom-skills-agent.evals.ts","./src/evals/infer-master-or-code-agent.evals.ts","./src/evals/master-agent.evals.ts","./src/evals/type.ts","./src/evals/update-scenario-agent.evals.ts","./src/file/client.ts","./src/file/server.ts","./src/human-in-the-loop/cli.ts","./src/human-in-the-loop/index.ts","./src/human-in-the-loop/ipc.ts","./src/page/index.ts","./src/prompts/lib/ts-transformer.ts","./src/recorder/env-variables.ts","./src/recorder/index.ts","./src/recorder/request.ts","./src/recorder/temp-files.ts","./src/recorder/upload.ts","./src/recorder/validation.ts","./src/
|
|
1
|
+
{"root":["./src/index.ts","./src/logger.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/skill.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/browsing/index.ts","./src/agent/browsing/run.ts","./src/agent/browsing/utils.ts","./src/agent/chat/agent-loop.ts","./src/agent/chat/exports.ts","./src/agent/chat/index.ts","./src/agent/chat/models.ts","./src/agent/chat/state.ts","./src/agent/chat/types.ts","./src/agent/chat/utils.ts","./src/agent/chat/prompt/index.ts","./src/agent/chat/prompt/pw-utils-docs.ts","./src/agent/chat/prompt/repo.ts","./src/agent/codegen/create-test-block.ts","./src/agent/codegen/fix-ts-errors.ts","./src/agent/codegen/generate-code-apply-changes.ts","./src/agent/codegen/lexical-scoped-vars.ts","./src/agent/codegen/repo-edit.ts","./src/agent/codegen/run.ts","./src/agent/codegen/skills-retriever.ts","./src/agent/codegen/test-update-feedback.ts","./src/agent/codegen/types.ts","./src/agent/codegen/update-flow.ts","./src/agent/codegen/use-skill.ts","./src/agent/codegen/utils.ts","./src/agent/cua/computer.ts","./src/agent/cua/index.ts","./src/agent/cua/model.ts","./src/agent/cua/pw-codegen/element-from-point.ts","./src/agent/cua/pw-codegen/types.ts","./src/agent/cua/pw-codegen/pw-pause/for-recorder.ts","./src/agent/cua/pw-codegen/pw-pause/index.ts","./src/agent/cua/pw-codegen/pw-pause/ipc.ts","./src/agent/cua/pw-codegen/pw-pause/patch.ts","./src/agent/cua/pw-codegen/pw-pause/types.ts","./src/agent/cua/pw-codegen/pw-pause/utils.ts","./src/agent/diagnosis-agent/index.ts","./src/agent/diagnosis-agent/strict-mode-violation.ts","./src/agent/enrich-prompt/index.ts","./src/agent/enrich-prompt/utils.ts","./src/agent/infer-agent/index.ts","./src/agent/master/action-tool-calls.ts","./src/agent/master/element-annotation.ts","./src/agent/master/execute-browser-action.ts","./src/agent/master/execute-skill-action.ts","./src/agent/master/next-action.ts","./src/agent/master/planner.ts","./src/agent/master/run.ts","./src/agent/master/scroller.ts","./src/agent/master/with-hints.ts","./src/agent/master/browser-tests/cua.spec.ts","./src/agent/master/browser-tests/fixtures.ts","./src/agent/master/browser-tests/index.spec.ts","./src/agent/master/browser-tests/skills.spec.ts","./src/agent/master/icon-descriptor/index.ts","./src/agent/master/icon-descriptor/normalize-svg.ts","./src/agent/planner/run-time-planner.ts","./src/agent/planner/run.ts","./src/artifacts/index.ts","./src/artifacts/utils.ts","./src/auth/api-client.ts","./src/auth/cli-auth.ts","./src/auth/index.ts","./src/auth/token-store.ts","./src/bin/environments.ts","./src/bin/index.ts","./src/bin/setup.ts","./src/bin/logger/index.ts","./src/bin/utils/context.ts","./src/bin/utils/index.ts","./src/bin/utils/fs/index.ts","./src/bin/utils/platform/web/index.ts","./src/bin/utils/platform/web/test-files/ts-path-import-validate.ts","./src/bin/utils/scenarios/index.ts","./src/browser-injected-scripts/annotate-elements.spec.ts","./src/constants/index.ts","./src/errors/index.ts","./src/evals/add-scenario-agent.evals.ts","./src/evals/append-create-test-agent.evals.ts","./src/evals/fetch-pom-skills-agent.evals.ts","./src/evals/infer-master-or-code-agent.evals.ts","./src/evals/master-agent.evals.ts","./src/evals/type.ts","./src/evals/update-scenario-agent.evals.ts","./src/file/client.ts","./src/file/server.ts","./src/human-in-the-loop/cli.ts","./src/human-in-the-loop/index.ts","./src/human-in-the-loop/ipc.ts","./src/page/index.ts","./src/prompts/lib/ts-transformer.ts","./src/recorder/env-variables.ts","./src/recorder/index.ts","./src/recorder/request.ts","./src/recorder/temp-files.ts","./src/recorder/upload.ts","./src/recorder/validation.ts","./src/session/index.ts","./src/test-build/index.ts","./src/tool-call-service/index.ts","./src/tool-call-service/utils.ts","./src/tools/commit-and-create-pr.ts","./src/tools/diagnosis-fetcher.ts","./src/tools/download-build.ts","./src/tools/list-environments.ts","./src/tools/run-test.ts","./src/tools/str_replace_editor.ts","./src/tools/test-gen-browser.ts","./src/tools/grep/index.ts","./src/tools/grep/ripgrep/index.ts","./src/tools/grep/ripgrep/types.ts","./src/tools/test-run-fetcher/index.ts","./src/tools/test-run-fetcher/types.ts","./src/tools/upgrade-packages/index.ts","./src/tools/upgrade-packages/utils.ts","./src/tools/utils/index.ts","./src/types/handlebars.d.ts","./src/types/index.ts","./src/utils/checkpoint.ts","./src/utils/env.ts","./src/utils/exec.ts","./src/utils/file-tree.ts","./src/utils/file.ts","./src/utils/git.ts","./src/utils/html.ts","./src/utils/index.ts","./src/utils/json.ts","./src/utils/repo-tree.ts","./src/utils/slug.ts","./src/utils/string.ts","./src/utils/stripAnsi.ts"],"version":"5.8.3"}
|
package/dist/reporter/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Reporter } from "./lib";
|
|
2
|
-
type ReporterConfigType = {
|
|
3
|
-
testSessionId: number;
|
|
4
|
-
generationId: number;
|
|
5
|
-
projectRepoName: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function getReporter(): Reporter | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* function will upload videos and json summary of test results to r2 and report them to reporter.
|
|
10
|
-
* method won't throw error if it fails to report
|
|
11
|
-
*/
|
|
12
|
-
export declare function setReporterConfig(config: ReporterConfigType): void;
|
|
13
|
-
export declare class TestGenUpdatesReporter {
|
|
14
|
-
private repoDir;
|
|
15
|
-
constructor();
|
|
16
|
-
reportGenAssets({ projectRepoName, testName, }: {
|
|
17
|
-
projectRepoName: string;
|
|
18
|
-
testName: string;
|
|
19
|
-
}): Promise<void>;
|
|
20
|
-
sendCurrentView(buffer: Buffer): Promise<void>;
|
|
21
|
-
sendMessage(message: string): Promise<void>;
|
|
22
|
-
sendLogUrl(message: string): Promise<void>;
|
|
23
|
-
sendAgentTraceUrl(message: string): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAAkB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjD,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAKF,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAUlD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAElE;AAED,qBAAa,sBAAsB;IACjC,OAAO,CAAC,OAAO,CAAS;;IAKlB,eAAe,CAAC,EACpB,eAAe,EACf,QAAQ,GACT,EAAE;QACD,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;KAClB;IAgDK,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8C9C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY1C,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWxD"}
|
package/dist/reporter/index.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
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.TestGenUpdatesReporter = void 0;
|
|
7
|
-
exports.getReporter = getReporter;
|
|
8
|
-
exports.setReporterConfig = setReporterConfig;
|
|
9
|
-
const r2_uploader_1 = require("@empiricalrun/r2-uploader");
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const logger_1 = require("../bin/logger");
|
|
13
|
-
const uploader_1 = require("../uploader");
|
|
14
|
-
const lib_1 = require("./lib");
|
|
15
|
-
let reporterInstance = undefined;
|
|
16
|
-
let reporterConfig = undefined;
|
|
17
|
-
function getReporter() {
|
|
18
|
-
// if no config is set, return undefined
|
|
19
|
-
if (!reporterConfig) {
|
|
20
|
-
console.warn("initialising reporter without any config");
|
|
21
|
-
}
|
|
22
|
-
// initialise once config is set
|
|
23
|
-
if (!reporterInstance && reporterConfig) {
|
|
24
|
-
reporterInstance = new lib_1.Reporter(reporterConfig);
|
|
25
|
-
}
|
|
26
|
-
return reporterInstance;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* function will upload videos and json summary of test results to r2 and report them to reporter.
|
|
30
|
-
* method won't throw error if it fails to report
|
|
31
|
-
*/
|
|
32
|
-
function setReporterConfig(config) {
|
|
33
|
-
reporterConfig = config;
|
|
34
|
-
}
|
|
35
|
-
class TestGenUpdatesReporter {
|
|
36
|
-
repoDir;
|
|
37
|
-
constructor() {
|
|
38
|
-
this.repoDir = process.cwd();
|
|
39
|
-
}
|
|
40
|
-
async reportGenAssets({ projectRepoName, testName, }) {
|
|
41
|
-
const logger = new logger_1.CustomLogger();
|
|
42
|
-
try {
|
|
43
|
-
if (!(0, uploader_1.checkIfResultsUploadAllowed)()) {
|
|
44
|
-
logger.log("Skipped uploading generated test video");
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
console.log("Uploading assets for the test genearation");
|
|
48
|
-
const { videoUrls, traceFiles } = await (0, uploader_1.uploadTestResultsUsingPrjRepo)({
|
|
49
|
-
projectRepoName,
|
|
50
|
-
testName,
|
|
51
|
-
repoDir: this.repoDir,
|
|
52
|
-
});
|
|
53
|
-
const reporter = getReporter();
|
|
54
|
-
await Promise.allSettled([
|
|
55
|
-
...(videoUrls.length
|
|
56
|
-
? [
|
|
57
|
-
reporter?.report(new lib_1.MessageBuilder({
|
|
58
|
-
type: "video",
|
|
59
|
-
message: JSON.stringify({
|
|
60
|
-
type: "video",
|
|
61
|
-
videoUrls,
|
|
62
|
-
}),
|
|
63
|
-
})),
|
|
64
|
-
]
|
|
65
|
-
: []),
|
|
66
|
-
...(traceFiles.length
|
|
67
|
-
? [
|
|
68
|
-
reporter?.report(new lib_1.MessageBuilder({
|
|
69
|
-
type: "pw-trace",
|
|
70
|
-
message: JSON.stringify({
|
|
71
|
-
type: "trace",
|
|
72
|
-
traceFiles,
|
|
73
|
-
}),
|
|
74
|
-
})),
|
|
75
|
-
]
|
|
76
|
-
: []),
|
|
77
|
-
]);
|
|
78
|
-
}
|
|
79
|
-
catch (err) {
|
|
80
|
-
logger.error("Failed to report test results");
|
|
81
|
-
console.error(err);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
async sendCurrentView(buffer) {
|
|
85
|
-
const logger = new logger_1.CustomLogger();
|
|
86
|
-
if (!(0, uploader_1.checkIfResultsUploadAllowed)()) {
|
|
87
|
-
logger.log("Skipped uploading current view screenshot");
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if (!reporterConfig?.projectRepoName) {
|
|
91
|
-
logger.log("Reporter config is not set skipping screenshot uploads.");
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
// upload current screenshot to r2 and report it to reporter
|
|
96
|
-
if (!fs_1.default.existsSync(path_1.default.join(this.repoDir, "gen-assets"))) {
|
|
97
|
-
fs_1.default.mkdirSync(path_1.default.join(this.repoDir, "gen-assets"));
|
|
98
|
-
}
|
|
99
|
-
fs_1.default.writeFileSync(path_1.default.join(this.repoDir, "gen-assets", `current-view-${Date.now()}.png`), buffer);
|
|
100
|
-
const uploadDir = (0, uploader_1.getUploadPathForRun)(reporterConfig?.projectRepoName);
|
|
101
|
-
const files = await (0, r2_uploader_1.uploadDirectory)({
|
|
102
|
-
sourceDir: path_1.default.join(this.repoDir, "gen-assets"),
|
|
103
|
-
destinationDir: uploadDir,
|
|
104
|
-
uploadBucket: uploader_1.UPLOAD_BUCKET,
|
|
105
|
-
});
|
|
106
|
-
const filePath = Object.keys(files)[0];
|
|
107
|
-
const relativeFilePath = filePath.replace(path_1.default.join(this.repoDir, "gen-assets"), "");
|
|
108
|
-
const url = `${uploader_1.UPLOAD_DOMAIN}/${uploadDir}${relativeFilePath}`;
|
|
109
|
-
await getReporter()?.report(new lib_1.MessageBuilder({
|
|
110
|
-
type: "current-snapshot",
|
|
111
|
-
message: JSON.stringify({ type: "current-view", url }),
|
|
112
|
-
}));
|
|
113
|
-
fs_1.default.rmdirSync(path_1.default.join(this.repoDir, "gen-assets"), {
|
|
114
|
-
recursive: true,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
console.warn("Failed to upload current view screenshot", e);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async sendMessage(message) {
|
|
122
|
-
const reporter = getReporter();
|
|
123
|
-
if (reporter) {
|
|
124
|
-
await reporter.report(new lib_1.MessageBuilder({
|
|
125
|
-
type: "message",
|
|
126
|
-
message,
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
async sendLogUrl(message) {
|
|
131
|
-
const reporter = getReporter();
|
|
132
|
-
if (reporter) {
|
|
133
|
-
await reporter.report(new lib_1.MessageBuilder({
|
|
134
|
-
type: "log-url",
|
|
135
|
-
message,
|
|
136
|
-
}));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
async sendAgentTraceUrl(message) {
|
|
140
|
-
const reporter = getReporter();
|
|
141
|
-
if (reporter) {
|
|
142
|
-
await reporter.report(new lib_1.MessageBuilder({
|
|
143
|
-
type: "agent-trace",
|
|
144
|
-
message,
|
|
145
|
-
}));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
exports.TestGenUpdatesReporter = TestGenUpdatesReporter;
|
package/dist/reporter/lib.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
type DashboardMessagePayload = {
|
|
2
|
-
message: string;
|
|
3
|
-
messageType: "message" | "agent-trace" | "current-snapshot" | "video" | "pw-trace" | "log-url" | "commit-id";
|
|
4
|
-
pull_request?: string;
|
|
5
|
-
testCaseName?: string;
|
|
6
|
-
testCaseId?: number;
|
|
7
|
-
projectRepoName?: string;
|
|
8
|
-
testSessionId?: number;
|
|
9
|
-
generationId?: number;
|
|
10
|
-
};
|
|
11
|
-
export declare class MessageBuilder {
|
|
12
|
-
private props;
|
|
13
|
-
constructor(props: {
|
|
14
|
-
message: string;
|
|
15
|
-
type: DashboardMessagePayload["messageType"];
|
|
16
|
-
});
|
|
17
|
-
buildMessage(dashboardOptions?: {
|
|
18
|
-
override?: Partial<DashboardMessagePayload>;
|
|
19
|
-
}): DashboardMessagePayload;
|
|
20
|
-
}
|
|
21
|
-
export declare class Reporter {
|
|
22
|
-
private config;
|
|
23
|
-
constructor(config: {
|
|
24
|
-
testSessionId: number;
|
|
25
|
-
generationId: number;
|
|
26
|
-
});
|
|
27
|
-
report(messageBuilder: MessageBuilder): Promise<void>;
|
|
28
|
-
private sendMessageToDashboard;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/reporter/lib.ts"],"names":[],"mappings":"AAMA,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EACP,SAAS,GACT,aAAa,GACb,kBAAkB,GAClB,OAAO,GACP,UAAU,GACV,SAAS,GACT,WAAW,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,qBAAa,cAAc;IAEvB,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,uBAAuB,CAAC,aAAa,CAAC,CAAC;KAC9C;IAGH,YAAY,CAAC,gBAAgB,CAAC,EAAE;QAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;KAC7C,GAAG,uBAAuB;CAO5B;AAED,qBAAa,QAAQ;IAEjB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE;QACd,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;KACtB;IAGG,MAAM,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;YAc7C,sBAAsB;CAkCrC"}
|
package/dist/reporter/lib.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
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.Reporter = exports.MessageBuilder = void 0;
|
|
7
|
-
const async_retry_1 = __importDefault(require("async-retry"));
|
|
8
|
-
const DASHBOARD_DOMAIN = process.env.DASHBOARD_DOMAIN ||
|
|
9
|
-
(process.env.CI === "true" ? "https://dash.empirical.run" : "");
|
|
10
|
-
class MessageBuilder {
|
|
11
|
-
props;
|
|
12
|
-
constructor(props) {
|
|
13
|
-
this.props = props;
|
|
14
|
-
}
|
|
15
|
-
buildMessage(dashboardOptions) {
|
|
16
|
-
return {
|
|
17
|
-
...dashboardOptions?.override,
|
|
18
|
-
message: this.props.message,
|
|
19
|
-
messageType: this.props.type,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.MessageBuilder = MessageBuilder;
|
|
24
|
-
class Reporter {
|
|
25
|
-
config;
|
|
26
|
-
constructor(config) {
|
|
27
|
-
this.config = config;
|
|
28
|
-
}
|
|
29
|
-
async report(messageBuilder) {
|
|
30
|
-
const message = messageBuilder.buildMessage({
|
|
31
|
-
override: {
|
|
32
|
-
testSessionId: this.config.testSessionId,
|
|
33
|
-
generationId: this.config.generationId,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
if (!message) {
|
|
37
|
-
console.info("No message found. Skipping sending message to dashboard");
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
await this.sendMessageToDashboard(message);
|
|
41
|
-
}
|
|
42
|
-
async sendMessageToDashboard(message) {
|
|
43
|
-
if (!DASHBOARD_DOMAIN) {
|
|
44
|
-
console.warn("No dashboard domain found. Skipping send message to dashboard");
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
await (0, async_retry_1.default)(async () => {
|
|
49
|
-
const body = JSON.stringify(message);
|
|
50
|
-
await fetch(`${DASHBOARD_DOMAIN}/api/github/updates`, {
|
|
51
|
-
method: "POST",
|
|
52
|
-
headers: {
|
|
53
|
-
"Content-Type": "application/json",
|
|
54
|
-
Authorization: `Bearer ${process.env.EMPIRICALRUN_API_KEY}`,
|
|
55
|
-
},
|
|
56
|
-
body,
|
|
57
|
-
});
|
|
58
|
-
}, {
|
|
59
|
-
retries: 3,
|
|
60
|
-
minTimeout: 1000,
|
|
61
|
-
maxTimeout: 60_000,
|
|
62
|
-
factor: 3,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
console.error(`Error sending message to Dashboard: ${e.code}`);
|
|
67
|
-
console.error(e.message);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.Reporter = Reporter;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-run.d.ts","sourceRoot":"","sources":["../../src/tools/test-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AAwDnE,eAAO,MAAM,WAAW,EAAE,IAqFzB,CAAC"}
|
package/dist/uploader/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export declare const UPLOAD_BUCKET = "test-report";
|
|
2
|
-
export declare const UPLOAD_DOMAIN = "https://reports.empirical.run";
|
|
3
|
-
export declare function getFullUploadPath(repoDir: string, filePath: string, uploadDir: string): string;
|
|
4
|
-
export declare function getRelativeUploadPath(filePath: string, repoDir: string): string;
|
|
5
|
-
/**
|
|
6
|
-
* Function to upload test results to R2 using the project repo name and test name.
|
|
7
|
-
* This function uploads both the JSON summary of test results and associated video files.
|
|
8
|
-
* @param {Object} params - The parameters for the function.
|
|
9
|
-
* @param {string} params.projectRepoName - Name of the project repository.
|
|
10
|
-
* @param {string} params.testName - Name of the testcase which called this test-gen.
|
|
11
|
-
* @returns {Promise<Object>} An object containing arrays of video URLs and the summary JSON URL.
|
|
12
|
-
* @returns {string[]} returns.videoUrls - URLs of the uploaded video files.
|
|
13
|
-
* @returns {string} returns.summaryUrl - URL of the uploaded summary JSON file.
|
|
14
|
-
*/
|
|
15
|
-
export declare function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, repoDir, }: {
|
|
16
|
-
projectRepoName: string;
|
|
17
|
-
testName: string;
|
|
18
|
-
repoDir: string;
|
|
19
|
-
}): Promise<{
|
|
20
|
-
videoUrls: string[];
|
|
21
|
-
summaryUrl: string;
|
|
22
|
-
traceFiles: string[];
|
|
23
|
-
}>;
|
|
24
|
-
export declare function getUploadPathForRun(projectRepoName: string): string;
|
|
25
|
-
export declare function checkIfResultsUploadAllowed(): string | undefined;
|
|
26
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAC3C,eAAO,MAAM,aAAa,kCAAkC,CAAC;AAG7D,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,UAKlB;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAEtE;AAED;;;;;;;;;GASG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,eAAe,EACf,QAAQ,EACR,OAAO,GACR,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC;IACV,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC,CAiED;AAED,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,UAM1D;AAED,wBAAgB,2BAA2B,uBAQ1C"}
|
package/dist/uploader/index.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
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.UPLOAD_DOMAIN = exports.UPLOAD_BUCKET = void 0;
|
|
7
|
-
exports.getFullUploadPath = getFullUploadPath;
|
|
8
|
-
exports.getRelativeUploadPath = getRelativeUploadPath;
|
|
9
|
-
exports.uploadTestResultsUsingPrjRepo = uploadTestResultsUsingPrjRepo;
|
|
10
|
-
exports.getUploadPathForRun = getUploadPathForRun;
|
|
11
|
-
exports.checkIfResultsUploadAllowed = checkIfResultsUploadAllowed;
|
|
12
|
-
const r2_uploader_1 = require("@empiricalrun/r2-uploader");
|
|
13
|
-
const path_1 = __importDefault(require("path"));
|
|
14
|
-
const utils_1 = require("./utils");
|
|
15
|
-
// json summary of test results
|
|
16
|
-
// originally we used to upload test results directory for this
|
|
17
|
-
// but now we have our test results (per testcase artifacts) inside playwright-report/data
|
|
18
|
-
// but we also have summary.json in playwright-report/
|
|
19
|
-
// we can avoid html report upload here if we don't want
|
|
20
|
-
const PLAYWRIGHT_REPORT_DATA = "playwright-report/data";
|
|
21
|
-
exports.UPLOAD_BUCKET = "test-report";
|
|
22
|
-
exports.UPLOAD_DOMAIN = "https://reports.empirical.run"; // domain based on bucket mentioned above
|
|
23
|
-
const uploadId = crypto.randomUUID();
|
|
24
|
-
function getFullUploadPath(repoDir, filePath, uploadDir) {
|
|
25
|
-
// remove the source dir from the file path - only keep the relative path
|
|
26
|
-
const relativeFilePath = getRelativeUploadPath(filePath, repoDir);
|
|
27
|
-
return `${exports.UPLOAD_DOMAIN}/${uploadDir}${relativeFilePath}`;
|
|
28
|
-
}
|
|
29
|
-
function getRelativeUploadPath(filePath, repoDir) {
|
|
30
|
-
return filePath.replace(path_1.default.join(repoDir, PLAYWRIGHT_REPORT_DATA), "");
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Function to upload test results to R2 using the project repo name and test name.
|
|
34
|
-
* This function uploads both the JSON summary of test results and associated video files.
|
|
35
|
-
* @param {Object} params - The parameters for the function.
|
|
36
|
-
* @param {string} params.projectRepoName - Name of the project repository.
|
|
37
|
-
* @param {string} params.testName - Name of the testcase which called this test-gen.
|
|
38
|
-
* @returns {Promise<Object>} An object containing arrays of video URLs and the summary JSON URL.
|
|
39
|
-
* @returns {string[]} returns.videoUrls - URLs of the uploaded video files.
|
|
40
|
-
* @returns {string} returns.summaryUrl - URL of the uploaded summary JSON file.
|
|
41
|
-
*/
|
|
42
|
-
async function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, repoDir, }) {
|
|
43
|
-
const uploadDir = getUploadPathForRun(projectRepoName);
|
|
44
|
-
console.log("Current directory for assets upload", repoDir);
|
|
45
|
-
const files = await (0, r2_uploader_1.uploadDirectory)({
|
|
46
|
-
sourceDir: path_1.default.join(repoDir, PLAYWRIGHT_REPORT_DATA),
|
|
47
|
-
destinationDir: uploadDir,
|
|
48
|
-
uploadBucket: exports.UPLOAD_BUCKET,
|
|
49
|
-
});
|
|
50
|
-
// upload summary.json
|
|
51
|
-
await (0, r2_uploader_1.uploadDirectory)({
|
|
52
|
-
sourceDir: path_1.default.join(repoDir, "playwright-report"),
|
|
53
|
-
// TODO: this will only work for repos that use playwright 1.47.1
|
|
54
|
-
fileList: [path_1.default.join(repoDir, "playwright-report", "summary.json")],
|
|
55
|
-
destinationDir: uploadDir,
|
|
56
|
-
uploadBucket: exports.UPLOAD_BUCKET,
|
|
57
|
-
});
|
|
58
|
-
// fileNames are relative upload paths
|
|
59
|
-
const fileNames = Object.keys(files);
|
|
60
|
-
console.log("Uploaded files", fileNames.map((f) => getFullUploadPath(repoDir, f, uploadDir)));
|
|
61
|
-
const defaultLocation = path_1.default.join(repoDir, "playwright-report", "summary.json");
|
|
62
|
-
const results = (0, utils_1.parseJsonReport)(defaultLocation);
|
|
63
|
-
const flatTestsList = (0, utils_1.getFlattenedTestList)(results.suites);
|
|
64
|
-
const testAttachmentPaths = [];
|
|
65
|
-
for (const test of flatTestsList) {
|
|
66
|
-
if (test.title === testName) {
|
|
67
|
-
if (test.tests[0]) {
|
|
68
|
-
if (test.tests[0].results[0]) {
|
|
69
|
-
// results array is basically made by retries
|
|
70
|
-
for (const attachments of test.tests[0].results[0].attachments) {
|
|
71
|
-
if (attachments.path) {
|
|
72
|
-
testAttachmentPaths.push(getRelativeUploadPath(attachments.path, repoDir));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
const videoFiles = fileNames.filter((fileName) => fileName.endsWith(".webm") && testAttachmentPaths.includes(fileName));
|
|
80
|
-
const traceFiles = fileNames.filter((fileName) => fileName.endsWith(".zip") && testAttachmentPaths.includes(fileName));
|
|
81
|
-
console.log("videoFiles", videoFiles);
|
|
82
|
-
console.log("traceFiles", traceFiles);
|
|
83
|
-
return {
|
|
84
|
-
videoUrls: videoFiles
|
|
85
|
-
.map((fileName) => getFullUploadPath(repoDir, fileName, uploadDir))
|
|
86
|
-
.filter((url) => !!url),
|
|
87
|
-
summaryUrl: `${exports.UPLOAD_DOMAIN}/${uploadDir}/summary.json`,
|
|
88
|
-
traceFiles: traceFiles
|
|
89
|
-
.map((fileName) => getFullUploadPath(repoDir, fileName, uploadDir))
|
|
90
|
-
.filter((url) => !!url),
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function getUploadPathForRun(projectRepoName) {
|
|
94
|
-
const uploadDir = `test-generation/${projectRepoName.replace("-tests", "")}/${uploadId}`;
|
|
95
|
-
return uploadDir;
|
|
96
|
-
}
|
|
97
|
-
function checkIfResultsUploadAllowed() {
|
|
98
|
-
// TODO: check for valid R2 credentials
|
|
99
|
-
// check for project repo name, and r2 creds
|
|
100
|
-
return (process.env.R2_ACCOUNT_ID &&
|
|
101
|
-
process.env.R2_ACCESS_KEY_ID &&
|
|
102
|
-
process.env.R2_SECRET_ACCESS_KEY);
|
|
103
|
-
}
|
package/dist/uploader/utils.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { JSONReportSpec, JSONReportSuite } from "@playwright/test/reporter";
|
|
2
|
-
export declare function parseJsonReport<T>(srcFile: string): T;
|
|
3
|
-
export type flattenedSpecT = JSONReportSpec & {
|
|
4
|
-
nesting: string[];
|
|
5
|
-
suitesString: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const getFlattenedTestList: (suites: JSONReportSuite[]) => flattenedSpecT[];
|
|
8
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/uploader/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAChB,MAAM,2BAA2B,CAAC;AAGnC,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAErD;AAMD,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG;IAC5C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,eAAe,EAAE,KACxB,cAAc,EA4BhB,CAAC"}
|
package/dist/uploader/utils.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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.getFlattenedTestList = void 0;
|
|
7
|
-
exports.parseJsonReport = parseJsonReport;
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
function parseJsonReport(srcFile) {
|
|
10
|
-
return JSON.parse(fs_1.default.readFileSync(srcFile, { encoding: "utf-8" }));
|
|
11
|
-
}
|
|
12
|
-
const getFlattenedTestList = (suites) => {
|
|
13
|
-
let flattenedSpecs = [];
|
|
14
|
-
const traverseSuites = (suite, nesting = []) => {
|
|
15
|
-
nesting = [...nesting, suite.title];
|
|
16
|
-
flattenedSpecs.push(...suite.specs.map((spec) => {
|
|
17
|
-
const finalNesting = [...nesting, spec.title];
|
|
18
|
-
const suites = nesting.slice(1);
|
|
19
|
-
const suitesString = suites.length ? suites.join("~~") : "~~";
|
|
20
|
-
return {
|
|
21
|
-
...spec,
|
|
22
|
-
nesting: finalNesting,
|
|
23
|
-
suitesString,
|
|
24
|
-
};
|
|
25
|
-
}));
|
|
26
|
-
// Traverse nested suites recursively
|
|
27
|
-
if (suite.suites && suite.suites.length > 0) {
|
|
28
|
-
suite.suites.forEach((suite) => traverseSuites(suite, nesting));
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
// Start the traversal from the top-level suites
|
|
32
|
-
suites.forEach((suite) => traverseSuites(suite));
|
|
33
|
-
return flattenedSpecs;
|
|
34
|
-
};
|
|
35
|
-
exports.getFlattenedTestList = getFlattenedTestList;
|