@empiricalrun/test-gen 0.72.0 → 0.73.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 +28 -0
- package/dist/agent/chat/agent-loop.d.ts.map +1 -1
- package/dist/agent/chat/agent-loop.js +1 -0
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +12 -22
- package/dist/agent/chat/prompt/index.d.ts.map +1 -1
- package/dist/agent/chat/prompt/index.js +3 -2
- 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/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 +9 -11
- 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 +6 -10
- 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 +2 -20
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +7 -81
- package/dist/dashboard/totp.d.ts +1 -1
- package/dist/dashboard/totp.d.ts.map +1 -1
- package/dist/dashboard/totp.js +2 -6
- 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/github.d.ts +2 -2
- package/dist/file-info/github.d.ts.map +1 -1
- package/dist/file-info/github.js +9 -10
- 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 +42 -35
- 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 +6 -9
- package/dist/tools/executor/index.d.ts.map +1 -1
- package/dist/tools/executor/index.js +23 -29
- package/dist/tools/executor/utils/checkpoint.d.ts +2 -2
- package/dist/tools/executor/utils/checkpoint.d.ts.map +1 -1
- package/dist/tools/executor/utils/checkpoint.js +6 -5
- package/dist/tools/executor/utils/git.d.ts +7 -12
- package/dist/tools/executor/utils/git.d.ts.map +1 -1
- package/dist/tools/executor/utils/git.js +11 -36
- package/dist/tools/executor/utils/index.d.ts +37 -21
- package/dist/tools/executor/utils/index.d.ts.map +1 -1
- package/dist/tools/executor/utils/index.js +57 -58
- 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 +62 -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 +2 -2
- 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 +10 -11
- 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/package.json +5 -5
- 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 -107
- 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/tools/definitions/index.d.ts +0 -22
- package/dist/tools/definitions/index.d.ts.map +0 -1
- package/dist/tools/definitions/index.js +0 -61
- package/dist/tools/definitions/utils/queue.d.ts +0 -8
- package/dist/tools/definitions/utils/queue.d.ts.map +0 -1
- package/dist/tools/definitions/utils/queue.js +0 -58
package/dist/dashboard/index.js
CHANGED
|
@@ -1,83 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RetryableHTTPError = exports.NonRetryableHTTPError = exports.HTTPError = void 0;
|
|
7
|
-
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
constructor(message, status) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.status = status;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.HTTPError = HTTPError;
|
|
19
|
-
class NonRetryableHTTPError extends HTTPError {
|
|
20
|
-
}
|
|
21
|
-
exports.NonRetryableHTTPError = NonRetryableHTTPError;
|
|
22
|
-
class RetryableHTTPError extends HTTPError {
|
|
23
|
-
}
|
|
24
|
-
exports.RetryableHTTPError = RetryableHTTPError;
|
|
25
|
-
async function makeAuthenticatedRequest(url, options, secretKey, dashboardDomain) {
|
|
26
|
-
const baseUrl = dashboardDomain || process.env.DASHBOARD_DOMAIN;
|
|
27
|
-
const fullUrl = new URL(url, baseUrl);
|
|
28
|
-
return await (0, async_retry_1.default)(async (bail) => {
|
|
29
|
-
if (options.params) {
|
|
30
|
-
Object.entries(options.params).forEach(([key, value]) => {
|
|
31
|
-
fullUrl.searchParams.append(key, value);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
const headers = {
|
|
35
|
-
...options.headers,
|
|
36
|
-
"Content-Type": "application/json",
|
|
37
|
-
};
|
|
38
|
-
if (!headers["Authorization"]) {
|
|
39
|
-
// Use API key auth if provided, else use TOTP
|
|
40
|
-
const totp = await (0, totp_1.getTOTP)(secretKey);
|
|
41
|
-
headers["X-Empirical-Auth-TOTP"] = totp;
|
|
42
|
-
}
|
|
43
|
-
const response = await fetch(fullUrl.toString(), {
|
|
44
|
-
headers,
|
|
45
|
-
method: options.method,
|
|
46
|
-
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
47
|
-
});
|
|
48
|
-
if (!response.ok) {
|
|
49
|
-
let error;
|
|
50
|
-
const msg = `HTTP error in ${options.method} request to ${fullUrl.toString()}! Status code: ${response.status}`;
|
|
51
|
-
if (response.status < 500) {
|
|
52
|
-
// Don't retry for status codes less than 500 (client errors)
|
|
53
|
-
error = new NonRetryableHTTPError(msg, response.status);
|
|
54
|
-
bail(error);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
error = new RetryableHTTPError(msg, response.status);
|
|
59
|
-
}
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
return response.json();
|
|
63
|
-
}, {
|
|
64
|
-
retries: 3,
|
|
65
|
-
factor: 2,
|
|
66
|
-
minTimeout: 1_000,
|
|
67
|
-
maxTimeout: 5_000,
|
|
68
|
-
onRetry: (error, retryCount) => {
|
|
69
|
-
console.log(`Retrying... ${retryCount}`);
|
|
70
|
-
console.log(error);
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
async function callGitHubProxy({ method, url, body, }) {
|
|
75
|
-
return await makeAuthenticatedRequest(`${process.env.DASHBOARD_DOMAIN}/api/github/proxy`, {
|
|
76
|
-
method: "POST",
|
|
77
|
-
body: {
|
|
78
|
-
method,
|
|
79
|
-
url,
|
|
80
|
-
body,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
}
|
|
3
|
+
exports.RetryableHTTPError = exports.NonRetryableHTTPError = exports.HTTPError = exports.DashboardAPIClient = void 0;
|
|
4
|
+
var client_1 = require("./client");
|
|
5
|
+
Object.defineProperty(exports, "DashboardAPIClient", { enumerable: true, get: function () { return client_1.DashboardAPIClient; } });
|
|
6
|
+
var types_1 = require("./types");
|
|
7
|
+
Object.defineProperty(exports, "HTTPError", { enumerable: true, get: function () { return types_1.HTTPError; } });
|
|
8
|
+
Object.defineProperty(exports, "NonRetryableHTTPError", { enumerable: true, get: function () { return types_1.NonRetryableHTTPError; } });
|
|
9
|
+
Object.defineProperty(exports, "RetryableHTTPError", { enumerable: true, get: function () { return types_1.RetryableHTTPError; } });
|
package/dist/dashboard/totp.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getTOTP(secretKey
|
|
1
|
+
export declare function getTOTP(secretKey: string): Promise<string>;
|
|
2
2
|
//# sourceMappingURL=totp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"totp.d.ts","sourceRoot":"","sources":["../../src/dashboard/totp.ts"],"names":[],"mappings":"AAAA,wBAAsB,OAAO,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"totp.d.ts","sourceRoot":"","sources":["../../src/dashboard/totp.ts"],"names":[],"mappings":"AAAA,wBAAsB,OAAO,CAAC,SAAS,EAAE,MAAM,mBAU9C"}
|
package/dist/dashboard/totp.js
CHANGED
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTOTP = getTOTP;
|
|
4
4
|
async function getTOTP(secretKey) {
|
|
5
|
-
|
|
6
|
-
if (!secret) {
|
|
7
|
-
throw new Error("EMPIRICAL_TOTP_SK is not set");
|
|
8
|
-
}
|
|
9
|
-
// NOTE: Had to import dynamically to avoid ECMA Script Modules error
|
|
5
|
+
// Dynamic import to avoid ECMA Script Modules error
|
|
10
6
|
const { generateTOTP } = await import("@epic-web/totp");
|
|
11
7
|
const totp = await generateTOTP({
|
|
12
|
-
secret,
|
|
8
|
+
secret: secretKey,
|
|
13
9
|
digits: 6,
|
|
14
10
|
period: 30,
|
|
15
11
|
algorithm: "SHA-256",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class HTTPError extends Error {
|
|
2
|
+
status: number;
|
|
3
|
+
constructor(message: string, status: number);
|
|
4
|
+
}
|
|
5
|
+
export declare class NonRetryableHTTPError extends HTTPError {
|
|
6
|
+
}
|
|
7
|
+
export declare class RetryableHTTPError extends HTTPError {
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dashboard/types.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,EAAE,MAAM,CAAC;gBACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI5C;AAED,qBAAa,qBAAsB,SAAQ,SAAS;CAAG;AAEvD,qBAAa,kBAAmB,SAAQ,SAAS;CAAG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RetryableHTTPError = exports.NonRetryableHTTPError = exports.HTTPError = void 0;
|
|
4
|
+
class HTTPError extends Error {
|
|
5
|
+
status;
|
|
6
|
+
constructor(message, status) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.HTTPError = HTTPError;
|
|
12
|
+
class NonRetryableHTTPError extends HTTPError {
|
|
13
|
+
}
|
|
14
|
+
exports.NonRetryableHTTPError = NonRetryableHTTPError;
|
|
15
|
+
class RetryableHTTPError extends HTTPError {
|
|
16
|
+
}
|
|
17
|
+
exports.RetryableHTTPError = RetryableHTTPError;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FileInfo } from "@empiricalrun/shared-types";
|
|
2
|
-
export declare function getFileInfoFromGitHub(repoName: string,
|
|
1
|
+
import { FileInfo, IDashboardAPIClient } from "@empiricalrun/shared-types";
|
|
2
|
+
export declare function getFileInfoFromGitHub(repoName: string, apiClient: IDashboardAPIClient): Promise<FileInfo>;
|
|
3
3
|
//# sourceMappingURL=github.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/file-info/github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/file-info/github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAyE3E,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,mBAAmB,GAC7B,OAAO,CAAC,QAAQ,CAAC,CAwFnB"}
|
package/dist/file-info/github.js
CHANGED
|
@@ -5,31 +5,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getFileInfoFromGitHub = getFileInfoFromGitHub;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
|
|
9
|
-
async function getFileContent(repoName, path, secretKey, dashboardDomain) {
|
|
8
|
+
async function getFileContent(repoName, path, apiClient) {
|
|
10
9
|
// TODO: specify ref (branch name) for the chat session
|
|
11
10
|
const url = `/api/github/files?repo=${repoName}&path=${path}`;
|
|
12
|
-
const response = await
|
|
11
|
+
const response = await apiClient.request(url, {
|
|
13
12
|
method: "GET",
|
|
14
|
-
}
|
|
13
|
+
});
|
|
15
14
|
if (!response.data) {
|
|
16
15
|
throw new Error(`Unable to fetch file for FileInfo`);
|
|
17
16
|
}
|
|
18
17
|
return response.data.fileContents.content;
|
|
19
18
|
}
|
|
20
|
-
async function getContentsForDirectory({ repo, path, },
|
|
19
|
+
async function getContentsForDirectory({ repo, path, }, apiClient) {
|
|
21
20
|
const url = `/api/github/tree?repo=${repo}&path=${path}`;
|
|
22
|
-
const response = await
|
|
21
|
+
const response = await apiClient.request(url, {
|
|
23
22
|
method: "GET",
|
|
24
|
-
}
|
|
23
|
+
});
|
|
25
24
|
if (!response.data) {
|
|
26
25
|
throw new Error(`Unable to fetch file for FileInfo`);
|
|
27
26
|
}
|
|
28
27
|
return response.data.tree;
|
|
29
28
|
}
|
|
30
29
|
// TODO: use this helper method in the dashboard
|
|
31
|
-
async function getFileInfoFromGitHub(repoName,
|
|
32
|
-
const files = await getContentsForDirectory({ repo: repoName, path: "" },
|
|
30
|
+
async function getFileInfoFromGitHub(repoName, apiClient) {
|
|
31
|
+
const files = await getContentsForDirectory({ repo: repoName, path: "" }, apiClient);
|
|
33
32
|
const root = [];
|
|
34
33
|
const nodeMap = {};
|
|
35
34
|
if (!files) {
|
|
@@ -54,7 +53,7 @@ async function getFileInfoFromGitHub(repoName, secretKey, dashboardDomain) {
|
|
|
54
53
|
type: "file",
|
|
55
54
|
path: currentPath,
|
|
56
55
|
name: fileName,
|
|
57
|
-
getContent: async () => getFileContent(repoName, currentPath,
|
|
56
|
+
getContent: async () => getFileContent(repoName, currentPath, apiClient),
|
|
58
57
|
}
|
|
59
58
|
: {
|
|
60
59
|
type: "directory",
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAYhD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAsB7C,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,IAAI,GAAG,YAAY,EAC5B,KAAK,CAAC,EAAE,SAAS,iBA0DlB;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,IAAI,iBAY7C"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,6 @@ const run_1 = require("./agent/master/run");
|
|
|
14
14
|
const scenarios_1 = require("./bin/utils/scenarios");
|
|
15
15
|
const client_1 = __importDefault(require("./file/client"));
|
|
16
16
|
const logger_1 = require("./logger");
|
|
17
|
-
const session_1 = require("./session");
|
|
18
17
|
var test_build_1 = require("./test-build");
|
|
19
18
|
Object.defineProperty(exports, "downloadBuild", { enumerable: true, get: function () { return test_build_1.downloadBuild; } });
|
|
20
19
|
const flushEvents = async () => {
|
|
@@ -45,14 +44,6 @@ async function createTest(task, pageRef, scope) {
|
|
|
45
44
|
},
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
|
-
if (testGenConfig.options && testGenConfig.options.metadata) {
|
|
49
|
-
(0, session_1.setSessionDetails)({
|
|
50
|
-
sessionId: testGenConfig.options?.metadata.testSessionId,
|
|
51
|
-
generationId: testGenConfig.options?.metadata.generationId,
|
|
52
|
-
testCaseId: testGenConfig.testCase.id,
|
|
53
|
-
projectRepoName: testGenConfig.options?.metadata.projectRepoName,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
47
|
// pageRef can be a FrameLocator, in which case we need to get the Page where the iframe is located
|
|
57
48
|
let page = "owner" in pageRef ? pageRef.owner().page() : pageRef;
|
|
58
49
|
const fileServiceClient = new client_1.default();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-variables.d.ts","sourceRoot":"","sources":["../../src/recorder/env-variables.ts"],"names":[],"mappings":"AAEA,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"env-variables.d.ts","sourceRoot":"","sources":["../../src/recorder/env-variables.ts"],"names":[],"mappings":"AAEA,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAyBjC"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchEnvironmentVariables = fetchEnvironmentVariables;
|
|
4
|
-
const
|
|
4
|
+
const client_1 = require("../dashboard/client");
|
|
5
5
|
async function fetchEnvironmentVariables(repoName) {
|
|
6
6
|
try {
|
|
7
|
-
const
|
|
7
|
+
const data = await client_1.apiClient.request(`/api/environment-variables`, {
|
|
8
8
|
method: "GET",
|
|
9
|
+
params: { project_repo_name: repoName },
|
|
9
10
|
});
|
|
10
|
-
if (!response.ok) {
|
|
11
|
-
const errorMessage = await response.text();
|
|
12
|
-
throw new Error(`Failed to fetch environment variables: ${errorMessage}`);
|
|
13
|
-
}
|
|
14
|
-
const data = await response.json();
|
|
15
11
|
if (!data.data) {
|
|
16
12
|
console.error("Failed to fetch environment variables:", data);
|
|
17
13
|
throw new Error("Failed to fetch environment variables");
|
package/dist/recorder/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const inquirer_1 = __importDefault(require("inquirer"));
|
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const utils_1 = require("../agent/browsing/utils");
|
|
12
12
|
const pw_pause_1 = require("../agent/cua/pw-codegen/pw-pause");
|
|
13
|
-
const
|
|
13
|
+
const client_1 = require("../dashboard/client");
|
|
14
14
|
const server_1 = require("../file/server");
|
|
15
15
|
const logger_1 = require("../logger");
|
|
16
16
|
const env_variables_1 = require("./env-variables");
|
|
@@ -20,7 +20,7 @@ const upload_1 = require("./upload");
|
|
|
20
20
|
const validation_1 = require("./validation");
|
|
21
21
|
async function runRecorder({ name }) {
|
|
22
22
|
try {
|
|
23
|
-
await
|
|
23
|
+
await client_1.apiClient.ensureUserIsAuthenticated();
|
|
24
24
|
}
|
|
25
25
|
catch (error) {
|
|
26
26
|
console.error("Authentication required: please run @empiricalrun/test-gen login first");
|
|
@@ -115,13 +115,13 @@ async function runRecorder({ name }) {
|
|
|
115
115
|
},
|
|
116
116
|
});
|
|
117
117
|
await (0, upload_1.waitForSummaryJson)(repoDir);
|
|
118
|
-
const
|
|
118
|
+
const videoArtifacts = (0, upload_1.extractVideoAttachments)(repoDir);
|
|
119
119
|
let attachments = [];
|
|
120
|
-
if (
|
|
120
|
+
if (videoArtifacts.length === 0) {
|
|
121
121
|
logger_1.logger.warn("No video attachments found for temp test");
|
|
122
122
|
}
|
|
123
123
|
else {
|
|
124
|
-
const videoUrls = await (0, upload_1.uploadVideosWithSpinner)(
|
|
124
|
+
const videoUrls = await (0, upload_1.uploadVideosWithSpinner)(videoArtifacts, name);
|
|
125
125
|
if (videoUrls) {
|
|
126
126
|
attachments = [...attachments, ...videoUrls];
|
|
127
127
|
}
|
package/dist/recorder/request.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.sendToDashboardAsRequest = sendToDashboardAsRequest;
|
|
7
7
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
-
const
|
|
8
|
+
const client_1 = require("../dashboard/client");
|
|
9
9
|
function truncateForDisplay(text, maxLineLength) {
|
|
10
10
|
const lines = text.split("\n");
|
|
11
11
|
return lines
|
|
@@ -174,9 +174,9 @@ async function createRequest({ repoName, title, description, }) {
|
|
|
174
174
|
// TODO: Fix the source and sourceIdentifier
|
|
175
175
|
const source = "cli";
|
|
176
176
|
const sourceIdentifier = "random-string";
|
|
177
|
-
const
|
|
177
|
+
const data = await client_1.apiClient.request("/api/requests", {
|
|
178
178
|
method: "POST",
|
|
179
|
-
body:
|
|
179
|
+
body: {
|
|
180
180
|
source,
|
|
181
181
|
source_identifier: sourceIdentifier,
|
|
182
182
|
title,
|
|
@@ -184,13 +184,8 @@ async function createRequest({ repoName, title, description, }) {
|
|
|
184
184
|
project_repo_name: repoName,
|
|
185
185
|
// TODO: Enable draft requests when we have UX on dashboard sorted
|
|
186
186
|
// status: "draft",
|
|
187
|
-
}
|
|
187
|
+
},
|
|
188
188
|
});
|
|
189
|
-
if (!response.ok) {
|
|
190
|
-
const errorMessage = await response.text();
|
|
191
|
-
throw new Error(`Failed to create request: ${errorMessage}`);
|
|
192
|
-
}
|
|
193
|
-
const data = await response.json();
|
|
194
189
|
const dashboardDomain = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
|
|
195
190
|
const requestUrl = `${dashboardDomain}/${repoName}/requests/${data.data.request.id}`;
|
|
196
191
|
// console.log("Request created successfully:", data);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { ArtifactInputPath, ArtifactInputUrl } from "@empiricalrun/shared-types";
|
|
1
2
|
export declare function waitForSummaryJson(repoDir: string): Promise<void>;
|
|
2
|
-
export declare function extractVideoAttachments(repoDir: string):
|
|
3
|
-
export declare function uploadVideosWithSpinner(
|
|
3
|
+
export declare function extractVideoAttachments(repoDir: string): Array<ArtifactInputPath | ArtifactInputUrl>;
|
|
4
|
+
export declare function uploadVideosWithSpinner(videoArtifacts: Array<ArtifactInputPath | ArtifactInputUrl>, testName: string): Promise<void | string[]>;
|
|
4
5
|
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/recorder/upload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/recorder/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAepC,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,iBAmBvD;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,GACd,KAAK,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,CAoB7C;AAmFD,wBAAsB,uBAAuB,CAC3C,cAAc,EAAE,KAAK,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,EAC3D,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC,CA0B1B"}
|
package/dist/recorder/upload.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.uploadVideosWithSpinner = uploadVideosWithSpinner;
|
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const utils_1 = require("../artifacts/utils");
|
|
12
|
-
const
|
|
12
|
+
const client_1 = require("../dashboard/client");
|
|
13
13
|
const slug_1 = require("../utils/slug");
|
|
14
14
|
const ASSETS_PRODUCTION_BUCKET = "empirical-assets-production";
|
|
15
15
|
const BUCKET_DOMAINS = {
|
|
@@ -46,11 +46,9 @@ function extractVideoAttachments(repoDir) {
|
|
|
46
46
|
return [];
|
|
47
47
|
}
|
|
48
48
|
const summaryContent = JSON.parse(fs_1.default.readFileSync(summaryPath, "utf-8"));
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
.map((attachment) => attachment.path);
|
|
53
|
-
return videoPaths;
|
|
49
|
+
const artifacts = (0, utils_1.extractAttachmentsFromPlaywrightJSONReport)(summaryContent, "temp test");
|
|
50
|
+
const videoArtifacts = artifacts.filter((artifact) => artifact.contentType === "video/webm");
|
|
51
|
+
return videoArtifacts;
|
|
54
52
|
}
|
|
55
53
|
catch (error) {
|
|
56
54
|
console.warn("Error processing summary.json:", error);
|
|
@@ -62,10 +60,11 @@ function buildVideoUrl(localPath, directory, bucket) {
|
|
|
62
60
|
const fileName = path_1.default.basename(localPath);
|
|
63
61
|
return `https://${domain}/${path_1.default.join(directory, fileName)}`;
|
|
64
62
|
}
|
|
65
|
-
async function uploadVideos(
|
|
66
|
-
if (
|
|
63
|
+
async function uploadVideos(videoArtifacts, testSlug) {
|
|
64
|
+
if (videoArtifacts.length === 0) {
|
|
67
65
|
return null;
|
|
68
66
|
}
|
|
67
|
+
const videoPaths = videoArtifacts.map((a) => a.path);
|
|
69
68
|
const uploadDestinationDir = `recorder-uploads/${testSlug}`;
|
|
70
69
|
const bucket = ASSETS_PRODUCTION_BUCKET;
|
|
71
70
|
try {
|
|
@@ -79,22 +78,14 @@ async function uploadVideos(videoPaths, testSlug) {
|
|
|
79
78
|
if (files.length === 0) {
|
|
80
79
|
return null;
|
|
81
80
|
}
|
|
82
|
-
const
|
|
81
|
+
const presignedResult = await client_1.apiClient.request("/api/upload", {
|
|
83
82
|
method: "POST",
|
|
84
|
-
|
|
85
|
-
"Content-Type": "application/json",
|
|
86
|
-
},
|
|
87
|
-
body: JSON.stringify({
|
|
83
|
+
body: {
|
|
88
84
|
files,
|
|
89
85
|
destination_dir: uploadDestinationDir,
|
|
90
86
|
bucket,
|
|
91
|
-
}
|
|
87
|
+
},
|
|
92
88
|
});
|
|
93
|
-
if (!presignedResponse.ok) {
|
|
94
|
-
console.warn(`Failed to get pre-signed URLs: ${presignedResponse.status} ${presignedResponse.statusText}`);
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
const presignedResult = await presignedResponse.json();
|
|
98
89
|
if (presignedResult.error) {
|
|
99
90
|
console.warn("Pre-signed URL error:", presignedResult.error.message);
|
|
100
91
|
return null;
|
|
@@ -126,17 +117,24 @@ async function uploadVideos(videoPaths, testSlug) {
|
|
|
126
117
|
return null;
|
|
127
118
|
}
|
|
128
119
|
}
|
|
129
|
-
async function uploadVideosWithSpinner(
|
|
120
|
+
async function uploadVideosWithSpinner(videoArtifacts, testName) {
|
|
130
121
|
// Use dynamic imports to avoid issues with ESM modules
|
|
131
122
|
// https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
|
132
123
|
const ora = (await import("ora")).default;
|
|
133
124
|
const uploadSpinner = ora("Uploading video recordings...").start();
|
|
134
125
|
try {
|
|
135
126
|
const slugifiedTestName = `${(0, slug_1.slugify)(testName)}-${Math.random().toString(36).substring(2, 8)}`;
|
|
136
|
-
const
|
|
127
|
+
const pathArtifacts = videoArtifacts.filter((v) => "path" in v);
|
|
128
|
+
const urlArtifacts = videoArtifacts.filter((v) => "url" in v);
|
|
129
|
+
const urlsForUrlArtifacts = urlArtifacts.map((v) => v.url);
|
|
130
|
+
if (pathArtifacts.length === 0) {
|
|
131
|
+
uploadSpinner.succeed("Video recordings uploaded successfully");
|
|
132
|
+
return urlsForUrlArtifacts;
|
|
133
|
+
}
|
|
134
|
+
const uploaded = await uploadVideos(pathArtifacts, slugifiedTestName);
|
|
137
135
|
if (uploaded) {
|
|
138
136
|
uploadSpinner.succeed("Video recordings uploaded successfully");
|
|
139
|
-
return uploaded;
|
|
137
|
+
return [...uploaded, ...urlsForUrlArtifacts];
|
|
140
138
|
}
|
|
141
139
|
else {
|
|
142
140
|
uploadSpinner.warn("Video upload skipped or failed");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit-and-create-pr.d.ts","sourceRoot":"","sources":["../../src/tools/commit-and-create-pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"commit-and-create-pr.d.ts","sourceRoot":"","sources":["../../src/tools/commit-and-create-pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AA+BvD,eAAO,MAAM,qBAAqB,EAAE,IAwFnC,CAAC"}
|
|
@@ -5,6 +5,7 @@ const child_process_1 = require("child_process");
|
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const utils_1 = require("./executor/utils");
|
|
7
7
|
const git_1 = require("./executor/utils/git");
|
|
8
|
+
const pr_description_1 = require("./executor/utils/pr-description");
|
|
8
9
|
const createPullRequestSchema = zod_1.z.object({
|
|
9
10
|
pullRequestTitle: zod_1.z
|
|
10
11
|
.string()
|
|
@@ -16,16 +17,6 @@ For example, if you used the test run tool, you should include the results (and
|
|
|
16
17
|
videos and other artifacts that help the reviewer gain more context and confidence in the changes. If tests pass, reviewer will see the video and merge the PR.
|
|
17
18
|
If tests fail, reviewer will see the video and the test artifacts, and will be able to help you debug the issue.`),
|
|
18
19
|
});
|
|
19
|
-
function descriptionWithMetadata(chatSessionId, description) {
|
|
20
|
-
const timestamp = new Date()
|
|
21
|
-
.toISOString()
|
|
22
|
-
.replace("T", " ")
|
|
23
|
-
.replace("Z", " UTC");
|
|
24
|
-
const sessionInfo = chatSessionId
|
|
25
|
-
? `\n\nPR created from session #${chatSessionId}`
|
|
26
|
-
: ``;
|
|
27
|
-
return `${description}${sessionInfo}\n\n<sup>Updated at ${timestamp}</sup>`;
|
|
28
|
-
}
|
|
29
20
|
exports.createPullRequestTool = {
|
|
30
21
|
schema: {
|
|
31
22
|
name: "createPullRequest",
|
|
@@ -40,51 +31,67 @@ Don't ask the user for this information, just come up with it yourself.
|
|
|
40
31
|
parameters: createPullRequestSchema,
|
|
41
32
|
},
|
|
42
33
|
needsBrowser: false,
|
|
43
|
-
execute: async ({ input, repoPath,
|
|
34
|
+
execute: async ({ input, repoPath, apiClient, chatSession }) => {
|
|
44
35
|
try {
|
|
45
36
|
const { pullRequestTitle, pullRequestDescription } = input;
|
|
46
|
-
const
|
|
47
|
-
const repoUrl = (0, child_process_1.execSync)("git config --get remote.origin.url", {
|
|
37
|
+
const remoteUrl = (0, child_process_1.execSync)("git config --get remote.origin.url", {
|
|
48
38
|
cwd: repoPath,
|
|
49
39
|
})
|
|
50
40
|
.toString()
|
|
51
41
|
.trim();
|
|
52
|
-
const { owner, repo } = (0, utils_1.parseGitHubUrl)(
|
|
42
|
+
const { owner, repo } = (0, utils_1.parseGitHubUrl)(remoteUrl);
|
|
43
|
+
const branchName = await (0, git_1.getCurrentBranchName)(repoPath);
|
|
53
44
|
(0, child_process_1.execSync)(`git push origin ${branchName} --set-upstream`, {
|
|
54
45
|
cwd: repoPath,
|
|
55
46
|
});
|
|
56
|
-
|
|
47
|
+
let pullRequest = await (0, utils_1.getExistingPR)({
|
|
57
48
|
owner,
|
|
58
49
|
repo,
|
|
59
50
|
branchName,
|
|
60
|
-
|
|
51
|
+
apiClient,
|
|
61
52
|
});
|
|
62
|
-
if (
|
|
63
|
-
await (0, utils_1.updatePullRequest)({
|
|
53
|
+
if (pullRequest) {
|
|
54
|
+
pullRequest = await (0, utils_1.updatePullRequest)({
|
|
55
|
+
owner,
|
|
56
|
+
repo,
|
|
57
|
+
prNumber: pullRequest.number,
|
|
58
|
+
body: (0, pr_description_1.addMetadataToPRDescription)(pullRequestDescription, chatSession),
|
|
59
|
+
apiClient,
|
|
60
|
+
});
|
|
61
|
+
const mergeableState = await (0, utils_1.getMergeableState)({
|
|
64
62
|
owner,
|
|
65
63
|
repo,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
apiKey,
|
|
64
|
+
pullRequest,
|
|
65
|
+
apiClient,
|
|
69
66
|
});
|
|
67
|
+
const stateDescription = (0, utils_1.getMergeableStateDescription)(mergeableState);
|
|
70
68
|
return {
|
|
71
69
|
isError: false,
|
|
72
|
-
result: `
|
|
70
|
+
result: `Updated existing PR: ${pullRequest.html_url}\n\nMergeable state: ${mergeableState} - ${stateDescription}`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
pullRequest = await (0, utils_1.createPullRequest)({
|
|
75
|
+
owner,
|
|
76
|
+
repo,
|
|
77
|
+
title: pullRequestTitle,
|
|
78
|
+
head: branchName,
|
|
79
|
+
base: "main",
|
|
80
|
+
body: (0, pr_description_1.addMetadataToPRDescription)(pullRequestDescription, chatSession),
|
|
81
|
+
apiClient,
|
|
82
|
+
});
|
|
83
|
+
const mergeableState = await (0, utils_1.getMergeableState)({
|
|
84
|
+
owner,
|
|
85
|
+
repo,
|
|
86
|
+
pullRequest,
|
|
87
|
+
apiClient,
|
|
88
|
+
});
|
|
89
|
+
const stateDescription = (0, utils_1.getMergeableStateDescription)(mergeableState);
|
|
90
|
+
return {
|
|
91
|
+
isError: false,
|
|
92
|
+
result: `Created a new PR: ${pullRequest.html_url}\n\nMergeable state: ${mergeableState} - ${stateDescription}`,
|
|
73
93
|
};
|
|
74
94
|
}
|
|
75
|
-
const pr = await (0, utils_1.createPullRequest)({
|
|
76
|
-
owner,
|
|
77
|
-
repo,
|
|
78
|
-
title: pullRequestTitle,
|
|
79
|
-
head: branchName,
|
|
80
|
-
base: "main",
|
|
81
|
-
body: descriptionWithMetadata(chatSessionId, pullRequestDescription),
|
|
82
|
-
apiKey,
|
|
83
|
-
});
|
|
84
|
-
return {
|
|
85
|
-
isError: false,
|
|
86
|
-
result: `Committed and pushed changes to new PR: ${pr.html_url}`,
|
|
87
|
-
};
|
|
88
95
|
}
|
|
89
96
|
catch (error) {
|
|
90
97
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-file.d.ts","sourceRoot":"","sources":["../../src/tools/delete-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,IAAI,EAEL,MAAM,4BAA4B,CAAC;AAepC,eAAO,MAAM,cAAc,EAAE,IAwE5B,CAAC"}
|