@empiricalrun/test-gen 0.46.9 → 0.46.11

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,18 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.46.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 0def0a2: feat: add inquirer prompts for missing CLI options
8
+
9
+ ## 0.46.10
10
+
11
+ ### Patch Changes
12
+
13
+ - b3ca74f: fix: bubble up browsing agent execution feedback for runtime planner
14
+ - b484292: fix: pages summary for runtime planner works without scoped vars
15
+
3
16
  ## 0.46.9
4
17
 
5
18
  ### Patch Changes
@@ -1 +1 @@
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
+ {"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,CA0CzE,CAAC"}
@@ -35,7 +35,7 @@ const gotoActionGenerator = (page) => {
35
35
  },
36
36
  url: {
37
37
  type: "string",
38
- description: "URL to navigate page to",
38
+ description: "URL to navigate page to. Must be prefixed with http or https (preferably https)",
39
39
  },
40
40
  },
41
41
  required: ["reason", "url"],
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW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8D1C"}
@@ -59,9 +59,10 @@ async function executeTaskUsingBrowsingAgent({ action, page, actions, llm, trace
59
59
  }
60
60
  catch (e) {
61
61
  void testgenUpdatesReporter.sendMessage(e.message);
62
+ throw e;
62
63
  }
63
64
  }
64
- toolCallsSpan?.end({ output: { toolCalls } });
65
+ toolCallsSpan?.end({ output: { toolCalls, generatedCodeSteps } });
65
66
  return generatedCodeSteps;
66
67
  }
67
68
  exports.executeTaskUsingBrowsingAgent = executeTaskUsingBrowsingAgent;
@@ -15,5 +15,10 @@ export declare function executeBrowserAction({ page, nextAction, flags, actions,
15
15
  llm: LLM;
16
16
  }): Promise<{
17
17
  generatedCodeSteps: string[];
18
+ output: {
19
+ action: string;
20
+ reason: string;
21
+ elementAnnotation?: string | undefined;
22
+ };
18
23
  }>;
19
24
  //# sourceMappingURL=execute-browser-action.d.ts.map
@@ -1 +1 @@
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;AAYlD,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,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,GAAG,EAAE,GAAG,CAAC;CACV;;GAsIA"}
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;AAYlD,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,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,GAAG,EAAE,GAAG,CAAC;CACV;;;gBAIW,MAAM;gBACN,MAAM;;;GAkIjB"}
@@ -118,6 +118,7 @@ async function executeBrowserAction({ page, nextAction, flags, actions, llm, tra
118
118
  }
119
119
  return {
120
120
  generatedCodeSteps,
121
+ output,
121
122
  };
122
123
  }
123
124
  exports.executeBrowserAction = executeBrowserAction;
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAelC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAgCxC,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;GAoRA"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAelC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAgCxC,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;GAwRA"}
@@ -115,7 +115,7 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
115
115
  task,
116
116
  successfulActions: [...masterAgentActions],
117
117
  pages: getPageVariables(actions.getStateVariables()),
118
- currentPage: testGenPage.name,
118
+ currentPage: testGenPage,
119
119
  });
120
120
  isGivenTaskDone = plannerResp.isDone;
121
121
  if (isGivenTaskDone) {
@@ -191,7 +191,7 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
191
191
  break;
192
192
  }
