@empiricalrun/playwright-utils 0.23.0 → 0.23.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 +6 -0
- package/package.json +2 -2
- package/bundled/test-gen/actions/assert.d.ts +0 -4
- package/bundled/test-gen/actions/assert.d.ts.map +0 -1
- package/bundled/test-gen/actions/assert.js +0 -50
- package/bundled/test-gen/actions/click.d.ts +0 -4
- package/bundled/test-gen/actions/click.d.ts.map +0 -1
- package/bundled/test-gen/actions/click.js +0 -51
- package/bundled/test-gen/actions/constants/index.d.ts +0 -2
- package/bundled/test-gen/actions/constants/index.d.ts.map +0 -1
- package/bundled/test-gen/actions/constants/index.js +0 -4
- package/bundled/test-gen/actions/done.d.ts +0 -4
- package/bundled/test-gen/actions/done.d.ts.map +0 -1
- package/bundled/test-gen/actions/done.js +0 -30
- package/bundled/test-gen/actions/fill.d.ts +0 -4
- package/bundled/test-gen/actions/fill.d.ts.map +0 -1
- package/bundled/test-gen/actions/fill.js +0 -82
- package/bundled/test-gen/actions/goto.d.ts +0 -4
- package/bundled/test-gen/actions/goto.d.ts.map +0 -1
- package/bundled/test-gen/actions/goto.js +0 -47
- package/bundled/test-gen/actions/hover.d.ts +0 -4
- package/bundled/test-gen/actions/hover.d.ts.map +0 -1
- package/bundled/test-gen/actions/hover.js +0 -51
- package/bundled/test-gen/actions/index.d.ts +0 -30
- package/bundled/test-gen/actions/index.d.ts.map +0 -1
- package/bundled/test-gen/actions/index.js +0 -159
- package/bundled/test-gen/actions/next-task.d.ts +0 -53
- package/bundled/test-gen/actions/next-task.d.ts.map +0 -1
- package/bundled/test-gen/actions/next-task.js +0 -58
- package/bundled/test-gen/actions/press.d.ts +0 -4
- package/bundled/test-gen/actions/press.d.ts.map +0 -1
- package/bundled/test-gen/actions/press.js +0 -56
- package/bundled/test-gen/actions/skill.d.ts +0 -21
- package/bundled/test-gen/actions/skill.d.ts.map +0 -1
- package/bundled/test-gen/actions/skill.js +0 -127
- package/bundled/test-gen/actions/text-content.d.ts +0 -4
- package/bundled/test-gen/actions/text-content.d.ts.map +0 -1
- package/bundled/test-gen/actions/text-content.js +0 -58
- package/bundled/test-gen/actions/utils/index.d.ts +0 -10
- package/bundled/test-gen/actions/utils/index.d.ts.map +0 -1
- package/bundled/test-gen/actions/utils/index.js +0 -109
- package/bundled/test-gen/agent/browsing/index.d.ts +0 -15
- package/bundled/test-gen/agent/browsing/index.d.ts.map +0 -1
- package/bundled/test-gen/agent/browsing/index.js +0 -68
- package/bundled/test-gen/agent/browsing/run.d.ts +0 -19
- package/bundled/test-gen/agent/browsing/run.d.ts.map +0 -1
- package/bundled/test-gen/agent/browsing/run.js +0 -88
- package/bundled/test-gen/agent/browsing/utils.d.ts +0 -41
- package/bundled/test-gen/agent/browsing/utils.d.ts.map +0 -1
- package/bundled/test-gen/agent/browsing/utils.js +0 -406
- package/bundled/test-gen/agent/codegen/create-test-block.d.ts +0 -9
- package/bundled/test-gen/agent/codegen/create-test-block.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/create-test-block.js +0 -63
- package/bundled/test-gen/agent/codegen/fix-ts-errors.d.ts +0 -13
- package/bundled/test-gen/agent/codegen/fix-ts-errors.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/fix-ts-errors.js +0 -80
- package/bundled/test-gen/agent/codegen/generate-code-apply-changes.d.ts +0 -13
- package/bundled/test-gen/agent/codegen/generate-code-apply-changes.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/generate-code-apply-changes.js +0 -381
- package/bundled/test-gen/agent/codegen/lexical-scoped-vars.d.ts +0 -9
- package/bundled/test-gen/agent/codegen/lexical-scoped-vars.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/lexical-scoped-vars.js +0 -56
- package/bundled/test-gen/agent/codegen/repo-edit.d.ts +0 -23
- package/bundled/test-gen/agent/codegen/repo-edit.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/repo-edit.js +0 -86
- package/bundled/test-gen/agent/codegen/run.d.ts +0 -16
- package/bundled/test-gen/agent/codegen/run.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/run.js +0 -119
- package/bundled/test-gen/agent/codegen/skills-retriever.d.ts +0 -26
- package/bundled/test-gen/agent/codegen/skills-retriever.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/skills-retriever.js +0 -93
- package/bundled/test-gen/agent/codegen/test-update-feedback.d.ts +0 -12
- package/bundled/test-gen/agent/codegen/test-update-feedback.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/test-update-feedback.js +0 -50
- package/bundled/test-gen/agent/codegen/types.d.ts +0 -25
- package/bundled/test-gen/agent/codegen/types.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/types.js +0 -8
- package/bundled/test-gen/agent/codegen/update-flow.d.ts +0 -34
- package/bundled/test-gen/agent/codegen/update-flow.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/update-flow.js +0 -300
- package/bundled/test-gen/agent/codegen/use-skill.d.ts +0 -11
- package/bundled/test-gen/agent/codegen/use-skill.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/use-skill.js +0 -54
- package/bundled/test-gen/agent/codegen/utils.d.ts +0 -126
- package/bundled/test-gen/agent/codegen/utils.d.ts.map +0 -1
- package/bundled/test-gen/agent/codegen/utils.js +0 -416
- package/bundled/test-gen/agent/diagnosis-agent/index.d.ts +0 -18
- package/bundled/test-gen/agent/diagnosis-agent/index.d.ts.map +0 -1
- package/bundled/test-gen/agent/diagnosis-agent/index.js +0 -105
- package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.d.ts +0 -9
- package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.d.ts.map +0 -1
- package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.js +0 -31
- package/bundled/test-gen/agent/enrich-prompt/index.d.ts +0 -12
- package/bundled/test-gen/agent/enrich-prompt/index.d.ts.map +0 -1
- package/bundled/test-gen/agent/enrich-prompt/index.js +0 -81
- package/bundled/test-gen/agent/enrich-prompt/utils.d.ts +0 -6
- package/bundled/test-gen/agent/enrich-prompt/utils.d.ts.map +0 -1
- package/bundled/test-gen/agent/enrich-prompt/utils.js +0 -12
- package/bundled/test-gen/agent/infer-agent/index.d.ts +0 -10
- package/bundled/test-gen/agent/infer-agent/index.d.ts.map +0 -1
- package/bundled/test-gen/agent/infer-agent/index.js +0 -70
- package/bundled/test-gen/agent/master/action-tool-calls.d.ts +0 -42
- package/bundled/test-gen/agent/master/action-tool-calls.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/action-tool-calls.js +0 -87
- package/bundled/test-gen/agent/master/browser-tests/fixtures.d.ts +0 -9
- package/bundled/test-gen/agent/master/browser-tests/fixtures.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/browser-tests/fixtures.js +0 -33
- package/bundled/test-gen/agent/master/browser-tests/index.spec.d.ts +0 -2
- package/bundled/test-gen/agent/master/browser-tests/index.spec.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/browser-tests/index.spec.js +0 -113
- package/bundled/test-gen/agent/master/browser-tests/skills.spec.d.ts +0 -2
- package/bundled/test-gen/agent/master/browser-tests/skills.spec.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/browser-tests/skills.spec.js +0 -109
- package/bundled/test-gen/agent/master/element-annotation.d.ts +0 -30
- package/bundled/test-gen/agent/master/element-annotation.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/element-annotation.js +0 -195
- package/bundled/test-gen/agent/master/execute-browser-action.d.ts +0 -24
- package/bundled/test-gen/agent/master/execute-browser-action.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/execute-browser-action.js +0 -124
- package/bundled/test-gen/agent/master/execute-skill-action.d.ts +0 -11
- package/bundled/test-gen/agent/master/execute-skill-action.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/execute-skill-action.js +0 -25
- package/bundled/test-gen/agent/master/icon-descriptor/index.d.ts +0 -22
- package/bundled/test-gen/agent/master/icon-descriptor/index.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/icon-descriptor/index.js +0 -250
- package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.d.ts +0 -2
- package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.js +0 -248
- package/bundled/test-gen/agent/master/next-action.d.ts +0 -22
- package/bundled/test-gen/agent/master/next-action.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/next-action.js +0 -104
- package/bundled/test-gen/agent/master/planner.d.ts +0 -15
- package/bundled/test-gen/agent/master/planner.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/planner.js +0 -144
- package/bundled/test-gen/agent/master/run.d.ts +0 -15
- package/bundled/test-gen/agent/master/run.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/run.js +0 -274
- package/bundled/test-gen/agent/master/scroller.d.ts +0 -15
- package/bundled/test-gen/agent/master/scroller.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/scroller.js +0 -375
- package/bundled/test-gen/agent/master/with-hints.d.ts +0 -17
- package/bundled/test-gen/agent/master/with-hints.d.ts.map +0 -1
- package/bundled/test-gen/agent/master/with-hints.js +0 -102
- package/bundled/test-gen/agent/planner/run-time-planner.d.ts +0 -15
- package/bundled/test-gen/agent/planner/run-time-planner.d.ts.map +0 -1
- package/bundled/test-gen/agent/planner/run-time-planner.js +0 -100
- package/bundled/test-gen/agent/planner/run.d.ts +0 -7
- package/bundled/test-gen/agent/planner/run.d.ts.map +0 -1
- package/bundled/test-gen/agent/planner/run.js +0 -127
- package/bundled/test-gen/agent/utils.d.ts +0 -2
- package/bundled/test-gen/agent/utils.d.ts.map +0 -1
- package/bundled/test-gen/agent/utils.js +0 -12
- package/bundled/test-gen/bin/index.d.ts +0 -3
- package/bundled/test-gen/bin/index.d.ts.map +0 -1
- package/bundled/test-gen/bin/index.js +0 -212
- package/bundled/test-gen/bin/logger/index.d.ts +0 -14
- package/bundled/test-gen/bin/logger/index.d.ts.map +0 -1
- package/bundled/test-gen/bin/logger/index.js +0 -57
- package/bundled/test-gen/bin/utils/context.d.ts +0 -13
- package/bundled/test-gen/bin/utils/context.d.ts.map +0 -1
- package/bundled/test-gen/bin/utils/context.js +0 -67
- package/bundled/test-gen/bin/utils/fs/index.d.ts +0 -6
- package/bundled/test-gen/bin/utils/fs/index.d.ts.map +0 -1
- package/bundled/test-gen/bin/utils/fs/index.js +0 -63
- package/bundled/test-gen/bin/utils/index.d.ts +0 -9
- package/bundled/test-gen/bin/utils/index.d.ts.map +0 -1
- package/bundled/test-gen/bin/utils/index.js +0 -64
- package/bundled/test-gen/bin/utils/platform/web/index.d.ts +0 -78
- package/bundled/test-gen/bin/utils/platform/web/index.d.ts.map +0 -1
- package/bundled/test-gen/bin/utils/platform/web/index.js +0 -544
- package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.d.ts +0 -2
- package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.d.ts.map +0 -1
- package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.js +0 -7
- package/bundled/test-gen/bin/utils/scenarios/index.d.ts +0 -6
- package/bundled/test-gen/bin/utils/scenarios/index.d.ts.map +0 -1
- package/bundled/test-gen/bin/utils/scenarios/index.js +0 -57
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.js +0 -615
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.d.ts +0 -2
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.d.ts.map +0 -1
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.js +0 -207
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.ts +0 -332
- package/bundled/test-gen/constants/index.d.ts +0 -7
- package/bundled/test-gen/constants/index.d.ts.map +0 -1
- package/bundled/test-gen/constants/index.js +0 -18
- package/bundled/test-gen/errors/index.d.ts +0 -5
- package/bundled/test-gen/errors/index.d.ts.map +0 -1
- package/bundled/test-gen/errors/index.js +0 -9
- package/bundled/test-gen/evals/add-scenario-agent.evals.d.ts +0 -4
- package/bundled/test-gen/evals/add-scenario-agent.evals.d.ts.map +0 -1
- package/bundled/test-gen/evals/add-scenario-agent.evals.js +0 -44
- package/bundled/test-gen/evals/append-create-test-agent.evals.d.ts +0 -4
- package/bundled/test-gen/evals/append-create-test-agent.evals.d.ts.map +0 -1
- package/bundled/test-gen/evals/append-create-test-agent.evals.js +0 -117
- package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.d.ts +0 -4
- package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.d.ts.map +0 -1
- package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.js +0 -36
- package/bundled/test-gen/evals/infer-master-or-code-agent.evals.d.ts +0 -4
- package/bundled/test-gen/evals/infer-master-or-code-agent.evals.d.ts.map +0 -1
- package/bundled/test-gen/evals/infer-master-or-code-agent.evals.js +0 -22
- package/bundled/test-gen/evals/master-agent.evals.d.ts +0 -4
- package/bundled/test-gen/evals/master-agent.evals.d.ts.map +0 -1
- package/bundled/test-gen/evals/master-agent.evals.js +0 -35
- package/bundled/test-gen/evals/type.d.ts +0 -12
- package/bundled/test-gen/evals/type.d.ts.map +0 -1
- package/bundled/test-gen/evals/type.js +0 -2
- package/bundled/test-gen/evals/update-scenario-agent.evals.d.ts +0 -4
- package/bundled/test-gen/evals/update-scenario-agent.evals.d.ts.map +0 -1
- package/bundled/test-gen/evals/update-scenario-agent.evals.js +0 -47
- package/bundled/test-gen/file/client.d.ts +0 -14
- package/bundled/test-gen/file/client.d.ts.map +0 -1
- package/bundled/test-gen/file/client.js +0 -48
- package/bundled/test-gen/file/server.d.ts +0 -13
- package/bundled/test-gen/file/server.d.ts.map +0 -1
- package/bundled/test-gen/file/server.js +0 -52
- package/bundled/test-gen/human-in-the-loop/cli.d.ts +0 -2
- package/bundled/test-gen/human-in-the-loop/cli.d.ts.map +0 -1
- package/bundled/test-gen/human-in-the-loop/cli.js +0 -24
- package/bundled/test-gen/human-in-the-loop/index.d.ts +0 -12
- package/bundled/test-gen/human-in-the-loop/index.d.ts.map +0 -1
- package/bundled/test-gen/human-in-the-loop/index.js +0 -30
- package/bundled/test-gen/human-in-the-loop/ipc.d.ts +0 -4
- package/bundled/test-gen/human-in-the-loop/ipc.d.ts.map +0 -1
- package/bundled/test-gen/human-in-the-loop/ipc.js +0 -47
- package/bundled/test-gen/index.d.ts +0 -4
- package/bundled/test-gen/index.d.ts.map +0 -1
- package/bundled/test-gen/index.js +0 -55
- package/bundled/test-gen/package.json +0 -106
- package/bundled/test-gen/page/index.d.ts +0 -11
- package/bundled/test-gen/page/index.d.ts.map +0 -1
- package/bundled/test-gen/page/index.js +0 -16
- package/bundled/test-gen/prompts/lib/ts-transformer.d.ts +0 -4
- package/bundled/test-gen/prompts/lib/ts-transformer.d.ts.map +0 -1
- package/bundled/test-gen/prompts/lib/ts-transformer.js +0 -92
- package/bundled/test-gen/reporter/index.d.ts +0 -33
- package/bundled/test-gen/reporter/index.d.ts.map +0 -1
- package/bundled/test-gen/reporter/index.js +0 -161
- package/bundled/test-gen/session/index.d.ts +0 -20
- package/bundled/test-gen/session/index.d.ts.map +0 -1
- package/bundled/test-gen/session/index.js +0 -105
- package/bundled/test-gen/test-build/index.d.ts +0 -10
- package/bundled/test-gen/test-build/index.d.ts.map +0 -1
- package/bundled/test-gen/test-build/index.js +0 -30
- package/bundled/test-gen/types/index.d.ts +0 -69
- package/bundled/test-gen/types/index.d.ts.map +0 -1
- package/bundled/test-gen/types/index.js +0 -2
- package/bundled/test-gen/uploader/index.d.ts +0 -26
- package/bundled/test-gen/uploader/index.d.ts.map +0 -1
- package/bundled/test-gen/uploader/index.js +0 -102
- package/bundled/test-gen/utils/env.d.ts +0 -2
- package/bundled/test-gen/utils/env.d.ts.map +0 -1
- package/bundled/test-gen/utils/env.js +0 -9
- package/bundled/test-gen/utils/exec.d.ts +0 -4
- package/bundled/test-gen/utils/exec.d.ts.map +0 -1
- package/bundled/test-gen/utils/exec.js +0 -45
- package/bundled/test-gen/utils/file.d.ts +0 -2
- package/bundled/test-gen/utils/file.d.ts.map +0 -1
- package/bundled/test-gen/utils/file.js +0 -25
- package/bundled/test-gen/utils/html.d.ts +0 -4
- package/bundled/test-gen/utils/html.d.ts.map +0 -1
- package/bundled/test-gen/utils/html.js +0 -46
- package/bundled/test-gen/utils/index.d.ts +0 -2
- package/bundled/test-gen/utils/index.d.ts.map +0 -1
- package/bundled/test-gen/utils/index.js +0 -5
- package/bundled/test-gen/utils/pw-test.d.ts +0 -3
- package/bundled/test-gen/utils/pw-test.d.ts.map +0 -1
- package/bundled/test-gen/utils/pw-test.js +0 -26
- package/bundled/test-gen/utils/slug.d.ts +0 -2
- package/bundled/test-gen/utils/slug.d.ts.map +0 -1
- package/bundled/test-gen/utils/slug.js +0 -18
- package/bundled/test-gen/utils/string.d.ts +0 -2
- package/bundled/test-gen/utils/string.d.ts.map +0 -1
- package/bundled/test-gen/utils/string.js +0 -9
- package/scripts/prepare-publish.js +0 -42
|
@@ -1,248 +0,0 @@
|
|
|
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,22 +0,0 @@
|
|
|
1
|
-
import { LLM, TraceClient } from "@empiricalrun/llm";
|
|
2
|
-
import { TestGenConfigOptions } from "@empiricalrun/shared-types";
|
|
3
|
-
import { Page } from "playwright";
|
|
4
|
-
import { PlaywrightActions } from "../../actions";
|
|
5
|
-
import { CustomLogger } from "../../bin/logger";
|
|
6
|
-
export declare function getNextAction({ page, pageScreenshot, task, executedActions, failedActions, trace, llm, options, actions, disableSkills, logger, }: {
|
|
7
|
-
page: Page;
|
|
8
|
-
pageScreenshot: string[];
|
|
9
|
-
task: string;
|
|
10
|
-
executedActions: string[];
|
|
11
|
-
failedActions: any[];
|
|
12
|
-
trace?: TraceClient;
|
|
13
|
-
llm?: LLM;
|
|
14
|
-
options?: Partial<TestGenConfigOptions>;
|
|
15
|
-
actions: PlaywrightActions;
|
|
16
|
-
disableSkills: boolean;
|
|
17
|
-
logger?: CustomLogger;
|
|
18
|
-
}): Promise<{
|
|
19
|
-
actionType: string;
|
|
20
|
-
toolCallArgs: string;
|
|
21
|
-
} | undefined>;
|
|
22
|
-
//# sourceMappingURL=next-action.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"next-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/next-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAWhD,wBAAsB,aAAa,CAAC,EAClC,IAAI,EACJ,cAAc,EACd,IAAI,EACJ,eAAe,EACf,aAAa,EACb,KAAK,EACL,GAAG,EACH,OAAO,EACP,OAAO,EACP,aAAa,EACb,MAAM,GACP,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,GAAG,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACxC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CACP;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD,SAAS,CACZ,CA8FA"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNextAction = void 0;
|
|
4
|
-
const llm_1 = require("@empiricalrun/llm");
|
|
5
|
-
const skill_1 = require("../../actions/skill");
|
|
6
|
-
const constants_1 = require("../../constants");
|
|
7
|
-
const promptTemplate_0 = "{{#section \"system\"}}\nYou are a web automation tool which is given a task to complete. You need to execute the\ntask provided to you with the help of web page screenshot, a browser automation tool or skills\nwhich are learnt while writing previous tests. \n \nBrowser automation tool is a tool which uses Playwright and browser to execute action using\nnext_action tool call.\nSkill usage is a tool which helps to execute previously known pieces of code to achieve a task.\n\nYou will be provided with a screenshot of the webpage which you will use to extract the action\nthat needs to be taken.\n\nYou will be provided with previously executed actions by the browser automation tool and based\non the current screenshot and previously executed actions, you need to predict the next action\nto be taken.\n\nYou will also be provided with failed next action predicted by you, so that you can avoid\nsuggesting the same action again - which failed.\n\nThe next action should be as atomic as possible. e.g: scroll, click on an element, fill an input\nelement, assert, extract text from an element are valid next action as they are atomic in nature.\n\nYou also need to provide the action type using the list below, action type which is not present in\nthe list is invalid: {{validActionTypes}}\n\nYou will also be provided with skill usage tool which you can use to execute action. These skills\nare compound functions which helps you to complete your action.\n\nYou need to respond with either:\n- Next action to be taken by a browser automation tool \n- Use previously learnt skills in the form of tool call.\n \nYou need to make a decision whether the given skill can be reused if \"YES\" respond with the\nskill else respond with the next action.\n{{/section}}\n\n{{#section \"user\"}}\nTask:\n{{task}}\n\n-----\n\nPrevious executed actions:\n{{executedActions}}\n\n-----\n\nPrevious failed actions:\n{{failedActions}}\n\n-----\n\nYou are also provided with a page screenshot for you to decide the next action.\n\nCurrent page URL: {{pageUrl}}\n\nFollow the instructions before responding:\n- Divide the task into sub tasks\n- Using previously executed actions, identify tasks are complete and which tasks needs to be executed next.\n- You will be provided a skill usage action, if the testStep matches the next action then respond with the skill usage.\n- If responding with next action, ensure next action to be detailed and explicit about what action needs to be done. Provide all the information which can be extracted from the screenshot as a part of next action.\n- Mark task as complete only when executed actions provided to you indicates that the task is done.\n- Refer to the text and references available in the screenshot to create the next action.\n- Do not take any extra actions which are not required for the execution of the task\n- If there are no further actions required based on the task, then respond with task as done.\n- Do not recommend actions which are not available in the screenshot\n\nScreenshots:\n{{images pageScreenshots}}\n\n{{/section}}\n";
|
|
8
|
-
const utils_1 = require("../utils");
|
|
9
|
-
const action_tool_calls_1 = require("./action-tool-calls");
|
|
10
|
-
const scroller_1 = require("./scroller");
|
|
11
|
-
async function getNextAction({ page, pageScreenshot, task, executedActions, failedActions, trace, llm, options, actions, disableSkills, logger, }) {
|
|
12
|
-
const pageUrl = page.url();
|
|
13
|
-
const nextActionSpan = trace?.span({
|
|
14
|
-
name: "master-agent-next-action",
|
|
15
|
-
input: {
|
|
16
|
-
task,
|
|
17
|
-
executedActions,
|
|
18
|
-
failedActions,
|
|
19
|
-
pageUrl,
|
|
20
|
-
options,
|
|
21
|
-
pageScreenshot,
|
|
22
|
-
disableSkills,
|
|
23
|
-
skills: skill_1.testCaseSkills.getAvailableSkills(),
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
const messages = (0, llm_1.compilePrompt)(promptTemplate_0, {
|
|
27
|
-
validActionTypes: Object.values(action_tool_calls_1.ActionType).join(", "),
|
|
28
|
-
task,
|
|
29
|
-
executedActions: executedActions.map((a) => a).join("\n"),
|
|
30
|
-
failedActions: failedActions.map((a) => a).join("\n"),
|
|
31
|
-
pageUrl,
|
|
32
|
-
pageScreenshots: pageScreenshot,
|
|
33
|
-
});
|
|
34
|
-
const actionSchemas = disableSkills || skill_1.testCaseSkills.getAvailableSkills().length === 0
|
|
35
|
-
? []
|
|
36
|
-
: actions.getMasterActionSchemas();
|
|
37
|
-
const tools = [...(0, action_tool_calls_1.getActionToolCalls)(), ...actionSchemas];
|
|
38
|
-
llm =
|
|
39
|
-
llm ||
|
|
40
|
-
new llm_1.LLM({
|
|
41
|
-
provider: options?.modelProvider || constants_1.DEFAULT_MODEL_PROVIDER,
|
|
42
|
-
defaultModel: options?.model || constants_1.DEFAULT_MODEL,
|
|
43
|
-
});
|
|
44
|
-
const completion = await llm.createChatCompletion({
|
|
45
|
-
messages,
|
|
46
|
-
modelParameters: {
|
|
47
|
-
...constants_1.DEFAULT_MODEL_PARAMETERS,
|
|
48
|
-
...options?.modelParameters,
|
|
49
|
-
tool_choice: "required",
|
|
50
|
-
temperature: 1,
|
|
51
|
-
},
|
|
52
|
-
trace: nextActionSpan,
|
|
53
|
-
traceName: "master-agent-llm",
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
tools,
|
|
56
|
-
});
|
|
57
|
-
const toolCall = completion?.tool_calls?.[0];
|
|
58
|
-
nextActionSpan?.end({ output: toolCall });
|
|
59
|
-
if (toolCall) {
|
|
60
|
-
const toolCallArgs = (0, utils_1.parseJson)(toolCall.function.arguments);
|
|
61
|
-
const actionType = toolCall.function.name;
|
|
62
|
-
// If the action type is scroll, we need to scroll the page and get the reference to the frame in which the element is visible
|
|
63
|
-
// else we return the next action
|
|
64
|
-
// For scroll we have at max 2 retries
|
|
65
|
-
// If the element is not visible after 2 retries, we throw an error
|
|
66
|
-
if (actionType === "scroll" && toolCallArgs) {
|
|
67
|
-
let maxScrollRetries = 2;
|
|
68
|
-
while (maxScrollRetries--) {
|
|
69
|
-
const frames = await (0, scroller_1.scroller)({
|
|
70
|
-
elementDescription: toolCallArgs.element,
|
|
71
|
-
page,
|
|
72
|
-
trace: nextActionSpan,
|
|
73
|
-
logger,
|
|
74
|
-
});
|
|
75
|
-
if (frames.length > 0) {
|
|
76
|
-
return getNextAction({
|
|
77
|
-
task,
|
|
78
|
-
executedActions,
|
|
79
|
-
failedActions,
|
|
80
|
-
trace,
|
|
81
|
-
llm,
|
|
82
|
-
options,
|
|
83
|
-
pageScreenshot: frames.map((frame) => frame.frameScreenshot),
|
|
84
|
-
actions,
|
|
85
|
-
disableSkills,
|
|
86
|
-
page,
|
|
87
|
-
logger,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (maxScrollRetries === -1) {
|
|
92
|
-
return {
|
|
93
|
-
actionType: action_tool_calls_1.ActionType.UNKNOWN,
|
|
94
|
-
toolCallArgs: "",
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
actionType,
|
|
100
|
-
toolCallArgs: toolCall?.function.arguments,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.getNextAction = getNextAction;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
-
import { Page } from "playwright/test";
|
|
3
|
-
export declare function runtimePlannerWithScreenshot({ trace, task, conversation, pages, page, currentPage, }: {
|
|
4
|
-
trace?: TraceClient;
|
|
5
|
-
conversation: string[];
|
|
6
|
-
task: string;
|
|
7
|
-
pages?: Record<string, any>;
|
|
8
|
-
page: Page;
|
|
9
|
-
currentPage?: string;
|
|
10
|
-
}): Promise<{
|
|
11
|
-
pageName: string;
|
|
12
|
-
isDone: boolean;
|
|
13
|
-
reason: string;
|
|
14
|
-
}>;
|
|
15
|
-
//# sourceMappingURL=planner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../../../src/agent/master/planner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKvC,wBAAsB,4BAA4B,CAAC,EACjD,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,IAAI,EACJ,WAAW,GACZ,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;GAwIA"}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runtimePlannerWithScreenshot = void 0;
|
|
4
|
-
const llm_1 = require("@empiricalrun/llm");
|
|
5
|
-
const vision_1 = require("@empiricalrun/llm/vision");
|
|
6
|
-
const constants_1 = require("../../constants");
|
|
7
|
-
const utils_1 = require("../utils");
|
|
8
|
-
async function runtimePlannerWithScreenshot({ trace, task, conversation, pages, page, currentPage, }) {
|
|
9
|
-
const buffer = await page.screenshot({
|
|
10
|
-
//This is done to improve element annotation accuracy, anyways it doesn't annotate elements which are out of viewport
|
|
11
|
-
// fullPage: true,
|
|
12
|
-
// path: `screenshots/screenshot-${screenshotIndex++}.png`, // enable this and screenshotIndex var for local debugging
|
|
13
|
-
});
|
|
14
|
-
const pageBuffer = buffer.toString("base64");
|
|
15
|
-
const runTimePlannerSpan = trace?.span({
|
|
16
|
-
name: "popup-verifier",
|
|
17
|
-
input: {
|
|
18
|
-
task,
|
|
19
|
-
conversation,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
const llm = new llm_1.LLM({ provider: "openai" });
|
|
23
|
-
const prompt = [
|
|
24
|
-
{
|
|
25
|
-
role: "system",
|
|
26
|
-
content: `
|
|
27
|
-
Given a successfully executed actions that lists only the actions that were successfully executed and a task comprising multiple actions, your goal is to analyse the list and determine if the entire task is completed.
|
|
28
|
-
These actions are executed by AI agents using Playwright on a browser. These agents already have access to browser tabs to execute actions. The successfully executed actions on browser post browser has opened, is provided to you as successfully executed actions.
|
|
29
|
-
|
|
30
|
-
You are also given a screenshot of the current screen which you can also use to determine whether the entire task is completed or not.
|
|
31
|
-
|
|
32
|
-
If the task is not fully completed, identify which specific actions are missing and suggest next steps to complete the task. Assume that the conversation provided is entirely truthful and no additional actions were performed beyond those listed.
|
|
33
|
-
|
|
34
|
-
To fulfil your goal, follow these steps:
|
|
35
|
-
- Divide the task into individual actions.
|
|
36
|
-
- Compare each task action against the actions listed in the successfully executed actions list.
|
|
37
|
-
- Identify which actions have been executed and which have not.
|
|
38
|
-
- If all actions are executed, respond with the task as done.
|
|
39
|
-
- If any actions are missing, respond with the task as not done, listing all actions and specifying which are complete and which are missing.
|
|
40
|
-
- If provided with list of pages, based on the next pending action and previously executed action, identify the page on which next action needs to be taken
|
|
41
|
-
`,
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
role: "user",
|
|
45
|
-
content: [
|
|
46
|
-
{
|
|
47
|
-
type: "text",
|
|
48
|
-
text: `
|
|
49
|
-
Task: ${task}
|
|
50
|
-
|
|
51
|
-
----
|
|
52
|
-
|
|
53
|
-
Following are successfully executed actions:
|
|
54
|
-
${conversation.join("\n")}
|
|
55
|
-
|
|
56
|
-
----
|
|
57
|
-
|
|
58
|
-
Current page:
|
|
59
|
-
${currentPage}
|
|
60
|
-
`,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
type: "text",
|
|
64
|
-
text: "Page Screenshot",
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
type: "image_url",
|
|
68
|
-
image_url: {
|
|
69
|
-
url: (0, vision_1.imageFormatForProvider)(constants_1.DEFAULT_MODEL_PROVIDER, pageBuffer),
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
];
|
|
75
|
-
const response = await llm.createChatCompletion({
|
|
76
|
-
trace: runTimePlannerSpan,
|
|
77
|
-
traceName: "runtime-planner-llm",
|
|
78
|
-
model: "gpt-4o",
|
|
79
|
-
messages: prompt,
|
|
80
|
-
tools: [
|
|
81
|
-
{
|
|
82
|
-
type: "function",
|
|
83
|
-
function: {
|
|
84
|
-
name: "task_done",
|
|
85
|
-
description: "end the task by calling this method",
|
|
86
|
-
parameters: {
|
|
87
|
-
type: "object",
|
|
88
|
-
properties: {
|
|
89
|
-
actions: {
|
|
90
|
-
type: "string",
|
|
91
|
-
description: "actions extracted from task",
|
|
92
|
-
},
|
|
93
|
-
successful_actions: {
|
|
94
|
-
type: "string",
|
|
95
|
-
description: "successful actions mentioned in the conversation",
|
|
96
|
-
},
|
|
97
|
-
reason: {
|
|
98
|
-
type: "string",
|
|
99
|
-
description: "reasoning for identification of task status",
|
|
100
|
-
},
|
|
101
|
-
isDone: {
|
|
102
|
-
type: "boolean",
|
|
103
|
-
description: "whether the task is done",
|
|
104
|
-
},
|
|
105
|
-
pageName: {
|
|
106
|
-
type: "string",
|
|
107
|
-
enum: pages ? Object.keys(pages) : [],
|
|
108
|
-
description: "page name for the next action.",
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
required: ["isDone", "reason", "pageName"],
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
modelParameters: {
|
|
117
|
-
tool_choice: "required",
|
|
118
|
-
temperature: 0.5,
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
const toolCallResp = (response?.tool_calls || [])[0];
|
|
122
|
-
if (toolCallResp) {
|
|
123
|
-
const toolCall = (0, utils_1.parseJson)(toolCallResp.function.arguments);
|
|
124
|
-
const output = {
|
|
125
|
-
pageName: toolCall.pageName,
|
|
126
|
-
isDone: toolCall.isDone,
|
|
127
|
-
reason: toolCall.reason,
|
|
128
|
-
};
|
|
129
|
-
runTimePlannerSpan?.end({
|
|
130
|
-
output,
|
|
131
|
-
});
|
|
132
|
-
return output;
|
|
133
|
-
}
|
|
134
|
-
const output = {
|
|
135
|
-
pageName: "",
|
|
136
|
-
isDone: false,
|
|
137
|
-
reason: "LLM failed to generate a valid response",
|
|
138
|
-
};
|
|
139
|
-
runTimePlannerSpan?.end({
|
|
140
|
-
output,
|
|
141
|
-
});
|
|
142
|
-
return output;
|
|
143
|
-
}
|
|
144
|
-
exports.runtimePlannerWithScreenshot = runtimePlannerWithScreenshot;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { TestCase, TestGenConfigOptions } from "@empiricalrun/shared-types";
|
|
2
|
-
import { Page } from "playwright";
|
|
3
|
-
import { ScopeVars } from "../../types";
|
|
4
|
-
export declare function createTestUsingMasterAgent({ task, page, testCase, specPath, options, scopeVars, }: {
|
|
5
|
-
task: string;
|
|
6
|
-
page: Page;
|
|
7
|
-
testCase?: TestCase;
|
|
8
|
-
specPath?: string;
|
|
9
|
-
options: Partial<TestGenConfigOptions>;
|
|
10
|
-
scopeVars?: ScopeVars;
|
|
11
|
-
}): Promise<{
|
|
12
|
-
code: string;
|
|
13
|
-
importPaths: string[];
|
|
14
|
-
}>;
|
|
15
|
-
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAelC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAgCxC,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;;;GAwRA"}
|