@empiricalrun/test-gen 0.81.0 → 0.81.2

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/file-info/adapters/github/reader.d.ts +1 -1
  3. package/dist/file-info/adapters/github/reader.d.ts.map +1 -1
  4. package/dist/file-info/adapters/github/reader.js +7 -5
  5. package/dist/tools/create-pull-request/index.d.ts.map +1 -1
  6. package/dist/tools/create-pull-request/index.js +1 -3
  7. package/dist/tools/create-pull-request/utils.d.ts +1 -0
  8. package/dist/tools/create-pull-request/utils.d.ts.map +1 -1
  9. package/dist/tools/create-pull-request/utils.js +4 -0
  10. package/dist/tools/executor/utils/git.d.ts +2 -1
  11. package/dist/tools/executor/utils/git.d.ts.map +1 -1
  12. package/dist/tools/executor/utils/git.js +3 -2
  13. package/dist/tools/executor/utils/index.d.ts.map +1 -1
  14. package/dist/tools/executor/utils/index.js +4 -0
  15. package/package.json +9 -9
  16. package/tsconfig.tsbuildinfo +1 -1
  17. package/dist/agent/browsing/index.d.ts +0 -15
  18. package/dist/agent/browsing/index.d.ts.map +0 -1
  19. package/dist/agent/browsing/index.js +0 -60
  20. package/dist/agent/master/action-tool-calls.d.ts +0 -42
  21. package/dist/agent/master/action-tool-calls.d.ts.map +0 -1
  22. package/dist/agent/master/action-tool-calls.js +0 -87
  23. package/dist/agent/master/element-annotation.d.ts +0 -30
  24. package/dist/agent/master/element-annotation.d.ts.map +0 -1
  25. package/dist/agent/master/element-annotation.js +0 -175
  26. package/dist/agent/master/execute-browser-action.d.ts +0 -24
  27. package/dist/agent/master/execute-browser-action.d.ts.map +0 -1
  28. package/dist/agent/master/execute-browser-action.js +0 -121
  29. package/dist/agent/master/next-action.d.ts +0 -22
  30. package/dist/agent/master/next-action.d.ts.map +0 -1
  31. package/dist/agent/master/next-action.js +0 -97
  32. package/dist/agent/master/planner.d.ts +0 -15
  33. package/dist/agent/master/planner.d.ts.map +0 -1
  34. package/dist/agent/master/planner.js +0 -142
  35. package/dist/agent/master/run.d.ts +0 -17
  36. package/dist/agent/master/run.d.ts.map +0 -1
  37. package/dist/agent/master/run.js +0 -156
  38. package/dist/agent/master/scroller.d.ts +0 -15
  39. package/dist/agent/master/scroller.d.ts.map +0 -1
  40. package/dist/agent/master/scroller.js +0 -369
  41. package/dist/agent/master/with-hints.d.ts +0 -17
  42. package/dist/agent/master/with-hints.d.ts.map +0 -1
  43. package/dist/agent/master/with-hints.js +0 -103
  44. package/dist/agent/planner/run-time-planner.d.ts +0 -15
  45. package/dist/agent/planner/run-time-planner.d.ts.map +0 -1
  46. package/dist/agent/planner/run-time-planner.js +0 -98
  47. package/dist/agent/planner/run.d.ts +0 -7
  48. package/dist/agent/planner/run.d.ts.map +0 -1
  49. package/dist/agent/planner/run.js +0 -128
  50. package/dist/browser-injected-scripts/annotate-elements.js +0 -612
  51. package/dist/browser-injected-scripts/annotate-elements.spec.d.ts +0 -2
  52. package/dist/browser-injected-scripts/annotate-elements.spec.d.ts.map +0 -1
  53. package/dist/browser-injected-scripts/annotate-elements.spec.js +0 -202
  54. package/dist/browser-injected-scripts/annotate-elements.spec.ts +0 -327
  55. package/dist/generate-summary/frame-sampling.d.ts +0 -12
  56. package/dist/generate-summary/frame-sampling.d.ts.map +0 -1
  57. package/dist/generate-summary/frame-sampling.js +0 -72
  58. package/dist/generate-summary/generate-error-stack-summary.d.ts +0 -11
  59. package/dist/generate-summary/generate-error-stack-summary.d.ts.map +0 -1
  60. package/dist/generate-summary/generate-error-stack-summary.js +0 -41
  61. package/dist/generate-summary/generate-failed-step-screenshot-diff-summary.d.ts +0 -58
  62. package/dist/generate-summary/generate-failed-step-screenshot-diff-summary.d.ts.map +0 -1
  63. package/dist/generate-summary/generate-failed-step-screenshot-diff-summary.js +0 -460
  64. package/dist/generate-summary/generate-grouped-summary.d.ts +0 -18
  65. package/dist/generate-summary/generate-grouped-summary.d.ts.map +0 -1
  66. package/dist/generate-summary/generate-grouped-summary.js +0 -88
  67. package/dist/generate-summary/merge-summary.d.ts +0 -16
  68. package/dist/generate-summary/merge-summary.d.ts.map +0 -1
  69. package/dist/generate-summary/merge-summary.js +0 -43
  70. package/dist/generate-summary/pick-videos-for-comparison.d.ts +0 -9
  71. package/dist/generate-summary/pick-videos-for-comparison.d.ts.map +0 -1
  72. package/dist/generate-summary/pick-videos-for-comparison.js +0 -54
  73. package/dist/utils/env.d.ts +0 -2
  74. package/dist/utils/env.d.ts.map +0 -1
  75. package/dist/utils/env.js +0 -7
