@empiricalrun/test-gen 0.81.0 → 0.81.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 +13 -0
- package/package.json +7 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/agent/browsing/index.d.ts +0 -15
- package/dist/agent/browsing/index.d.ts.map +0 -1
- package/dist/agent/browsing/index.js +0 -60
- package/dist/agent/master/action-tool-calls.d.ts +0 -42
- package/dist/agent/master/action-tool-calls.d.ts.map +0 -1
- package/dist/agent/master/action-tool-calls.js +0 -87
- package/dist/agent/master/element-annotation.d.ts +0 -30
- package/dist/agent/master/element-annotation.d.ts.map +0 -1
- package/dist/agent/master/element-annotation.js +0 -175
- package/dist/agent/master/execute-browser-action.d.ts +0 -24
- package/dist/agent/master/execute-browser-action.d.ts.map +0 -1
- package/dist/agent/master/execute-browser-action.js +0 -121
- package/dist/agent/master/next-action.d.ts +0 -22
- package/dist/agent/master/next-action.d.ts.map +0 -1
- package/dist/agent/master/next-action.js +0 -97
- package/dist/agent/master/planner.d.ts +0 -15
- package/dist/agent/master/planner.d.ts.map +0 -1
- package/dist/agent/master/planner.js +0 -142
- package/dist/agent/master/run.d.ts +0 -17
- package/dist/agent/master/run.d.ts.map +0 -1
- package/dist/agent/master/run.js +0 -156
- package/dist/agent/master/scroller.d.ts +0 -15
- package/dist/agent/master/scroller.d.ts.map +0 -1
- package/dist/agent/master/scroller.js +0 -369
- package/dist/agent/master/with-hints.d.ts +0 -17
- package/dist/agent/master/with-hints.d.ts.map +0 -1
- package/dist/agent/master/with-hints.js +0 -103
- package/dist/agent/planner/run-time-planner.d.ts +0 -15
- package/dist/agent/planner/run-time-planner.d.ts.map +0 -1
- package/dist/agent/planner/run-time-planner.js +0 -98
- package/dist/agent/planner/run.d.ts +0 -7
- package/dist/agent/planner/run.d.ts.map +0 -1
- package/dist/agent/planner/run.js +0 -128
- package/dist/browser-injected-scripts/annotate-elements.js +0 -612
- package/dist/browser-injected-scripts/annotate-elements.spec.d.ts +0 -2
- package/dist/browser-injected-scripts/annotate-elements.spec.d.ts.map +0 -1
- package/dist/browser-injected-scripts/annotate-elements.spec.js +0 -202
- package/dist/browser-injected-scripts/annotate-elements.spec.ts +0 -327
- package/dist/generate-summary/frame-sampling.d.ts +0 -12
- package/dist/generate-summary/frame-sampling.d.ts.map +0 -1
- package/dist/generate-summary/frame-sampling.js +0 -72
- package/dist/generate-summary/generate-error-stack-summary.d.ts +0 -11
- package/dist/generate-summary/generate-error-stack-summary.d.ts.map +0 -1
- package/dist/generate-summary/generate-error-stack-summary.js +0 -41
- package/dist/generate-summary/generate-failed-step-screenshot-diff-summary.d.ts +0 -58
- package/dist/generate-summary/generate-failed-step-screenshot-diff-summary.d.ts.map +0 -1
- package/dist/generate-summary/generate-failed-step-screenshot-diff-summary.js +0 -460
- package/dist/generate-summary/generate-grouped-summary.d.ts +0 -18
- package/dist/generate-summary/generate-grouped-summary.d.ts.map +0 -1
- package/dist/generate-summary/generate-grouped-summary.js +0 -88
- package/dist/generate-summary/merge-summary.d.ts +0 -16
- package/dist/generate-summary/merge-summary.d.ts.map +0 -1
- package/dist/generate-summary/merge-summary.js +0 -43
- package/dist/generate-summary/pick-videos-for-comparison.d.ts +0 -9
- package/dist/generate-summary/pick-videos-for-comparison.d.ts.map +0 -1
- package/dist/generate-summary/pick-videos-for-comparison.js +0 -54
- package/dist/utils/env.d.ts +0 -2
- package/dist/utils/env.d.ts.map +0 -1
- package/dist/utils/env.js +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.81.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [76d0872]
|
|
8
|
+
- @empiricalrun/shared-types@0.14.0
|
|
9
|
+
- @empiricalrun/llm@0.27.0
|
|
10
|
+
- @empiricalrun/cua@0.4.1
|
|
11
|
+
- @empiricalrun/dashboard-client@0.3.0
|
|
12
|
+
- @empiricalrun/reporter@0.29.0
|
|
13
|
+
- @empiricalrun/test-run@0.17.0
|
|
14
|
+
- videostil@0.3.6
|
|
15
|
+
|
|
3
16
|
## 0.81.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -89,15 +89,15 @@
|
|
|
89
89
|
"typescript": "^5.3.3",
|
|
90
90
|
"zod": "^4.0.1",
|
|
91
91
|
"@empiricalrun/ast-parser": "^0.0.10",
|
|
92
|
-
"@empiricalrun/cua": "^0.4.
|
|
92
|
+
"@empiricalrun/cua": "^0.4.1",
|
|
93
93
|
"@empiricalrun/dashboard-client": "^0.3.0",
|
|
94
|
-
"@empiricalrun/shared-types": "0.
|
|
95
|
-
"@empiricalrun/llm": "^0.
|
|
94
|
+
"@empiricalrun/shared-types": "0.14.0",
|
|
95
|
+
"@empiricalrun/llm": "^0.27.0",
|
|
96
96
|
"@empiricalrun/r2-uploader": "^0.9.1",
|
|
97
97
|
"@empiricalrun/trace-utils": "^0.1.0",
|
|
98
98
|
"@empiricalrun/reporter": "^0.29.0",
|
|
99
99
|
"@empiricalrun/test-run": "^0.17.0",
|
|
100
|
-
"videostil": "0.3.
|
|
100
|
+
"videostil": "0.3.6"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@playwright/test": "1.60.0",
|
|
@@ -119,11 +119,11 @@
|
|
|
119
119
|
},
|
|
120
120
|
"scripts": {
|
|
121
121
|
"dev": "tspc --build --watch",
|
|
122
|
-
"build": "tspc --build
|
|
122
|
+
"build": "tspc --build",
|
|
123
123
|
"clean": "tspc --build --clean",
|
|
124
124
|
"lint": "biome check --unsafe",
|
|
125
125
|
"test": "vitest run",
|
|
126
|
-
"test-browser": "pnpm build &&
|
|
126
|
+
"test-browser": "pnpm build && npx playwright test",
|
|
127
127
|
"test:watch": "vitest",
|
|
128
128
|
"test:watch-files": "vitest $0 --watch"
|
|
129
129
|
}
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/index.ts","./src/logger.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/cli.ts","./src/agent/index.ts","./src/agent/base/index.ts","./src/agent/browsing/
|
|
1
|
+
{"root":["./src/index.ts","./src/logger.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/cli.ts","./src/agent/index.ts","./src/agent/base/index.ts","./src/agent/browsing/run.ts","./src/agent/browsing/utils.ts","./src/agent/chat/agent-loop.ts","./src/agent/chat/exports.ts","./src/agent/chat/index.ts","./src/agent/chat/models.ts","./src/agent/chat/state.ts","./src/agent/chat/types.ts","./src/agent/chat/utils.ts","./src/agent/chat/prompt/pw-utils-docs.ts","./src/agent/chat/prompt/repo.ts","./src/agent/chat/prompt/skills.ts","./src/agent/chat/prompt/test-case-def.ts","./src/agent/chat/prompt/trace-utils-docs.ts","./src/agent/code-review/index.ts","./src/agent/code-review/types.ts","./src/agent/code-review/xml-parser.ts","./src/agent/code-review/executor/index.ts","./src/agent/fast-triage/index.ts","./src/agent/master/browser-tests/cua.spec.ts","./src/agent/master/browser-tests/fixtures.ts","./src/agent/master/browser-tests/index.spec.ts","./src/agent/triage/index.ts","./src/artifacts/index.ts","./src/artifacts/utils.ts","./src/auth/cli-auth.ts","./src/auth/index.ts","./src/auth/token-store.ts","./src/bin/index.ts","./src/bin/setup.ts","./src/bin/logger/index.ts","./src/bin/utils/context.ts","./src/bin/utils/index.ts","./src/bin/utils/fs/index.ts","./src/bin/utils/platform/web/index.ts","./src/bin/utils/platform/web/test-files/ts-path-import-validate.ts","./src/bin/utils/scenarios/index.ts","./src/constants/index.ts","./src/dashboard/client.ts","./src/dashboard/index.ts","./src/dashboard/tool-response-from-sandbox.ts","./src/dashboard/tool-response.ts","./src/dashboard/totp.ts","./src/dashboard/types.ts","./src/errors/index.ts","./src/file/client.ts","./src/file/server.ts","./src/file-info/index.ts","./src/file-info/adapters/file-system/index.ts","./src/file-info/adapters/file-system/reader.ts","./src/file-info/adapters/github/reader.ts","./src/human-in-the-loop/cli.ts","./src/human-in-the-loop/index.ts","./src/human-in-the-loop/ipc.ts","./src/page/index.ts","./src/prompts/lib/ts-transformer.ts","./src/recorder/env-variables.ts","./src/recorder/index.ts","./src/recorder/request.ts","./src/recorder/temp-files.ts","./src/recorder/upload.ts","./src/recorder/validation.ts","./src/telemetry/index.ts","./src/test-build/index.ts","./src/tools/diagnosis-fetcher.ts","./src/tools/index.ts","./src/tools/list-environments.ts","./src/tools/run-test.ts","./src/tools/test-gen-browser.ts","./src/tools/analyse-video/index.ts","./src/tools/api-client/index.ts","./src/tools/create-pull-request/index.ts","./src/tools/create-pull-request/utils.ts","./src/tools/definitions/analyse-video.ts","./src/tools/definitions/delete-file.ts","./src/tools/definitions/download-build.ts","./src/tools/definitions/grep.ts","./src/tools/definitions/list-tests-and-projects.ts","./src/tools/definitions/merge-conflicts.ts","./src/tools/definitions/publish-markdown-report.ts","./src/tools/definitions/rename-file.ts","./src/tools/definitions/run-test.ts","./src/tools/definitions/safe-bash.ts","./src/tools/definitions/str_replace_editor.ts","./src/tools/definitions/test-gen-browser.ts","./src/tools/definitions/trace-dot-zip.ts","./src/tools/definitions/utils.ts","./src/tools/delete-file/index.ts","./src/tools/download-build/index.ts","./src/tools/executor/base.ts","./src/tools/executor/index.ts","./src/tools/executor/types.ts","./src/tools/executor/utils/checkpoint.ts","./src/tools/executor/utils/git.ts","./src/tools/executor/utils/index.ts","./src/tools/executor/utils/pr-description.ts","./src/tools/fetch-file/index.ts","./src/tools/fetch-file/utils.ts","./src/tools/fetch-session-diff/index.ts","./src/tools/file-operations/create.ts","./src/tools/file-operations/index.ts","./src/tools/file-operations/insert.ts","./src/tools/file-operations/replace.ts","./src/tools/file-operations/shared/helpers.ts","./src/tools/file-operations/view/index.ts","./src/tools/firecrawl-scrape/index.ts","./src/tools/grep/index.ts","./src/tools/grep/types.ts","./src/tools/grep/ripgrep/index.ts","./src/tools/issues-v1/index.ts","./src/tools/issues-v1/list-issues.ts","./src/tools/issues-v1/utils.ts","./src/tools/issues-v2/create-issue.ts","./src/tools/issues-v2/set-issue-description.ts","./src/tools/issues-v2/update-issue.ts","./src/tools/list-tests-and-projects/index.ts","./src/tools/merge-conflicts/index.ts","./src/tools/publish-markdown-report/index.ts","./src/tools/rename-file/index.ts","./src/tools/safe-bash/index.ts","./src/tools/test-run-fetcher/index.ts","./src/tools/trace-dot-zip/index.ts","./src/tools/trace-dot-zip/types.ts","./src/tools/trace-dot-zip/utils/console-trace.ts","./src/tools/trace-dot-zip/utils/extract-screenshots.ts","./src/tools/trace-dot-zip/utils/extract-steps.ts","./src/tools/trace-dot-zip/utils/extract-zip.ts","./src/tools/trace-dot-zip/utils/network-trace.ts","./src/tools/triage-summary/index.ts","./src/tools/triage-summary/types.ts","./src/tools/triage-summary/utils.ts","./src/tools/utils/apply-line-limit.ts","./src/tools/utils/validate-schema.ts","./src/tools/utils/validators.ts","./src/types/handlebars.d.ts","./src/types/index.ts","./src/utils/exec.ts","./src/utils/file.ts","./src/utils/hash.ts","./src/utils/html.ts","./src/utils/index.ts","./src/utils/json.ts","./src/utils/model.ts","./src/utils/playwright-test-id.ts","./src/utils/repo-tree.ts","./src/utils/slug.ts","./src/utils/string.ts","./src/utils/stripAnsi.ts","./src/utils/url-validation.ts","./src/utils/dedup/dedup-image.ts","./src/utils/dedup/find-threshold.ts","./src/video-core/index.ts","./src/video-core/model-limits.ts","./src/video-core/storage-manager.ts","./src/video-core/types.ts","./src/video-core/utils.ts"],"version":"5.8.3"}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAKlD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF,wBAAsB,6BAA6B,CAAC,EAClD,MAAM,EACN,IAAI,EACJ,OAAO,EACP,GAAG,EACH,KAAK,GACN,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,iBAAiB,CAAC;IAC3B,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CA0D1C"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeTaskUsingBrowsingAgent = executeTaskUsingBrowsingAgent;
|
|
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 html_1 = require("../../utils/html");
|
|
8
|
-
async function executeTaskUsingBrowsingAgent({ action, page, actions, llm, trace, }) {
|
|
9
|
-
let generatedCodeSteps;
|
|
10
|
-
const tools = actions.getBrowsingActionSchemas();
|
|
11
|
-
const browsingAgentSpan = trace?.span({
|
|
12
|
-
name: `browsing-agent`,
|
|
13
|
-
input: {
|
|
14
|
-
action,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
const pageContentSpan = browsingAgentSpan?.span({
|
|
18
|
-
name: "page-content",
|
|
19
|
-
});
|
|
20
|
-
const pageContent = await page.content();
|
|
21
|
-
pageContentSpan?.end({ output: { pageContent } });
|
|
22
|
-
const sanitizationSpan = browsingAgentSpan?.span({
|
|
23
|
-
name: "page-sanitization",
|
|
24
|
-
});
|
|
25
|
-
const pageSnapshot = (0, html_1.sanitizeHtml)(pageContent);
|
|
26
|
-
sanitizationSpan?.end({ output: { pageSnapshot } });
|
|
27
|
-
const promptSpan = browsingAgentSpan?.span({ name: "page-prompt" });
|
|
28
|
-
const messages = (0, llm_1.compilePrompt)(promptTemplate_0, { pageSnapshot, task: action });
|
|
29
|
-
promptSpan?.end({ output: { messages } });
|
|
30
|
-
llm =
|
|
31
|
-
llm ||
|
|
32
|
-
new llm_1.LLM({
|
|
33
|
-
provider: constants_1.DEFAULT_MODEL_PROVIDER,
|
|
34
|
-
});
|
|
35
|
-
const completion = await llm.createChatCompletion({
|
|
36
|
-
model: "o3-mini-2025-01-31",
|
|
37
|
-
messages,
|
|
38
|
-
tools,
|
|
39
|
-
trace: browsingAgentSpan,
|
|
40
|
-
modelParameters: {
|
|
41
|
-
tool_choice: "required",
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
const toolCalls = completion?.tool_calls || [];
|
|
45
|
-
const toolCallsSpan = browsingAgentSpan?.span({ name: "tool-calls" });
|
|
46
|
-
for (const i in toolCalls) {
|
|
47
|
-
const toolCall = toolCalls[i];
|
|
48
|
-
if ("function" in toolCall) {
|
|
49
|
-
const args = JSON.parse(toolCall.function.arguments);
|
|
50
|
-
const code = await actions.executeAction(toolCall.function.name, JSON.parse(toolCall.function.arguments), toolCallsSpan);
|
|
51
|
-
generatedCodeSteps = {
|
|
52
|
-
// Passing reason as action, in order to pass the correct action that took place to runtime planner
|
|
53
|
-
action: args.reason,
|
|
54
|
-
code,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
toolCallsSpan?.end({ output: { toolCalls, generatedCodeSteps } });
|
|
59
|
-
return generatedCodeSteps;
|
|
60
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export declare enum ActionType {
|
|
2
|
-
FILL = "fill",
|
|
3
|
-
PAGE_GOTO = "page_goto",
|
|
4
|
-
CLICK = "click",
|
|
5
|
-
PRESS_ACTION = "keyboard_press_on_element",
|
|
6
|
-
ASSERT_TEXT = "assert_text",
|
|
7
|
-
HOVER = "hover_element",
|
|
8
|
-
SCROLL = "scroll",
|
|
9
|
-
OBSERVATION = "observation",
|
|
10
|
-
UNKNOWN = "unknown"
|
|
11
|
-
}
|
|
12
|
-
export declare function isValidActionType(value: string): value is ActionType;
|
|
13
|
-
export declare function getActionToolCalls(): {
|
|
14
|
-
type: string;
|
|
15
|
-
function: {
|
|
16
|
-
name: string;
|
|
17
|
-
description: string;
|
|
18
|
-
parameters: {
|
|
19
|
-
type: string;
|
|
20
|
-
properties: {
|
|
21
|
-
reason: {
|
|
22
|
-
type: string;
|
|
23
|
-
description: string;
|
|
24
|
-
};
|
|
25
|
-
action: {
|
|
26
|
-
type: string;
|
|
27
|
-
description: string;
|
|
28
|
-
};
|
|
29
|
-
element_description: {
|
|
30
|
-
type: string;
|
|
31
|
-
description: string;
|
|
32
|
-
};
|
|
33
|
-
is_element_visible: {
|
|
34
|
-
type: string;
|
|
35
|
-
description: string;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
required: string[];
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
}[];
|
|
42
|
-
//# sourceMappingURL=action-tool-calls.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action-tool-calls.d.ts","sourceRoot":"","sources":["../../../src/agent/master/action-tool-calls.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,YAAY,8BAA8B;IAC1C,WAAW,gBAAgB;IAC3B,KAAK,kBAAkB;IACvB,MAAM,WAAW;IACjB,WAAW,gBAAgB;IAC3B,OAAO,YAAY;CACpB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,UAAU,CAEpE;AAqDD,wBAAgB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA8CjC"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ActionType = void 0;
|
|
4
|
-
exports.isValidActionType = isValidActionType;
|
|
5
|
-
exports.getActionToolCalls = getActionToolCalls;
|
|
6
|
-
var ActionType;
|
|
7
|
-
(function (ActionType) {
|
|
8
|
-
ActionType["FILL"] = "fill";
|
|
9
|
-
ActionType["PAGE_GOTO"] = "page_goto";
|
|
10
|
-
ActionType["CLICK"] = "click";
|
|
11
|
-
ActionType["PRESS_ACTION"] = "keyboard_press_on_element";
|
|
12
|
-
ActionType["ASSERT_TEXT"] = "assert_text";
|
|
13
|
-
ActionType["HOVER"] = "hover_element";
|
|
14
|
-
ActionType["SCROLL"] = "scroll";
|
|
15
|
-
ActionType["OBSERVATION"] = "observation";
|
|
16
|
-
ActionType["UNKNOWN"] = "unknown";
|
|
17
|
-
})(ActionType || (exports.ActionType = ActionType = {}));
|
|
18
|
-
function isValidActionType(value) {
|
|
19
|
-
return Object.values(ActionType).includes(value);
|
|
20
|
-
}
|
|
21
|
-
const createActionCall = (name, description, additionalProperties = {}) => ({
|
|
22
|
-
type: "function",
|
|
23
|
-
function: {
|
|
24
|
-
name,
|
|
25
|
-
description,
|
|
26
|
-
parameters: {
|
|
27
|
-
type: "object",
|
|
28
|
-
properties: {
|
|
29
|
-
reason: {
|
|
30
|
-
type: "string",
|
|
31
|
-
description: "explain how this action will help to complete the task. the reason should align with the task provided",
|
|
32
|
-
},
|
|
33
|
-
action: {
|
|
34
|
-
type: "string",
|
|
35
|
-
description: `explain the next action in natural language.
|
|
36
|
-
The next action should be as atomic as possible, precise and should contain enough details about the action to be performed.
|
|
37
|
-
E.g. each click, key press, input, assert, observation should be a separate action.
|
|
38
|
-
Each action should take the task to completion, if not the action is invalid.
|
|
39
|
-
If the element is not visible then action should be scroll.`,
|
|
40
|
-
},
|
|
41
|
-
element_description: {
|
|
42
|
-
type: "string",
|
|
43
|
-
description: "The description of the element on which action needs to be taken, including its position, appearance, etc.",
|
|
44
|
-
},
|
|
45
|
-
is_element_visible: {
|
|
46
|
-
type: "boolean",
|
|
47
|
-
description: "A boolean to indicate whether the concerned element is visible in the screenshot.",
|
|
48
|
-
},
|
|
49
|
-
...additionalProperties,
|
|
50
|
-
},
|
|
51
|
-
required: [
|
|
52
|
-
"reason",
|
|
53
|
-
"action",
|
|
54
|
-
"element_description",
|
|
55
|
-
"is_element_visible",
|
|
56
|
-
...Object.keys(additionalProperties),
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
function getActionToolCalls() {
|
|
62
|
-
return [
|
|
63
|
-
createActionCall(ActionType.ASSERT_TEXT, "assert whether the given element on the page is visible", {
|
|
64
|
-
assertion_text: {
|
|
65
|
-
type: "string",
|
|
66
|
-
description: "The text for which the visibility needs to be asserted.",
|
|
67
|
-
},
|
|
68
|
-
}),
|
|
69
|
-
createActionCall(ActionType.FILL, "fill the input element with a particular text"),
|
|
70
|
-
createActionCall(ActionType.CLICK, "click an element on the page"),
|
|
71
|
-
createActionCall(ActionType.PAGE_GOTO, "navigate the page to a new URL"),
|
|
72
|
-
createActionCall(ActionType.PRESS_ACTION, "Focuses the matching element and presses a combination of the keys"),
|
|
73
|
-
createActionCall(ActionType.HOVER, "hover over an element on the page"),
|
|
74
|
-
createActionCall(ActionType.SCROLL, "Scroll the page since element is not visible in the screenshot", {
|
|
75
|
-
element: {
|
|
76
|
-
type: "string",
|
|
77
|
-
description: "Element to look for after scrolling to complete the task.",
|
|
78
|
-
},
|
|
79
|
-
}),
|
|
80
|
-
createActionCall(ActionType.OBSERVATION, "Observation based on the task provided. If the task doesn't explicitly mention any browser interaction, and instead, asks questions to be answered — use this tool call", {
|
|
81
|
-
observation: {
|
|
82
|
-
type: "string",
|
|
83
|
-
description: "Observation based on the task provided.",
|
|
84
|
-
},
|
|
85
|
-
}),
|
|
86
|
-
];
|
|
87
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { LLM, TraceClient } from "@empiricalrun/llm";
|
|
2
|
-
import { TestGenConfigOptions } from "@empiricalrun/shared-types/agent-workflow";
|
|
3
|
-
import { Page } from "playwright";
|
|
4
|
-
import { ActionType } from "./action-tool-calls";
|
|
5
|
-
export declare function getElementAnnotation({ elementDescription, annotations, annotatedScreenshot, trace, llm, options, preference, }: {
|
|
6
|
-
elementDescription: string;
|
|
7
|
-
annotations: string;
|
|
8
|
-
annotatedScreenshot: string;
|
|
9
|
-
trace?: TraceClient;
|
|
10
|
-
llm?: LLM;
|
|
11
|
-
options?: TestGenConfigOptions;
|
|
12
|
-
preference: AnnotationPreference;
|
|
13
|
-
}): Promise<string | undefined>;
|
|
14
|
-
export type AnnotationPreference = {
|
|
15
|
-
actionType: "all" | ActionType.FILL | ActionType.ASSERT_TEXT | ActionType.SCROLL;
|
|
16
|
-
assertionText?: string | undefined;
|
|
17
|
-
};
|
|
18
|
-
export declare function getAnnotationKeys({ page, preference, trace, }: {
|
|
19
|
-
page: Page;
|
|
20
|
-
preference: AnnotationPreference;
|
|
21
|
-
trace?: TraceClient;
|
|
22
|
-
}): Promise<{
|
|
23
|
-
annotationKeys: {
|
|
24
|
-
elementID: string;
|
|
25
|
-
text: string;
|
|
26
|
-
}[];
|
|
27
|
-
annotationBuffer: Buffer;
|
|
28
|
-
annotatedPageScreenshot: string;
|
|
29
|
-
}>;
|
|
30
|
-
//# sourceMappingURL=element-annotation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAQlC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA0DjD,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,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,oBAAoB,CAAC;IACjC,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,CAmFD"}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getElementAnnotation = getElementAnnotation;
|
|
4
|
-
exports.getAnnotationKeys = getAnnotationKeys;
|
|
5
|
-
const llm_1 = require("@empiricalrun/llm");
|
|
6
|
-
const constants_1 = require("../../constants");
|
|
7
|
-
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}}";
|
|
8
|
-
const annotationToolAction = {
|
|
9
|
-
name: "element_annotation",
|
|
10
|
-
schema: {
|
|
11
|
-
type: "function",
|
|
12
|
-
function: {
|
|
13
|
-
name: "element_annotation",
|
|
14
|
-
description: "Handles annotations for elements and enriched annotations.",
|
|
15
|
-
parameters: {
|
|
16
|
-
type: "object",
|
|
17
|
-
properties: {
|
|
18
|
-
enriched_annotations: {
|
|
19
|
-
type: "array",
|
|
20
|
-
description: "List of enriched annotations for elements.",
|
|
21
|
-
items: {
|
|
22
|
-
type: "object",
|
|
23
|
-
properties: {
|
|
24
|
-
element_id: {
|
|
25
|
-
type: "string",
|
|
26
|
-
description: "Unique element ID for the element.",
|
|
27
|
-
},
|
|
28
|
-
description: {
|
|
29
|
-
type: "string",
|
|
30
|
-
description: "Detailed description for the element. Must not be NA",
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
required: ["element_id", "description"],
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
reason: {
|
|
37
|
-
type: "string",
|
|
38
|
-
description: "Explain why this element is selected. The reason should be clear and align with the task or purpose.",
|
|
39
|
-
},
|
|
40
|
-
element: {
|
|
41
|
-
type: "string",
|
|
42
|
-
description: "Detailed description of the DOM element's visual characteristics and position.",
|
|
43
|
-
},
|
|
44
|
-
element_annotation: {
|
|
45
|
-
type: "string",
|
|
46
|
-
description: "Return the unique element ID for the element on which the action needs to be performed.",
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
required: [
|
|
50
|
-
"enriched_annotations",
|
|
51
|
-
"reason",
|
|
52
|
-
"element",
|
|
53
|
-
"element_annotation",
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
async function getElementAnnotation({ elementDescription, annotations, annotatedScreenshot, trace, llm, options, preference, }) {
|
|
60
|
-
const annotationsSpan = trace?.span({
|
|
61
|
-
name: "get-element-annotation",
|
|
62
|
-
input: {
|
|
63
|
-
elementDescription,
|
|
64
|
-
annotations,
|
|
65
|
-
annotatedScreenshot,
|
|
66
|
-
preference,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
const messages = (0, llm_1.compilePrompt)(promptTemplate_0, {
|
|
70
|
-
elementDescription,
|
|
71
|
-
annotations,
|
|
72
|
-
annotatedScreenshot,
|
|
73
|
-
}, options);
|
|
74
|
-
llm =
|
|
75
|
-
llm ||
|
|
76
|
-
new llm_1.LLM({
|
|
77
|
-
provider: options?.modelProvider || constants_1.DEFAULT_MODEL_PROVIDER,
|
|
78
|
-
defaultModel: options?.model || constants_1.DEFAULT_MODEL,
|
|
79
|
-
});
|
|
80
|
-
const completion = await llm.createChatCompletion({
|
|
81
|
-
messages,
|
|
82
|
-
modelParameters: {
|
|
83
|
-
...constants_1.DEFAULT_MODEL_PARAMETERS,
|
|
84
|
-
...options?.modelParameters,
|
|
85
|
-
tool_choice: "required",
|
|
86
|
-
temperature: 0.5,
|
|
87
|
-
},
|
|
88
|
-
trace: annotationsSpan,
|
|
89
|
-
traceName: "get-element-from-action",
|
|
90
|
-
//@ts-ignore
|
|
91
|
-
tools: [annotationToolAction.schema],
|
|
92
|
-
});
|
|
93
|
-
const toolCall = completion?.tool_calls?.[0];
|
|
94
|
-
annotationsSpan?.end({ output: toolCall });
|
|
95
|
-
if (toolCall && "function" in toolCall) {
|
|
96
|
-
const args = JSON.parse(toolCall.function.arguments);
|
|
97
|
-
return args.element_annotation;
|
|
98
|
-
}
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
async function getAnnotationKeys({ page, preference, trace, }) {
|
|
102
|
-
const annotatedElements = await page.evaluate(({ preference, options }) => {
|
|
103
|
-
// @ts-ignore
|
|
104
|
-
window.annotationInstance = annotateElementsWithPreference({
|
|
105
|
-
options: options,
|
|
106
|
-
preference: preference,
|
|
107
|
-
});
|
|
108
|
-
const annotations = Object.entries(
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
window.annotationInstance.annotations).map(([key, value]) => {
|
|
111
|
-
// Helper function to safely get text content
|
|
112
|
-
const getTextContent = (node) => {
|
|
113
|
-
try {
|
|
114
|
-
return node?.innerText?.trim() || null;
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
// Helper function to safely get placeholder
|
|
121
|
-
const getPlaceholder = (node) => {
|
|
122
|
-
try {
|
|
123
|
-
return node?.placeholder?.trim() || null;
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
return {
|
|
130
|
-
elementID: key,
|
|
131
|
-
innerText: getTextContent(value.node),
|
|
132
|
-
innerHTML: value.node.innerHTML,
|
|
133
|
-
outerHTML: value.node.outerHTML,
|
|
134
|
-
placeholder: getPlaceholder(value.node),
|
|
135
|
-
};
|
|
136
|
-
});
|
|
137
|
-
const fullPageHTML = document.documentElement.outerHTML;
|
|
138
|
-
return { annotations, fullPageHTML };
|
|
139
|
-
}, { preference, options: {} });
|
|
140
|
-
const annotationKeys = await enrichAnnotations(annotatedElements.annotations, annotatedElements.fullPageHTML, trace);
|
|
141
|
-
const annotationBuffer = await page.screenshot({
|
|
142
|
-
// path: `screenshots/screenshot-${screenshotIndex++}.png`,
|
|
143
|
-
});
|
|
144
|
-
const annotatedPageScreenshot = annotationBuffer.toString("base64");
|
|
145
|
-
await page.evaluate(() => {
|
|
146
|
-
console.log({
|
|
147
|
-
// @ts-ignore
|
|
148
|
-
disable: window?.annotationInstance?.disable,
|
|
149
|
-
});
|
|
150
|
-
if (
|
|
151
|
-
// @ts-ignore
|
|
152
|
-
window?.annotationInstance &&
|
|
153
|
-
// @ts-ignore
|
|
154
|
-
window?.annotationInstance?.destroy) {
|
|
155
|
-
// @ts-ignore
|
|
156
|
-
window?.annotationInstance?.destroy();
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
return {
|
|
160
|
-
annotationKeys,
|
|
161
|
-
annotationBuffer,
|
|
162
|
-
annotatedPageScreenshot,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
async function enrichAnnotations(annotatedElements, _pageHtml, _trace) {
|
|
166
|
-
const results = [];
|
|
167
|
-
for (const element of annotatedElements) {
|
|
168
|
-
const text = element.innerText?.trim() || element.placeholder?.trim();
|
|
169
|
-
results.push({
|
|
170
|
-
elementID: element.elementID,
|
|
171
|
-
text: text || "NA",
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return results;
|
|
175
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { LLM, TraceClient } from "@empiricalrun/llm";
|
|
2
|
-
import type { Page } from "@playwright/test";
|
|
3
|
-
import { PlaywrightActions } from "../../actions";
|
|
4
|
-
export declare function executeBrowserAction({ page, nextAction, flags, actions, llm, trace, }: {
|
|
5
|
-
page: Page;
|
|
6
|
-
nextAction: {
|
|
7
|
-
actionType: string;
|
|
8
|
-
toolCallArgs: string;
|
|
9
|
-
};
|
|
10
|
-
flags: {
|
|
11
|
-
useActionSpecificAnnotations: boolean;
|
|
12
|
-
};
|
|
13
|
-
actions: PlaywrightActions;
|
|
14
|
-
trace?: TraceClient | undefined;
|
|
15
|
-
llm: LLM;
|
|
16
|
-
}): Promise<{
|
|
17
|
-
generatedCodeSteps: string[];
|
|
18
|
-
output: {
|
|
19
|
-
action: string;
|
|
20
|
-
reason: string;
|
|
21
|
-
elementAnnotation?: string;
|
|
22
|
-
};
|
|
23
|
-
}>;
|
|
24
|
-
//# sourceMappingURL=execute-browser-action.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execute-browser-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/execute-browser-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAUlD,wBAAsB,oBAAoB,CAAC,EACzC,IAAI,EACJ,UAAU,EACV,KAAK,EACL,OAAO,EACP,GAAG,EACH,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,KAAK,EAAE;QACL,4BAA4B,EAAE,OAAO,CAAC;KACvC,CAAC;IACF,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAChC,GAAG,EAAE,GAAG,CAAC;CACV;;;gBAIW,MAAM;gBACN,MAAM;4BACM,MAAM;;GA+H7B"}
|