@empiricalrun/test-gen 0.71.2 → 0.73.0
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 +57 -0
- package/dist/agent/chat/agent-loop.d.ts +11 -9
- package/dist/agent/chat/agent-loop.d.ts.map +1 -1
- package/dist/agent/chat/agent-loop.js +20 -10
- package/dist/agent/chat/exports.d.ts +2 -2
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +6 -1
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +53 -28
- package/dist/agent/chat/prompt/index.d.ts +2 -2
- package/dist/agent/chat/prompt/index.d.ts.map +1 -1
- package/dist/agent/chat/prompt/index.js +5 -4
- package/dist/agent/chat/prompt/repo.d.ts +2 -2
- package/dist/agent/chat/prompt/repo.d.ts.map +1 -1
- package/dist/agent/chat/prompt/repo.js +20 -11
- package/dist/agent/chat/state.d.ts +2 -2
- package/dist/agent/chat/state.d.ts.map +1 -1
- package/dist/agent/chat/types.d.ts +0 -6
- package/dist/agent/chat/types.d.ts.map +1 -1
- package/dist/agent/chat/utils/tool-calls.d.ts +21 -0
- package/dist/agent/chat/utils/tool-calls.d.ts.map +1 -0
- package/dist/agent/chat/utils/tool-calls.js +64 -0
- package/dist/agent/chat/utils.d.ts +2 -4
- package/dist/agent/chat/utils.d.ts.map +1 -1
- package/dist/agent/chat/utils.js +5 -11
- package/dist/agent/code-review/prompt.d.ts +2 -0
- package/dist/agent/code-review/prompt.d.ts.map +1 -0
- package/dist/agent/code-review/prompt.js +19 -0
- package/dist/agent/codegen/create-test-block.d.ts.map +1 -1
- package/dist/agent/codegen/create-test-block.js +0 -10
- package/dist/agent/diagnosis-agent/index.d.ts.map +1 -1
- package/dist/agent/diagnosis-agent/index.js +0 -9
- package/dist/agent/master/browser-tests/index.spec.js +1 -1
- package/dist/agent/master/execute-browser-action.d.ts +1 -1
- package/dist/agent/master/execute-browser-action.d.ts.map +1 -1
- package/dist/agent/master/execute-skill-action.d.ts +1 -1
- package/dist/agent/master/execute-skill-action.d.ts.map +1 -1
- package/dist/agent/master/run.d.ts.map +1 -1
- package/dist/agent/master/run.js +0 -74
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +18 -6
- package/dist/artifacts/utils.d.ts +2 -2
- package/dist/artifacts/utils.d.ts.map +1 -1
- package/dist/artifacts/utils.js +16 -5
- package/dist/auth/cli-auth.d.ts.map +1 -1
- package/dist/auth/cli-auth.js +3 -7
- package/dist/auth/index.d.ts +1 -2
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +2 -4
- package/dist/auth/token-store.d.ts +1 -1
- package/dist/auth/token-store.d.ts.map +1 -1
- package/dist/auth/token-store.js +3 -3
- package/dist/bin/environments.d.ts +5 -1
- package/dist/bin/environments.d.ts.map +1 -1
- package/dist/bin/environments.js +76 -44
- package/dist/bin/index.js +33 -74
- package/dist/bin/setup.d.ts +3 -1
- package/dist/bin/setup.d.ts.map +1 -1
- package/dist/bin/setup.js +16 -20
- package/dist/dashboard/client.d.ts +26 -0
- package/dist/dashboard/client.d.ts.map +1 -0
- package/dist/dashboard/client.js +185 -0
- package/dist/dashboard/index.d.ts +3 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +9 -0
- package/dist/dashboard/totp.d.ts +2 -0
- package/dist/dashboard/totp.d.ts.map +1 -0
- package/dist/dashboard/totp.js +14 -0
- package/dist/dashboard/types.d.ts +9 -0
- package/dist/dashboard/types.d.ts.map +1 -0
- package/dist/dashboard/types.js +17 -0
- package/dist/file-info/file-system.d.ts +3 -0
- package/dist/file-info/file-system.d.ts.map +1 -0
- package/dist/{utils/file-tree.js → file-info/file-system.js} +2 -8
- package/dist/file-info/github.d.ts +3 -0
- package/dist/file-info/github.d.ts.map +1 -0
- package/dist/file-info/github.js +107 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -9
- package/dist/recorder/env-variables.d.ts.map +1 -1
- package/dist/recorder/env-variables.js +3 -7
- package/dist/recorder/index.js +5 -5
- package/dist/recorder/request.js +4 -9
- package/dist/recorder/upload.d.ts +3 -2
- package/dist/recorder/upload.d.ts.map +1 -1
- package/dist/recorder/upload.js +20 -22
- package/dist/tools/commit-and-create-pr.d.ts.map +1 -1
- package/dist/tools/commit-and-create-pr.js +44 -37
- package/dist/tools/definitions/run-test.d.ts +23 -0
- package/dist/tools/definitions/run-test.d.ts.map +1 -0
- package/dist/tools/definitions/run-test.js +28 -0
- package/dist/tools/definitions/str_replace_editor.d.ts +3 -0
- package/dist/tools/definitions/str_replace_editor.d.ts.map +1 -0
- package/dist/tools/definitions/str_replace_editor.js +74 -0
- package/dist/tools/definitions/test-gen-browser.d.ts +26 -0
- package/dist/tools/definitions/test-gen-browser.d.ts.map +1 -0
- package/dist/tools/definitions/test-gen-browser.js +88 -0
- package/dist/tools/delete-file.d.ts +3 -0
- package/dist/tools/delete-file.d.ts.map +1 -0
- package/dist/tools/delete-file.js +83 -0
- package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
- package/dist/tools/diagnosis-fetcher.js +3 -7
- package/dist/tools/executor/index.d.ts +24 -0
- package/dist/tools/executor/index.d.ts.map +1 -0
- package/dist/{tool-call-service → tools/executor}/index.js +38 -58
- package/dist/tools/executor/utils/checkpoint.d.ts +7 -0
- package/dist/tools/executor/utils/checkpoint.d.ts.map +1 -0
- package/dist/{utils → tools/executor/utils}/checkpoint.js +6 -5
- package/dist/{utils → tools/executor/utils}/git.d.ts +7 -12
- package/dist/tools/executor/utils/git.d.ts.map +1 -0
- package/dist/{utils → tools/executor/utils}/git.js +11 -36
- package/dist/tools/executor/utils/index.d.ts +77 -0
- package/dist/tools/executor/utils/index.d.ts.map +1 -0
- package/dist/tools/executor/utils/index.js +121 -0
- package/dist/tools/executor/utils/pr-description.d.ts +4 -0
- package/dist/tools/executor/utils/pr-description.d.ts.map +1 -0
- package/dist/tools/executor/utils/pr-description.js +24 -0
- package/dist/tools/fetch-image/index.d.ts +3 -0
- package/dist/tools/fetch-image/index.d.ts.map +1 -0
- package/dist/tools/fetch-image/index.js +56 -0
- package/dist/tools/grep/index.d.ts.map +1 -1
- package/dist/tools/grep/index.js +1 -1
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +60 -0
- package/dist/tools/list-environments.d.ts.map +1 -1
- package/dist/tools/list-environments.js +2 -5
- package/dist/tools/merge-conflicts.d.ts +3 -0
- package/dist/tools/merge-conflicts.d.ts.map +1 -0
- package/dist/tools/merge-conflicts.js +107 -0
- package/dist/tools/run-test.d.ts.map +1 -1
- package/dist/tools/run-test.js +4 -25
- package/dist/tools/str_replace_editor.d.ts.map +1 -1
- package/dist/tools/str_replace_editor.js +6 -58
- package/dist/tools/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/test-gen-browser.js +2 -83
- package/dist/tools/test-run-fetcher/index.d.ts.map +1 -1
- package/dist/tools/test-run-fetcher/index.js +2 -6
- package/dist/tools/upgrade-packages/index.d.ts.map +1 -1
- package/dist/tools/upgrade-packages/index.js +12 -13
- package/dist/tools/upgrade-packages/utils.d.ts +3 -2
- package/dist/tools/upgrade-packages/utils.d.ts.map +1 -1
- package/dist/tools/upgrade-packages/utils.js +5 -8
- package/dist/tools/utils/queue.d.ts +5 -0
- package/dist/tools/utils/queue.d.ts.map +1 -0
- package/dist/tools/utils/queue.js +41 -0
- package/dist/types/index.d.ts +0 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/SQSClient.d.ts +14 -0
- package/dist/utils/SQSClient.d.ts.map +1 -0
- package/dist/utils/SQSClient.js +116 -0
- package/dist/utils/repo-tree.d.ts +1 -1
- package/dist/utils/repo-tree.d.ts.map +1 -1
- package/dist/utils/repo-tree.js +7 -7
- package/package.json +16 -8
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/auth/api-client.d.ts +0 -13
- package/dist/auth/api-client.d.ts.map +0 -1
- package/dist/auth/api-client.js +0 -103
- package/dist/session/index.d.ts +0 -20
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/index.js +0 -104
- package/dist/tool-call-service/index.d.ts +0 -32
- package/dist/tool-call-service/index.d.ts.map +0 -1
- package/dist/tool-call-service/utils.d.ts +0 -6
- package/dist/tool-call-service/utils.d.ts.map +0 -1
- package/dist/tool-call-service/utils.js +0 -57
- package/dist/tools/utils/index.d.ts +0 -61
- package/dist/tools/utils/index.d.ts.map +0 -1
- package/dist/tools/utils/index.js +0 -122
- package/dist/utils/checkpoint.d.ts +0 -7
- package/dist/utils/checkpoint.d.ts.map +0 -1
- package/dist/utils/file-tree.d.ts +0 -3
- package/dist/utils/file-tree.d.ts.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
package/dist/agent/chat/utils.js
CHANGED
|
@@ -11,8 +11,8 @@ const log = (...args) => {
|
|
|
11
11
|
console.log((0, picocolors_1.gray)(args.join(" ")));
|
|
12
12
|
};
|
|
13
13
|
exports.log = log;
|
|
14
|
-
function logError(
|
|
15
|
-
console.error((0, picocolors_1.gray)(`[Error
|
|
14
|
+
function logError(error, trace) {
|
|
15
|
+
console.error((0, picocolors_1.gray)(`[Error]:`), error instanceof Error ? error.stack || error.message : error);
|
|
16
16
|
trace?.update({
|
|
17
17
|
output: {
|
|
18
18
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -29,7 +29,7 @@ function getModelName(model) {
|
|
|
29
29
|
return "o4";
|
|
30
30
|
return "AI";
|
|
31
31
|
}
|
|
32
|
-
async function handleAgentError({
|
|
32
|
+
async function handleAgentError({ error, chatModel, selectedModel, reporter, trace, }) {
|
|
33
33
|
const errorObject = {
|
|
34
34
|
message: error.message,
|
|
35
35
|
stack: error.stack || "Stack trace not available",
|
|
@@ -40,14 +40,8 @@ async function handleAgentError({ context, error, chatModel, selectedModel, repo
|
|
|
40
40
|
selectedModel,
|
|
41
41
|
error: errorObject,
|
|
42
42
|
}), chatModel.getHumanReadableLatestMessage());
|
|
43
|
-
trace?.update({
|
|
44
|
-
|
|
45
|
-
error: errorObject,
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
if (context) {
|
|
49
|
-
logError(context, error, trace);
|
|
50
|
-
}
|
|
43
|
+
trace?.update({ output: { error: errorObject } });
|
|
44
|
+
logError(error, trace);
|
|
51
45
|
}
|
|
52
46
|
function extractAttachments(userPrompt) {
|
|
53
47
|
const attachments = [];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const PROMPT = "\nIdentify code smells in tests\n- try-catch\n- conditionals added without a comment\n\nPlaywright gotchas\n- isVisible(), count() do not auto-wait\n\nPlaywright code smells\n- waitForLoadState is not required\n - Especially with \"networkidle\", because modern webapps keep doing network activity\n\nIdentify test assumptions\n- What data does the test require?\n- Clean up test entities\n";
|
|
2
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/agent/code-review/prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,8YAelB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROMPT = void 0;
|
|
4
|
+
exports.PROMPT = `
|
|
5
|
+
Identify code smells in tests
|
|
6
|
+
- try-catch
|
|
7
|
+
- conditionals added without a comment
|
|
8
|
+
|
|
9
|
+
Playwright gotchas
|
|
10
|
+
- isVisible(), count() do not auto-wait
|
|
11
|
+
|
|
12
|
+
Playwright code smells
|
|
13
|
+
- waitForLoadState is not required
|
|
14
|
+
- Especially with "networkidle", because modern webapps keep doing network activity
|
|
15
|
+
|
|
16
|
+
Identify test assumptions
|
|
17
|
+
- What data does the test require?
|
|
18
|
+
- Clean up test entities
|
|
19
|
+
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-test-block.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/create-test-block.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"create-test-block.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/create-test-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAa3D,wBAAsB,wBAAwB,CAAC,EAC7C,QAAQ,EACR,IAAI,EACJ,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,+BAsCA"}
|
|
@@ -7,20 +7,10 @@ const context_1 = require("../../bin/utils/context");
|
|
|
7
7
|
const web_1 = require("../../bin/utils/platform/web");
|
|
8
8
|
const constants_1 = require("../../constants");
|
|
9
9
|
const promptTemplate_0 = "{{#section \"system\"}}\nYou are a software test engineer who is given a task to write an empty test block.\nBased on the inputs you need to create an empty playwright test block with correctly imported fixture.\n\nThe test will contain a test name which you will need to use to build the empty test case block.\n\nYou will be provided with current tests, fixtures and page object models for you to use and create test case block as\nper the task provided to you.\n\nBefore responding you need to ensure that the code change is minimal and the change is reusable across tests. You need\nto ensure the code follows DRY principle.\n\nHere is the list of current tests and fixtures:\n\n{{testFiles}}\n\nHere is the list of current page object models:\n\n{{pageFiles}}\n{{/section}}\n\n{{#section \"user\"}}\nFollowing is the test scenario for which you need to write the empty test case block:\ntest name:\n{{scenarioName}}\n\ntask:\ncreate an empty test case block for the following test steps:\n{{scenario}}\n\ntest file path: {{scenarioFile}}\n\n------\n\nYou also need to ensure that the empty test case block has a starting page to begin test.\n\nIn order to identify the right page with which the test should start, follow the steps:\n- based on the similarities with other test cases mentioned in the file, identify the right page fixture to be imported\n- Read the page fixture methods step by step. Identify whether the fixture handles navigating to a page.\n- Identify whether other tests using the page fixture had to add separate steps for navigation or not\n- Based on the above analysis there will be following cases and choose either for the given test scenario:\n-- Case 1: if the test case scenario provided inside the task mentions about page navigation, then use that page\nnavigation. skip other cases if this case is satisfied.\n-- Case 2: refer other test cases which import similar fixtures and infer the first page navigation of this test case.\nYou should prefer tests which are in the same file. Tests within same file have higher overlaps in first page\nnavigation.\n- Once the page fixture is decided, look for userContext fixture in files. If its available then add \"userContext\" to\nthe test case block\n\n\n\nFollow these instructions before responding with output:\n- Read the code line by line and achieve the task provided to you\n- Read the dependencies of the code block by scanning through file paths and file provided to you. refer the same file\npath while responding with update\n- Focus only on the test case provided and associated JS methods called from the test case.\n- Respond only with the new empty test case block to be created and nothing else.\n- DO NOT respond with any backticks or markdown syntax\n- If \"userContext\" fixture is available in fixtures file, ensure importing that fixture in the test case block.\n- Provide a reason based on the test steps provided to you on why you chose the fixture or page.goto statement. The\nreason should be one of the list steps provided to you and mention why the case was chosen\n{{/section}}";
|
|
10
|
-
const session_1 = require("../../session");
|
|
11
10
|
async function createEmptyTestCaseBlock({ testCase, file, trace, }) {
|
|
12
11
|
const logger = new logger_1.CustomLogger({ useReporter: false });
|
|
13
12
|
logger.log("Creating new test block");
|
|
14
13
|
const context = await (0, context_1.contextForGeneration)(file);
|
|
15
|
-
// TODO: move this to a common place
|
|
16
|
-
const session = (0, session_1.getSessionDetails)();
|
|
17
|
-
trace =
|
|
18
|
-
trace ||
|
|
19
|
-
llm_1.langfuseInstance?.trace({
|
|
20
|
-
name: "create-empty-test-block",
|
|
21
|
-
id: crypto.randomUUID(),
|
|
22
|
-
release: session.version,
|
|
23
|
-
});
|
|
24
14
|
const promptSpan = trace?.span({
|
|
25
15
|
name: "build-create-empty-test-case-prompt",
|
|
26
16
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/diagnosis-agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/diagnosis-agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAoChD,wBAAsB,+BAA+B,CAAC,EACpD,KAAK,EACL,SAAS,EACT,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,yBAAyB,CAAC;IACrC,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAqE5B"}
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTaskUsingFailureDiagnosis = createTaskUsingFailureDiagnosis;
|
|
4
4
|
const llm_1 = require("@empiricalrun/llm");
|
|
5
|
-
const session_1 = require("../../session");
|
|
6
5
|
const strict_mode_violation_1 = require("./strict-mode-violation");
|
|
7
|
-
const session = (0, session_1.getSessionDetails)();
|
|
8
6
|
const responseFormat = {
|
|
9
7
|
type: "json_schema",
|
|
10
8
|
json_schema: {
|
|
@@ -31,13 +29,6 @@ const responseFormat = {
|
|
|
31
29
|
},
|
|
32
30
|
};
|
|
33
31
|
async function createTaskUsingFailureDiagnosis({ trace, diagnosis, logger, }) {
|
|
34
|
-
trace =
|
|
35
|
-
trace ||
|
|
36
|
-
llm_1.langfuseInstance?.trace({
|
|
37
|
-
name: "infer-agent-task",
|
|
38
|
-
id: crypto.randomUUID(),
|
|
39
|
-
release: session.version,
|
|
40
|
-
});
|
|
41
32
|
const failureDiagnosisSpan = trace?.span({
|
|
42
33
|
name: "auto-fix",
|
|
43
34
|
input: {
|
|
@@ -72,7 +72,7 @@ fixtures_1.test.skip("master agent can click icons accurately", async ({ page, s
|
|
|
72
72
|
// expect(icons.length).toBe(4); // 1 for each unique icon
|
|
73
73
|
fs_1.default.unlinkSync(iconsRegistryFile);
|
|
74
74
|
});
|
|
75
|
-
|
|
75
|
+
fixtures_1.test.skip("cua agent can click icons accurately", async ({ page, server }) => {
|
|
76
76
|
await page.goto(`${server.baseURL}/icons-navbar.html`);
|
|
77
77
|
await (0, fixtures_1.expect)(page.getByText("select an icon")).toBeVisible();
|
|
78
78
|
const response = await (0, run_1.createTestUsingComputerUseAgent)({
|
|
@@ -11,7 +11,7 @@ export declare function executeBrowserAction({ page, nextAction, flags, actions,
|
|
|
11
11
|
useActionSpecificAnnotations: boolean;
|
|
12
12
|
};
|
|
13
13
|
actions: PlaywrightActions;
|
|
14
|
-
trace
|
|
14
|
+
trace?: TraceClient | undefined;
|
|
15
15
|
llm: LLM;
|
|
16
16
|
}): Promise<{
|
|
17
17
|
generatedCodeSteps: string[];
|
|
@@ -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;AAUlD,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;
|
|
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;AAUlD,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,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAChC,GAAG,EAAE,GAAG,CAAC;CACV;;;gBAIW,MAAM;gBACN,MAAM;4BACM,MAAM;;GA8H7B"}
|
|
@@ -6,6 +6,6 @@ export declare function executeSkillAction({ actions, nextAction, trace, }: {
|
|
|
6
6
|
actionType: string;
|
|
7
7
|
toolCallArgs: string;
|
|
8
8
|
};
|
|
9
|
-
trace
|
|
9
|
+
trace?: TraceClient | undefined;
|
|
10
10
|
}): Promise<string | undefined>;
|
|
11
11
|
//# sourceMappingURL=execute-skill-action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-skill-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/execute-skill-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAMlD,wBAAsB,kBAAkB,CAAC,EACvC,OAAO,EACP,UAAU,EACV,KAAK,GACN,EAAE;IACD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,UAAU,EAAE;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"execute-skill-action.d.ts","sourceRoot":"","sources":["../../../src/agent/master/execute-skill-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAMlD,wBAAsB,kBAAkB,CAAC,EACvC,OAAO,EACP,UAAU,EACV,KAAK,GACN,EAAE;IACD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,UAAU,EAAE;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACjC,+BAeA"}
|
|
@@ -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;
|
|
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;AAalC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAUxC,OAAO,EAAE,+BAA+B,EAAE,MAAM,QAAQ,CAAC;AAKzD,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAqB9C,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;;;GAiLA"}
|
package/dist/agent/master/run.js
CHANGED
|
@@ -10,7 +10,6 @@ const logger_1 = require("../../bin/logger");
|
|
|
10
10
|
const constants_1 = require("../../constants");
|
|
11
11
|
const errors_1 = require("../../errors");
|
|
12
12
|
const page_1 = require("../../page");
|
|
13
|
-
const session_1 = require("../../session");
|
|
14
13
|
const utils_2 = require("../browsing/utils");
|
|
15
14
|
const skills_retriever_1 = require("../codegen/skills-retriever");
|
|
16
15
|
const run_1 = require("../planner/run");
|
|
@@ -40,24 +39,8 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
40
39
|
const useActionSpecificAnnotations = options?.useActionSpecificAnnotations || false;
|
|
41
40
|
const usePlannerInMaster = options?.usePlannerInMaster || false;
|
|
42
41
|
const logger = new logger_1.CustomLogger({ useReporter: false });
|
|
43
|
-
const session = (0, session_1.getSessionDetails)();
|
|
44
42
|
const testGenPage = new page_1.TestGenPage(page, (0, utils_1.getPageVarName)());
|
|
45
|
-
const trace = llm_1.langfuseInstance?.trace({
|
|
46
|
-
name: "test-generator",
|
|
47
|
-
id: crypto.randomUUID(),
|
|
48
|
-
version: session.version,
|
|
49
|
-
metadata: {
|
|
50
|
-
generationId: session.generationId,
|
|
51
|
-
sessionId: session.sessionId,
|
|
52
|
-
testUrl: session.testUrl,
|
|
53
|
-
},
|
|
54
|
-
tags: [
|
|
55
|
-
options.metadata?.projectName,
|
|
56
|
-
options.metadata?.environment,
|
|
57
|
-
].filter((s) => !!s),
|
|
58
|
-
});
|
|
59
43
|
const llm = new llm_1.LLM({
|
|
60
|
-
trace,
|
|
61
44
|
provider: options.modelProvider || constants_1.DEFAULT_MODEL_PROVIDER,
|
|
62
45
|
defaultModel: options.model || constants_1.DEFAULT_MODEL,
|
|
63
46
|
providerApiKey: constants_1.MODEL_API_KEYS[options.modelProvider || constants_1.DEFAULT_MODEL_PROVIDER],
|
|
@@ -68,7 +51,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
68
51
|
if (testCase && exports.IS_ALLOWED_TO_USE_SKILLS) {
|
|
69
52
|
skills = await (0, skills_retriever_1.getAppropriateSkills)({
|
|
70
53
|
testCase,
|
|
71
|
-
trace,
|
|
72
54
|
//@ts-ignore
|
|
73
55
|
options,
|
|
74
56
|
});
|
|
@@ -79,7 +61,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
79
61
|
const plan = await (0, run_1.planTask)({
|
|
80
62
|
task,
|
|
81
63
|
specPath,
|
|
82
|
-
trace,
|
|
83
64
|
});
|
|
84
65
|
logger.log(`Here is the plan:\n${plan}`);
|
|
85
66
|
// Will assume this is the task hereon
|
|
@@ -87,26 +68,13 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
87
68
|
}
|
|
88
69
|
const actions = new actions_1.PlaywrightActions(testGenPage, scopeVars);
|
|
89
70
|
await (0, utils_2.injectPwLocatorGenerator)(page);
|
|
90
|
-
trace?.update({ input: { task } });
|
|
91
71
|
let isGivenTaskDone = false;
|
|
92
72
|
const masterAgentActions = [];
|
|
93
73
|
let failedActions = [];
|
|
94
74
|
let disableSkills = false;
|
|
95
75
|
// Run the loop until task is done or we have reached max retry limit
|
|
96
76
|
while (!isGivenTaskDone) {
|
|
97
|
-
if (await (0, session_1.shouldStopSession)()) {
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
const masterAgentSpan = trace?.span({
|
|
101
|
-
name: "master-agent",
|
|
102
|
-
input: {
|
|
103
|
-
task,
|
|
104
|
-
executedActions: masterAgentActions,
|
|
105
|
-
failedActions,
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
77
|
const plannerResp = await (0, run_time_planner_1.runtimePlanner)({
|
|
109
|
-
trace: masterAgentSpan,
|
|
110
78
|
task,
|
|
111
79
|
successfulActions: [...masterAgentActions],
|
|
112
80
|
pages: getPageVariables(actions.getStateVariables()),
|
|
@@ -128,9 +96,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
128
96
|
const pageScreenshot = buffer.toString("base64");
|
|
129
97
|
let output;
|
|
130
98
|
let generatedCodeSteps = [];
|
|
131
|
-
if (await (0, session_1.shouldStopSession)()) {
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
99
|
// Provides next action that needs to be taken
|
|
135
100
|
const nextAction = await (0, next_action_1.getNextAction)({
|
|
136
101
|
page,
|
|
@@ -138,25 +103,18 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
138
103
|
task,
|
|
139
104
|
executedActions: masterAgentActions,
|
|
140
105
|
failedActions,
|
|
141
|
-
trace: masterAgentSpan,
|
|
142
106
|
llm,
|
|
143
107
|
options,
|
|
144
108
|
actions,
|
|
145
109
|
disableSkills,
|
|
146
110
|
logger,
|
|
147
111
|
});
|
|
148
|
-
if (await (0, session_1.shouldStopSession)()) {
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
112
|
if (nextAction) {
|
|
152
113
|
if (nextAction.actionType === action_tool_calls_1.ActionType.UNKNOWN) {
|
|
153
114
|
logger.error("Agent is not able to figure out next action since element is not visible on screen.");
|
|
154
115
|
break;
|
|
155
116
|
}
|
|
156
117
|
const args = JSON.parse(nextAction.toolCallArgs);
|
|
157
|
-
const masterAgentActionSpan = masterAgentSpan?.span({
|
|
158
|
-
name: "master-agent-execute-action",
|
|
159
|
-
});
|
|
160
118
|
output = {
|
|
161
119
|
action: args.action || args.skill,
|
|
162
120
|
reason: args.reason,
|
|
@@ -168,7 +126,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
168
126
|
const code = await (0, execute_skill_action_1.executeSkillAction)({
|
|
169
127
|
actions,
|
|
170
128
|
nextAction,
|
|
171
|
-
trace: masterAgentActionSpan,
|
|
172
129
|
});
|
|
173
130
|
if (code) {
|
|
174
131
|
generatedCodeSteps.push(code);
|
|
@@ -189,7 +146,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
189
146
|
},
|
|
190
147
|
actions,
|
|
191
148
|
llm,
|
|
192
|
-
trace: masterAgentActionSpan,
|
|
193
149
|
});
|
|
194
150
|
const { generatedCodeSteps: codeFromExecuteAction, output: outputFromExecuteAction, } = result;
|
|
195
151
|
generatedCodeSteps.push(...codeFromExecuteAction);
|
|
@@ -199,16 +155,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
199
155
|
// resetting error count as there is a successful action
|
|
200
156
|
failedActions = [];
|
|
201
157
|
masterAgentActions.push(output.action);
|
|
202
|
-
masterAgentActionSpan?.end({
|
|
203
|
-
input: {
|
|
204
|
-
action: output.action,
|
|
205
|
-
reason: output.reason,
|
|
206
|
-
type: nextAction.actionType,
|
|
207
|
-
},
|
|
208
|
-
output: {
|
|
209
|
-
success: true,
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
158
|
// enable skills after success
|
|
213
159
|
disableSkills = false;
|
|
214
160
|
}
|
|
@@ -217,17 +163,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
217
163
|
logger.log("Disabling skill usage for next retry");
|
|
218
164
|
disableSkills = true;
|
|
219
165
|
}
|
|
220
|
-
masterAgentActionSpan?.end({
|
|
221
|
-
input: {
|
|
222
|
-
action: output.action,
|
|
223
|
-
reason: output.reason,
|
|
224
|
-
type: nextAction.actionType,
|
|
225
|
-
},
|
|
226
|
-
output: {
|
|
227
|
-
error: true,
|
|
228
|
-
errorSummary: e.message,
|
|
229
|
-
},
|
|
230
|
-
});
|
|
231
166
|
if (!(e instanceof errors_1.HumanApprovalDenied)) {
|
|
232
167
|
logger.error("Failed to run master agent's next task", JSON.stringify(nextAction, null, 2), e);
|
|
233
168
|
failedActions.push(output.action);
|
|
@@ -239,17 +174,8 @@ async function createTestUsingMasterAgent({ task, page, testCase, specPath, opti
|
|
|
239
174
|
}
|
|
240
175
|
}
|
|
241
176
|
}
|
|
242
|
-
trace?.update({ input: { task }, output: { output } });
|
|
243
|
-
masterAgentSpan?.end({
|
|
244
|
-
output: {
|
|
245
|
-
action: output?.action,
|
|
246
|
-
reason: output?.reason,
|
|
247
|
-
code: generatedCodeSteps,
|
|
248
|
-
},
|
|
249
|
-
});
|
|
250
177
|
}
|
|
251
178
|
const { code, importPaths } = actions.generateCode();
|
|
252
|
-
trace?.update({ input: { task }, output: { code } });
|
|
253
179
|
logger.success("Successfully generated code for the given task");
|
|
254
180
|
return {
|
|
255
181
|
code,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/artifacts/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/artifacts/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,aAAa,EAId,MAAM,4BAA4B,CAAC;AAwBpC,wBAAgB,2BAA2B,uBAM1C;AA6HD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,aAAa,EAAE,EACvB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAsErB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,aAAa,CAA8B;gBAEvC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAKvC,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAelD,iBAAiB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;CAMtD"}
|
package/dist/artifacts/index.js
CHANGED
|
@@ -16,6 +16,9 @@ function isArtifactInputData(artifact) {
|
|
|
16
16
|
function isArtifactInputPath(artifact) {
|
|
17
17
|
return "path" in artifact;
|
|
18
18
|
}
|
|
19
|
+
function isArtifactInputUrl(artifact) {
|
|
20
|
+
return "url" in artifact;
|
|
21
|
+
}
|
|
19
22
|
function isArtifactCollectionEnabled() {
|
|
20
23
|
return (process.env.R2_ACCOUNT_ID &&
|
|
21
24
|
process.env.R2_ACCESS_KEY_ID &&
|
|
@@ -159,6 +162,7 @@ async function collectArtifacts(inputs, repoDir, toolCallId) {
|
|
|
159
162
|
return [];
|
|
160
163
|
const dataArtifacts = inputs.filter(isArtifactInputData);
|
|
161
164
|
const pathArtifacts = inputs.filter(isArtifactInputPath);
|
|
165
|
+
const urlArtifacts = inputs.filter(isArtifactInputUrl);
|
|
162
166
|
for (const artifact of pathArtifacts) {
|
|
163
167
|
if (!isFullPath(artifact.path, repoDir)) {
|
|
164
168
|
throw new Error(`Invalid path: "${artifact.path}". Path should be a full path relative to the repo directory: "${repoDir}"`);
|
|
@@ -179,14 +183,22 @@ async function collectArtifacts(inputs, repoDir, toolCallId) {
|
|
|
179
183
|
const inputsWithFileNames = [
|
|
180
184
|
...pathArtifacts,
|
|
181
185
|
...dataArtifactsWithFileName,
|
|
186
|
+
...urlArtifacts,
|
|
182
187
|
];
|
|
183
188
|
const results = inputsWithFileNames.map((artifact) => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
189
|
+
let url;
|
|
190
|
+
if (isArtifactInputUrl(artifact)) {
|
|
191
|
+
// url artifacts are passthrough
|
|
192
|
+
url = artifact.url;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
const isPathArtifact = isArtifactInputPath(artifact);
|
|
196
|
+
const relativePath = isPathArtifact
|
|
197
|
+
? path_1.default.relative(repoDir, artifact.path)
|
|
198
|
+
: artifact.fileName;
|
|
199
|
+
const pathInBucket = path_1.default.join(destinationDir, relativePath);
|
|
200
|
+
url = `https://reports.empirical.run/${pathInBucket}`;
|
|
201
|
+
}
|
|
190
202
|
return {
|
|
191
203
|
name: artifact.name,
|
|
192
204
|
contentType: artifact.contentType,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ArtifactInput, ArtifactInputPath } from "@empiricalrun/shared-types";
|
|
1
|
+
import { ArtifactInput, ArtifactInputPath, ArtifactInputUrl } from "@empiricalrun/shared-types";
|
|
2
2
|
import { JSONReport as PlaywrightJSONReport } from "@playwright/test/reporter";
|
|
3
3
|
/**
|
|
4
4
|
* Extracts attachment information from a Playwright JSON report.
|
|
5
5
|
* @param report The Playwright JSON report to extract attachments from
|
|
6
6
|
* @returns An array of objects containing path and contentType for each attachment
|
|
7
7
|
*/
|
|
8
|
-
export declare function extractAttachmentsFromPlaywrightJSONReport(report: PlaywrightJSONReport, testNameFilter?: string): ArtifactInputPath
|
|
8
|
+
export declare function extractAttachmentsFromPlaywrightJSONReport(report: PlaywrightJSONReport, testNameFilter?: string): Array<ArtifactInputUrl | ArtifactInputPath>;
|
|
9
9
|
/**
|
|
10
10
|
* Scans the given repository directory for Playwright artifacts (attachments) by:
|
|
11
11
|
* - Constructing the path to the Playwright report directory using the provided repoDir.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/artifacts/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/artifacts/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,UAAU,IAAI,oBAAoB,EAGnC,MAAM,2BAA2B,CAAC;AAInC;;;;GAIG;AACH,wBAAgB,0CAA0C,CACxD,MAAM,EAAE,oBAAoB,EAC5B,cAAc,CAAC,EAAE,MAAM,GACtB,KAAK,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,CAsE7C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CAmCxE"}
|
package/dist/artifacts/utils.js
CHANGED
|
@@ -40,11 +40,22 @@ function extractAttachmentsFromPlaywrightJSONReport(report, testNameFilter) {
|
|
|
40
40
|
for (const attachment of result.attachments) {
|
|
41
41
|
// Only collect attachments that have a 'path' (i.e., not embedded content)
|
|
42
42
|
if (attachment.path && attachment.contentType) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
const isUrl = attachment.path.startsWith("http://") ||
|
|
44
|
+
attachment.path.startsWith("https://");
|
|
45
|
+
if (isUrl) {
|
|
46
|
+
attachments.push({
|
|
47
|
+
name: `${testTitle} - ${attachment.name}`,
|
|
48
|
+
url: attachment.path,
|
|
49
|
+
contentType: attachment.contentType,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
attachments.push({
|
|
54
|
+
name: `${testTitle} - ${attachment.name}`,
|
|
55
|
+
path: attachment.path,
|
|
56
|
+
contentType: attachment.contentType,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
48
59
|
}
|
|
49
60
|
}
|
|
50
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-auth.d.ts","sourceRoot":"","sources":["../../src/auth/cli-auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-auth.d.ts","sourceRoot":"","sources":["../../src/auth/cli-auth.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,UAAU,CAAC,CAwKxD;AAED,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAE5C;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC;IAC7C,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACtC,CAAC,CAeD"}
|
package/dist/auth/cli-auth.js
CHANGED
|
@@ -11,14 +11,10 @@ const http_1 = require("http");
|
|
|
11
11
|
const url_1 = require("url");
|
|
12
12
|
const token_store_1 = require("./token-store");
|
|
13
13
|
const CLIENT_PORT_DEFAULT = 8080;
|
|
14
|
-
// Get dashboard URL
|
|
15
|
-
const getDashboardUrl = () => {
|
|
16
|
-
return process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
|
|
17
|
-
};
|
|
18
14
|
async function authenticate() {
|
|
19
15
|
// Check if already authenticated
|
|
20
16
|
if (await (0, token_store_1.isAuthenticated)()) {
|
|
21
|
-
const tokens = await (0, token_store_1.
|
|
17
|
+
const tokens = await (0, token_store_1.getStoredUserTokens)();
|
|
22
18
|
if (tokens) {
|
|
23
19
|
return {
|
|
24
20
|
success: true,
|
|
@@ -29,7 +25,7 @@ async function authenticate() {
|
|
|
29
25
|
};
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
|
-
const appUrl =
|
|
28
|
+
const appUrl = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
|
|
33
29
|
const clientPort = await (0, detect_port_1.default)(CLIENT_PORT_DEFAULT);
|
|
34
30
|
const redirectUri = `http://localhost:${clientPort}/callback`;
|
|
35
31
|
return new Promise((resolve) => {
|
|
@@ -175,7 +171,7 @@ async function logout() {
|
|
|
175
171
|
}
|
|
176
172
|
async function getAuthStatus() {
|
|
177
173
|
if (await (0, token_store_1.isAuthenticated)()) {
|
|
178
|
-
const tokens = await (0, token_store_1.
|
|
174
|
+
const tokens = await (0, token_store_1.getStoredUserTokens)();
|
|
179
175
|
if (tokens) {
|
|
180
176
|
return {
|
|
181
177
|
authenticated: true,
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { apiClient } from "./api-client";
|
|
2
1
|
export { authenticate, getAuthStatus, logout } from "./cli-auth";
|
|
3
|
-
export { clearTokens, getStoredTokens, isAuthenticated, type StoredTokens, storeTokens, } from "./token-store";
|
|
2
|
+
export { clearTokens, getStoredUserTokens as getStoredTokens, isAuthenticated, type StoredTokens, storeTokens, } from "./token-store";
|
|
4
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EACL,WAAW,EACX,mBAAmB,IAAI,eAAe,EACtC,eAAe,EACf,KAAK,YAAY,EACjB,WAAW,GACZ,MAAM,eAAe,CAAC"}
|
package/dist/auth/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.storeTokens = exports.isAuthenticated = exports.getStoredTokens = exports.clearTokens = exports.logout = exports.getAuthStatus = exports.authenticate =
|
|
4
|
-
var api_client_1 = require("./api-client");
|
|
5
|
-
Object.defineProperty(exports, "apiClient", { enumerable: true, get: function () { return api_client_1.apiClient; } });
|
|
3
|
+
exports.storeTokens = exports.isAuthenticated = exports.getStoredTokens = exports.clearTokens = exports.logout = exports.getAuthStatus = exports.authenticate = void 0;
|
|
6
4
|
var cli_auth_1 = require("./cli-auth");
|
|
7
5
|
Object.defineProperty(exports, "authenticate", { enumerable: true, get: function () { return cli_auth_1.authenticate; } });
|
|
8
6
|
Object.defineProperty(exports, "getAuthStatus", { enumerable: true, get: function () { return cli_auth_1.getAuthStatus; } });
|
|
9
7
|
Object.defineProperty(exports, "logout", { enumerable: true, get: function () { return cli_auth_1.logout; } });
|
|
10
8
|
var token_store_1 = require("./token-store");
|
|
11
9
|
Object.defineProperty(exports, "clearTokens", { enumerable: true, get: function () { return token_store_1.clearTokens; } });
|
|
12
|
-
Object.defineProperty(exports, "getStoredTokens", { enumerable: true, get: function () { return token_store_1.
|
|
10
|
+
Object.defineProperty(exports, "getStoredTokens", { enumerable: true, get: function () { return token_store_1.getStoredUserTokens; } });
|
|
13
11
|
Object.defineProperty(exports, "isAuthenticated", { enumerable: true, get: function () { return token_store_1.isAuthenticated; } });
|
|
14
12
|
Object.defineProperty(exports, "storeTokens", { enumerable: true, get: function () { return token_store_1.storeTokens; } });
|
|
@@ -9,7 +9,7 @@ export interface TokenStorage {
|
|
|
9
9
|
[dashboardDomain: string]: StoredTokens;
|
|
10
10
|
}
|
|
11
11
|
export declare function storeTokens(tokens: StoredTokens): Promise<void>;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function getStoredUserTokens(): Promise<StoredTokens | null>;
|
|
13
13
|
export declare function clearTokens(): Promise<void>;
|
|
14
14
|
export declare function isAuthenticated(): Promise<boolean>;
|
|
15
15
|
//# sourceMappingURL=token-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-store.d.ts","sourceRoot":"","sources":["../../src/auth/token-store.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,CAAC,eAAe,EAAE,MAAM,GAAG,YAAY,CAAC;CACzC;AAgCD,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA2CrE;AAED,wBAAsB,
|
|
1
|
+
{"version":3,"file":"token-store.d.ts","sourceRoot":"","sources":["../../src/auth/token-store.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,CAAC,eAAe,EAAE,MAAM,GAAG,YAAY,CAAC;CACzC;AAgCD,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA2CrE;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAqBxE;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CA4CjD;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAUxD"}
|
package/dist/auth/token-store.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.storeTokens = storeTokens;
|
|
4
|
-
exports.
|
|
4
|
+
exports.getStoredUserTokens = getStoredUserTokens;
|
|
5
5
|
exports.clearTokens = clearTokens;
|
|
6
6
|
exports.isAuthenticated = isAuthenticated;
|
|
7
7
|
const crypto_1 = require("crypto");
|
|
@@ -81,7 +81,7 @@ async function storeTokens(tokens) {
|
|
|
81
81
|
throw new Error(`Failed to store authentication tokens: ${error}`);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
async function
|
|
84
|
+
async function getStoredUserTokens() {
|
|
85
85
|
try {
|
|
86
86
|
const dashboardDomain = getDashboardDomain();
|
|
87
87
|
const tokenStorage = await getTokenStorage();
|
|
@@ -138,7 +138,7 @@ async function clearTokens() {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
async function isAuthenticated() {
|
|
141
|
-
const tokens = await
|
|
141
|
+
const tokens = await getStoredUserTokens();
|
|
142
142
|
if (!tokens)
|
|
143
143
|
return false;
|
|
144
144
|
// Check if token is not expired (with 5 minute buffer)
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { IDashboardAPIClient } from "@empiricalrun/shared-types";
|
|
2
|
+
export declare function listEnvironments({ apiClient, repoPath: repoDir, }: {
|
|
3
|
+
repoPath: string;
|
|
4
|
+
apiClient: IDashboardAPIClient;
|
|
5
|
+
}): Promise<void>;
|
|
2
6
|
//# sourceMappingURL=environments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../../src/bin/environments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../../src/bin/environments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAEpB,MAAM,4BAA4B,CAAC;AAiEpC,wBAAsB,gBAAgB,CAAC,EACrC,SAAS,EACT,QAAQ,EAAE,OAAO,GAClB,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,mBAAmB,CAAC;CAChC,iBAiDA"}
|