@empiricalrun/test-gen 0.80.3 → 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 +31 -0
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +1 -9
- package/dist/agent/chat/prompt/pw-utils-docs.d.ts +1 -1
- package/dist/agent/chat/prompt/pw-utils-docs.d.ts.map +1 -1
- package/dist/agent/chat/prompt/pw-utils-docs.js +0 -56
- package/dist/agent/chat/prompt/skills.d.ts +1 -2
- package/dist/agent/chat/prompt/skills.d.ts.map +1 -1
- package/dist/agent/chat/prompt/skills.js +34 -20
- package/dist/recorder/index.d.ts.map +1 -1
- package/dist/recorder/index.js +5 -3
- package/dist/tools/diagnosis-fetcher.d.ts +6 -2
- package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
- package/dist/tools/diagnosis-fetcher.js +1 -1
- package/dist/tools/executor/index.d.ts.map +1 -1
- package/dist/tools/executor/index.js +0 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +3 -1
- package/dist/tools/run-test.js +2 -2
- package/dist/tools/test-run-fetcher/index.d.ts.map +1 -1
- package/package.json +11 -11
- 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/tools/slack-message/index.d.ts +0 -3
- package/dist/tools/slack-message/index.d.ts.map +0 -1
- package/dist/tools/slack-message/index.js +0 -69
- package/dist/tools/test-run-fetcher/types.d.ts +0 -79
- package/dist/tools/test-run-fetcher/types.d.ts.map +0 -1
- package/dist/tools/test-run-fetcher/types.js +0 -2
- package/dist/utils/env.d.ts +0 -2
- package/dist/utils/env.d.ts.map +0 -1
- package/dist/utils/env.js +0 -7
|
@@ -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
|
-
}
|