@empiricalrun/test-gen 0.31.10 → 0.31.13
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 +21 -0
- package/dist/actions/next-task.d.ts.map +1 -1
- package/dist/actions/next-task.js +2 -1
- package/dist/actions/utils/index.d.ts.map +1 -1
- package/dist/actions/utils/index.js +2 -1
- package/dist/agent/browsing/o1-completion.d.ts.map +1 -1
- package/dist/agent/browsing/o1-completion.js +1 -0
- package/dist/agent/master/run.d.ts +9 -0
- package/dist/agent/master/run.d.ts.map +1 -1
- package/dist/agent/master/run.js +24 -12
- package/dist/bin/index.js +6 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.31.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 759bfc0: fix: accuracy of element selector
|
|
8
|
+
|
|
9
|
+
## 0.31.12
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- a8f2ea6: chore: add test for master agent
|
|
14
|
+
- Updated dependencies [10f554d]
|
|
15
|
+
- @empiricalrun/reporter@0.20.2
|
|
16
|
+
|
|
17
|
+
## 0.31.11
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [9623b74]
|
|
22
|
+
- @empiricalrun/reporter@0.20.1
|
|
23
|
+
|
|
3
24
|
## 0.31.10
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-task.d.ts","sourceRoot":"","sources":["../../src/actions/next-task.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"next-task.d.ts","sourceRoot":"","sources":["../../src/actions/next-task.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;CA2B1B,CAAC"}
|
|
@@ -15,7 +15,8 @@ exports.NextTaskAction = {
|
|
|
15
15
|
action: {
|
|
16
16
|
type: "string",
|
|
17
17
|
description: `explain the next action in natural language.
|
|
18
|
-
The next action should be as atomic as possible
|
|
18
|
+
The next action should be as atomic as possible, precise and should contain enough details about the action to be performed.
|
|
19
|
+
E.g. each click, key press, input, assert should be a separate action.
|
|
19
20
|
Each action should take the task to completion, if not the action is invalid.`,
|
|
20
21
|
},
|
|
21
22
|
reason: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actions/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE,GAAG,CAAC;QAChB,MAAM,EAAE,GAAG,CAAC;KACb;CACF;AAED,wBAAsB,oCAAoC,CACxD,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actions/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE,GAAG,CAAC;QAChB,MAAM,EAAE,GAAG,CAAC;KACb;CACF;AAED,wBAAsB,oCAAoC,CACxD,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,IAAI,gBA8CX;AAED,wBAAgB,cAAc,WAG7B"}
|
|
@@ -14,7 +14,8 @@ async function getPlaywrightLocatorUsingCssSelector(cssSelector, xpath, page) {
|
|
|
14
14
|
}
|
|
15
15
|
let selectedElem;
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
const xpath = locator.xpath?.replaceAll("text()", "normalize-space()");
|
|
18
|
+
selectedElem = getElementByXpath(xpath);
|
|
18
19
|
}
|
|
19
20
|
catch (e) {
|
|
20
21
|
// ignore error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o1-completion.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/o1-completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAKpC,wBAAsB,eAAe,CAAC,EACpC,QAAQ,EACR,KAAK,EACL,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"o1-completion.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/o1-completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAKpC,wBAAsB,eAAe,CAAC,EACpC,QAAQ,EACR,KAAK,EACL,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CA0D7C"}
|
|
@@ -31,6 +31,7 @@ async function getO1Completion({ messages, tools, trace, }) {
|
|
|
31
31
|
Before responding, ensure the following:
|
|
32
32
|
- Do not respond with markdown, respond only with the JSON object.
|
|
33
33
|
- Do not respond with any backticks.
|
|
34
|
+
- The reason for action should also include what was been executed in the action.
|
|
34
35
|
`;
|
|
35
36
|
const response = (await llm.createChatCompletion({
|
|
36
37
|
messages: [userInstruction],
|
|
@@ -2,6 +2,15 @@ import { LLM, TraceClient } from "@empiricalrun/llm";
|
|
|
2
2
|
import { Page } from "playwright";
|
|
3
3
|
import { TestGenConfigOptions } from "../../types";
|
|
4
4
|
type BrowsingAgentOptions = Partial<TestGenConfigOptions>;
|
|
5
|
+
export declare function getNextAction({ task, executedActions, page, trace, llm, options, pageScreenshot, }: {
|
|
6
|
+
task: string;
|
|
7
|
+
executedActions: string[];
|
|
8
|
+
page: Page;
|
|
9
|
+
trace?: TraceClient;
|
|
10
|
+
llm: LLM;
|
|
11
|
+
options: BrowsingAgentOptions;
|
|
12
|
+
pageScreenshot: string;
|
|
13
|
+
}): Promise<import("openai/resources/index.mjs").ChatCompletionMessageToolCall | undefined>;
|
|
5
14
|
export declare function masterAgent(task: string, page: Page, executedActions: string[], trace: TraceClient, llm: LLM, options: BrowsingAgentOptions): Promise<any>;
|
|
6
15
|
export {};
|
|
7
16
|
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAQlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,KAAK,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAE1D,wBAAsB,aAAa,CAAC,EAClC,IAAI,EACJ,eAAe,EACf,IAAI,EACJ,KAAK,EACL,GAAG,EACH,OAAO,EACP,cAAc,GACf,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,GAAG,EAAE,GAAG,CAAC;IACT,OAAO,EAAE,oBAAoB,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;CACxB,2FA+CA;AAED,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,eAAe,EAAE,MAAM,EAAE,EACzB,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,oBAAoB,gBAsC9B"}
|
package/dist/agent/master/run.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.masterAgent = void 0;
|
|
3
|
+
exports.masterAgent = exports.getNextAction = void 0;
|
|
4
4
|
const llm_1 = require("@empiricalrun/llm");
|
|
5
5
|
const vision_1 = require("@empiricalrun/llm/vision");
|
|
6
|
-
const done_1 = require("../../actions/done");
|
|
7
6
|
const next_task_1 = require("../../actions/next-task");
|
|
8
7
|
const constants_1 = require("../../constants");
|
|
9
8
|
const reporter_1 = require("../../reporter");
|
|
10
|
-
async function
|
|
11
|
-
trace
|
|
12
|
-
const promptSpan = trace.span({ name: "page-prompt" });
|
|
13
|
-
const buffer = await page.screenshot({ fullPage: true });
|
|
14
|
-
const testGenReporter = new reporter_1.TestGenUpdatesReporter();
|
|
15
|
-
const testGenSnapshotUpdatePromise = testGenReporter.sendCurrentView(buffer);
|
|
16
|
-
const pageScreenshot = buffer.toString("base64");
|
|
9
|
+
async function getNextAction({ task, executedActions, page, trace, llm, options, pageScreenshot, }) {
|
|
10
|
+
const promptSpan = trace?.span({ name: "page-prompt" });
|
|
17
11
|
const promptMessages = await (0, llm_1.getPrompt)("test-gen", {
|
|
18
12
|
task,
|
|
19
13
|
executedActions: executedActions.map((a) => a).join("\n"),
|
|
@@ -38,8 +32,8 @@ async function masterAgent(task, page, executedActions, trace, llm, options) {
|
|
|
38
32
|
systemMessage,
|
|
39
33
|
userMessage,
|
|
40
34
|
];
|
|
41
|
-
const tools = [next_task_1.NextTaskAction.schema
|
|
42
|
-
promptSpan
|
|
35
|
+
const tools = [next_task_1.NextTaskAction.schema];
|
|
36
|
+
promptSpan?.end({ output: { messages } });
|
|
43
37
|
const completion = await llm.createChatCompletion({
|
|
44
38
|
messages,
|
|
45
39
|
modelParameters: {
|
|
@@ -52,8 +46,26 @@ async function masterAgent(task, page, executedActions, trace, llm, options) {
|
|
|
52
46
|
// @ts-ignore
|
|
53
47
|
tools,
|
|
54
48
|
});
|
|
55
|
-
let output;
|
|
56
49
|
const toolCall = completion?.tool_calls?.[0];
|
|
50
|
+
return toolCall;
|
|
51
|
+
}
|
|
52
|
+
exports.getNextAction = getNextAction;
|
|
53
|
+
async function masterAgent(task, page, executedActions, trace, llm, options) {
|
|
54
|
+
trace.update({ input: { task } });
|
|
55
|
+
const buffer = await page.screenshot({ fullPage: true });
|
|
56
|
+
const testGenReporter = new reporter_1.TestGenUpdatesReporter();
|
|
57
|
+
const testGenSnapshotUpdatePromise = testGenReporter.sendCurrentView(buffer);
|
|
58
|
+
const pageScreenshot = buffer.toString("base64");
|
|
59
|
+
let output;
|
|
60
|
+
const toolCall = await getNextAction({
|
|
61
|
+
task,
|
|
62
|
+
executedActions,
|
|
63
|
+
page,
|
|
64
|
+
trace,
|
|
65
|
+
llm,
|
|
66
|
+
options,
|
|
67
|
+
pageScreenshot,
|
|
68
|
+
});
|
|
57
69
|
if (toolCall) {
|
|
58
70
|
if (toolCall.function.name === "task_done") {
|
|
59
71
|
output = {
|
package/dist/bin/index.js
CHANGED
|
@@ -69,10 +69,12 @@ async function runAgent(testGenConfig) {
|
|
|
69
69
|
testGenFailed = true;
|
|
70
70
|
new logger_1.CustomLogger().error(`Failed to generate test for the scenario. ${process.env.LOG_URL ? `[view log](${process.env.LOG_URL})` : ""}`);
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
if (testGenConfig.options?.agent !== "code") {
|
|
73
|
+
await new reporter_1.TestGenUpdatesReporter().reportGenAssets({
|
|
74
|
+
projectRepoName: testGenConfig.options.metadata.projectRepoName,
|
|
75
|
+
testName: testGenConfig.testCase.name,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
76
78
|
// TODO: move these reporters to a better lifecycle
|
|
77
79
|
await (0, ci_1.reportOnCI)(testGenConfig.testCase);
|
|
78
80
|
await (0, llm_1.flushAllTraces)();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.13",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"ts-morph": "^23.0.0",
|
|
45
45
|
"tsx": "^4.16.2",
|
|
46
46
|
"typescript": "^5.3.3",
|
|
47
|
-
"@empiricalrun/llm": "^0.9.3",
|
|
48
47
|
"@empiricalrun/r2-uploader": "^0.3.3",
|
|
49
|
-
"@empiricalrun/reporter": "^0.20.
|
|
48
|
+
"@empiricalrun/reporter": "^0.20.2",
|
|
49
|
+
"@empiricalrun/llm": "^0.9.3"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/detect-port": "^1.3.5",
|