@@ -1 +0,0 @@
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;AAE1C,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;cA6EoC,MAAM;YACV,OAAO;YACP,MAAM;GAgBtC"}
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runtimePlanner = runtimePlanner;
4
- const llm_1 = require("@empiricalrun/llm");
5
- const promptTemplate_0 = "{{#section \"system\"}}\nYou are given a list of successfully executed actions that are done towards completing a task (which\nis also provided to you). Your goal is to analyse the list and determine if the task is completed.\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\nThese actions were executed by AI agents using Playwright on a browser. These agents\nalready have access to browser tabs to execute actions. If there is a pending action,\none of the agents will execute it in the browser. However, they need your help to\nchoose which browser tab (= page) to use for the next action.\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\nSuccessfully executed actions:\n{{successfulActions}}\n\n----\n\nList of pages with their current URLs:\n{{pagesSummary}}\n\n\n{{/section}}\n";
6
- async function runtimePlanner({ trace, task, successfulActions, pages, currentPage, }) {
7
- const runTimePlannerSpan = trace?.span({
8
- name: "runtime-planner",
9
- input: {
10
- task,
11
- successfulActions,
12
- currentPage,
13
- },
14
- });
15
- const llm = new llm_1.LLM({ provider: "openai" });
16
- // Add the current page to the page state variables
17
- pages[currentPage.name] = currentPage.pwPageInstance;
18
- const pagesSummary = pages
19
- ? Object.entries(pages).map(([pageName, page]) => `${pageName}: Currently on ${page.url()}`)
20
- : [];
21
- const pageNamesEnum = Object.keys(pages);
22
- const response = await llm.createChatCompletion({
23
- trace: runTimePlannerSpan,
24
- traceName: "runtime-planner-llm",
25
- model: "gpt-4o",
26
- messages: (0, llm_1.compilePrompt)(promptTemplate_0, {
27
- task,
28
- successfulActions: successfulActions.join("\n"),
29
- pagesSummary: pagesSummary.join("\n"),
30
- }),
31
- tools: [
32
- {
33
- type: "function",
34
- function: {
35
- name: "task_done",
36
- description: "end the task by calling this method",
37
- parameters: {
38
- type: "object",
39
- properties: {
40
- actions: {
41
- type: "string",
42
- description: "actions extracted from task",
43
- },
44
- successful_actions: {
45
- type: "string",
46
- description: "successful actions mentioned in the conversation",
47
- },
48
- reason: {
49
- type: "string",
50
- description: "reasoning for identification of task status",
51
- },
52
- nextAction: {
53
- type: "string",
54
- description: "next action to be taken",
55
- },
56
- pageName: {
57
- type: "string",
58
- enum: pageNamesEnum,
59
- description: "page name for the next action.",
60
- },
61
- isDone: {
62
- type: "boolean",
63
- description: "whether the task is done",
64
- },
65
- },
66
- required: ["isDone", "reason", "pageName", "nextAction"],
67
- },
68
- },
69
- },
70
- ],
71
- modelParameters: {
72
- tool_choice: "required",
73
- temperature: 0.5,
74
- },
75
- });
76
- const toolCallResp = (response?.tool_calls || [])[0];
77
- if (toolCallResp && "function" in toolCallResp) {
78
- const toolCall = JSON.parse(toolCallResp.function.arguments);
79
- const output = {
80
- pageName: toolCall.pageName,
81
- isDone: toolCall.isDone,
82
- reason: toolCall.reason,
83
- };
84
- runTimePlannerSpan?.end({
85
- output,
86
- });
87
- return output;
88
- }
89
- const output = {
90
- pageName: "",
91
- isDone: false,
92
- reason: "LLM failed to generate a valid response",
93
- };
94
- runTimePlannerSpan?.end({
95
- output,
96
- });
97
- return output;
98
- }
@@ -1,7 +0,0 @@
1
- import { TraceClient } from "@empiricalrun/llm";
2
- export declare function planTask({ task, specPath, trace, }: {
3
- task: string;
4
- specPath: string;
5
- trace?: TraceClient;
6
- }): Promise<any>;
7
- //# sourceMappingURL=run.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/planner/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAcpE,wBAAsB,QAAQ,CAAC,EAC7B,IAAI,EACJ,QAAQ,EACR,KAAK,GACN,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,gBA6HA"}
@@ -1,128 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.planTask = planTask;
4
- const llm_1 = require("@empiricalrun/llm");
5
- const context_1 = require("../../bin/utils/context");
6
- const human_in_the_loop_1 = require("../../human-in-the-loop");
7
- const promptTemplate_0 = "{{#section \"system\"}}\nYou are an expert software engineer in test and have capability to collaborate with user to generate a test plan.\nYou are given a task to provide a high level plan to create a test for a given scenario.\n\nYou will be provided with already added Playwright tests and page object object models which you can use generate the test plan.\nTest plan should be a list of bullet points and each bullet point representing each test step.\nYou will be provided with app knowledge which can help you groom the steps in the plan.\n\n{{#if humanLoopRequired}}\nDo NOT finish until you have a complete understanding of the plan and have all the minute details of how the test should look like.\n\nALWAYS VERIFY THE PLAN WITH USER BEFORE FINISHING. THE USER SHOULD BE ABLE TO REVIEW AND GIVE GO AHEAD TO THE PLAN.\n\nDO NOT FINISH UNTIL USER EXPLICITLY CONFIRMS THE PLAN IS GOOD TO GO.\n{{/if}}\n\n### Test Plan Creation Guidelines\n\n- **Create Subtasks:**\n - Read the task step by step and create subtasks from the given task.\n - Do not add any new steps that are not mentioned in the task.\n\n- **Enrich Subtasks:**\n - Read the provided app knowledge.\n - Enrich the subtasks based on the information from the app knowledge.\n\n- **Plan:**\n - Once all subtasks are enriched, list them as bullet points.\n - Each bullet point must start with one of the following actions: \n - Open page \n - Click on \n - Fill in \n - Assert \n - Hover on \n - Press \n - Extract textContent\n - Do not include any bullet points that do not start with the above actions.\n\n- **Additional Notes:**\n - The final output should only contain bullet points listing the test steps.\n - Do not add any assertions that are not mentioned in the task or app knowledge.\n - The plan should not reference the knowledge base used to generate it.\n\n{{/section}}\n\n{{#section \"user\"}}\n\nApp knowledge:\n{{appKnowledge}}\n\n-----\n\nCurrent tests and page object model references:\n{{fileContext}}\n\n------\n\nTask:\n{{task}}\n\n------\n{{/section}}";
8
- const env_1 = require("../../utils/env");
9
- async function planTask({ task, specPath, trace, }) {
10
- let fileContext = "";
11
- try {
12
- const { pomPrompt, testFileContent } = await (0, context_1.contextForGeneration)(specPath);
13
- fileContext = `
14
- ${testFileContent}
15
- ${pomPrompt}
16
- `;
17
- }
18
- catch (e) {
19
- console.warn("Failed to generate file context for planner", e);
20
- }
21
- const plannerSpan = trace?.span({
22
- name: "planner",
23
- input: {
24
- task,
25
- },
26
- });
27
- // if the code in running in ci worker or github actions, disable human loop
28
- const humanLoopRequired = !(0, env_1.isRunningOnCloud)();
29
- const appKnowledge = await (0, context_1.fetchAppKnowledge)();
30
- const messages = (0, llm_1.compilePrompt)(promptTemplate_0, {
31
- appKnowledge,
32
- fileContext,
33
- task,
34
- humanLoopRequired,
35
- });
36
- const llm = new llm_1.LLM({
37
- provider: "openai",
38
- defaultModel: "gpt-4o",
39
- });
40
- let maxRetries = 10;
41
- const tools = [
42
- {
43
- type: "function",
44
- function: {
45
- name: "finish",
46
- description: "Final output of the conversation",
47
- parameters: {
48
- type: "object",
49
- properties: {
50
- plan: {
51
- type: "string",
52
- description: "Final plan which is verified by the user",
53
- },
54
- },
55
- required: ["plan"],
56
- additionalProperties: false,
57
- },
58
- },
59
- },
60
- ];
61
- if (humanLoopRequired) {
62
- tools.push({
63
- type: "function",
64
- function: {
65
- name: "send_user_message",
66
- description: "Send user message",
67
- parameters: {
68
- type: "object",
69
- properties: {
70
- message: {
71
- type: "string",
72
- description: "Message to be sent to the user for any confirmation or clarification",
73
- },
74
- },
75
- required: ["message"],
76
- additionalProperties: false,
77
- },
78
- strict: true,
79
- },
80
- });
81
- }
82
- while (maxRetries--) {
83
- const response = await llm.createChatCompletion({
84
- trace: plannerSpan,
85
- traceName: "planner-llm",
86
- messages,
87
- tools,
88
- modelParameters: {
89
- temperature: 0.5,
90
- tool_choice: "required",
91
- },
92
- });
93
- const toolCall = response?.tool_calls?.[0];
94
- const respStr = toolCall && "function" in toolCall && toolCall.function.arguments;
95
- const resp = JSON.parse(respStr || "{}");
96
- // TODO: handle this as a part of actions handler
97
- if (toolCall &&
98
- "function" in toolCall &&
99
- toolCall.function.name === "send_user_message") {
100
- const feedback = await human_in_the_loop_1.humanLoop.getFeedback({
101
- message: resp.message,
102
- });
103
- messages.push(response);
104
- messages.push({
105
- role: "tool",
106
- tool_call_id: toolCall?.id,
107
- content: feedback,
108
- });
109
- }
110
- else {
111
- const plan = resp.plan;
112
- plannerSpan?.end({
113
- output: {
114
- plan,
115
- },
116
- });
117
- return plan;
118
- }
119
- }
120
- // TODO: handle planner failure scenario
121
- plannerSpan?.end({
122
- output: {
123
- plan: "",
124
- error: "Failed to generate test plan",
125
- },
126
- });
127
- return "";
128
- }