@empiricalrun/test-gen 0.42.4 → 0.42.8

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 CHANGED
@@ -1,5 +1,35 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.42.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 18444bc: fix: pass action to BA in case of no annotations
8
+
9
+ ## 0.42.7
10
+
11
+ ### Patch Changes
12
+
13
+ - b6879bb: test: added assert scenario for annotations
14
+
15
+ ## 0.42.6
16
+
17
+ ### Patch Changes
18
+
19
+ - b0b578c: fix: added page for token debugging
20
+ - 25ae4b6: fix: added preference in trace for annotations
21
+ - 9247f19: fix: assertion capability with selector hints
22
+
23
+ ## 0.42.5
24
+
25
+ ### Patch Changes
26
+
27
+ - 8f5a315: fix: trace url is clickable
28
+ - 02784a8: chore: move browser-injected-scripts to enable lint
29
+ - Updated dependencies [4df759f]
30
+ - Updated dependencies [1749342]
31
+ - @empiricalrun/llm@0.9.30
32
+
3
33
  ## 0.42.4
4
34
 
5
35
  ### Patch Changes
@@ -125,7 +125,7 @@ exports.generateCodeUsingRepoAgent = generateCodeUsingRepoAgent;
125
125
  async function repoEditAgent({ trace, task, logger, }) {
126
126
  const testgenUpdatesReporter = new reporter_1.TestGenUpdatesReporter();
127
127
  void testgenUpdatesReporter.sendMessage(`Updating test code as per the task. \n View [trace](${trace?.getTraceUrl()})`);
128
- logger?.log(`Starting repo agent: ${trace?.getTraceUrl()}`);
128
+ logger?.log(`Starting repo agent: [trace](${trace?.getTraceUrl()})`);
129
129
  const { prompt: repoFiles } = await (0, context_1.generateTxtForRepository)();
130
130
  const repoAgentOutput = await generateCodeUsingRepoAgent({
131
131
  task,
@@ -0,0 +1,35 @@
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
+ }
9
+ export declare function isValidActionType(value: string): value is ActionType;
10
+ export declare function getActionToolCalls(): {
11
+ type: string;
12
+ function: {
13
+ name: string;
14
+ description: string;
15
+ parameters: {
16
+ type: string;
17
+ properties: {
18
+ reason: {
19
+ type: string;
20
+ description: string;
21
+ };
22
+ action: {
23
+ type: string;
24
+ description: string;
25
+ };
26
+ element_description: {
27
+ type: string;
28
+ description: string;
29
+ };
30
+ };
31
+ required: string[];
32
+ };
33
+ };
34
+ }[];
35
+ //# sourceMappingURL=action-tool-calls.d.ts.map
@@ -0,0 +1 @@
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;CACxB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,UAAU,CAEpE;AAkDD,wBAAgB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;IAyBjC"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getActionToolCalls = exports.isValidActionType = exports.ActionType = void 0;
4
+ var ActionType;
5
+ (function (ActionType) {
6
+ ActionType["FILL"] = "fill";
7
+ ActionType["PAGE_GOTO"] = "page_goto";
8
+ ActionType["CLICK"] = "click";
9
+ ActionType["PRESS_ACTION"] = "keyboard_press_on_element";
10
+ ActionType["ASSERT_TEXT"] = "assert_text";
11
+ ActionType["HOVER"] = "hover_element";
12
+ })(ActionType || (exports.ActionType = ActionType = {}));
13
+ function isValidActionType(value) {
14
+ return Object.values(ActionType).includes(value);
15
+ }
16
+ exports.isValidActionType = isValidActionType;
17
+ const createActionCall = (name, description, additionalProperties = {}) => ({
18
+ name: "next_task",
19
+ description: "take the next action based on the provided task",
20
+ schema: {
21
+ type: "function",
22
+ function: {
23
+ name,
24
+ description,
25
+ parameters: {
26
+ type: "object",
27
+ properties: {
28
+ reason: {
29
+ type: "string",
30
+ description: "explain how this action will help to complete the task. the reason should align with the task provided",
31
+ },
32
+ action: {
33
+ type: "string",
34
+ description: `explain the next action in natural language.
35
+ The next action should be as atomic as possible, precise and should contain enough details about the action to be performed.
36
+ E.g. each click, key press, input, assert should be a separate action.
37
+ Each action should take the task to completion, if not the action is invalid.`,
38
+ },
39
+ element_description: {
40
+ type: "string",
41
+ description: "The description of the element on which action needs to be taken, including its position, appearance, etc.",
42
+ },
43
+ ...additionalProperties,
44
+ },
45
+ required: [
46
+ "reason",
47
+ "action",
48
+ "element_description",
49
+ ...Object.keys(additionalProperties),
50
+ ],
51
+ },
52
+ },
53
+ },
54
+ });
55
+ function getActionToolCalls() {
56
+ return [
57
+ createActionCall(ActionType.ASSERT_TEXT, "assert whether the given element on the page is visible", {
58
+ assertion_text: {
59
+ type: "string",
60
+ description: "The text for which the visibility needs to be asserted.",
61
+ },
62
+ }),
63
+ createActionCall(ActionType.FILL, "fill the input element with a particular text"),
64
+ createActionCall(ActionType.CLICK, "click an element on the page"),
65
+ createActionCall(ActionType.PAGE_GOTO, "navigate the page to a new URL"),
66
+ createActionCall(ActionType.PRESS_ACTION, "Focuses the matching element and presses a combination of the keys"),
67
+ createActionCall(ActionType.HOVER, "hover over an element on the page"),
68
+ ].map((call) => call.schema);
69
+ }
70
+ exports.getActionToolCalls = getActionToolCalls;
@@ -1,15 +1,20 @@
1
1
  import { LLM, TraceClient } from "@empiricalrun/llm";
2
2
  import { Page } from "playwright";
3
3
  import { BrowsingAgentOptions } from "../browsing";
4
- export declare function getElementAnnotation({ elementDescription, annotations, annotatedScreenshot, trace, llm, options, }: {
4
+ import { ActionType } from "./action-tool-calls";
5
+ export declare function getElementAnnotation({ elementDescription, annotations, annotatedScreenshot, trace, llm, options, preference, }: {
5
6
  elementDescription: string;
6
7
  annotations: string;
7
8
  annotatedScreenshot: string;
8
9
  trace?: TraceClient;
9
10
  llm?: LLM;
10
11
  options?: BrowsingAgentOptions;
12
+ preference: AnnotationPreference;
11
13
  }): Promise<string | undefined>;
12
- export type AnnotationPreference = "all" | "fill";
14
+ export type AnnotationPreference = {
15
+ actionType: "all" | ActionType.FILL | ActionType.ASSERT_TEXT;
16
+ assertionText?: string | undefined;
17
+ };
13
18
  export declare function getAnnotationKeys({ page, preference, options, }: {
14
19
  page: Page;
15
20
  preference: AnnotationPreference;
@@ -1 +1 @@
1
- {"version":3,"file":"element-annotation.d.ts","sourceRoot":"","sources":["../../../src/agent/master/element-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAgDnD,wBAAsB,oBAAoB,CAAC,EACzC,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,KAAK,EACL,GAAG,EACH,OAAO,GACR,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;CAChC,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA4F9B;AAED,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,MAAM,CAAC;AAElD,wBAAsB,iBAAiB,CAAC,EACtC,IAAI,EACJ,UAAU,EACV,OAAO,GACR,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,oBAAoB,CAAC;IACjC,OAAO,EAAE,oBAAoB,CAAC;CAC/B,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,CAqDD"}
1
+ {"version":3,"file":"element-annotation.d.ts","sourceRoot":"","sources":["../../../src/agent/master/element-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAgDjD,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,CA6F9B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,KAAK,GAAG,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC;IAC7D,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,EACtC,IAAI,EACJ,UAAU,EACV,OAAO,GACR,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,oBAAoB,CAAC;IACjC,OAAO,EAAE,oBAAoB,CAAC;CAC/B,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,CAqDD"}
@@ -46,13 +46,14 @@ const annotationToolAction = {
46
46
  },
47
47
  },
48
48
  };
49
- async function getElementAnnotation({ elementDescription, annotations, annotatedScreenshot, trace, llm, options, }) {
49
+ async function getElementAnnotation({ elementDescription, annotations, annotatedScreenshot, trace, llm, options, preference, }) {
50
50
  const annotationsSpan = trace?.span({
51
51
  name: "get-element-annotation",
52
52
  input: {
53
53
  elementDescription,
54
54
  annotations,
55
55
  annotatedScreenshot,
56
+ preference,
56
57
  },
57
58
  });
58
59
  const systemMessage = {
@@ -1,16 +1,8 @@
1
1
  import { LLM, TraceClient } from "@empiricalrun/llm";
2
2
  import { PlaywrightActions } from "../../actions";
3
3
  import { BrowsingAgentOptions } from "../browsing";
4
- export declare enum actionTypes {
5
- PLAYWRIGHT_FILL_ACTION_NAME = "fill_input_element",
6
- PLAYWRIGHT_GOTO_ACTION_NAME = "page_goto",
7
- PLAYWRIGHT_CLICK_ACTION_NAME = "click_element",
8
- PLAYWRIGHT_PRESS_ACTION_NAME = "keyboard_press_on_element",
9
- PLAYWRIGHT_ASSERT_TEXT_VISIBILITY_ACTION_NAME = "assert_text_visibility",
10
- PLAYWRIGHT_HOVER_ACTION_NAME = "hover_element"
11
- }
12
- export declare function isValidActionType(value: string): value is actionTypes;
13
- export declare function getNextAction({ task, executedActions, failedActions, pageUrl, trace, llm, options, pageScreenshot, actions, disableSkills, }: {
4
+ import { ActionType } from "./action-tool-calls";
5
+ export declare function getNextAction({ task, executedActions, failedActions, pageUrl, trace, llm, options, pageScreenshot, actions, actionTypes, disableSkills, }: {
14
6
  task: string;
15
7
  executedActions: string[];
16
8
  failedActions: any[];
@@ -21,6 +13,7 @@ export declare function getNextAction({ task, executedActions, failedActions, pa
21
13
  pageScreenshot: string;
22
14
  annotatedPageScreenshot?: string;
23
15
  actions: PlaywrightActions;
16
+ actionTypes: typeof ActionType;
24
17
  disableSkills: boolean;
25
18
  annotations?: string[];
26
19
  }): Promise<import("openai/resources/index.mjs").ChatCompletionMessageToolCall | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"next-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/next-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAOlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,oBAAY,WAAW;IACrB,2BAA2B,uBAAuB;IAClD,2BAA2B,cAAc;IACzC,4BAA4B,kBAAkB;IAC9C,4BAA4B,8BAA8B;IAC1D,6CAA6C,2BAA2B;IACxE,4BAA4B,kBAAkB;CAC/C;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,WAAW,CAErE;AAED,wBAAsB,aAAa,CAAC,EAClC,IAAI,EACJ,eAAe,EACf,aAAa,EACb,OAAO,EACP,KAAK,EACL,GAAG,EACH,OAAO,EACP,cAAc,EACd,OAAO,EACP,aAAa,GACd,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,GAAG,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB,2FA0KA"}
1
+ {"version":3,"file":"next-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/next-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAOlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,UAAU,EAAsB,MAAM,qBAAqB,CAAC;AAErE,wBAAsB,aAAa,CAAC,EAClC,IAAI,EACJ,eAAe,EACf,aAAa,EACb,OAAO,EACP,KAAK,EACL,GAAG,EACH,OAAO,EACP,cAAc,EACd,OAAO,EACP,WAAW,EACX,aAAa,GACd,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,GAAG,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,WAAW,EAAE,OAAO,UAAU,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB,2FAmIA"}
@@ -1,24 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNextAction = exports.isValidActionType = exports.actionTypes = void 0;
3
+ exports.getNextAction = void 0;
4
4
  const llm_1 = require("@empiricalrun/llm");
5
5
  const vision_1 = require("@empiricalrun/llm/vision");
6
6
  const skill_1 = require("../../actions/skill");
7
7
  const constants_1 = require("../../constants");
8
- var actionTypes;
9
- (function (actionTypes) {
10
- actionTypes["PLAYWRIGHT_FILL_ACTION_NAME"] = "fill_input_element";
11
- actionTypes["PLAYWRIGHT_GOTO_ACTION_NAME"] = "page_goto";
12
- actionTypes["PLAYWRIGHT_CLICK_ACTION_NAME"] = "click_element";
13
- actionTypes["PLAYWRIGHT_PRESS_ACTION_NAME"] = "keyboard_press_on_element";
14
- actionTypes["PLAYWRIGHT_ASSERT_TEXT_VISIBILITY_ACTION_NAME"] = "assert_text_visibility";
15
- actionTypes["PLAYWRIGHT_HOVER_ACTION_NAME"] = "hover_element";
16
- })(actionTypes || (exports.actionTypes = actionTypes = {}));
17
- function isValidActionType(value) {
18
- return Object.values(actionTypes).includes(value);
19
- }
20
- exports.isValidActionType = isValidActionType;
21
- async function getNextAction({ task, executedActions, failedActions, pageUrl, trace, llm, options, pageScreenshot, actions, disableSkills, }) {
8
+ const action_tool_calls_1 = require("./action-tool-calls");
9
+ async function getNextAction({ task, executedActions, failedActions, pageUrl, trace, llm, options, pageScreenshot, actions, actionTypes, disableSkills, }) {
22
10
  const nextActionSpan = trace?.span({
23
11
  name: "master-agent-next-action",
24
12
  input: {
@@ -117,44 +105,7 @@ async function getNextAction({ task, executedActions, failedActions, pageUrl, tr
117
105
  const actionSchemas = disableSkills || skill_1.testCaseSkills.getAvailableSkills().length === 0
118
106
  ? []
119
107
  : actions.getMasterActionSchemas();
120
- const actionToolCall = {
121
- name: "next_task",
122
- schema: {
123
- type: "function",
124
- function: {
125
- name: "next_task",
126
- description: "take the next action base on the provided task",
127
- parameters: {
128
- type: "object",
129
- properties: {
130
- reason: {
131
- type: "string",
132
- description: "explain how this action will help to complete the task. the reason should align with the task provided",
133
- },
134
- action: {
135
- type: "string",
136
- description: `explain the next action in natural language.
137
- The next action should be as atomic as possible, precise and should contain enough details about the action to be performed.
138
- E.g. each click, key press, input, assert should be a separate action.
139
- Each action should take the task to completion, if not the action is invalid.`,
140
- },
141
- action_type: {
142
- type: "string",
143
- enum: Object.values(actionTypes),
144
- description: `type of the action that needs to be taken.
145
- Any other action type than the provided action type is invalid.`,
146
- },
147
- element_description: {
148
- type: "string",
149
- description: "The description of the element on which action needs to be taken, including its position, appearance, etc.",
150
- },
151
- },
152
- required: ["reason", "action", "element_description", "action_type"],
153
- },
154
- },
155
- },
156
- };
157
- const tools = [actionToolCall.schema, ...actionSchemas];
108
+ const tools = [...(0, action_tool_calls_1.getActionToolCalls)(), ...actionSchemas];
158
109
  promptSpan?.end({ output: { messages } });
159
110
  llm =
160
111
  llm ||
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAelC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EACL,oBAAoB,EAErB,MAAM,aAAa,CAAC;AA0BrB,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;GAmUA"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAclC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EACL,oBAAoB,EAErB,MAAM,aAAa,CAAC;AA2BrB,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;GAiVA"}
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTestUsingMasterAgent = void 0;
4
4
  const llm_1 = require("@empiricalrun/llm");
5
5
  const actions_1 = require("../../actions");
6
- const fill_1 = require("../../actions/fill");
7
6
  const skill_1 = require("../../actions/skill");
8
7
  const utils_1 = require("../../actions/utils");
9
8
  const logger_1 = require("../../bin/logger");
@@ -15,6 +14,7 @@ const browsing_1 = require("../browsing");
15
14
  const utils_2 = require("../browsing/utils");
16
15
  const skills_retriever_1 = require("../codegen/skills-retriever");
17
16
  const run_time_planner_1 = require("../planner/run-time-planner");
17
+ const action_tool_calls_1 = require("./action-tool-calls");
18
18
  const element_annotation_1 = require("./element-annotation");
19
19
  const next_action_1 = require("./next-action");
20
20
  const with_hints_1 = require("./with-hints");
@@ -136,6 +136,7 @@ async function createTestUsingMasterAgent({ task, page, testCase, options, scope
136
136
  options,
137
137
  pageScreenshot,
138
138
  actions,
139
+ actionTypes: action_tool_calls_1.ActionType,
139
140
  disableSkills,
140
141
  });
141
142
  if (await (0, session_1.shouldStopSession)()) {
@@ -165,15 +166,28 @@ async function createTestUsingMasterAgent({ task, page, testCase, options, scope
165
166
  let hintsExecutionCompletion;
166
167
  let elementAnnotation;
167
168
  await page.waitForTimeout(2000);
168
- const actionType = JSON.parse(toolCall.function.arguments).action_type;
169
- let preference = "all";
170
- if (useActionSpecificAnnotations && (0, next_action_1.isValidActionType)(actionType)) {
169
+ const nextActionToolCall = JSON.parse(toolCall.function.arguments);
170
+ const actionType = toolCall.function.name;
171
+ let preference = {
172
+ actionType: "all",
173
+ };
174
+ if (useActionSpecificAnnotations && (0, action_tool_calls_1.isValidActionType)(actionType)) {
171
175
  switch (actionType) {
172
- case fill_1.PLAYWRIGHT_FILL_ACTION_NAME:
173
- preference = "fill";
176
+ case action_tool_calls_1.ActionType.FILL:
177
+ preference = {
178
+ actionType: action_tool_calls_1.ActionType.FILL,
179
+ };
180
+ break;
181
+ case action_tool_calls_1.ActionType.ASSERT_TEXT:
182
+ preference = {
183
+ actionType: action_tool_calls_1.ActionType.ASSERT_TEXT,
184
+ assertionText: nextActionToolCall.assertion_text,
185
+ };
174
186
  break;
175
187
  default:
176
- preference = "all";
188
+ preference = {
189
+ actionType: "all",
190
+ };
177
191
  }
178
192
  }
179
193
  let { annotationKeys, annotatedPageScreenshot, annotationBuffer } = await (0, element_annotation_1.getAnnotationKeys)({
@@ -181,42 +195,45 @@ async function createTestUsingMasterAgent({ task, page, testCase, options, scope
181
195
  preference,
182
196
  options,
183
197
  });
184
- const annotationMapString = annotationKeys
185
- ?.map((a) => `${a.elementID}:${a.text}`)
186
- .join("\n");
187
- // Provides the annotations for all the element present on screen
188
- // Also provides the annotation of element on which the action needs to be taken
189
- elementAnnotation = await (0, element_annotation_1.getElementAnnotation)({
190
- elementDescription: JSON.parse(toolCall.function.arguments)
191
- .element_description,
192
- annotations: annotationMapString,
193
- annotatedScreenshot: annotatedPageScreenshot,
194
- trace: masterAgentActionSpan,
195
- llm,
196
- });
197
- output.elementAnnotation = elementAnnotation;
198
- console.log("Output: ", output);
199
- await testGenReporter.sendCurrentView(annotationBuffer);
200
- const triggerHintsFlowSpan = masterAgentActionSpan?.span({
201
- name: "trigger-hints-flow",
202
- input: {
198
+ if (annotationKeys.length > 0) {
199
+ const annotationMapString = annotationKeys
200
+ ?.map((a) => `${a.elementID}:${a.text}`)
201
+ .join("\n");
202
+ // Provides the annotations for all the element present on screen
203
+ // Also provides the annotation of element on which the action needs to be taken
204
+ elementAnnotation = await (0, element_annotation_1.getElementAnnotation)({
205
+ elementDescription: JSON.parse(toolCall.function.arguments)
206
+ .element_description,
207
+ annotations: annotationMapString,
208
+ annotatedScreenshot: annotatedPageScreenshot,
209
+ trace: masterAgentActionSpan,
210
+ llm,
211
+ preference,
212
+ });
213
+ output.elementAnnotation = elementAnnotation;
214
+ console.log("Output: ", output);
215
+ await testGenReporter.sendCurrentView(annotationBuffer);
216
+ const triggerHintsFlowSpan = masterAgentActionSpan?.span({
217
+ name: "trigger-hints-flow",
218
+ input: {
219
+ outputFromGetNextAction: output,
220
+ generatedAnnotations: annotationKeys,
221
+ },
222
+ });
223
+ // Provides the action whether its a click, fill etc.
224
+ const result = await (0, with_hints_1.triggerHintsFlow)({
203
225
  outputFromGetNextAction: output,
204
226
  generatedAnnotations: annotationKeys,
205
- },
206
- });
207
- // Provides the action whether its a click, fill etc.
208
- const result = await (0, with_hints_1.triggerHintsFlow)({
209
- outputFromGetNextAction: output,
210
- generatedAnnotations: annotationKeys,
211
- actions,
212
- llm,
213
- trace: triggerHintsFlowSpan,
214
- });
215
- shouldTriggerHintsFlow = result.shouldTriggerHintsFlow;
216
- hintsExecutionCompletion = result.hintsExecutionCompletion;
217
- triggerHintsFlowSpan?.end({
218
- output: result,
219
- });
227
+ actions,
228
+ llm,
229
+ trace: triggerHintsFlowSpan,
230
+ });
231
+ shouldTriggerHintsFlow = result.shouldTriggerHintsFlow;
232
+ hintsExecutionCompletion = result.hintsExecutionCompletion;
233
+ triggerHintsFlowSpan?.end({
234
+ output: result,
235
+ });
236
+ }
220
237
  if (shouldTriggerHintsFlow && hintsExecutionCompletion) {
221
238
  const toolCalls = hintsExecutionCompletion?.tool_calls || [];
222
239
  for (const i in toolCalls) {
@@ -1 +1 @@
1
- {"version":3,"file":"with-hints.d.ts","sourceRoot":"","sources":["../../../src/agent/master/with-hints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAQlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,eAAO,MAAM,0BAA0B;iBAMxB,OAAO,8BAA8B;;oBAElC,MAAM;6BACG,MAAM;MAC7B,MAAM,GAAG,OAAO,yBAAyB,EAiC5C,CAAC;AAEF,eAAO,MAAM,gBAAgB;6BAOF;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B;0BACqB,OAAO,MAAM,EAAE,GAAG,CAAC;aAChC,iBAAiB;SACrB,GAAG;;MAEN,QAAQ;IACV,sBAAsB,EAAE,OAAO,CAAC;IAChC,wBAAwB,EAAE,OAAO,qBAAqB,GAAG,SAAS,CAAC;CACpE,CAuGA,CAAC"}
1
+ {"version":3,"file":"with-hints.d.ts","sourceRoot":"","sources":["../../../src/agent/master/with-hints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AASlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,eAAO,MAAM,0BAA0B;iBAMxB,OAAO,8BAA8B;;oBAElC,MAAM;6BACG,MAAM;MAC7B,MAAM,GAAG,OAAO,yBAAyB,EAiC5C,CAAC;AAEF,eAAO,MAAM,gBAAgB;6BAOF;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B;0BACqB,OAAO,MAAM,EAAE,GAAG,CAAC;aAChC,iBAAiB;SACrB,GAAG;;MAEN,QAAQ;IACV,sBAAsB,EAAE,OAAO,CAAC;IAChC,wBAAwB,EAAE,OAAO,qBAAqB,GAAG,SAAS,CAAC;CACpE,CAyGA,CAAC"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.triggerHintsFlow = exports.getUserMessageWithForHints = void 0;
4
4
  const vision_1 = require("@empiricalrun/llm/vision");
5
+ const assert_1 = require("../../actions/assert");
5
6
  const click_1 = require("../../actions/click");
6
7
  const fill_1 = require("../../actions/fill");
7
8
  const hover_1 = require("../../actions/hover");
@@ -92,7 +93,9 @@ const triggerHintsFlow = async ({ outputFromGetNextAction, generatedAnnotations,
92
93
  });
93
94
  const canTriggerHintsFlow = completion?.tool_calls?.some((currentToolCall) => currentToolCall.function.name === fill_1.PLAYWRIGHT_FILL_ACTION_NAME ||
94
95
  currentToolCall.function.name === click_1.PLAYWRIGHT_CLICK_ACTION_NAME ||
95
- currentToolCall.function.name === hover_1.PLAYWRIGHT_HOVER_ACTION_NAME);
96
+ currentToolCall.function.name === hover_1.PLAYWRIGHT_HOVER_ACTION_NAME ||
97
+ currentToolCall.function.name ===
98
+ assert_1.PLAYWRIGHT_ASSERT_TEXT_VISIBILITY_ACTION_NAME);
96
99
  trace?.event({
97
100
  name: "can-trigger-hints-flow",
98
101
  output: {