@empiricalrun/test-gen 0.45.1 → 0.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/agent/master/browser-tests/index.spec.js +30 -1
- package/dist/agent/master/element-annotation.d.ts +2 -1
- package/dist/agent/master/element-annotation.d.ts.map +1 -1
- package/dist/agent/master/element-annotation.js +60 -12
- package/dist/agent/master/icon-descriptor/index.d.ts +22 -0
- package/dist/agent/master/icon-descriptor/index.d.ts.map +1 -0
- package/dist/agent/master/icon-descriptor/index.js +211 -0
- package/dist/agent/master/icon-descriptor/normalize-svg.d.ts +2 -0
- package/dist/agent/master/icon-descriptor/normalize-svg.d.ts.map +1 -0
- package/dist/agent/master/icon-descriptor/normalize-svg.js +248 -0
- package/dist/agent/master/run.d.ts.map +1 -1
- package/dist/agent/master/run.js +1 -0
- package/dist/agent/master/scroller.d.ts.map +1 -1
- package/dist/agent/master/scroller.js +1 -0
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.46.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0aa2054: test: add failing test for annotation enrichment for iframes
|
|
8
|
+
- 21f5534: fix: enrich annotations inside iframes
|
|
9
|
+
|
|
10
|
+
## 0.46.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- b6dfc91: feat: create icon registry for test repositories
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- b6dfc91: feat: cache icon description generated through LLM
|
|
19
|
+
|
|
3
20
|
## 0.45.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -4,8 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const test_1 = require("@playwright/test");
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
8
|
const http_server_1 = __importDefault(require("http-server"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const utils_1 = require("../../browsing/utils");
|
|
11
|
+
const element_annotation_1 = require("../element-annotation");
|
|
9
12
|
const run_1 = require("../run");
|
|
10
13
|
let server;
|
|
11
14
|
let PORT = 2345;
|
|
@@ -57,9 +60,35 @@ test_1.test.afterAll(() => {
|
|
|
57
60
|
page,
|
|
58
61
|
options: {},
|
|
59
62
|
});
|
|
63
|
+
// Validate code generated and action performed
|
|
60
64
|
await (0, test_1.expect)(page.getByText("you clicked Gear")).toBeVisible();
|
|
61
65
|
console.log(response);
|
|
62
66
|
(0, test_1.expect)(response.importPaths.length).toBe(0);
|
|
63
|
-
(0, test_1.expect)(response.code).toContain("page.
|
|
67
|
+
(0, test_1.expect)(response.code).toContain("page.locator");
|
|
64
68
|
(0, test_1.expect)(response.code).toContain("click()");
|
|
69
|
+
// Validate icons registry
|
|
70
|
+
const iconsRegistryFile = path_1.default.join(process.cwd(), "icons.json");
|
|
71
|
+
const icons = JSON.parse(fs_1.default.readFileSync(iconsRegistryFile, "utf-8"));
|
|
72
|
+
(0, test_1.expect)(icons.length).toBe(4); // 1 for each unique icon
|
|
73
|
+
fs_1.default.unlinkSync(iconsRegistryFile);
|
|
74
|
+
});
|
|
75
|
+
(0, test_1.test)("annotate and enrich annotations correctly", async ({ page }) => {
|
|
76
|
+
await (0, utils_1.injectPwLocatorGenerator)(page);
|
|
77
|
+
await page.goto(`http://localhost:${PORT}/iframe-elements.html`);
|
|
78
|
+
const { annotationKeys: keys } = await (0, element_annotation_1.getAnnotationKeys)({
|
|
79
|
+
page,
|
|
80
|
+
preference: {
|
|
81
|
+
actionType: "all",
|
|
82
|
+
},
|
|
83
|
+
options: {},
|
|
84
|
+
});
|
|
85
|
+
console.log(keys);
|
|
86
|
+
(0, test_1.expect)(keys.length).toBe(6);
|
|
87
|
+
// 2 icons: 1 in main frame, 1 in iframe
|
|
88
|
+
(0, test_1.expect)(keys.filter((k) => k.text.includes("icon") && k.text.includes("close"))
|
|
89
|
+
.length).toBe(2);
|
|
90
|
+
// 2 text inputs: 1 in main frame, 1 in iframe
|
|
91
|
+
(0, test_1.expect)(keys.filter((k) => k.text.includes("Enter your name")).length).toBe(2);
|
|
92
|
+
// 2 clickable divs: 1 in main frame, 1 in iframe
|
|
93
|
+
(0, test_1.expect)(keys.filter((k) => k.text.includes("Lorem Ipsum")).length).toBe(2);
|
|
65
94
|
});
|
|
@@ -15,10 +15,11 @@ export type AnnotationPreference = {
|
|
|
15
15
|
actionType: "all" | ActionType.FILL | ActionType.ASSERT_TEXT | ActionType.SCROLL;
|
|
16
16
|
assertionText?: string | undefined;
|
|
17
17
|
};
|
|
18
|
-
export declare function getAnnotationKeys({ page, preference, options, }: {
|
|
18
|
+
export declare function getAnnotationKeys({ page, preference, options, trace, }: {
|
|
19
19
|
page: Page;
|
|
20
20
|
preference: AnnotationPreference;
|
|
21
21
|
options: BrowsingAgentOptions;
|
|
22
|
+
trace?: TraceClient;
|
|
22
23
|
}): Promise<{
|
|
23
24
|
annotationKeys: {
|
|
24
25
|
elementID: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-annotation.d.ts","sourceRoot":"","sources":["../../../src/agent/master/element-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAQlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"element-annotation.d.ts","sourceRoot":"","sources":["../../../src/agent/master/element-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAQlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA2DjD,wBAAsB,oBAAoB,CAAC,EACzC,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,KAAK,EACL,GAAG,EACH,OAAO,EACP,UAAU,GACX,EAAE;IACD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,UAAU,EAAE,oBAAoB,CAAC;CAClC,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA8C9B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EACN,KAAK,GACL,UAAU,CAAC,IAAI,GACf,UAAU,CAAC,WAAW,GACtB,UAAU,CAAC,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC;AAgBF,wBAAsB,iBAAiB,CAAC,EACtC,IAAI,EACJ,UAAU,EACV,OAAO,EACP,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,oBAAoB,CAAC;IACjC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IACV,cAAc,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtD,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB,EAAE,MAAM,CAAC;CACjC,CAAC,CAoFD"}
|
|
@@ -5,6 +5,7 @@ const llm_1 = require("@empiricalrun/llm");
|
|
|
5
5
|
const constants_1 = require("../../constants");
|
|
6
6
|
const promptTemplate_0 = "{{#section \"system\"}}\nYou are an expert in describing the images and it's content. You need to provide the descriptions of annotated elements\npresent in the image.\n\nYou will be provided with an annotated screenshot where interact-able / clickable elements are annotated. The annotation\nis done by drawing a red box around the element and a small yellow box on it which contains unique element id.\n\nYou are given a Annotations which contains list of unique element id and description of the element separated by \":\".\n\nYou are also given the description of the element on which the action needs to be taken. The description includes\ninformation about how the element looks, it's position etc.\n\nYour task is to provide the annotation of the element on which the action needs to be performed based on the element\ndescription.\n\nFollow steps to fulfil your task:\n- Using the list of all element Ids provided to you, map all the element Ids on the annotated screen and describe each\nelement.\n- For describing each element Id\n-- iterate over each element Id in annotation list\n-- check if the description is already present for the element Id in the Annotation provided to you. If present skip\ndescribing it and use it as is.\n-- if the description is NA, then identify the element in the annotated screenshot and describe it using the image or\nicon enclosed in the element.\n- Respond with the mapped element Ids as \"enriched_annotations\"\n- Based on the description provided to you and the enriched annotations, first identify the element Id whose description\nmatches the task provided\n\nNote:\n- Ensure providing the description of all the elements in the list.\n- Don't update the description if its already present in the given annotations\n- Replace all the \"NA\" with description of the element. Its position, how does it look like etc.\n- There should be no \"NA\" present in any of the element description\n{{/section}}\n\n{{#section \"user\"}}\nElement description:\n{{elementDescription}}\n\nAnnotations:\n{{annotations}}\n\n{{image annotatedScreenshot}}\n{{/section}}";
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
+
const icon_descriptor_1 = require("./icon-descriptor");
|
|
8
9
|
const annotationToolAction = {
|
|
9
10
|
name: "element_annotation",
|
|
10
11
|
schema: {
|
|
@@ -99,8 +100,8 @@ async function getElementAnnotation({ elementDescription, annotations, annotated
|
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
101
102
|
exports.getElementAnnotation = getElementAnnotation;
|
|
102
|
-
async function getAnnotationKeys({ page, preference, options, }) {
|
|
103
|
-
const
|
|
103
|
+
async function getAnnotationKeys({ page, preference, options, trace, }) {
|
|
104
|
+
const annotatedElements = await page.evaluate(({ preference, options }) => {
|
|
104
105
|
// @ts-ignore
|
|
105
106
|
// eslint-disable-next-line no-undef
|
|
106
107
|
window.annotationInstance = annotateElementsWithPreference({
|
|
@@ -109,17 +110,37 @@ async function getAnnotationKeys({ page, preference, options, }) {
|
|
|
109
110
|
});
|
|
110
111
|
const annotations = Object.entries(
|
|
111
112
|
// @ts-ignore
|
|
112
|
-
window.annotationInstance.annotations).map(([key, value]) =>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
113
|
+
window.annotationInstance.annotations).map(([key, value]) => {
|
|
114
|
+
// Helper function to safely get text content
|
|
115
|
+
const getTextContent = (node) => {
|
|
116
|
+
try {
|
|
117
|
+
return node?.innerText?.trim() || null;
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
// Helper function to safely get placeholder
|
|
124
|
+
const getPlaceholder = (node) => {
|
|
125
|
+
try {
|
|
126
|
+
return node?.placeholder?.trim() || null;
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
elementID: key,
|
|
134
|
+
innerText: getTextContent(value.node),
|
|
135
|
+
innerHTML: value.node.innerHTML,
|
|
136
|
+
outerHTML: value.node.outerHTML,
|
|
137
|
+
placeholder: getPlaceholder(value.node),
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
const fullPageHTML = document.documentElement.outerHTML;
|
|
141
|
+
return { annotations, fullPageHTML };
|
|
122
142
|
}, { preference, options });
|
|
143
|
+
const annotationKeys = await enrichAnnotations(annotatedElements.annotations, annotatedElements.fullPageHTML, trace);
|
|
123
144
|
const annotationBuffer = await page.screenshot({
|
|
124
145
|
// path: `screenshots/screenshot-${screenshotIndex++}.png`,
|
|
125
146
|
});
|
|
@@ -145,3 +166,30 @@ async function getAnnotationKeys({ page, preference, options, }) {
|
|
|
145
166
|
};
|
|
146
167
|
}
|
|
147
168
|
exports.getAnnotationKeys = getAnnotationKeys;
|
|
169
|
+
async function enrichAnnotations(annotatedElements, pageHtml, trace) {
|
|
170
|
+
// create icon descriptor span
|
|
171
|
+
const iconDescriptionSpan = trace?.span({
|
|
172
|
+
name: "describe-icons",
|
|
173
|
+
});
|
|
174
|
+
const results = [];
|
|
175
|
+
for (const element of annotatedElements) {
|
|
176
|
+
const text = element.innerText?.trim() || element.placeholder?.trim();
|
|
177
|
+
if (text) {
|
|
178
|
+
results.push({
|
|
179
|
+
elementID: element.elementID,
|
|
180
|
+
text,
|
|
181
|
+
});
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const description = await (0, icon_descriptor_1.getIconDescription)({
|
|
185
|
+
htmlString: element.outerHTML,
|
|
186
|
+
pageHtml: pageHtml,
|
|
187
|
+
trace: iconDescriptionSpan,
|
|
188
|
+
});
|
|
189
|
+
results.push({
|
|
190
|
+
elementID: element.elementID,
|
|
191
|
+
text: description || "NA",
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return results;
|
|
195
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
+
type IconKnowledge = {
|
|
3
|
+
description: string;
|
|
4
|
+
key: string;
|
|
5
|
+
normalized: string;
|
|
6
|
+
createdAt: Date;
|
|
7
|
+
};
|
|
8
|
+
export declare function loadIconsKnowledge(): Array<IconKnowledge>;
|
|
9
|
+
export declare function saveIconsKnowledge(iconsData: Array<IconKnowledge>): Promise<void>;
|
|
10
|
+
export declare function generateKey(htmlString: string): string;
|
|
11
|
+
export declare function reverseKey(hash: string): string;
|
|
12
|
+
export declare function createNodeFromHTML(htmlString: string): {
|
|
13
|
+
node: Element | null;
|
|
14
|
+
children: Element[];
|
|
15
|
+
};
|
|
16
|
+
export declare function getIconDescription({ htmlString, pageHtml, trace, }: {
|
|
17
|
+
htmlString: string;
|
|
18
|
+
trace?: TraceClient;
|
|
19
|
+
pageHtml: string;
|
|
20
|
+
}): Promise<string | undefined>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agent/master/icon-descriptor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAWrD,KAAK,aAAa,GAAG;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,KAAK,CAAC,aAAa,CAAC,CAczD;AAED,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM;;;EAUpD;AAqKD,wBAAsB,kBAAkB,CAAC,EACvC,UAAU,EACV,QAAQ,EACR,KAAK,GACN,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkC9B"}
|
|
@@ -0,0 +1,211 @@
|
|
|
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.getIconDescription = exports.createNodeFromHTML = exports.reverseKey = exports.generateKey = exports.saveIconsKnowledge = exports.loadIconsKnowledge = void 0;
|
|
7
|
+
const llm_1 = require("@empiricalrun/llm");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const jsdom_1 = require("jsdom");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const constants_1 = require("../../../constants");
|
|
12
|
+
const normalize_svg_1 = require("./normalize-svg");
|
|
13
|
+
const ICONS_KNOWLEDGE_PATH = path_1.default.join(process.cwd(), "icons.json");
|
|
14
|
+
function loadIconsKnowledge() {
|
|
15
|
+
if (!fs_1.default.existsSync(ICONS_KNOWLEDGE_PATH)) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const raw = fs_1.default.readFileSync(ICONS_KNOWLEDGE_PATH, "utf-8");
|
|
19
|
+
if (raw) {
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(raw);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
console.log("error parsing iconsKnowledge json");
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
exports.loadIconsKnowledge = loadIconsKnowledge;
|
|
31
|
+
async function saveIconsKnowledge(iconsData) {
|
|
32
|
+
const content = JSON.stringify(iconsData, null, 2);
|
|
33
|
+
fs_1.default.writeFileSync(ICONS_KNOWLEDGE_PATH, content, "utf-8");
|
|
34
|
+
}
|
|
35
|
+
exports.saveIconsKnowledge = saveIconsKnowledge;
|
|
36
|
+
function generateKey(htmlString) {
|
|
37
|
+
const normalized = (0, normalize_svg_1.normalizeSVG)(htmlString);
|
|
38
|
+
// generate base64 string
|
|
39
|
+
const encoded = Buffer.from(normalized).toString("base64");
|
|
40
|
+
return `icon_${encoded}`;
|
|
41
|
+
}
|
|
42
|
+
exports.generateKey = generateKey;
|
|
43
|
+
function reverseKey(hash) {
|
|
44
|
+
const encoded = hash.replace(/^icon_/, "");
|
|
45
|
+
return Buffer.from(encoded, "base64").toString();
|
|
46
|
+
}
|
|
47
|
+
exports.reverseKey = reverseKey;
|
|
48
|
+
function createNodeFromHTML(htmlString) {
|
|
49
|
+
const dom = new jsdom_1.JSDOM(htmlString);
|
|
50
|
+
const document = dom.window.document;
|
|
51
|
+
const node = document.body.firstElementChild;
|
|
52
|
+
return {
|
|
53
|
+
node, // Return the first node
|
|
54
|
+
children: node?.children ? Array.from(node.children) : [], // Convert HTMLCollection to array
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.createNodeFromHTML = createNodeFromHTML;
|
|
58
|
+
function processSvgWithUseElements(svgElement, document) {
|
|
59
|
+
try {
|
|
60
|
+
const useElements = svgElement.querySelectorAll("use");
|
|
61
|
+
for (const useEl of Array.from(useElements)) {
|
|
62
|
+
const href = useEl.getAttribute("href") || useEl.getAttribute("xlink:href");
|
|
63
|
+
if (!href)
|
|
64
|
+
continue;
|
|
65
|
+
const id = href.startsWith("#") ? href.substring(1) : href;
|
|
66
|
+
const referencedElement = document.getElementById(id);
|
|
67
|
+
if (referencedElement) {
|
|
68
|
+
if (referencedElement.tagName.toLowerCase() === "symbol" ||
|
|
69
|
+
referencedElement.tagName.toLowerCase() === "svg") {
|
|
70
|
+
const group = document.createElement("g");
|
|
71
|
+
Array.from(useEl.attributes).forEach((attr) => {
|
|
72
|
+
if (attr.name !== "href" && attr.name !== "xlink:href") {
|
|
73
|
+
group.setAttribute(attr.name, attr.value);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
if (referencedElement.hasAttribute("viewBox")) {
|
|
77
|
+
group.setAttribute("viewBox", referencedElement.getAttribute("viewBox") || "");
|
|
78
|
+
}
|
|
79
|
+
group.innerHTML = referencedElement.innerHTML;
|
|
80
|
+
useEl.parentNode?.replaceChild(group, useEl);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
console.error("Error processing SVG with use elements:", error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Extracts and returns an SVG element from a given HTML string.
|
|
91
|
+
*
|
|
92
|
+
* This function checks whether the provided HTML string contains an SVG element
|
|
93
|
+
* either as the root node or as a child node.
|
|
94
|
+
*/
|
|
95
|
+
function getHtmlForDescription(elementHtml, pageHtml) {
|
|
96
|
+
const dom = new jsdom_1.JSDOM(pageHtml);
|
|
97
|
+
const page = dom.window.document;
|
|
98
|
+
const { node, children } = createNodeFromHTML(elementHtml);
|
|
99
|
+
if (!node) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
if (node.tagName.toLowerCase() === "svg") {
|
|
103
|
+
processSvgWithUseElements(node, page);
|
|
104
|
+
return node.outerHTML;
|
|
105
|
+
}
|
|
106
|
+
const svgChildren = children?.filter((child) => child?.tagName?.toLowerCase() === "svg");
|
|
107
|
+
if (svgChildren && svgChildren.length > 0) {
|
|
108
|
+
for (const svgChild of svgChildren) {
|
|
109
|
+
processSvgWithUseElements(svgChild, page);
|
|
110
|
+
}
|
|
111
|
+
return node.outerHTML;
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
async function describeSVGElementWithLLM({ element, trace, }) {
|
|
116
|
+
try {
|
|
117
|
+
const svgDescriptionSpan = trace?.span({
|
|
118
|
+
name: "get-svg-description",
|
|
119
|
+
input: {
|
|
120
|
+
element,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
const messages = [
|
|
124
|
+
{
|
|
125
|
+
role: "system",
|
|
126
|
+
content: `
|
|
127
|
+
You are an expert at reading svg icons. You are given a task to provide the description of an icon based on the given HTML element string.
|
|
128
|
+
If the string does not contain any svg element, return NA.
|
|
129
|
+
`,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
role: "user",
|
|
133
|
+
content: `
|
|
134
|
+
Provide the description of below element:
|
|
135
|
+
${element}
|
|
136
|
+
|
|
137
|
+
Follow below steps to provide the description:
|
|
138
|
+
- Identify the svg element in the given HTML string
|
|
139
|
+
- If the string does not contain any svg element, return NA
|
|
140
|
+
- Else, read the svg element and provide a single line description for the element
|
|
141
|
+
- The description should be precise and readable
|
|
142
|
+
- Only provide the element description and nothing else
|
|
143
|
+
`,
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
const llm = new llm_1.LLM({
|
|
147
|
+
trace: svgDescriptionSpan,
|
|
148
|
+
provider: "anthropic",
|
|
149
|
+
defaultModel: "claude-3-5-sonnet-latest",
|
|
150
|
+
providerApiKey: constants_1.MODEL_API_KEYS["anthropic"],
|
|
151
|
+
});
|
|
152
|
+
const svgDescription = await llm.createChatCompletion({
|
|
153
|
+
messages,
|
|
154
|
+
modelParameters: {
|
|
155
|
+
temperature: 0.3,
|
|
156
|
+
},
|
|
157
|
+
responseFormat: {
|
|
158
|
+
type: "json_schema",
|
|
159
|
+
json_schema: {
|
|
160
|
+
name: "describe-svg-element",
|
|
161
|
+
strict: true,
|
|
162
|
+
schema: {
|
|
163
|
+
type: "object",
|
|
164
|
+
properties: {
|
|
165
|
+
description: {
|
|
166
|
+
type: "string",
|
|
167
|
+
description: "A clear description of what the SVG visually represents",
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
additionalProperties: false,
|
|
171
|
+
required: ["description"],
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
svgDescriptionSpan?.end({ output: svgDescription });
|
|
177
|
+
return svgDescription?.content ?? undefined;
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
console.error(`Error generating svg description ${err}`);
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async function getIconDescription({ htmlString, pageHtml, trace, }) {
|
|
185
|
+
const elementStringForDescription = getHtmlForDescription(htmlString, pageHtml);
|
|
186
|
+
if (!elementStringForDescription) {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
const key = generateKey(elementStringForDescription);
|
|
190
|
+
const iconsData = loadIconsKnowledge();
|
|
191
|
+
const cachedIcon = iconsData.find((icon) => icon.key === key);
|
|
192
|
+
if (cachedIcon) {
|
|
193
|
+
return cachedIcon.description;
|
|
194
|
+
}
|
|
195
|
+
const description = await describeSVGElementWithLLM({
|
|
196
|
+
element: elementStringForDescription,
|
|
197
|
+
trace,
|
|
198
|
+
});
|
|
199
|
+
if (description) {
|
|
200
|
+
const newIconEntry = {
|
|
201
|
+
description,
|
|
202
|
+
key,
|
|
203
|
+
normalized: htmlString,
|
|
204
|
+
createdAt: new Date(),
|
|
205
|
+
};
|
|
206
|
+
iconsData.push(newIconEntry);
|
|
207
|
+
await saveIconsKnowledge(iconsData);
|
|
208
|
+
}
|
|
209
|
+
return description;
|
|
210
|
+
}
|
|
211
|
+
exports.getIconDescription = getIconDescription;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-svg.d.ts","sourceRoot":"","sources":["../../../../src/agent/master/icon-descriptor/normalize-svg.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA8BpD"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeSVG = void 0;
|
|
4
|
+
const jsdom_1 = require("jsdom");
|
|
5
|
+
function normalizeSVG(svgHtml) {
|
|
6
|
+
// Parse the SVG HTML into a DOM structure using JSDOM
|
|
7
|
+
const dom = new jsdom_1.JSDOM(svgHtml);
|
|
8
|
+
const document = dom.window.document;
|
|
9
|
+
const svgElement = document.querySelector("svg");
|
|
10
|
+
if (!svgElement) {
|
|
11
|
+
throw new Error("No SVG element found in the provided HTML");
|
|
12
|
+
}
|
|
13
|
+
// Normalize whitespace and formatting
|
|
14
|
+
normalizeWhitespace(svgElement);
|
|
15
|
+
// Normalize attribute order
|
|
16
|
+
normalizeAttributeOrder(svgElement);
|
|
17
|
+
// Normalize transform values
|
|
18
|
+
normalizeTransforms(svgElement);
|
|
19
|
+
// Normalize color formats (convert rgb to hex, standardize hex case)
|
|
20
|
+
normalizeColors(svgElement);
|
|
21
|
+
// Normalize path data (standardize spacing, remove redundant commands)
|
|
22
|
+
normalizePaths(svgElement);
|
|
23
|
+
// Normalize viewBox and preserveAspectRatio
|
|
24
|
+
normalizeViewBox(svgElement);
|
|
25
|
+
// Return the normalized SVG string
|
|
26
|
+
return svgElement.outerHTML;
|
|
27
|
+
}
|
|
28
|
+
exports.normalizeSVG = normalizeSVG;
|
|
29
|
+
/**
|
|
30
|
+
* Normalizes whitespace in SVG element
|
|
31
|
+
* @param element - The element to normalize
|
|
32
|
+
*/
|
|
33
|
+
function normalizeWhitespace(element) {
|
|
34
|
+
// Convert text nodes to have consistent spacing
|
|
35
|
+
const walkNodes = (node) => {
|
|
36
|
+
if (node.nodeType === 3) {
|
|
37
|
+
// TEXT_NODE
|
|
38
|
+
if (node.textContent?.trim() === "") {
|
|
39
|
+
node.textContent = "";
|
|
40
|
+
}
|
|
41
|
+
else if (node.textContent) {
|
|
42
|
+
node.textContent = node.textContent.trim().replace(/\s+/g, " ");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else if (node.nodeType === 1) {
|
|
46
|
+
// ELEMENT_NODE
|
|
47
|
+
for (let child of Array.from(node.childNodes)) {
|
|
48
|
+
walkNodes(child);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
walkNodes(element);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Normalizes attribute order on SVG elements
|
|
56
|
+
* @param element - The element to normalize
|
|
57
|
+
*/
|
|
58
|
+
function normalizeAttributeOrder(element) {
|
|
59
|
+
const walkElements = (node) => {
|
|
60
|
+
if (node.nodeType === 1) {
|
|
61
|
+
// ELEMENT_NODE
|
|
62
|
+
const elementNode = node;
|
|
63
|
+
// Get all attributes in a sorted array
|
|
64
|
+
const attributes = Array.from(elementNode.attributes);
|
|
65
|
+
const sortedAttributes = attributes.sort((a, b) => a.name.localeCompare(b.name));
|
|
66
|
+
// Remove all attributes
|
|
67
|
+
for (const attr of attributes) {
|
|
68
|
+
elementNode.removeAttribute(attr.name);
|
|
69
|
+
}
|
|
70
|
+
// Add them back in sorted order
|
|
71
|
+
for (const attr of sortedAttributes) {
|
|
72
|
+
elementNode.setAttribute(attr.name, attr.value);
|
|
73
|
+
}
|
|
74
|
+
// Process children
|
|
75
|
+
for (let child of Array.from(node.childNodes)) {
|
|
76
|
+
walkElements(child);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
walkElements(element);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Normalizes transform values to a consistent format
|
|
84
|
+
* @param element - The element to normalize
|
|
85
|
+
*/
|
|
86
|
+
function normalizeTransforms(element) {
|
|
87
|
+
const walkElements = (node) => {
|
|
88
|
+
if (node.nodeType === 1) {
|
|
89
|
+
// ELEMENT_NODE
|
|
90
|
+
const elementNode = node;
|
|
91
|
+
if (elementNode.hasAttribute("transform")) {
|
|
92
|
+
const transform = elementNode.getAttribute("transform");
|
|
93
|
+
if (transform) {
|
|
94
|
+
// Normalize transform by ensuring consistent spacing and order
|
|
95
|
+
const normalizedTransform = transform
|
|
96
|
+
.replace(/\s*,\s*/g, ",")
|
|
97
|
+
.replace(/\s+/g, " ")
|
|
98
|
+
.replace(/\(\s+/g, "(")
|
|
99
|
+
.replace(/\s+\)/g, ")");
|
|
100
|
+
elementNode.setAttribute("transform", normalizedTransform);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Process children
|
|
104
|
+
for (let child of Array.from(node.childNodes)) {
|
|
105
|
+
walkElements(child);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
walkElements(element);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Normalizes color formats to consistent hex values
|
|
113
|
+
* @param element - The element to normalize
|
|
114
|
+
*/
|
|
115
|
+
function normalizeColors(element) {
|
|
116
|
+
const colorAttributes = ["fill", "stroke", "stop-color", "color"];
|
|
117
|
+
const convertRgbToHex = (rgb) => {
|
|
118
|
+
// Convert rgb(r, g, b) or rgba(r, g, b, a) to hex
|
|
119
|
+
const rgbMatch = rgb.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)/);
|
|
120
|
+
if (rgbMatch) {
|
|
121
|
+
const r = parseInt(rgbMatch[1], 10);
|
|
122
|
+
const g = parseInt(rgbMatch[2], 10);
|
|
123
|
+
const b = parseInt(rgbMatch[3], 10);
|
|
124
|
+
// Convert to hex
|
|
125
|
+
const toHex = (c) => {
|
|
126
|
+
const hex = c.toString(16);
|
|
127
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
128
|
+
};
|
|
129
|
+
let hexColor = "#" + toHex(r) + toHex(g) + toHex(b);
|
|
130
|
+
// If there's alpha, we need to handle it separately (SVG doesn't use hex for alpha)
|
|
131
|
+
if (rgbMatch[4] && rgbMatch[4] !== "1") {
|
|
132
|
+
// Keep original rgba format but with normalized spacing
|
|
133
|
+
return `rgba(${r},${g},${b},${parseFloat(rgbMatch[4])})`;
|
|
134
|
+
}
|
|
135
|
+
return hexColor.toLowerCase();
|
|
136
|
+
}
|
|
137
|
+
return rgb;
|
|
138
|
+
};
|
|
139
|
+
const normalizeHex = (hex) => {
|
|
140
|
+
// Ensure lowercase for hex colors
|
|
141
|
+
if (hex.match(/#[0-9a-fA-F]{3,8}/)) {
|
|
142
|
+
return hex.toLowerCase();
|
|
143
|
+
}
|
|
144
|
+
return hex;
|
|
145
|
+
};
|
|
146
|
+
const walkElements = (node) => {
|
|
147
|
+
if (node.nodeType === 1) {
|
|
148
|
+
// ELEMENT_NODE
|
|
149
|
+
const elementNode = node;
|
|
150
|
+
// Check for color attributes
|
|
151
|
+
for (const attr of colorAttributes) {
|
|
152
|
+
if (elementNode.hasAttribute(attr)) {
|
|
153
|
+
let value = elementNode.getAttribute(attr);
|
|
154
|
+
if (value) {
|
|
155
|
+
value = convertRgbToHex(value);
|
|
156
|
+
value = normalizeHex(value);
|
|
157
|
+
elementNode.setAttribute(attr, value);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Check for style attribute with colors
|
|
162
|
+
if (elementNode.hasAttribute("style")) {
|
|
163
|
+
let style = elementNode.getAttribute("style");
|
|
164
|
+
if (style) {
|
|
165
|
+
// Replace any colors in the style attribute
|
|
166
|
+
for (const attr of colorAttributes) {
|
|
167
|
+
style = style.replace(new RegExp(`${attr}:\\s*([^;]+)`, "g"), (match, color) => {
|
|
168
|
+
const normalizedColor = normalizeHex(convertRgbToHex(color));
|
|
169
|
+
return `${attr}: ${normalizedColor}`;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
elementNode.setAttribute("style", style);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// Process children
|
|
176
|
+
for (let child of Array.from(node.childNodes)) {
|
|
177
|
+
walkElements(child);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
walkElements(element);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Normalizes SVG path data
|
|
185
|
+
* @param element - The element to normalize
|
|
186
|
+
*/
|
|
187
|
+
function normalizePaths(element) {
|
|
188
|
+
const walkElements = (node) => {
|
|
189
|
+
if (node.nodeType === 1) {
|
|
190
|
+
// ELEMENT_NODE
|
|
191
|
+
const elementNode = node;
|
|
192
|
+
if (elementNode.tagName.toLowerCase() === "path" &&
|
|
193
|
+
elementNode.hasAttribute("d")) {
|
|
194
|
+
const pathData = elementNode.getAttribute("d");
|
|
195
|
+
if (pathData) {
|
|
196
|
+
// Normalize spacing in path data
|
|
197
|
+
const normalizedPathData = pathData
|
|
198
|
+
.replace(/\s+/g, " ")
|
|
199
|
+
.replace(/\s*([MmLlHhVvCcSsQqTtAaZz])\s*/g, "$1")
|
|
200
|
+
.replace(/\s*,\s*/g, ",")
|
|
201
|
+
.trim();
|
|
202
|
+
elementNode.setAttribute("d", normalizedPathData);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// Process children
|
|
206
|
+
for (let child of Array.from(node.childNodes)) {
|
|
207
|
+
walkElements(child);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
walkElements(element);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Normalizes viewBox and preserveAspectRatio attributes
|
|
215
|
+
* @param element - The element to normalize
|
|
216
|
+
*/
|
|
217
|
+
function normalizeViewBox(element) {
|
|
218
|
+
if (element.tagName.toLowerCase() === "svg") {
|
|
219
|
+
if (element.hasAttribute("viewBox")) {
|
|
220
|
+
const viewBoxAttr = element.getAttribute("viewBox");
|
|
221
|
+
if (viewBoxAttr) {
|
|
222
|
+
// Normalize viewBox format
|
|
223
|
+
const viewBox = viewBoxAttr
|
|
224
|
+
.trim()
|
|
225
|
+
.replace(/\s+/g, " ")
|
|
226
|
+
.split(" ")
|
|
227
|
+
.map((val) => parseFloat(val).toString())
|
|
228
|
+
.join(" ");
|
|
229
|
+
element.setAttribute("viewBox", viewBox);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (element.hasAttribute("preserveAspectRatio")) {
|
|
233
|
+
const aspectRatio = element.getAttribute("preserveAspectRatio");
|
|
234
|
+
if (aspectRatio) {
|
|
235
|
+
// Normalize preserveAspectRatio to consistent formatting
|
|
236
|
+
const value = aspectRatio.trim();
|
|
237
|
+
element.setAttribute("preserveAspectRatio", value);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// Process children (in case of nested SVGs)
|
|
242
|
+
for (let child of Array.from(element.childNodes)) {
|
|
243
|
+
if (child.nodeType === 1) {
|
|
244
|
+
// ELEMENT_NODE
|
|
245
|
+
normalizeViewBox(child);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAqBlC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EACL,oBAAoB,EAErB,MAAM,aAAa,CAAC;AA6BrB,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,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAqBlC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EACL,oBAAoB,EAErB,MAAM,aAAa,CAAC;AA6BrB,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,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;GA8XA"}
|
package/dist/agent/master/run.js
CHANGED
|
@@ -224,6 +224,7 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
224
224
|
page,
|
|
225
225
|
preference,
|
|
226
226
|
options,
|
|
227
|
+
trace: masterAgentActionSpan,
|
|
227
228
|
});
|
|
228
229
|
if (annotationKeys.length > 0) {
|
|
229
230
|
// TODO: this string has newline characters that makes it harder to read
|
|
@@ -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;AAGrE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAchD,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB,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;AAGrE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAchD,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AA4ZF,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"}
|
|
@@ -188,6 +188,7 @@ async function getDivAnnotationToScrollOn({ elementDescription, page, trace, log
|
|
|
188
188
|
actionType: action_tool_calls_1.ActionType.SCROLL,
|
|
189
189
|
},
|
|
190
190
|
options: {},
|
|
191
|
+
trace,
|
|
191
192
|
});
|
|
192
193
|
// Remove the used annotations from the list
|
|
193
194
|
annotationKeys = annotationKeys.filter((key) => !usedAnnotations.includes(key.elementID));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"google-spreadsheet": "^4.1.2",
|
|
60
60
|
"ignore": "^5.3.1",
|
|
61
61
|
"inquirer": "^12.4.2",
|
|
62
|
+
"jsdom": "^26.0.0",
|
|
62
63
|
"lodash.isequal": "^4.5.0",
|
|
63
64
|
"md5": "^2.3.0",
|
|
64
65
|
"mime": "^4.0.4",
|
|
@@ -73,9 +74,9 @@
|
|
|
73
74
|
"ts-morph": "^23.0.0",
|
|
74
75
|
"tsx": "^4.16.2",
|
|
75
76
|
"typescript": "^5.3.3",
|
|
76
|
-
"@empiricalrun/llm": "^0.9.35",
|
|
77
77
|
"@empiricalrun/r2-uploader": "^0.3.8",
|
|
78
|
-
"@empiricalrun/reporter": "^0.23.1"
|
|
78
|
+
"@empiricalrun/reporter": "^0.23.1",
|
|
79
|
+
"@empiricalrun/llm": "^0.9.35"
|
|
79
80
|
},
|
|
80
81
|
"devDependencies": {
|
|
81
82
|
"@playwright/test": "1.47.1",
|
|
@@ -84,6 +85,7 @@
|
|
|
84
85
|
"@types/fs-extra": "^11.0.4",
|
|
85
86
|
"@types/http-server": "^0.12.4",
|
|
86
87
|
"@types/js-levenshtein": "^1.1.3",
|
|
88
|
+
"@types/jsdom": "^21.1.7",
|
|
87
89
|
"@types/lodash.isequal": "^4.5.8",
|
|
88
90
|
"@types/md5": "^2.3.5",
|
|
89
91
|
"http-server": "^14.1.1",
|