193
193
  default: {
194
- const { generatedCodeSteps: codeFromExecuteAction } = await (0, execute_browser_action_1.executeBrowserAction)({
194
+ const result = await (0, execute_browser_action_1.executeBrowserAction)({
195
195
  page,
196
196
  nextAction,
197
197
  flags: {
@@ -201,7 +201,9 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
201
201
  llm,
202
202
  trace: masterAgentActionSpan,
203
203
  });
204
+ const { generatedCodeSteps: codeFromExecuteAction, output: outputFromExecuteAction, } = result;
204
205
  generatedCodeSteps.push(...codeFromExecuteAction);
206
+ output = outputFromExecuteAction;
205
207
  }
206
208
  }
207
209
  // resetting error count as there is a successful action
@@ -1,11 +1,12 @@
1
1
  import { TraceClient } from "@empiricalrun/llm";
2
2
  import type { Page } from "playwright";
3
+ import { TestGenPage } from "../../types";
3
4
  export declare function runtimePlanner({ trace, task, successfulActions, pages, currentPage, }: {
4
5
  trace?: TraceClient;
5
6
  successfulActions: string[];
6
7
  task: string;
7
- pages?: Record<string, Page>;
8
- currentPage?: string;
8
+ pages: Record<string, Page>;
9
+ currentPage: TestGenPage;
9
10
  }): Promise<{
10
11
  pageName: string;
11
12
  isDone: boolean;
@@ -1 +1 @@
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;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAKvC,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,IAAI,CAAC,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;GA4FA"}
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;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,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,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5B,WAAW,EAAE,WAAW,CAAC;CAC1B;;;;GA+FA"}
@@ -14,9 +14,12 @@ async function runtimePlanner({ trace, task, successfulActions, pages, currentPa
14
14
  },
15
15
  });
16
16
  const llm = new llm_1.LLM({ provider: "openai" });
17
+ // Add the current page to the page state variables
18
+ pages[currentPage.name] = currentPage.pwPageInstance;
17
19
  const pagesSummary = pages
18
20
  ? Object.entries(pages).map(([pageName, page]) => `${pageName}: Currently on ${page.url()}`)
19
21
  : [];
22
+ const pageNamesEnum = Object.keys(pages);
20
23
  const response = await llm.createChatCompletion({
21
24
  trace: runTimePlannerSpan,
22
25
  traceName: "runtime-planner-llm",
@@ -53,7 +56,7 @@ async function runtimePlanner({ trace, task, successfulActions, pages, currentPa
53
56
  },
54
57
  pageName: {
55
58
  type: "string",
56
- enum: pages ? Object.keys(pages) : [],
59
+ enum: pageNamesEnum,
57
60
  description: "page name for the next action.",
58
61
  },
59
62
  isDone: {
package/dist/bin/index.js CHANGED
@@ -160,13 +160,13 @@ async function runAgent(testGenConfig, testGenToken) {
160
160
  .option("--suites <suites>", "Comma separated list of describe blocks")
161
161
  .parse(process.argv);
162
162
  const options = program.opts();
163
- (0, utils_2.validateCliOptions)(options);
164
- const testGenConfig = options.token
165
- ? (0, scenarios_1.loadTestConfigs)(options.token)
166
- : (0, scenarios_1.buildTestConfigFromOptions)(options);
167
- const testGenToken = options.token
168
- ? options.token
169
- : (0, scenarios_1.buildTokenFromOptions)(options);
163
+ const completedOptions = await (0, utils_2.validateAndCompleteCliOptions)(options);
164
+ const testGenConfig = completedOptions.token
165
+ ? (0, scenarios_1.loadTestConfigs)(completedOptions.token)
166
+ : (0, scenarios_1.buildTestConfigFromOptions)(completedOptions);
167
+ const testGenToken = completedOptions.token
168
+ ? completedOptions.token
169
+ : (0, scenarios_1.buildTokenFromOptions)(completedOptions);
170
170
  (0, reporter_1.setReporterConfig)({
171
171
  projectRepoName: testGenConfig.options?.metadata.projectRepoName,
172
172
  testSessionId: testGenConfig.options?.metadata.testSessionId,
@@ -5,5 +5,5 @@ export interface CliOptions {
5
5
  prompt?: string;
6
6
  suites?: string;
7
7
  }
8
- export declare function validateCliOptions(options: CliOptions): void;
8
+ export declare function validateAndCompleteCliOptions(options: CliOptions): Promise<CliOptions>;
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAS5D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AASD,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,UAAU,CAAC,CAiErB"}
@@ -1,12 +1,64 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateCliOptions = void 0;
4
- function validateCliOptions(options) {
6
+ exports.validateAndCompleteCliOptions = void 0;
7
+ const inquirer_1 = __importDefault(require("inquirer"));
8
+ async function validateAndCompleteCliOptions(options) {
5
9
  const hasToken = !!options.token;
6
- const hasNameAndFile = !!options.name && !!options.file && !!options.prompt;
7
- if (!hasToken && !hasNameAndFile) {
8
- console.error("Invalid arguments. Provide either --token OR all of --name, --file, and --prompt");
9
- process.exit(1);
10
+ if (hasToken) {
11
+ return options;
10
12
  }
13
+ const questions = [];
14
+ if (!options.name) {
15
+ questions.push({
16
+ type: "input",
17
+ name: "name",
18
+ message: "Enter the test name:",
19
+ validate: (input) => input.trim().length > 0 || "Test name is required",
20
+ });
21
+ }
22
+ if (!options.file) {
23
+ questions.push({
24
+ type: "input",
25
+ name: "file",
26
+ message: "Enter the test file path (inside tests dir):",
27
+ validate: (input) => input.trim().length > 0 || "Test file path is required",
28
+ });
29
+ }
30
+ if (!options.prompt) {
31
+ questions.push({
32
+ type: "editor",
33
+ name: "prompt",
34
+ message: "Enter the test prompt (opens in your editor):",
35
+ validate: (input) => input.trim().length > 0 || "Test prompt is required",
36
+ });
37
+ }
38
+ if (!options.suites) {
39
+ questions.push({
40
+ type: "input",
41
+ name: "suites",
42
+ message: "Enter comma-separated test suites (optional):",
43
+ });
44
+ }
45
+ if (questions.length > 0) {
46
+ // Ask each question individually to avoid type issues
47
+ const answers = {};
48
+ for (const question of questions) {
49
+ const answer = await inquirer_1.default.prompt({
50
+ type: question.type,
51
+ name: "value",
52
+ message: question.message,
53
+ validate: question.validate,
54
+ });
55
+ answers[question.name] = answer.value;
56
+ }
57
+ return {
58
+ ...options,
59
+ ...answers,
60
+ };
61
+ }
62
+ return options;
11
63
  }
12
- exports.validateCliOptions = validateCliOptions;
64
+ exports.validateAndCompleteCliOptions = validateAndCompleteCliOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.46.9",
3
+ "version": "0.46.11",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"