@empiricalrun/test-gen 0.45.0 → 0.45.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.45.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 04db1a6: chore: better types for playwright action generators
8
+ - 1b1815d: chore: move runtime planner to handlebars
9
+ - 62800d7: fix: prevent sending test run events to sentry
10
+
3
11
  ## 0.45.0
4
12
 
5
13
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { PlaywrightActionGenerator } from "../types";
1
+ import { AssertTextVisibilityActionArgs, PlaywrightActionGenerator } from "../types";
2
2
  export declare const PLAYWRIGHT_ASSERT_TEXT_VISIBILITY_ACTION_NAME = "assert_text_visibility";
3
- export declare const assertTextVisibilityActionGenerator: PlaywrightActionGenerator;
3
+ export declare const assertTextVisibilityActionGenerator: PlaywrightActionGenerator<AssertTextVisibilityActionArgs>;
4
4
  //# sourceMappingURL=assert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/actions/assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,6CAA6C,2BAChC,CAAC;AAE3B,eAAO,MAAM,mCAAmC,EAAE,yBAuDjD,CAAC"}
1
+ {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/actions/assert.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAIlB,eAAO,MAAM,6CAA6C,2BAChC,CAAC;AAE3B,eAAO,MAAM,mCAAmC,EAAE,yBAAyB,CACzE,8BAA8B,CAqD/B,CAAC"}
@@ -14,8 +14,7 @@ const assertTextVisibilityActionGenerator = (page) => {
14
14
  locator,
15
15
  };
16
16
  },
