@empiricalrun/playwright-utils 0.22.7 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/bundled/test-gen/actions/assert.d.ts +4 -0
- package/bundled/test-gen/actions/assert.d.ts.map +1 -0
- package/bundled/test-gen/actions/assert.js +50 -0
- package/bundled/test-gen/actions/click.d.ts +4 -0
- package/bundled/test-gen/actions/click.d.ts.map +1 -0
- package/bundled/test-gen/actions/click.js +51 -0
- package/bundled/test-gen/actions/constants/index.d.ts +2 -0
- package/bundled/test-gen/actions/constants/index.d.ts.map +1 -0
- package/bundled/test-gen/actions/constants/index.js +4 -0
- package/bundled/test-gen/actions/done.d.ts +4 -0
- package/bundled/test-gen/actions/done.d.ts.map +1 -0
- package/bundled/test-gen/actions/done.js +30 -0
- package/bundled/test-gen/actions/fill.d.ts +4 -0
- package/bundled/test-gen/actions/fill.d.ts.map +1 -0
- package/bundled/test-gen/actions/fill.js +82 -0
- package/bundled/test-gen/actions/goto.d.ts +4 -0
- package/bundled/test-gen/actions/goto.d.ts.map +1 -0
- package/bundled/test-gen/actions/goto.js +47 -0
- package/bundled/test-gen/actions/hover.d.ts +4 -0
- package/bundled/test-gen/actions/hover.d.ts.map +1 -0
- package/bundled/test-gen/actions/hover.js +51 -0
- package/bundled/test-gen/actions/index.d.ts +30 -0
- package/bundled/test-gen/actions/index.d.ts.map +1 -0
- package/bundled/test-gen/actions/index.js +159 -0
- package/bundled/test-gen/actions/next-task.d.ts +53 -0
- package/bundled/test-gen/actions/next-task.d.ts.map +1 -0
- package/bundled/test-gen/actions/next-task.js +58 -0
- package/bundled/test-gen/actions/press.d.ts +4 -0
- package/bundled/test-gen/actions/press.d.ts.map +1 -0
- package/bundled/test-gen/actions/press.js +56 -0
- package/bundled/test-gen/actions/skill.d.ts +21 -0
- package/bundled/test-gen/actions/skill.d.ts.map +1 -0
- package/bundled/test-gen/actions/skill.js +127 -0
- package/bundled/test-gen/actions/text-content.d.ts +4 -0
- package/bundled/test-gen/actions/text-content.d.ts.map +1 -0
- package/bundled/test-gen/actions/text-content.js +58 -0
- package/bundled/test-gen/actions/utils/index.d.ts +10 -0
- package/bundled/test-gen/actions/utils/index.d.ts.map +1 -0
- package/bundled/test-gen/actions/utils/index.js +109 -0
- package/bundled/test-gen/agent/browsing/index.d.ts +15 -0
- package/bundled/test-gen/agent/browsing/index.d.ts.map +1 -0
- package/bundled/test-gen/agent/browsing/index.js +68 -0
- package/bundled/test-gen/agent/browsing/run.d.ts +19 -0
- package/bundled/test-gen/agent/browsing/run.d.ts.map +1 -0
- package/bundled/test-gen/agent/browsing/run.js +88 -0
- package/bundled/test-gen/agent/browsing/utils.d.ts +41 -0
- package/bundled/test-gen/agent/browsing/utils.d.ts.map +1 -0
- package/bundled/test-gen/agent/browsing/utils.js +406 -0
- package/bundled/test-gen/agent/codegen/create-test-block.d.ts +9 -0
- package/bundled/test-gen/agent/codegen/create-test-block.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/create-test-block.js +63 -0
- package/bundled/test-gen/agent/codegen/fix-ts-errors.d.ts +13 -0
- package/bundled/test-gen/agent/codegen/fix-ts-errors.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/fix-ts-errors.js +80 -0
- package/bundled/test-gen/agent/codegen/generate-code-apply-changes.d.ts +13 -0
- package/bundled/test-gen/agent/codegen/generate-code-apply-changes.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/generate-code-apply-changes.js +381 -0
- package/bundled/test-gen/agent/codegen/lexical-scoped-vars.d.ts +9 -0
- package/bundled/test-gen/agent/codegen/lexical-scoped-vars.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/lexical-scoped-vars.js +56 -0
- package/bundled/test-gen/agent/codegen/repo-edit.d.ts +23 -0
- package/bundled/test-gen/agent/codegen/repo-edit.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/repo-edit.js +86 -0
- package/bundled/test-gen/agent/codegen/run.d.ts +16 -0
- package/bundled/test-gen/agent/codegen/run.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/run.js +119 -0
- package/bundled/test-gen/agent/codegen/skills-retriever.d.ts +26 -0
- package/bundled/test-gen/agent/codegen/skills-retriever.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/skills-retriever.js +93 -0
- package/bundled/test-gen/agent/codegen/test-update-feedback.d.ts +12 -0
- package/bundled/test-gen/agent/codegen/test-update-feedback.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/test-update-feedback.js +50 -0
- package/bundled/test-gen/agent/codegen/types.d.ts +25 -0
- package/bundled/test-gen/agent/codegen/types.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/types.js +8 -0
- package/bundled/test-gen/agent/codegen/update-flow.d.ts +34 -0
- package/bundled/test-gen/agent/codegen/update-flow.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/update-flow.js +300 -0
- package/bundled/test-gen/agent/codegen/use-skill.d.ts +11 -0
- package/bundled/test-gen/agent/codegen/use-skill.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/use-skill.js +54 -0
- package/bundled/test-gen/agent/codegen/utils.d.ts +126 -0
- package/bundled/test-gen/agent/codegen/utils.d.ts.map +1 -0
- package/bundled/test-gen/agent/codegen/utils.js +416 -0
- package/bundled/test-gen/agent/diagnosis-agent/index.d.ts +18 -0
- package/bundled/test-gen/agent/diagnosis-agent/index.d.ts.map +1 -0
- package/bundled/test-gen/agent/diagnosis-agent/index.js +105 -0
- package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.d.ts +9 -0
- package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.d.ts.map +1 -0
- package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.js +31 -0
- package/bundled/test-gen/agent/enrich-prompt/index.d.ts +12 -0
- package/bundled/test-gen/agent/enrich-prompt/index.d.ts.map +1 -0
- package/bundled/test-gen/agent/enrich-prompt/index.js +81 -0
- package/bundled/test-gen/agent/enrich-prompt/utils.d.ts +6 -0
- package/bundled/test-gen/agent/enrich-prompt/utils.d.ts.map +1 -0
- package/bundled/test-gen/agent/enrich-prompt/utils.js +12 -0
- package/bundled/test-gen/agent/infer-agent/index.d.ts +10 -0
- package/bundled/test-gen/agent/infer-agent/index.d.ts.map +1 -0
- package/bundled/test-gen/agent/infer-agent/index.js +70 -0
- package/bundled/test-gen/agent/master/action-tool-calls.d.ts +42 -0
- package/bundled/test-gen/agent/master/action-tool-calls.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/action-tool-calls.js +87 -0
- package/bundled/test-gen/agent/master/browser-tests/fixtures.d.ts +9 -0
- package/bundled/test-gen/agent/master/browser-tests/fixtures.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/browser-tests/fixtures.js +33 -0
- package/bundled/test-gen/agent/master/browser-tests/index.spec.d.ts +2 -0
- package/bundled/test-gen/agent/master/browser-tests/index.spec.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/browser-tests/index.spec.js +113 -0
- package/bundled/test-gen/agent/master/browser-tests/skills.spec.d.ts +2 -0
- package/bundled/test-gen/agent/master/browser-tests/skills.spec.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/browser-tests/skills.spec.js +109 -0
- package/bundled/test-gen/agent/master/element-annotation.d.ts +30 -0
- package/bundled/test-gen/agent/master/element-annotation.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/element-annotation.js +195 -0
- package/bundled/test-gen/agent/master/execute-browser-action.d.ts +24 -0
- package/bundled/test-gen/agent/master/execute-browser-action.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/execute-browser-action.js +124 -0
- package/bundled/test-gen/agent/master/execute-skill-action.d.ts +11 -0
- package/bundled/test-gen/agent/master/execute-skill-action.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/execute-skill-action.js +25 -0
- package/bundled/test-gen/agent/master/icon-descriptor/index.d.ts +22 -0
- package/bundled/test-gen/agent/master/icon-descriptor/index.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/icon-descriptor/index.js +250 -0
- package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.d.ts +2 -0
- package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.js +248 -0
- package/bundled/test-gen/agent/master/next-action.d.ts +22 -0
- package/bundled/test-gen/agent/master/next-action.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/next-action.js +104 -0
- package/bundled/test-gen/agent/master/planner.d.ts +15 -0
- package/bundled/test-gen/agent/master/planner.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/planner.js +144 -0
- package/bundled/test-gen/agent/master/run.d.ts +15 -0
- package/bundled/test-gen/agent/master/run.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/run.js +274 -0
- package/bundled/test-gen/agent/master/scroller.d.ts +15 -0
- package/bundled/test-gen/agent/master/scroller.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/scroller.js +375 -0
- package/bundled/test-gen/agent/master/with-hints.d.ts +17 -0
- package/bundled/test-gen/agent/master/with-hints.d.ts.map +1 -0
- package/bundled/test-gen/agent/master/with-hints.js +102 -0
- package/bundled/test-gen/agent/planner/run-time-planner.d.ts +15 -0
- package/bundled/test-gen/agent/planner/run-time-planner.d.ts.map +1 -0
- package/bundled/test-gen/agent/planner/run-time-planner.js +100 -0
- package/bundled/test-gen/agent/planner/run.d.ts +7 -0
- package/bundled/test-gen/agent/planner/run.d.ts.map +1 -0
- package/bundled/test-gen/agent/planner/run.js +127 -0
- package/bundled/test-gen/agent/utils.d.ts +2 -0
- package/bundled/test-gen/agent/utils.d.ts.map +1 -0
- package/bundled/test-gen/agent/utils.js +12 -0
- package/bundled/test-gen/bin/index.d.ts +3 -0
- package/bundled/test-gen/bin/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/index.js +212 -0
- package/bundled/test-gen/bin/logger/index.d.ts +14 -0
- package/bundled/test-gen/bin/logger/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/logger/index.js +57 -0
- package/bundled/test-gen/bin/utils/context.d.ts +13 -0
- package/bundled/test-gen/bin/utils/context.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/context.js +67 -0
- package/bundled/test-gen/bin/utils/fs/index.d.ts +6 -0
- package/bundled/test-gen/bin/utils/fs/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/fs/index.js +63 -0
- package/bundled/test-gen/bin/utils/index.d.ts +9 -0
- package/bundled/test-gen/bin/utils/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/index.js +64 -0
- package/bundled/test-gen/bin/utils/platform/web/index.d.ts +78 -0
- package/bundled/test-gen/bin/utils/platform/web/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/platform/web/index.js +544 -0
- package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.d.ts +2 -0
- package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.js +7 -0
- package/bundled/test-gen/bin/utils/scenarios/index.d.ts +6 -0
- package/bundled/test-gen/bin/utils/scenarios/index.d.ts.map +1 -0
- package/bundled/test-gen/bin/utils/scenarios/index.js +57 -0
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.js +615 -0
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.d.ts +2 -0
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.d.ts.map +1 -0
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.js +207 -0
- package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.ts +332 -0
- package/bundled/test-gen/constants/index.d.ts +7 -0
- package/bundled/test-gen/constants/index.d.ts.map +1 -0
- package/bundled/test-gen/constants/index.js +18 -0
- package/bundled/test-gen/errors/index.d.ts +5 -0
- package/bundled/test-gen/errors/index.d.ts.map +1 -0
- package/bundled/test-gen/errors/index.js +9 -0
- package/bundled/test-gen/evals/add-scenario-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/add-scenario-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/add-scenario-agent.evals.js +44 -0
- package/bundled/test-gen/evals/append-create-test-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/append-create-test-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/append-create-test-agent.evals.js +117 -0
- package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.js +36 -0
- package/bundled/test-gen/evals/infer-master-or-code-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/infer-master-or-code-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/infer-master-or-code-agent.evals.js +22 -0
- package/bundled/test-gen/evals/master-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/master-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/master-agent.evals.js +35 -0
- package/bundled/test-gen/evals/type.d.ts +12 -0
- package/bundled/test-gen/evals/type.d.ts.map +1 -0
- package/bundled/test-gen/evals/type.js +2 -0
- package/bundled/test-gen/evals/update-scenario-agent.evals.d.ts +4 -0
- package/bundled/test-gen/evals/update-scenario-agent.evals.d.ts.map +1 -0
- package/bundled/test-gen/evals/update-scenario-agent.evals.js +47 -0
- package/bundled/test-gen/file/client.d.ts +14 -0
- package/bundled/test-gen/file/client.d.ts.map +1 -0
- package/bundled/test-gen/file/client.js +48 -0
- package/bundled/test-gen/file/server.d.ts +13 -0
- package/bundled/test-gen/file/server.d.ts.map +1 -0
- package/bundled/test-gen/file/server.js +52 -0
- package/bundled/test-gen/human-in-the-loop/cli.d.ts +2 -0
- package/bundled/test-gen/human-in-the-loop/cli.d.ts.map +1 -0
- package/bundled/test-gen/human-in-the-loop/cli.js +24 -0
- package/bundled/test-gen/human-in-the-loop/index.d.ts +12 -0
- package/bundled/test-gen/human-in-the-loop/index.d.ts.map +1 -0
- package/bundled/test-gen/human-in-the-loop/index.js +30 -0
- package/bundled/test-gen/human-in-the-loop/ipc.d.ts +4 -0
- package/bundled/test-gen/human-in-the-loop/ipc.d.ts.map +1 -0
- package/bundled/test-gen/human-in-the-loop/ipc.js +47 -0
- package/bundled/test-gen/index.d.ts +4 -0
- package/bundled/test-gen/index.d.ts.map +1 -0
- package/bundled/test-gen/index.js +55 -0
- package/bundled/test-gen/package.json +106 -0
- package/bundled/test-gen/page/index.d.ts +11 -0
- package/bundled/test-gen/page/index.d.ts.map +1 -0
- package/bundled/test-gen/page/index.js +16 -0
- package/bundled/test-gen/prompts/lib/ts-transformer.d.ts +4 -0
- package/bundled/test-gen/prompts/lib/ts-transformer.d.ts.map +1 -0
- package/bundled/test-gen/prompts/lib/ts-transformer.js +92 -0
- package/bundled/test-gen/reporter/index.d.ts +33 -0
- package/bundled/test-gen/reporter/index.d.ts.map +1 -0
- package/bundled/test-gen/reporter/index.js +161 -0
- package/bundled/test-gen/session/index.d.ts +20 -0
- package/bundled/test-gen/session/index.d.ts.map +1 -0
- package/bundled/test-gen/session/index.js +105 -0
- package/bundled/test-gen/test-build/index.d.ts +10 -0
- package/bundled/test-gen/test-build/index.d.ts.map +1 -0
- package/bundled/test-gen/test-build/index.js +30 -0
- package/bundled/test-gen/types/index.d.ts +69 -0
- package/bundled/test-gen/types/index.d.ts.map +1 -0
- package/bundled/test-gen/types/index.js +2 -0
- package/bundled/test-gen/uploader/index.d.ts +26 -0
- package/bundled/test-gen/uploader/index.d.ts.map +1 -0
- package/bundled/test-gen/uploader/index.js +102 -0
- package/bundled/test-gen/utils/env.d.ts +2 -0
- package/bundled/test-gen/utils/env.d.ts.map +1 -0
- package/bundled/test-gen/utils/env.js +9 -0
- package/bundled/test-gen/utils/exec.d.ts +4 -0
- package/bundled/test-gen/utils/exec.d.ts.map +1 -0
- package/bundled/test-gen/utils/exec.js +45 -0
- package/bundled/test-gen/utils/file.d.ts +2 -0
- package/bundled/test-gen/utils/file.d.ts.map +1 -0
- package/bundled/test-gen/utils/file.js +25 -0
- package/bundled/test-gen/utils/html.d.ts +4 -0
- package/bundled/test-gen/utils/html.d.ts.map +1 -0
- package/bundled/test-gen/utils/html.js +46 -0
- package/bundled/test-gen/utils/index.d.ts +2 -0
- package/bundled/test-gen/utils/index.d.ts.map +1 -0
- package/bundled/test-gen/utils/index.js +5 -0
- package/bundled/test-gen/utils/pw-test.d.ts +3 -0
- package/bundled/test-gen/utils/pw-test.d.ts.map +1 -0
- package/bundled/test-gen/utils/pw-test.js +26 -0
- package/bundled/test-gen/utils/slug.d.ts +2 -0
- package/bundled/test-gen/utils/slug.d.ts.map +1 -0
- package/bundled/test-gen/utils/slug.js +18 -0
- package/bundled/test-gen/utils/string.d.ts +2 -0
- package/bundled/test-gen/utils/string.d.ts.map +1 -0
- package/bundled/test-gen/utils/string.js +9 -0
- package/dist/overlay-tests/click.spec.js +1 -1
- package/package.json +3 -3
- package/scripts/prepare-publish.js +42 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NextTaskAction = exports.NEXT_TASK = void 0;
|
|
4
|
+
exports.NEXT_TASK = "next_task";
|
|
5
|
+
exports.NextTaskAction = {
|
|
6
|
+
name: exports.NEXT_TASK,
|
|
7
|
+
schema: {
|
|
8
|
+
type: "function",
|
|
9
|
+
function: {
|
|
10
|
+
name: exports.NEXT_TASK,
|
|
11
|
+
description: "take the next action base on the provided task",
|
|
12
|
+
parameters: {
|
|
13
|
+
type: "object",
|
|
14
|
+
properties: {
|
|
15
|
+
reason: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "explain how this action will help to complete the task. the reason should align with the task provided",
|
|
18
|
+
},
|
|
19
|
+
action: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: `explain the next action in natural language.
|
|
22
|
+
The next action should be as atomic as possible, precise and should contain enough details about the action to be performed.
|
|
23
|
+
E.g. each click, key press, input, assert should be a separate action.
|
|
24
|
+
Each action should take the task to completion, if not the action is invalid.`,
|
|
25
|
+
},
|
|
26
|
+
listOfAnnotations: {
|
|
27
|
+
type: "array",
|
|
28
|
+
items: {
|
|
29
|
+
type: "object",
|
|
30
|
+
properties: {
|
|
31
|
+
elementID: {
|
|
32
|
+
type: "string",
|
|
33
|
+
},
|
|
34
|
+
text: {
|
|
35
|
+
type: "string",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ["elementId", "text"],
|
|
39
|
+
},
|
|
40
|
+
description: "A list which contains mapping of all the unique element IDs within the yellow box on the screen to their corresponding texts/icons. If an element is an icon, return 'Icon: <description of icon>'.",
|
|
41
|
+
},
|
|
42
|
+
unannotatedElements: {
|
|
43
|
+
type: "array",
|
|
44
|
+
items: {
|
|
45
|
+
type: "string",
|
|
46
|
+
},
|
|
47
|
+
description: "A list of text/icon of elements which are unannotated, clickable and are present on the screen. An element is annotated if there is a red box drawn around it. If an element is an icon, return 'Icon: <description of icon>'.",
|
|
48
|
+
},
|
|
49
|
+
elementAnnotation: {
|
|
50
|
+
type: "string",
|
|
51
|
+
description: "If the element is present in listOfAnnotations, return the element ID; otherwise, return empty string ''.",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
required: ["reason", "action", "elementAnnotation"],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PlaywrightActionGenerator, PressActionArgs } from "../types";
|
|
2
|
+
export declare const PLAYWRIGHT_PRESS_ACTION_NAME = "keyboard_press_on_element";
|
|
3
|
+
export declare const pressActionGenerator: PlaywrightActionGenerator<PressActionArgs>;
|
|
4
|
+
//# sourceMappingURL=press.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../src/actions/press.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAItE,eAAO,MAAM,4BAA4B,8BAA8B,CAAC;AAExE,eAAO,MAAM,oBAAoB,EAAE,yBAAyB,CAC1D,eAAe,CA6DhB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pressActionGenerator = exports.PLAYWRIGHT_PRESS_ACTION_NAME = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
exports.PLAYWRIGHT_PRESS_ACTION_NAME = "keyboard_press_on_element";
|
|
7
|
+
const pressActionGenerator = (page) => {
|
|
8
|
+
return {
|
|
9
|
+
execute: async ({ args }) => {
|
|
10
|
+
const css = args.css_selector;
|
|
11
|
+
const locator = await (0, utils_1.getPlaywrightLocatorUsingCssSelector)(css, args.xpath, page.pwPageInstance, args?.elementAnnotation);
|
|
12
|
+
const exec = new Function("page", `return page.${locator}.press("${args.key}", { timeout: 3000 })`);
|
|
13
|
+
await exec(page.pwPageInstance);
|
|
14
|
+
return {
|
|
15
|
+
locator,
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
// TODO: args transformer to be kept at a single place
|
|
19
|
+
template: (args, options) => {
|
|
20
|
+
return {
|
|
21
|
+
code: `await ${page.name}.${options.locator}.press("${args.key}");`,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
name: exports.PLAYWRIGHT_PRESS_ACTION_NAME,
|
|
25
|
+
schema: {
|
|
26
|
+
type: "function",
|
|
27
|
+
function: {
|
|
28
|
+
name: exports.PLAYWRIGHT_PRESS_ACTION_NAME,
|
|
29
|
+
description: "Focuses the matching element and presses a combination of the keys",
|
|
30
|
+
parameters: {
|
|
31
|
+
type: "object",
|
|
32
|
+
properties: {
|
|
33
|
+
reason: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: constants_1.DEFAULT_ACTION_REASON_PROMPT,
|
|
36
|
+
},
|
|
37
|
+
key: {
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "The key to press on the keyboard after focusing the element. Example: F1 - F12, Digit0- Digit9, KeyA- KeyZ, Backquote, Minus, Equal, Backslash, Backspace, Tab, Delete, Escape, ArrowDown, End, Enter, Home, Insert, PageDown, PageUp, ArrowRight, ArrowUp, etc.",
|
|
40
|
+
},
|
|
41
|
+
xpath: {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "XPath selector to identify the element uniquely and click it. When creating XPATH selector, ensure they are unique and specific enough to select only one element, even if there are multiple elements of the same type (like multiple h1 elements)",
|
|
44
|
+
},
|
|
45
|
+
css_selector: {
|
|
46
|
+
type: "string",
|
|
47
|
+
description: "CSS selector to identify the element uniquely.When creating CSS selectors, ensure they are unique to the page and specific enough to select only one element.",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
required: ["reason", "key", "xpath", "css_selector"],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports.pressActionGenerator = pressActionGenerator;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PlaywrightActionGenerator, SkillActionArgs } from "../types";
|
|
2
|
+
export declare const SKILL_USAGE = "skill_usage";
|
|
3
|
+
export type Skill = {
|
|
4
|
+
testStep: string;
|
|
5
|
+
filePath: string;
|
|
6
|
+
usageExample: string;
|
|
7
|
+
reason: string;
|
|
8
|
+
};
|
|
9
|
+
declare class TestCaseSkills {
|
|
10
|
+
private skills;
|
|
11
|
+
constructor(skills: Skill[]);
|
|
12
|
+
getAvailableSkills(): Skill[];
|
|
13
|
+
updateSkills(skills: Skill[]): void;
|
|
14
|
+
}
|
|
15
|
+
export declare const testCaseSkills: TestCaseSkills;
|
|
16
|
+
export declare function extractSkillFromArgs(args: Record<string, any>): {
|
|
17
|
+
skillDetails: Skill | undefined;
|
|
18
|
+
};
|
|
19
|
+
export declare const skillActionGenerator: PlaywrightActionGenerator<SkillActionArgs>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=skill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../src/actions/skill.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEtE,eAAO,MAAM,WAAW,gBAAgB,CAAC;AAEzC,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,cAAM,cAAc;IACN,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,KAAK,EAAE;IAEnC,kBAAkB;IAIlB,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE;CAG7B;AAED,eAAO,MAAM,cAAc,gBAAyB,CAAC;AAErD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;EAO7D;AAED,eAAO,MAAM,oBAAoB,EAAE,yBAAyB,CAC1D,eAAe,CAkHhB,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
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.skillActionGenerator = exports.extractSkillFromArgs = exports.testCaseSkills = exports.SKILL_USAGE = void 0;
|
|
7
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
+
const api_1 = __importDefault(require("tsx/cjs/api"));
|
|
9
|
+
const use_skill_1 = require("../agent/codegen/use-skill");
|
|
10
|
+
const web_1 = require("../bin/utils/platform/web");
|
|
11
|
+
exports.SKILL_USAGE = "skill_usage";
|
|
12
|
+
class TestCaseSkills {
|
|
13
|
+
skills;
|
|
14
|
+
constructor(skills) {
|
|
15
|
+
this.skills = skills;
|
|
16
|
+
}
|
|
17
|
+
getAvailableSkills() {
|
|
18
|
+
return this.skills;
|
|
19
|
+
}
|
|
20
|
+
updateSkills(skills) {
|
|
21
|
+
this.skills = skills;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.testCaseSkills = new TestCaseSkills([]);
|
|
25
|
+
function extractSkillFromArgs(args) {
|
|
26
|
+
const availableSkills = exports.testCaseSkills.getAvailableSkills();
|
|
27
|
+
const { skill } = args;
|
|
28
|
+
const [skillDetails] = availableSkills.filter((skillDetails) => skillDetails.testStep === skill);
|
|
29
|
+
return { skillDetails };
|
|
30
|
+
}
|
|
31
|
+
exports.extractSkillFromArgs = extractSkillFromArgs;
|
|
32
|
+
const skillActionGenerator = (page, options) => {
|
|
33
|
+
const availableSkills = exports.testCaseSkills.getAvailableSkills();
|
|
34
|
+
return {
|
|
35
|
+
execute: async ({ args, trace }) => {
|
|
36
|
+
const { skill, action } = args;
|
|
37
|
+
const [skillDetails] = availableSkills.filter((skillDetails) => skillDetails.testStep === skill);
|
|
38
|
+
if (!skillDetails) {
|
|
39
|
+
throw new Error(`No skill found for ${skill}`);
|
|
40
|
+
}
|
|
41
|
+
const skillFilePath = skillDetails.filePath;
|
|
42
|
+
// This assumes repoDir is process.cwd()
|
|
43
|
+
const [lastDir] = process.cwd().split("/").reverse();
|
|
44
|
+
const dir = `${process.cwd()}/${lastDir}`;
|
|
45
|
+
const module = await api_1.default.require(`./${skillFilePath}`, dir);
|
|
46
|
+
const skillFile = await promises_1.default.readFile(skillFilePath, "utf-8");
|
|
47
|
+
const imports = Object.keys(module);
|
|
48
|
+
const code = await (0, use_skill_1.generateSkillUsageCode)({
|
|
49
|
+
task: action,
|
|
50
|
+
sampleUsageMethod: skillDetails.usageExample,
|
|
51
|
+
importPathForSkill: skillFilePath,
|
|
52
|
+
scopeVariablesMapStr: JSON.stringify(options.stateVariables || {}, null, 2),
|
|
53
|
+
pageVariableName: page.name,
|
|
54
|
+
skillMethodDefinition: skillFile,
|
|
55
|
+
trace,
|
|
56
|
+
});
|
|
57
|
+
console.log("Usage code generated", code);
|
|
58
|
+
const stateVarKeys = Object.keys(options.stateVariables || {});
|
|
59
|
+
const newVariablesSpan = trace?.span({
|
|
60
|
+
name: "new-state-variables",
|
|
61
|
+
});
|
|
62
|
+
const newVariables = (0, web_1.getVariableDeclarationsFromCode)(code);
|
|
63
|
+
newVariablesSpan?.end({
|
|
64
|
+
output: {
|
|
65
|
+
newVariables,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
const exec = new Function(page.name, ...imports, ...stateVarKeys,
|
|
69
|
+
// assuming all POMs are async methods and the LLM should respond with await keyword
|
|
70
|
+
`
|
|
71
|
+
return (async () => {
|
|
72
|
+
${code}
|
|
73
|
+
return {
|
|
74
|
+
${newVariables.join(",")}
|
|
75
|
+
}
|
|
76
|
+
})()`);
|
|
77
|
+
// extract the state variables after execution
|
|
78
|
+
const newStateVariables = await exec(page.pwPageInstance, ...imports.map((i) => module[i]), ...stateVarKeys.map((s) => options.stateVariables[s]));
|
|
79
|
+
options.setStateVariables({
|
|
80
|
+
...options.stateVariables,
|
|
81
|
+
...newStateVariables,
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
locator: code,
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
template: (args, options) => {
|
|
88
|
+
const code = `${options.locator}`;
|
|
89
|
+
const skill = args.skill;
|
|
90
|
+
const [skillDetails] = availableSkills.filter((skillDetails) => skillDetails.testStep === skill);
|
|
91
|
+
return {
|
|
92
|
+
code,
|
|
93
|
+
importPath: skillDetails?.filePath,
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
name: exports.SKILL_USAGE,
|
|
97
|
+
schema: {
|
|
98
|
+
type: "function",
|
|
99
|
+
function: {
|
|
100
|
+
name: exports.SKILL_USAGE,
|
|
101
|
+
description: "Ability to use already defined skills in the form of page object models to execute a particular task.",
|
|
102
|
+
parameters: {
|
|
103
|
+
type: "object",
|
|
104
|
+
properties: {
|
|
105
|
+
reason: {
|
|
106
|
+
type: "string",
|
|
107
|
+
description: "Explain how this action will help to complete the task. The reason should align with the task provided",
|
|
108
|
+
},
|
|
109
|
+
action: {
|
|
110
|
+
type: "string",
|
|
111
|
+
description: "Explain the action for which this skill needs to be used. Mention all details about the action so that it could be used by the skill",
|
|
112
|
+
},
|
|
113
|
+
skill: {
|
|
114
|
+
type: "string",
|
|
115
|
+
enum: availableSkills.map((skill) => skill.testStep),
|
|
116
|
+
description: `skill to use. Choose one of the available skills: ${availableSkills
|
|
117
|
+
.map((skill) => skill.testStep)
|
|
118
|
+
.join(", ")}`,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
required: ["reason", "action", "skill"],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
exports.skillActionGenerator = skillActionGenerator;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PlaywrightActionGenerator, TextContentActionArgs } from "../types";
|
|
2
|
+
export declare const PLAYWRIGHT_TEXT_CONTENT_ACTION_NAME = "text_content";
|
|
3
|
+
export declare const textContentActionGenerator: PlaywrightActionGenerator<TextContentActionArgs>;
|
|
4
|
+
//# sourceMappingURL=text-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-content.d.ts","sourceRoot":"","sources":["../../src/actions/text-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAI5E,eAAO,MAAM,mCAAmC,iBAAiB,CAAC;AAElE,eAAO,MAAM,0BAA0B,EAAE,yBAAyB,CAChE,qBAAqB,CA2DtB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textContentActionGenerator = exports.PLAYWRIGHT_TEXT_CONTENT_ACTION_NAME = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
exports.PLAYWRIGHT_TEXT_CONTENT_ACTION_NAME = "text_content";
|
|
7
|
+
const textContentActionGenerator = (page, options) => {
|
|
8
|
+
return {
|
|
9
|
+
execute: async ({ args }) => {
|
|
10
|
+
const locator = await (0, utils_1.getPlaywrightLocatorUsingCssSelector)(args.css_selector, args.xpath, page.pwPageInstance, args?.elementAnnotation);
|
|
11
|
+
const exec = new Function("page", `return page.${locator}.textContent()`);
|
|
12
|
+
const textContent = await exec(page.pwPageInstance);
|
|
13
|
+
options.setStateVariables({
|
|
14
|
+
...options.stateVariables,
|
|
15
|
+
[args.variable_name]: textContent,
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
locator,
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
template: (args, options) => {
|
|
22
|
+
return {
|
|
23
|
+
code: `const ${args.variable_name} = await ${page.name}.${options.locator}.textContent();`,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
name: exports.PLAYWRIGHT_TEXT_CONTENT_ACTION_NAME,
|
|
27
|
+
schema: {
|
|
28
|
+
type: "function",
|
|
29
|
+
function: {
|
|
30
|
+
name: exports.PLAYWRIGHT_TEXT_CONTENT_ACTION_NAME,
|
|
31
|
+
description: "extract text content of the element",
|
|
32
|
+
parameters: {
|
|
33
|
+
type: "object",
|
|
34
|
+
properties: {
|
|
35
|
+
reason: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: constants_1.DEFAULT_ACTION_REASON_PROMPT,
|
|
38
|
+
},
|
|
39
|
+
variable_name: {
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "name of the variable to store the text content. The variable name should describe what the text content is about.",
|
|
42
|
+
},
|
|
43
|
+
xpath: {
|
|
44
|
+
type: "string",
|
|
45
|
+
description: "XPath selector to identify the element uniquely and click it. When creating XPATH selector, ensure they are unique and specific enough to select only one element, even if there are multiple elements of the same type (like multiple h1 elements)",
|
|
46
|
+
},
|
|
47
|
+
css_selector: {
|
|
48
|
+
type: "string",
|
|
49
|
+
description: "CSS selector to identify the element uniquely.When creating CSS selectors, ensure they are unique to the page and specific enough to select only one element.",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ["reason", "variable_name", "xpath", "css_selector"],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
exports.textContentActionGenerator = textContentActionGenerator;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Page } from "playwright";
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
playwright: any;
|
|
5
|
+
jQuery: any;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare function getPlaywrightLocatorUsingCssSelector(cssSelector: string, xpath: string, page: Page, elementAnnotation?: string): Promise<any>;
|
|
9
|
+
export declare function getPageVarName(): string;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,EACV,iBAAiB,CAAC,EAAE,MAAM,gBAkH3B;AAED,wBAAgB,cAAc,WAG7B"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPageVarName = exports.getPlaywrightLocatorUsingCssSelector = void 0;
|
|
4
|
+
async function getPlaywrightLocatorUsingCssSelector(cssSelector, xpath, page, elementAnnotation) {
|
|
5
|
+
// TODO: analyse other solutions than just css. Also find other solutions to support :has-text -> prompting ?
|
|
6
|
+
// jquery doesnt support :has-text. neither css. Only playwright locator supports this selector though.
|
|
7
|
+
const sanitizedCssSelectorForJQuery = cssSelector
|
|
8
|
+
?.replaceAll(":has-text", ":contains")
|
|
9
|
+
?.replaceAll(":text", ":contains");
|
|
10
|
+
return await page.evaluate((locator) => {
|
|
11
|
+
const elementAnnotation = locator?.elementAnnotation;
|
|
12
|
+
let selectedElem;
|
|
13
|
+
if (elementAnnotation &&
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
window?.annotationInstance?.annotations?.[elementAnnotation]) {
|
|
16
|
+
selectedElem =
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
window?.annotationInstance?.annotations?.[elementAnnotation]?.node;
|
|
19
|
+
const elementDepth =
|
|
20
|
+
//@ts-ignore
|
|
21
|
+
window?.annotationInstance?.annotations?.[elementAnnotation].depth;
|
|
22
|
+
const frameLocatorStr = elementDepth
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
.map((e, index) => {
|
|
25
|
+
const locator = index === 0
|
|
26
|
+
? //To handle the parent iframe
|
|
27
|
+
window.playwright.generateLocator(e)
|
|
28
|
+
: elementDepth[index - 1].contentWindow.playwright.generateLocator(e);
|
|
29
|
+
return locator.replace(/^locator\(/, "frameLocator(");
|
|
30
|
+
})
|
|
31
|
+
.join(".");
|
|
32
|
+
let elementLocator;
|
|
33
|
+
//If the element is inside an iframe, we need to append the locator for the iframe
|
|
34
|
+
if (elementDepth.length > 0) {
|
|
35
|
+
elementLocator =
|
|
36
|
+
elementDepth[elementDepth.length - 1].contentWindow.playwright.generateLocator(selectedElem);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
elementLocator = window.playwright.generateLocator(selectedElem);
|
|
40
|
+
}
|
|
41
|
+
return frameLocatorStr
|
|
42
|
+
? `${frameLocatorStr}.${elementLocator}`
|
|
43
|
+
: elementLocator;
|
|
44
|
+
}
|
|
45
|
+
else if (locator.xpath) {
|
|
46
|
+
try {
|
|
47
|
+
const xpath = locator.xpath.replaceAll("text()", "normalize-space()");
|
|
48
|
+
const result = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
|
|
49
|
+
let node = result.iterateNext();
|
|
50
|
+
const elements = [];
|
|
51
|
+
// Store all matched elements
|
|
52
|
+
while (node) {
|
|
53
|
+
elements.push(node);
|
|
54
|
+
node = result.iterateNext();
|
|
55
|
+
}
|
|
56
|
+
// Find the least deep nesting (i.e., with the fewest child elements)
|
|
57
|
+
let minChildCount = Infinity;
|
|
58
|
+
const leastNestedElements = [];
|
|
59
|
+
elements.forEach((el) => {
|
|
60
|
+
//@ts-ignore
|
|
61
|
+
const childCount = el.children.length; // Count direct child elements
|
|
62
|
+
if (childCount < minChildCount) {
|
|
63
|
+
minChildCount = childCount;
|
|
64
|
+
leastNestedElements.length = 0;
|
|
65
|
+
leastNestedElements.push(el);
|
|
66
|
+
}
|
|
67
|
+
else if (childCount === minChildCount) {
|
|
68
|
+
leastNestedElements.push(el);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
selectedElem = leastNestedElements[0];
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
// ignore error
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (!selectedElem) {
|
|
78
|
+
const elements = window.jQuery(locator.cssForJq);
|
|
79
|
+
let elIdx = 0;
|
|
80
|
+
Array.from(elements).some((el, i) => {
|
|
81
|
+
if (window.jQuery(el).is(":visible")) {
|
|
82
|
+
elIdx = i;
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
});
|
|
87
|
+
//@ts-ignore
|
|
88
|
+
selectedElem = elements[elIdx];
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
console.log("using xpath locator");
|
|
92
|
+
}
|
|
93
|
+
if (!selectedElem) {
|
|
94
|
+
throw Error(`Unable to find element, css: ${locator.css}`);
|
|
95
|
+
}
|
|
96
|
+
return window.playwright.generateLocator(selectedElem);
|
|
97
|
+
}, {
|
|
98
|
+
css: cssSelector,
|
|
99
|
+
cssForJq: sanitizedCssSelectorForJQuery,
|
|
100
|
+
xpath: xpath,
|
|
101
|
+
elementAnnotation,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
exports.getPlaywrightLocatorUsingCssSelector = getPlaywrightLocatorUsingCssSelector;
|
|
105
|
+
function getPageVarName() {
|
|
106
|
+
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
107
|
+
return process.env.PAGE_VAR_NAME || "page";
|
|
108
|
+
}
|
|
109
|
+
exports.getPageVarName = getPageVarName;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LLM, TraceClient } from "@empiricalrun/llm";
|
|
2
|
+
import { Page } from "playwright";
|
|
3
|
+
import { PlaywrightActions } from "../../actions";
|
|
4
|
+
export type BrowserAgentAction = {
|
|
5
|
+
action: string;
|
|
6
|
+
code: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare function executeTaskUsingBrowsingAgent({ action, page, actions, llm, trace, }: {
|
|
9
|
+
action: string;
|
|
10
|
+
page: Page;
|
|
11
|
+
actions: PlaywrightActions;
|
|
12
|
+
llm?: LLM;
|
|
13
|
+
trace?: TraceClient;
|
|
14
|
+
}): Promise<BrowserAgentAction | undefined>;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAOlD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF,wBAAsB,6BAA6B,CAAC,EAClD,MAAM,EACN,IAAI,EACJ,OAAO,EACP,GAAG,EACH,KAAK,GACN,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,iBAAiB,CAAC;IAC3B,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CA8D1C"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeTaskUsingBrowsingAgent = void 0;
|
|
4
|
+
const llm_1 = require("@empiricalrun/llm");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const promptTemplate_0 = "{{#section \"system\"}}\nYou are a browser automation agent who is given a task to generate code for navigation and assertion. This task is your\ngoal and you must achieve it.\n\nYou will be provided with already executed actions and basis that you need to pick the next step to achieve the task.\nRemember that the goal must be achieved.\n\nYou will be provided with the web page snapshot in the form of Document Object Model. Based on the goal and available\ntool calls you need to pick the appropriate tool call.\n\nInstructions:\n- Take actions one at a time. Do not try to take multiple actions\n- You can respond with multiple assertions in one shot\n- Do not repeat the same actions again otherwise your response will be marked INVALID\n- Avoid repeating errors which we got while executing the last action\n- Stick to the task provided to you and mark the task done once the task is complete\n- Do not execute any action which is not mentioned in the task\n- Do not repeat actions which are already executed more than twice otherwise your response will be marked INVALID\n- Always refer to \"Executed actions\" before deciding your next action for completion of the task.\n- End the task done if all actions required for task are executed\n{{/section}}\n\n{{#section \"user\"}}\nTask:\n{{task}}\n\nCurrent page snapshot:\n{{pageSnapshot}}\n{{/section}}";
|
|
7
|
+
const reporter_1 = require("../../reporter");
|
|
8
|
+
const html_1 = require("../../utils/html");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
async function executeTaskUsingBrowsingAgent({ action, page, actions, llm, trace, }) {
|
|
11
|
+
let generatedCodeSteps;
|
|
12
|
+
const tools = actions.getBrowsingActionSchemas();
|
|
13
|
+
const testgenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
|
|
14
|
+
const browsingAgentSpan = trace?.span({
|
|
15
|
+
name: `browsing-agent`,
|
|
16
|
+
input: {
|
|
17
|
+
action,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const pageContentSpan = browsingAgentSpan?.span({
|
|
21
|
+
name: "page-content",
|
|
22
|
+
});
|
|
23
|
+
const pageContent = await page.content();
|
|
24
|
+
pageContentSpan?.end({ output: { pageContent } });
|
|
25
|
+
const sanitizationSpan = browsingAgentSpan?.span({
|
|
26
|
+
name: "page-sanitization",
|
|
27
|
+
});
|
|
28
|
+
const pageSnapshot = (0, html_1.sanitizeHtml)(pageContent);
|
|
29
|
+
sanitizationSpan?.end({ output: { pageSnapshot } });
|
|
30
|
+
const promptSpan = browsingAgentSpan?.span({ name: "page-prompt" });
|
|
31
|
+
const messages = (0, llm_1.compilePrompt)(promptTemplate_0, { pageSnapshot, task: action });
|
|
32
|
+
promptSpan?.end({ output: { messages } });
|
|
33
|
+
llm =
|
|
34
|
+
llm ||
|
|
35
|
+
new llm_1.LLM({
|
|
36
|
+
provider: constants_1.DEFAULT_MODEL_PROVIDER,
|
|
37
|
+
});
|
|
38
|
+
const completion = await llm.createChatCompletion({
|
|
39
|
+
model: "o3-mini-2025-01-31",
|
|
40
|
+
messages,
|
|
41
|
+
tools,
|
|
42
|
+
trace: browsingAgentSpan,
|
|
43
|
+
modelParameters: {
|
|
44
|
+
tool_choice: "required",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const toolCalls = completion?.tool_calls || [];
|
|
48
|
+
const toolCallsSpan = browsingAgentSpan?.span({ name: "tool-calls" });
|
|
49
|
+
for (const i in toolCalls) {
|
|
50
|
+
const toolCall = toolCalls[i];
|
|
51
|
+
const args = (0, utils_1.parseJson)(toolCall.function.arguments);
|
|
52
|
+
try {
|
|
53
|
+
const code = await actions.executeAction(toolCall.function.name, (0, utils_1.parseJson)(toolCall.function.arguments), toolCallsSpan);
|
|
54
|
+
generatedCodeSteps = {
|
|
55
|
+
// Passing reason as action, in order to pass the correct action that took place to runtime planner
|
|
56
|
+
action: args.reason,
|
|
57
|
+
code,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
void testgenUpdatesReporter.sendMessage(e.message);
|
|
62
|
+
throw e;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
toolCallsSpan?.end({ output: { toolCalls, generatedCodeSteps } });
|
|
66
|
+
return generatedCodeSteps;
|
|
67
|
+
}
|
|
68
|
+
exports.executeTaskUsingBrowsingAgent = executeTaskUsingBrowsingAgent;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type GenerateTestsType = {
|
|
2
|
+
testFilePath: string;
|
|
3
|
+
filePathToUpdate: string;
|
|
4
|
+
pwProjectsFilter: string[];
|
|
5
|
+
testGenToken: string;
|
|
6
|
+
repoDir: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* Function to generate tests using master agent
|
|
11
|
+
* @export
|
|
12
|
+
* @param {GenerateTestsType} {
|
|
13
|
+
* testFilePath,
|
|
14
|
+
* filePathToUpdate,
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, pwProjectsFilter, testGenToken, repoDir, }: GenerateTestsType): Promise<void>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAkBA,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,OAAO,GACR,EAAE,iBAAiB,iBA6EnB"}
|