17
- // TODO: args transformer to be kept at a single place
18
- template: (_, options) => {
17
+ template: (args, options) => {
19
18
  return {
20
19
  code: `await expect(${page.name}.${options.locator}).toBeVisible();`,
21
20
  };
@@ -1,4 +1,4 @@
1
- import { PlaywrightActionGenerator } from "../types";
1
+ import { ClickActionArgs, PlaywrightActionGenerator } from "../types";
2
2
  export declare const PLAYWRIGHT_CLICK_ACTION_NAME = "click_element";
3
- export declare const clickActionGenerator: PlaywrightActionGenerator;
3
+ export declare const clickActionGenerator: PlaywrightActionGenerator<ClickActionArgs>;
4
4
  //# sourceMappingURL=click.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/actions/click.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,4BAA4B,kBAAkB,CAAC;AAE5D,eAAO,MAAM,oBAAoB,EAAE,yBAsDlC,CAAC"}
1
+ {"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/actions/click.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAItE,eAAO,MAAM,4BAA4B,kBAAkB,CAAC;AAE5D,eAAO,MAAM,oBAAoB,EAAE,yBAAyB,CAC1D,eAAe,CAsDhB,CAAC"}
@@ -15,8 +15,7 @@ const clickActionGenerator = (page) => {
15
15
  locator,
16
16
  };
17
17
  },
18
- // TODO: args transformer to be kept at a single place
19
- template: (_, options) => {
18
+ template: (args, options) => {
20
19
  return {
21
20
  code: `await ${page.name}.${options.locator}.click();`,
22
21
  };
@@ -1,4 +1,4 @@
1
- import { PlaywrightActionGenerator } from "../types";
1
+ import { BaseActionArgs, PlaywrightActionGenerator } from "../types";
2
2
  export declare const PLAYWRIGHT_DONE_ACTION_NAME = "task_done";
3
- export declare const doneActionGenerator: PlaywrightActionGenerator;
3
+ export declare const doneActionGenerator: PlaywrightActionGenerator<BaseActionArgs>;
4
4
  //# sourceMappingURL=done.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"done.d.ts","sourceRoot":"","sources":["../../src/actions/done.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAGrD,eAAO,MAAM,2BAA2B,cAAc,CAAC;AAEvD,eAAO,MAAM,mBAAmB,EAAE,yBAuBjC,CAAC"}
1
+ {"version":3,"file":"done.d.ts","sourceRoot":"","sources":["../../src/actions/done.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAGrE,eAAO,MAAM,2BAA2B,cAAc,CAAC;AAEvD,eAAO,MAAM,mBAAmB,EAAE,yBAAyB,CACzD,cAAc,CAwBf,CAAC"}
@@ -1,4 +1,4 @@
1
- import { PlaywrightActionGenerator } from "../types";
1
+ import { FillActionArgs, PlaywrightActionGenerator } from "../types";
2
2
  export declare const PLAYWRIGHT_FILL_ACTION_NAME = "fill_input_element";
3
- export declare const fillActionGenerator: PlaywrightActionGenerator;
3
+ export declare const fillActionGenerator: PlaywrightActionGenerator<FillActionArgs>;
4
4
  //# sourceMappingURL=fill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fill.d.ts","sourceRoot":"","sources":["../../src/actions/fill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAGhE,eAAO,MAAM,mBAAmB,EAAE,yBAgGjC,CAAC"}
1
+ {"version":3,"file":"fill.d.ts","sourceRoot":"","sources":["../../src/actions/fill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrE,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAGhE,eAAO,MAAM,mBAAmB,EAAE,yBAAyB,CAAC,cAAc,CA+FzE,CAAC"}
@@ -25,8 +25,7 @@ const fillActionGenerator = (page, options) => {
25
25
  testCaseLine,
26
26
  };
27
27
  },
28
- // TODO: args transformer to be kept at a single place
29
- template: (_, options) => {
28
+ template: (args, options) => {
30
29
  return {
31
30
  code: `await ${page.name}.${options.testCaseLine}`,
32
31
  };
@@ -1,4 +1,4 @@
1
- import { PlaywrightActionGenerator } from "../types";
1
+ import { GotoActionArgs, PlaywrightActionGenerator } from "../types";
2
2
  export declare const PLAYWRIGHT_GOTO_ACTION_NAME = "page_goto";
3
- export declare const gotoActionGenerator: PlaywrightActionGenerator;
3
+ export declare const gotoActionGenerator: PlaywrightActionGenerator<GotoActionArgs>;
4
4
  //# sourceMappingURL=goto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"goto.d.ts","sourceRoot":"","sources":["../../src/actions/goto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAGrD,eAAO,MAAM,2BAA2B,cAAc,CAAC;AAEvD,eAAO,MAAM,mBAAmB,EAAE,yBAuCjC,CAAC"}
1
+ {"version":3,"file":"goto.d.ts","sourceRoot":"","sources":["../../src/actions/goto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAGrE,eAAO,MAAM,2BAA2B,cAAc,CAAC;AAEvD,eAAO,MAAM,mBAAmB,EAAE,yBAAyB,CAAC,cAAc,CAyCzE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { PlaywrightActionGenerator } from "../types";
1
+ import { HoverActionArgs, PlaywrightActionGenerator } from "../types";
2
2
  export declare const PLAYWRIGHT_HOVER_ACTION_NAME = "hover_element";
3
- export declare const hoverActionGenerator: PlaywrightActionGenerator;
3
+ export declare const hoverActionGenerator: PlaywrightActionGenerator<HoverActionArgs>;
4
4
  //# sourceMappingURL=hover.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hover.d.ts","sourceRoot":"","sources":["../../src/actions/hover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,4BAA4B,kBAAkB,CAAC;AAE5D,eAAO,MAAM,oBAAoB,EAAE,yBAqDlC,CAAC"}
1
+ {"version":3,"file":"hover.d.ts","sourceRoot":"","sources":["../../src/actions/hover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAItE,eAAO,MAAM,4BAA4B,kBAAkB,CAAC;AAE5D,eAAO,MAAM,oBAAoB,EAAE,yBAAyB,CAC1D,eAAe,CAsDhB,CAAC"}
@@ -11,14 +11,14 @@ const hoverActionGenerator = (page) => {
11
11
  const locator = await (0, utils_1.getPlaywrightLocatorUsingCssSelector)(selector, args.xpath, page.pwPageInstance, args?.elementAnnotation);
12
12
  const exec = new Function("page", `return page.${locator}.hover({ timeout: 3000 })`);
13
13
  await exec(page.pwPageInstance);
14
- await page.pwPageInstance.waitForTimeout(3000);
15
14
  return {
16
15
  locator,
17
16
  };
18
17
  },
19
- // TODO: args transformer to be kept at a single place
20
18
  template: (args, options) => {
21
- return { code: `await ${page.name}.${options.locator}.hover();` };
19
+ return {
20
+ code: `await ${page.name}.${options.locator}.hover();`,
21
+ };
22
22
  },
23
23
  name: exports.PLAYWRIGHT_HOVER_ACTION_NAME,
24
24
  schema: {
@@ -1,13 +1,13 @@
1
1
  import { TraceClient } from "@empiricalrun/llm";
2
2
  import { TestGenPage } from "../page";
3
- import { ActionSchema } from "../types";
3
+ import { ActionArgs, ActionSchema } from "../types";
4
4
  export declare class PlaywrightActions {
5
5
  private page;
6
6
  private stateVariables;
7
7
  private actionGenerators;
8
8
  private recordedActions;
9
9
  constructor(page: TestGenPage, stateVariables?: Record<string, any>);
10
- executeAction(name: string | undefined, args: Record<string, any>, trace?: TraceClient): Promise<string | undefined>;
10
+ executeAction(name: string | undefined, args: ActionArgs, trace?: TraceClient): Promise<string | undefined>;
11
11
  getBrowsingActionSchemas(): ActionSchema[];
12
12
  getMasterActionSchemas(): ActionSchema[];
13
13
  generateCode(): {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,EAAE,YAAY,EAA6B,MAAM,UAAU,CAAC;AAWnE,qBAAa,iBAAiB;IAQ1B,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,cAAc;IARxB,OAAO,CAAC,gBAAgB,CAA8B;IACtD,OAAO,CAAC,eAAe,CAInB;gBAEM,IAAI,EAAE,WAAW,EACjB,cAAc,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAgB5C,aAAa,CACjB,IAAI,oBAAa,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IA0D9B,wBAAwB,IAAI,YAAY,EAAE;IAoB1C,sBAAsB,IAAI,YAAY,EAAE;IAWxC,YAAY,IAAI;QACd,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,EAAE,CAAC;KACvB;IAUD,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAK9B;;;;;;OAMG;IACH,aAAa,IAAI,OAAO;IAQxB,UAAU;IAWV,iBAAiB;IAIjB,iBAAiB,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAItD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,EAEL,UAAU,EACV,YAAY,EAEb,MAAM,UAAU,CAAC;AAWlB,qBAAa,iBAAiB;IAQ1B,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,cAAc;IARxB,OAAO,CAAC,gBAAgB,CAAwC;IAChE,OAAO,CAAC,eAAe,CAInB;gBAEM,IAAI,EAAE,WAAW,EACjB,cAAc,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAgB5C,aAAa,CACjB,IAAI,oBAAa,EACjB,IAAI,EAAE,UAAU,EAChB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IA0D9B,wBAAwB,IAAI,YAAY,EAAE;IAoB1C,sBAAsB,IAAI,YAAY,EAAE;IAWxC,YAAY,IAAI;QACd,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,EAAE,CAAC;KACvB;IAUD,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAK9B;;;;;;OAMG;IACH,aAAa,IAAI,OAAO;IAQxB,UAAU;IAWV,iBAAiB;IAIjB,iBAAiB,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAItD"}
@@ -1,4 +1,4 @@
1
- import { PlaywrightActionGenerator } from "../types";
1
+ import { PlaywrightActionGenerator, PressActionArgs } from "../types";
2
2
  export declare const PLAYWRIGHT_PRESS_ACTION_NAME = "keyboard_press_on_element";
3
- export declare const pressActionGenerator: PlaywrightActionGenerator;
3
+ export declare const pressActionGenerator: PlaywrightActionGenerator<PressActionArgs>;
4
4
  //# sourceMappingURL=press.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../src/actions/press.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,4BAA4B,8BAA8B,CAAC;AAExE,eAAO,MAAM,oBAAoB,EAAE,yBA4DlC,CAAC"}
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"}
@@ -1,4 +1,4 @@
1
- import { PlaywrightActionGenerator } from "../types";
1
+ import { PlaywrightActionGenerator, SkillActionArgs } from "../types";
2
2
  export declare const SKILL_USAGE = "skill_usage";
3
3
  export type Skill = {
4
4
  testStep: string;
@@ -16,6 +16,6 @@ export declare const testCaseSkills: TestCaseSkills;
16
16
  export declare function extractSkillFromArgs(args: Record<string, any>): {
17
17
  skillDetails: Skill | undefined;
18
18
  };
19
- export declare const skillActionGenerator: PlaywrightActionGenerator;
19
+ export declare const skillActionGenerator: PlaywrightActionGenerator<SkillActionArgs>;
20
20
  export {};
21
21
  //# sourceMappingURL=skill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../src/actions/skill.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAGrD,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,yBAmHlC,CAAC"}
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;AAGtE,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"}
@@ -35,9 +35,9 @@ const skillActionGenerator = (page, options) => {
35
35
  return {
36
36
  execute: async ({ args, trace }) => {
37
37
  const { skill, action } = args;
38
- const { skillDetails } = extractSkillFromArgs(args);
38
+ const [skillDetails] = availableSkills.filter((skillDetails) => skillDetails.testStep === skill);
39
39
  if (!skillDetails) {
40
- throw new Error(`No skill found for skill: ${skill}`);
40
+ throw new Error(`No skill found for ${skill}`);
41
41
  }
42
42
  const skillFilePath = skillDetails.filePath;
43
43
  // This assumes repoDir is process.cwd()
@@ -86,7 +86,6 @@ const skillActionGenerator = (page, options) => {
86
86
  };
87
87
  },
88
88
  template: (args, options) => {
89
- // TODO: support for import statement
90
89
  const code = `${options.locator}`;
91
90
  const skill = args.skill;
92
91
  const [skillDetails] = availableSkills.filter((skillDetails) => skillDetails.testStep === skill);
@@ -1,4 +1,4 @@
1
- import { PlaywrightActionGenerator } from "../types";
2
- export declare const PLAYWRIGHT_GOTO_ACTION_NAME = "text_content";
3
- export declare const textContentActionGenerator: PlaywrightActionGenerator;
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
4
  //# sourceMappingURL=text-content.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text-content.d.ts","sourceRoot":"","sources":["../../src/actions/text-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,2BAA2B,iBAAiB,CAAC;AAE1D,eAAO,MAAM,0BAA0B,EAAE,yBA8DxC,CAAC"}
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"}
@@ -1,34 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textContentActionGenerator = exports.PLAYWRIGHT_GOTO_ACTION_NAME = void 0;
3
+ exports.textContentActionGenerator = exports.PLAYWRIGHT_TEXT_CONTENT_ACTION_NAME = void 0;
4
4
  const constants_1 = require("./constants");
5
5
  const utils_1 = require("./utils");
6
- exports.PLAYWRIGHT_GOTO_ACTION_NAME = "text_content";
6
+ exports.PLAYWRIGHT_TEXT_CONTENT_ACTION_NAME = "text_content";
7
7
  const textContentActionGenerator = (page, options) => {
8
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);
9
+ execute: async ({ args }) => {
10
+ const locator = await (0, utils_1.getPlaywrightLocatorUsingCssSelector)(args.css_selector, args.xpath, page.pwPageInstance, args?.elementAnnotation);
12
11
  const exec = new Function("page", `return page.${locator}.textContent()`);
13
- const value = (await exec(page.pwPageInstance));
14
- if (options) {
15
- options.stateVariables[args.variable_name] = value;
16
- }
12
+ const textContent = await exec(page.pwPageInstance);
13
+ options.setStateVariables({
14
+ ...options.stateVariables,
15
+ [args.variable_name]: textContent,
16
+ });
17
17
  return {
18
18
  locator,
19
19
  };
20
20
  },
21
21
  template: (args, options) => {
22
- const code = `const ${args.variable_name} = await ${page.name}.${options.locator}.textContent();`;
23
22
  return {
24
- code,
23
+ code: `const ${args.variable_name} = await ${page.name}.${options.locator}.textContent();`,
25
24
  };
26
25
  },
27
- name: exports.PLAYWRIGHT_GOTO_ACTION_NAME,
26
+ name: exports.PLAYWRIGHT_TEXT_CONTENT_ACTION_NAME,
28
27
  schema: {
29
28
  type: "function",
30
29
  function: {
31
- name: exports.PLAYWRIGHT_GOTO_ACTION_NAME,
30
+ name: exports.PLAYWRIGHT_TEXT_CONTENT_ACTION_NAME,
32
31
  description: "extract text content of the element",
33
32
  parameters: {
34
33
  type: "object",
@@ -114,7 +114,7 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
114
114
  const plannerResp = await (0, run_time_planner_1.runtimePlanner)({
115
115
  trace: masterAgentSpan,
116
116
  task,
117
- conversation: [...masterAgentActions],
117
+ successfulActions: [...masterAgentActions],
118
118
  pages: getPageVariables(actions.getStateVariables()),
119
119
  currentPage: (0, utils_1.getPageVarName)(),
120
120
  });
@@ -1,14 +1,7 @@
1
1
  import { TraceClient } from "@empiricalrun/llm";
2
- /**
3
- * This agent is used to divide the tasl into individual actions and then
4
- * compare each action against the actions listed in the conversation.
5
- * If the task is not fully completed, identify which specific actions are missing and suggest next steps to complete the task.
6
- *
7
- * This is very initial stage planner and needs iteration and currently forked from verification agent
8
- */
9
- export declare function runtimePlanner({ trace, task, conversation, pages, currentPage, }: {
2
+ export declare function runtimePlanner({ trace, task, successfulActions, pages, currentPage, }: {
10
3
  trace?: TraceClient;
11
- conversation: string[];
4
+ successfulActions: string[];
12
5
  task: string;
13
6
  pages?: Record<string, any>;
14
7
  currentPage?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"run-time-planner.d.ts","sourceRoot":"","sources":["../../../src/agent/planner/run-time-planner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,EACnC,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,WAAW,GACZ,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;GAkHA"}
1
+ {"version":3,"file":"run-time-planner.d.ts","sourceRoot":"","sources":["../../../src/agent/planner/run-time-planner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKpE,wBAAsB,cAAc,CAAC,EACnC,KAAK,EACL,IAAI,EACJ,iBAAiB,EACjB,KAAK,EACL,WAAW,GACZ,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;GAoFA"}
@@ -2,64 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runtimePlanner = void 0;
4
4
  const llm_1 = require("@empiricalrun/llm");
5
+ const promptTemplate_0 = "{{#section \"system\"}}\nGiven a successfully executed actions that lists only the actions that were\nsuccessfully executed and a task comprising multiple actions, your goal is to\nanalyse the list and determine if the entire task is completed.\n\nThese actions are executed by AI agents using Playwright on a browser. These agents\nalready have access to browser tabs to execute actions. The successfully executed\nactions on browser post browser has opened, is provided to you as successfully\nexecuted actions.\n\nIf the task is not fully completed, identify which specific actions are missing\nand suggest next steps to complete the task. Assume that the conversation provided\nis entirely truthful and no additional actions were performed beyond those listed.\n\nTo fulfil your goal, follow these steps:\n- Divide the task into individual actions.\n- Compare each task action against the actions listed in the successfully executed actions list.\n- Identify which actions have been executed and which have not.\n- If all actions are executed, respond with the task as done.\n- If any actions are missing, respond with the task as not done, listing all actions\n and specifying which are complete and which are missing.\n- If provided with list of pages, based on the next pending action and previously executed\n action, identify the page on which next action needs to be taken \n{{/section}}\n\n{{#section \"user\"}}\nTask:\n{{task}}\n\n----\n\nFollowing are successfully executed actions:\n{{successfulActions}}\n\n----\n\nCurrent page:\n{{currentPage}}\n\n{{/section}}\n";
5
6
  const utils_1 = require("../utils");
6
- /**
7
- * This agent is used to divide the tasl into individual actions and then
8
- * compare each action against the actions listed in the conversation.
9
- * If the task is not fully completed, identify which specific actions are missing and suggest next steps to complete the task.
10
- *
11
- * This is very initial stage planner and needs iteration and currently forked from verification agent
12
- */
13
- async function runtimePlanner({ trace, task, conversation, pages, currentPage, }) {
7
+ async function runtimePlanner({ trace, task, successfulActions, pages, currentPage, }) {
14
8
  const runTimePlannerSpan = trace?.span({
15
9
  name: "runtime-planner",
16
10
  input: {
17
11
  task,
18
- conversation,
12
+ successfulActions,
13
+ currentPage,
19
14
  },
20
15
  });
21
16
  const llm = new llm_1.LLM({ provider: "openai" });
22
- const prompt = [
23
- {
24
- role: "system",
25
- content: `
26
- Given a successfully executed actions that lists only the actions that were successfully executed and a task comprising multiple actions, your goal is to analyse the list and determine if the entire task is completed.
27
- These actions are executed by AI agents using Playwright on a browser. These agents already have access to browser tabs to execute actions. The successfully executed actions on browser post browser has opened, is provided to you as successfully executed actions.
28
-
29
- If the task is not fully completed, identify which specific actions are missing and suggest next steps to complete the task. Assume that the conversation provided is entirely truthful and no additional actions were performed beyond those listed.
30
-
31
- To fulfil your goal, follow these steps:
32
- - Divide the task into individual actions.
33
- - Compare each task action against the actions listed in the successfully executed actions list.
34
- - Identify which actions have been executed and which have not.
35
- - If all actions are executed, respond with the task as done.
36
- - If any actions are missing, respond with the task as not done, listing all actions and specifying which are complete and which are missing.
37
- - If provided with list of pages, based on the next pending action and previously executed action, identify the page on which next action needs to be taken
38
- `,
39
- },
40
- {
41
- role: "user",
42
- content: `
43
- Task:
44
- ${task}
45
-
46
- ----
47
-
48
- Following are successfully executed actions:
49
- ${conversation.join("\n")}
50
-
51
- ----
52
-
53
- Current page:
54
- ${currentPage}
55
- `,
56
- },
57
- ];
58
17
  const response = await llm.createChatCompletion({
59
18
  trace: runTimePlannerSpan,
60
19
  traceName: "runtime-planner-llm",
61
20
  model: "gpt-4o",
62
- messages: prompt,
21
+ messages: (0, llm_1.compilePrompt)(promptTemplate_0, {
22
+ task,
23
+ successfulActions: successfulActions.join("\n"),
24
+ currentPage,
25
+ }),
63
26
  tools: [
64
27
  {
65
28
  type: "function",
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import "./initSentry";
2
1
  import { Page } from "playwright";
3
2
  import { ScopeVars } from "./types";
4
3
  export declare function createTest(task: string, page: Page, scope?: ScopeVars): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAItB,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOlC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAapC,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,SAAS,iBAsC3E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOlC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAYpC,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,SAAS,iBAsC3E"}
package/dist/index.js CHANGED
@@ -1,35 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  exports.createTest = void 0;
30
- require("./initSentry");
31
7
  const llm_1 = require("@empiricalrun/llm");
32
- const Sentry = __importStar(require("@sentry/node"));
33
8
  const run_1 = require("./agent/master/run");
34
9
  const scenarios_1 = require("./bin/utils/scenarios");
35
10
  const client_1 = __importDefault(require("./file/client"));
@@ -38,7 +13,6 @@ const session_1 = require("./session");
38
13
  const pw_test_1 = require("./utils/pw-test");
39
14
  const flushEvents = async () => {
40
15
  await (0, llm_1.flushAllTraces)();
41
- await Sentry.flush();
42
16
  };
43
17
  process.on("beforeExit", async () => await flushEvents());
44
18
  process.on("exit", async () => await flushEvents());
@@ -1,22 +1,23 @@
1
1
  import { TraceClient } from "@empiricalrun/llm";
2
2
  import OpenAI from "openai";
3
3
  import { TestGenPage } from "../page";
4
- export type PlaywrightActionGenerator = (page: TestGenPage, options: {
4
+ export type { TestGenPage };
5
+ export type PlaywrightActionGenerator<T extends BaseActionArgs = ActionArgs> = (page: TestGenPage, options: {
5
6
  stateVariables: Record<string, any>;
6
7
  setStateVariables: (stateVariables: Record<string, any>) => void;
7
- }) => Action;
8
+ }) => Action<T>;
8
9
  export type ActionSchema = OpenAI.Chat.Completions.ChatCompletionTool;
9
- export type Action = {
10
+ export type Action<T extends BaseActionArgs = ActionArgs> = {
10
11
  name: string;
11
12
  schema: ActionSchema;
12
13
  execute: (options: {
13
- args: Record<string, any>;
14
+ args: T;
14
15
  trace?: TraceClient;
15
16
  }) => Promise<{
16
17
  locator: string;
17
18
  testCaseLine?: string;
18
19
  } | void>;
19
- template: (args: Record<string, any>, options: {
20
+ template: (args: T, options: {
20
21
  locator: string;
21
22
  testCaseLine?: string;
22
23
  }) => {
@@ -25,4 +26,44 @@ export type Action = {
25
26
  };
26
27
  };
27
28
  export type ScopeVars = Record<string, any>;
29
+ export type BaseActionArgs = {
30
+ reason: string;
31
+ elementAnnotation?: string;
32
+ };
33
+ export type ClickActionArgs = BaseActionArgs & {
34
+ xpath: string;
35
+ css_selector: string;
36
+ };
37
+ export type FillActionArgs = BaseActionArgs & {
38
+ text: string;
39
+ variable_name: string;
40
+ xpath: string;
41
+ css_selector: string;
42
+ };
43
+ export type GotoActionArgs = BaseActionArgs & {
44
+ url: string;
45
+ };
46
+ export type PressActionArgs = BaseActionArgs & {
47
+ key: string;
48
+ xpath: string;
49
+ css_selector: string;
50
+ };
51
+ export type AssertTextVisibilityActionArgs = BaseActionArgs & {
52
+ xpath: string;
53
+ css_selector: string;
54
+ };
55
+ export type TextContentActionArgs = BaseActionArgs & {
56
+ variable_name: string;
57
+ xpath: string;
58
+ css_selector: string;
59
+ };
60
+ export type HoverActionArgs = BaseActionArgs & {
61
+ xpath: string;
62
+ css_selector: string;
63
+ };
64
+ export type SkillActionArgs = BaseActionArgs & {
65
+ skill: string;
66
+ action: string;
67
+ };
68
+ export type ActionArgs = ClickActionArgs | FillActionArgs | GotoActionArgs | PressActionArgs | AssertTextVisibilityActionArgs | TextContentActionArgs | HoverActionArgs | SkillActionArgs;
28
69
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE;IACP,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,iBAAiB,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;CAClE,KACE,MAAM,CAAC;AAEZ,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC;AAEtE,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,CAAC,OAAO,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAA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D,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,cAAc,GAAG;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,eAAe,GACf,cAAc,GACd,cAAc,GACd,eAAe,GACf,8BAA8B,GAC9B,qBAAqB,GACrB,eAAe,GACf,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -74,8 +74,8 @@
74
74
  "tsx": "^4.16.2",
75
75
  "typescript": "^5.3.3",
76
76
  "@empiricalrun/llm": "^0.9.35",
77
- "@empiricalrun/reporter": "^0.23.1",
78
- "@empiricalrun/r2-uploader": "^0.3.8"
77
+ "@empiricalrun/r2-uploader": "^0.3.8",
78
+ "@empiricalrun/reporter": "^0.23.1"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@playwright/test": "1.47.1",