@testver/testver 1.4.2 → 1.4.3
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/dist/index.js +1174 -800
- package/package.json +1 -1
- package/src/ui/static/assets/AIPanel-KQFq4c0Q.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-CAs8fXyS.js +40 -0
- package/src/ui/static/assets/AIStreamUI-p_sMTEDQ.js +9 -0
- package/src/ui/static/assets/{AITestGenPage-D3t2gPAA.js → AITestGenPage-CHaHfmu4.js} +1 -1
- package/src/ui/static/assets/APITestingPage-BSGJY_hd.js +19 -0
- package/src/ui/static/assets/{AboutPage-CjEqKB-q.js → AboutPage-CDa24SCJ.js} +1 -1
- package/src/ui/static/assets/{AdvancedPage-4kAcpE8Y.js → AdvancedPage-BqXP0FLg.js} +1 -1
- package/src/ui/static/assets/{AnalyticsPage-64mYNK2v.js → AnalyticsPage-Lm8noJqC.js} +1 -1
- package/src/ui/static/assets/{AuditLogPage-BQjOzQje.js → AuditLogPage-BvldSIik.js} +1 -1
- package/src/ui/static/assets/ChangesSummary-Cu0_4Ucf.js +3 -0
- package/src/ui/static/assets/{CodeMapPage-B1ezmnlE.js → CodeMapPage-uEjuo3fk.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-t7mpeeSN.js → ConfirmDialog-DtotgVmI.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-YMmCbiBk.js → CoveragePage-jNkQJA1P.js} +1 -1
- package/src/ui/static/assets/{CronBuilder-Nk-K-_8I.js → CronBuilder-D2fERHt9.js} +1 -1
- package/src/ui/static/assets/{Dashboard-BDVxO2V4.js → Dashboard-BaIj_IdQ.js} +1 -1
- package/src/ui/static/assets/{DefectsPage-l8yGeCyR.js → DefectsPage-DH0njYFG.js} +3 -3
- package/src/ui/static/assets/{EmptyState-D1T3JWUr.js → EmptyState-utxlJ0fu.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Dt5RhL-h.js → ExportButton-ouKqn9CU.js} +1 -1
- package/src/ui/static/assets/{FileViewer-CrKgh_cB.js → FileViewer-mU3JloJ6.js} +1 -1
- package/src/ui/static/assets/{GitPage-_4nCEzkJ.js → GitPage-TrX-RqNC.js} +5 -5
- package/src/ui/static/assets/{ImportExportPage-BcR7IQi9.js → ImportExportPage-CIhK_raX.js} +1 -1
- package/src/ui/static/assets/{JiraPushDialog-C2sP4_4h.js → JiraPushDialog-DgEZS-0u.js} +1 -1
- package/src/ui/static/assets/{KpiTile-inmeEsy3.js → KpiTile-BHLE3HVj.js} +1 -1
- package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-CaIf7Jux.js} +1 -1
- package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
- package/src/ui/static/assets/{MediaModal-C5n6sHYi.js → MediaModal-DNM45Uz2.js} +1 -1
- package/src/ui/static/assets/{MobileRunPicker-0h-N2c6d.js → MobileRunPicker-DFKm6_nU.js} +1 -1
- package/src/ui/static/assets/{MobileRunTarget-Bo_xekig.js → MobileRunTarget-DHDoDZ_F.js} +3 -3
- package/src/ui/static/assets/{ModuleExplorer-VGcmK167.js → ModuleExplorer-rni7JbsL.js} +1 -1
- package/src/ui/static/assets/{OutputPage-B_1nPPxE.js → OutputPage-Cn2WCpJ6.js} +1 -1
- package/src/ui/static/assets/{PipelinesPanel-PmmPu8pj.js → PipelinesPanel-D6zWcLtD.js} +1 -1
- package/src/ui/static/assets/{ProfilePage-y7tJNNFd.js → ProfilePage-BKNdkSnx.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-DbfGhRq0.js → ProjectExplorer-5e7J8t-o.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-WuRKtx_h.js → RemoteFileStrip-C1S2aclP.js} +1 -1
- package/src/ui/static/assets/{ReportCard-G52Q6-2i.js → ReportCard-D4EElEe9.js} +2 -2
- package/src/ui/static/assets/{ReportFullView-Bt8UFP2J.js → ReportFullView-2w2ysKRg.js} +1 -1
- package/src/ui/static/assets/{ReportsPage-DMtDi73Q.js → ReportsPage-9Fx-IEwV.js} +2 -2
- package/src/ui/static/assets/{ResultsPage-BI9jpK2N.js → ResultsPage-DPkfGh-K.js} +1 -1
- package/src/ui/static/assets/{RunState-ifC4zi6M.js → RunState-CRuS_bC2.js} +1 -1
- package/src/ui/static/assets/{RunTargets-C7vpCbck.js → RunTargets-CPKBrefj.js} +1 -1
- package/src/ui/static/assets/{ScriptMappingPage-7vHuvhQw.js → ScriptMappingPage-C3K_uyf0.js} +1 -1
- package/src/ui/static/assets/{SearchableDevicePicker-BYxYJNWl.js → SearchableDevicePicker-DubIldKj.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-DSISg7r7.js → SettingsPage-BuZrrlW2.js} +1 -1
- package/src/ui/static/assets/{SharedReportView-BOqKGJmR.js → SharedReportView-ig5hECRk.js} +1 -1
- package/src/ui/static/assets/{SourcesPage-CgqtYGBi.js → SourcesPage-BPkqRqkC.js} +1 -1
- package/src/ui/static/assets/{TestExplorerPage-gYLhCD4d.js → TestExplorerPage-C_jl93GR.js} +3 -3
- package/src/ui/static/assets/{TestManagementPage-wqYTKP7W.js → TestManagementPage-DJiWpCne.js} +2 -2
- package/src/ui/static/assets/{TestPlansPage-DOKX9p6z.js → TestPlansPage-G1lvK1C0.js} +3 -3
- package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
- package/src/ui/static/assets/{TestverCreditsRing-DpMzl3h7.js → TestverCreditsRing-CEBSy3w3.js} +1 -1
- package/src/ui/static/assets/{UncommittedDiffViewer-BxS0zi-p.js → UncommittedDiffViewer-FKvUZcRi.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-B5d0uDU_.js → UserManagementPage-gDGhaHE4.js} +3 -3
- package/src/ui/static/assets/{WorkflowsPage-Bk0DFnFS.js → WorkflowsPage-BACdnU-1.js} +1 -1
- package/src/ui/static/assets/{hiddenLlmProviders-CdhhNa5G.js → hiddenLlmProviders-DzwaR-b9.js} +1 -1
- package/src/ui/static/assets/index-D6sQYc_0.js +47 -0
- package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
- package/src/ui/static/assets/index-aInN0yoR.css +1 -0
- package/src/ui/static/assets/{reportMeta-AKcU_qwq.js → reportMeta-3kxT7BIT.js} +1 -1
- package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
- package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
- package/src/ui/static/assets/{useFeatureFlags-DNkIctil.js → useFeatureFlags-DrhvBp0C.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-D5ysBBvz.js → useJiraConnector-Dwj69Rfh.js} +1 -1
- package/src/ui/static/assets/useOwnership-C1CmzcvJ.js +1 -0
- package/src/ui/static/assets/useSuites-V0AxZYex.js +1 -0
- package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-DT8frjCK.js → useTestExplorer-CUqC18DV.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-OcwQaB1s.js → useTestLifecycle-C2S_vaX2.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-Xm4Bcx3u.js → useTestManagement-DW6AW2mt.js} +2 -2
- package/src/ui/static/assets/{useTestResults-D5EwGIX9.js → useTestResults-yjH1aUy-.js} +1 -1
- package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
- package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-BKPiFyYV.js → vendor-icons-D_Dmmj8d.js} +277 -282
- package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
- package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
- package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
- package/src/ui/static/index.html +5 -5
- package/src/ui/static/assets/AIPanel-B_R-CbrF.js +0 -32
- package/src/ui/static/assets/AIRecordPanel-BRQWIU5h.js +0 -40
- package/src/ui/static/assets/AIStreamUI-C3D989_6.js +0 -9
- package/src/ui/static/assets/APITestingPage-Cmwkiiys.js +0 -19
- package/src/ui/static/assets/ChangesSummary-CY_Vb27i.js +0 -2
- package/src/ui/static/assets/DiffViewer-BIU09a_i.js +0 -2
- package/src/ui/static/assets/index-BYVxKLrT.js +0 -47
- package/src/ui/static/assets/index-C2KJt7SI.css +0 -1
- package/src/ui/static/assets/useOwnership-U0AfKBRo.js +0 -1
- package/src/ui/static/assets/useSuites-DyfN9HVv.js +0 -1
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
package/dist/index.js
CHANGED
|
@@ -4185,7 +4185,7 @@ ${pattern}
|
|
|
4185
4185
|
dir = up;
|
|
4186
4186
|
}
|
|
4187
4187
|
}
|
|
4188
|
-
function npmScriptRunning(command, cwd,
|
|
4188
|
+
function npmScriptRunning(command, cwd, runs4) {
|
|
4189
4189
|
const m = /^\s*(npm|yarn|pnpm)\s+(?:(test|t)\b|run(?:-script)?\s+([\w:.-]+))(\s+--(\s|$))?/i.exec(command);
|
|
4190
4190
|
if (!m) return void 0;
|
|
4191
4191
|
if (/[;&|]/.test(command)) return void 0;
|
|
@@ -4195,7 +4195,7 @@ function npmScriptRunning(command, cwd, runs3) {
|
|
|
4195
4195
|
try {
|
|
4196
4196
|
const pkg = JSON.parse(readFileSync(join4(cwd, "package.json"), "utf-8"));
|
|
4197
4197
|
const body = pkg.scripts?.[script];
|
|
4198
|
-
if (!body || /&&|\|\||;|\|/.test(body) || !
|
|
4198
|
+
if (!body || /&&|\|\||;|\|/.test(body) || !runs4(body)) return void 0;
|
|
4199
4199
|
return { script, scriptCommand: body, hasDashDash: !!m[4], needsDashDash: tool === "npm" };
|
|
4200
4200
|
} catch {
|
|
4201
4201
|
return void 0;
|
|
@@ -22939,7 +22939,7 @@ function readOrNull(abs) {
|
|
|
22939
22939
|
function holdVendorFiles(dir, root = dir) {
|
|
22940
22940
|
const held = [];
|
|
22941
22941
|
const journal = readVendorJournal(root);
|
|
22942
|
-
let
|
|
22942
|
+
let changed2 = false;
|
|
22943
22943
|
for (const rel of VENDOR_CONFIG_DIRS) {
|
|
22944
22944
|
const abs = join41(dir, rel);
|
|
22945
22945
|
const hold = dirHolds.get(abs);
|
|
@@ -22949,7 +22949,7 @@ function holdVendorFiles(dir, root = dir) {
|
|
|
22949
22949
|
dirHolds.set(abs, { existed, holders: 1, root });
|
|
22950
22950
|
if (!existed) {
|
|
22951
22951
|
journal.dirs[abs] = { existed };
|
|
22952
|
-
|
|
22952
|
+
changed2 = true;
|
|
22953
22953
|
}
|
|
22954
22954
|
}
|
|
22955
22955
|
held.push(abs);
|
|
@@ -22962,11 +22962,11 @@ function holdVendorFiles(dir, root = dir) {
|
|
|
22962
22962
|
const original = readOrNull(abs);
|
|
22963
22963
|
fileHolds.set(abs, { original, holders: 1, root });
|
|
22964
22964
|
journal.files[abs] = { original: original ? original.toString("base64") : null, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
22965
|
-
|
|
22965
|
+
changed2 = true;
|
|
22966
22966
|
}
|
|
22967
22967
|
held.push(abs);
|
|
22968
22968
|
}
|
|
22969
|
-
if (
|
|
22969
|
+
if (changed2) writeJournal(root, journal);
|
|
22970
22970
|
return held;
|
|
22971
22971
|
}
|
|
22972
22972
|
function noteVendorFilesWritten(held) {
|
|
@@ -29778,8 +29778,8 @@ var init_ci_store = __esm({
|
|
|
29778
29778
|
tokens: Array.isArray(cfg.tokens) ? cfg.tokens : []
|
|
29779
29779
|
};
|
|
29780
29780
|
}
|
|
29781
|
-
const
|
|
29782
|
-
this.runs = Array.isArray(
|
|
29781
|
+
const runs4 = readJsonWithBackup(this.runsPath);
|
|
29782
|
+
this.runs = Array.isArray(runs4) ? runs4 : [];
|
|
29783
29783
|
}
|
|
29784
29784
|
persistConfig() {
|
|
29785
29785
|
try {
|
|
@@ -32872,15 +32872,15 @@ function stampSkip(runId, testNames, reason, force = false) {
|
|
|
32872
32872
|
const { resultsStore: resultsStore4 } = deps;
|
|
32873
32873
|
const fresh = resultsStore4.getRun(runId);
|
|
32874
32874
|
if (!fresh) return;
|
|
32875
|
-
let
|
|
32875
|
+
let changed2 = false;
|
|
32876
32876
|
const failedRow = (t) => t.status === "failed" || t.status === "error";
|
|
32877
32877
|
for (const t of fresh.tests) {
|
|
32878
32878
|
if (testNames.includes(t.name) && failedRow(t) && (!t.autoHeal || force)) {
|
|
32879
32879
|
t.autoHealSkip = { reason, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
32880
|
-
|
|
32880
|
+
changed2 = true;
|
|
32881
32881
|
}
|
|
32882
32882
|
}
|
|
32883
|
-
if (
|
|
32883
|
+
if (changed2) resultsStore4.saveRun(fresh, { skipHistory: true });
|
|
32884
32884
|
if (fresh.parentRunId) {
|
|
32885
32885
|
const parent = resultsStore4.getRun(fresh.parentRunId);
|
|
32886
32886
|
if (parent) {
|
|
@@ -32938,8 +32938,8 @@ function findPendingSuggestion(sites) {
|
|
|
32938
32938
|
const windowMs = systemConfig.getAutoHeal().reviewWindowDays * 864e5;
|
|
32939
32939
|
const want = sites.map((s) => `${s.file}|${s.find}`).sort().join("\n");
|
|
32940
32940
|
try {
|
|
32941
|
-
const { runs:
|
|
32942
|
-
for (const r of
|
|
32941
|
+
const { runs: runs4 } = resultsStore4.getRunHistory(200, 0);
|
|
32942
|
+
for (const r of runs4) {
|
|
32943
32943
|
for (const t of r.tests) {
|
|
32944
32944
|
const s = t.autoHeal;
|
|
32945
32945
|
if (s?.state !== "suggested" || !s.pairs?.length) continue;
|
|
@@ -32997,9 +32997,9 @@ function flipIdenticalSuggestions(targets) {
|
|
|
32997
32997
|
const { resultsStore: resultsStore4 } = deps;
|
|
32998
32998
|
const want = targets.map((t) => `${t.file}|${t.find}|${t.replace}`).sort().join("\n");
|
|
32999
32999
|
try {
|
|
33000
|
-
const { runs:
|
|
33001
|
-
const all = [...
|
|
33002
|
-
for (const r of
|
|
33000
|
+
const { runs: runs4 } = resultsStore4.getRunHistory(500, 0);
|
|
33001
|
+
const all = [...runs4];
|
|
33002
|
+
for (const r of runs4) {
|
|
33003
33003
|
for (const t of r.tests) if (t.childRunId) {
|
|
33004
33004
|
const c2 = resultsStore4.getRun(t.childRunId);
|
|
33005
33005
|
if (c2) all.push(c2);
|
|
@@ -34722,9 +34722,9 @@ function mountRunnerRoutes(app, wss, scanner, options, resultsStore4, cloudConfi
|
|
|
34722
34722
|
let estimatedDuration;
|
|
34723
34723
|
let estimatedTotal;
|
|
34724
34724
|
try {
|
|
34725
|
-
const { runs:
|
|
34726
|
-
const recentDurations =
|
|
34727
|
-
const recentTotals =
|
|
34725
|
+
const { runs: runs4 } = resultsStore4.getRunHistory(5, 0);
|
|
34726
|
+
const recentDurations = runs4.filter((r) => r.duration && r.duration > 0).map((r) => r.duration);
|
|
34727
|
+
const recentTotals = runs4.filter((r) => r.summary?.total > 0).map((r) => r.summary.total);
|
|
34728
34728
|
if (recentDurations.length > 0) estimatedDuration = Math.round(recentDurations.reduce((a, b) => a + b, 0) / recentDurations.length);
|
|
34729
34729
|
if (recentTotals.length > 0) estimatedTotal = Math.round(recentTotals.reduce((a, b) => a + b, 0) / recentTotals.length);
|
|
34730
34730
|
} catch {
|
|
@@ -35291,8 +35291,8 @@ ${closing.stderr}`, mobileAppRef)) {
|
|
|
35291
35291
|
res.json({ ticket: t });
|
|
35292
35292
|
});
|
|
35293
35293
|
app.get("/api/runner/runs/live", (_req, res) => {
|
|
35294
|
-
const
|
|
35295
|
-
res.json({ runs:
|
|
35294
|
+
const runs4 = Array.from(activeRuns.entries()).filter(([, e]) => e.cloudProvider === "testver-grid").map(([runId, e]) => ({ runId, gridRunId: e.gridRunId ?? null, browser: e.gridBrowser ?? null, command: e.result.command || "", startTime: e.result.startTime, source: e.source }));
|
|
35295
|
+
res.json({ runs: runs4 });
|
|
35296
35296
|
});
|
|
35297
35297
|
app.get("/api/runner/runs/:id/live", async (req, res) => {
|
|
35298
35298
|
const runId = req.params.id;
|
|
@@ -43510,12 +43510,12 @@ async function buildFetchOptions(request, vars, baseDir = process.cwd()) {
|
|
|
43510
43510
|
if (!field.enabled || !field.key) continue;
|
|
43511
43511
|
const resolvedKey = resolveVariables(field.key, vars);
|
|
43512
43512
|
if (field.fieldType === "file" && field.filePath) {
|
|
43513
|
-
const { readFileSync:
|
|
43513
|
+
const { readFileSync: readFileSync103 } = await import("fs");
|
|
43514
43514
|
const { resolve: resolve36, basename: basename31 } = await import("path");
|
|
43515
43515
|
const rel = resolveVariables(String(field.filePath), vars);
|
|
43516
43516
|
let buffer;
|
|
43517
43517
|
try {
|
|
43518
|
-
buffer =
|
|
43518
|
+
buffer = readFileSync103(resolve36(baseDir, rel));
|
|
43519
43519
|
} catch (err5) {
|
|
43520
43520
|
throw new Error(`Cannot read upload file "${rel}": ${err5.message}`);
|
|
43521
43521
|
}
|
|
@@ -43567,12 +43567,12 @@ async function fetchFor(connection, vars, baseDir) {
|
|
|
43567
43567
|
const undici = await import("undici");
|
|
43568
43568
|
let dispatcher = dispatchers.get(key2);
|
|
43569
43569
|
if (!dispatcher) {
|
|
43570
|
-
const { readFileSync:
|
|
43570
|
+
const { readFileSync: readFileSync103 } = await import("fs");
|
|
43571
43571
|
const { resolve: resolve36 } = await import("path");
|
|
43572
43572
|
const read5 = (p2) => {
|
|
43573
43573
|
if (!p2) return void 0;
|
|
43574
43574
|
try {
|
|
43575
|
-
return
|
|
43575
|
+
return readFileSync103(resolve36(baseDir, p2));
|
|
43576
43576
|
} catch (err5) {
|
|
43577
43577
|
throw new Error(`Cannot read certificate file "${p2}": ${err5.message}`);
|
|
43578
43578
|
}
|
|
@@ -46013,7 +46013,7 @@ var init_api_testing = __esm({
|
|
|
46013
46013
|
category: "api-testing",
|
|
46014
46014
|
definition: {
|
|
46015
46015
|
name: "api_request",
|
|
46016
|
-
description: "Send
|
|
46016
|
+
description: "Send a one-off HTTP request to a REST or GraphQL API endpoint. Returns status code, headers, response body, and timing information. If the request is already saved in a collection, use api_send_collection_request instead.",
|
|
46017
46017
|
parameters: {
|
|
46018
46018
|
type: "object",
|
|
46019
46019
|
properties: {
|
|
@@ -47042,7 +47042,7 @@ Verify the provider with api_pact_verify pact_file="${out}".`;
|
|
|
47042
47042
|
handler: async (args2, ctx) => {
|
|
47043
47043
|
if (!apiStore) return "Error: API testing store not initialized";
|
|
47044
47044
|
const { readFile: readFile16, writeFile: writeFile11, mkdir: mkdir8 } = await import("fs/promises");
|
|
47045
|
-
const { resolve: resolve36, join:
|
|
47045
|
+
const { resolve: resolve36, join: join128 } = await import("path");
|
|
47046
47046
|
if (!args2.file_path && !args2.url) return "Error: pass file_path or url";
|
|
47047
47047
|
let content;
|
|
47048
47048
|
let savedAs;
|
|
@@ -47077,10 +47077,10 @@ Verify the provider with api_pact_verify pact_file="${out}".`;
|
|
|
47077
47077
|
}
|
|
47078
47078
|
})();
|
|
47079
47079
|
const ext = /^\s*[{[]/.test(content) ? "json" : "yaml";
|
|
47080
|
-
const dir =
|
|
47080
|
+
const dir = join128(ctx.workingDirectory, ".testver", "specs");
|
|
47081
47081
|
await mkdir8(dir, { recursive: true });
|
|
47082
47082
|
savedAs = `.testver/specs/${host}-openapi.${ext}`;
|
|
47083
|
-
await writeFile11(
|
|
47083
|
+
await writeFile11(join128(ctx.workingDirectory, savedAs), content, "utf-8");
|
|
47084
47084
|
}
|
|
47085
47085
|
const { importOpenApiSpec: importOpenApiSpec2 } = await Promise.resolve().then(() => (init_openapi_importer(), openapi_importer_exports));
|
|
47086
47086
|
const collection = importOpenApiSpec2(content);
|
|
@@ -51298,7 +51298,7 @@ var init_dist = __esm({
|
|
|
51298
51298
|
},
|
|
51299
51299
|
{
|
|
51300
51300
|
key: "join",
|
|
51301
|
-
value: function
|
|
51301
|
+
value: function join128(s) {
|
|
51302
51302
|
if (this.length === 0) return "";
|
|
51303
51303
|
var p2 = this.head;
|
|
51304
51304
|
var ret = "" + p2.data;
|
|
@@ -69939,7 +69939,7 @@ var init_dist = __esm({
|
|
|
69939
69939
|
pathToParagraph: []
|
|
69940
69940
|
};
|
|
69941
69941
|
let currentRunStringLength = 0;
|
|
69942
|
-
const
|
|
69942
|
+
const runs4 = node.element.elements.map((element, i) => ({
|
|
69943
69943
|
element,
|
|
69944
69944
|
i
|
|
69945
69945
|
})).filter(({ element }) => element.name === "w:r").map(({ element, i }) => {
|
|
@@ -69948,8 +69948,8 @@ var init_dist = __esm({
|
|
|
69948
69948
|
return renderedRunNode;
|
|
69949
69949
|
}).filter((e) => !!e);
|
|
69950
69950
|
return {
|
|
69951
|
-
text:
|
|
69952
|
-
runs:
|
|
69951
|
+
text: runs4.reduce((acc, curr) => acc + curr.text, ""),
|
|
69952
|
+
runs: runs4,
|
|
69953
69953
|
index: node.index,
|
|
69954
69954
|
pathToParagraph: buildNodePath(node)
|
|
69955
69955
|
};
|
|
@@ -70736,17 +70736,17 @@ function withCellAddresses(buf) {
|
|
|
70736
70736
|
} catch {
|
|
70737
70737
|
return buf;
|
|
70738
70738
|
}
|
|
70739
|
-
let
|
|
70739
|
+
let changed2 = false;
|
|
70740
70740
|
for (const name2 of Object.keys(files)) {
|
|
70741
70741
|
if (!SHEET_XML.test(name2)) continue;
|
|
70742
70742
|
const xml = strFromU8(files[name2]);
|
|
70743
70743
|
const fixed = addAddresses(xml);
|
|
70744
70744
|
if (fixed !== xml) {
|
|
70745
70745
|
files[name2] = strToU8(fixed);
|
|
70746
|
-
|
|
70746
|
+
changed2 = true;
|
|
70747
70747
|
}
|
|
70748
70748
|
}
|
|
70749
|
-
return
|
|
70749
|
+
return changed2 ? zipSync(files) : buf;
|
|
70750
70750
|
}
|
|
70751
70751
|
function addAddresses(xml) {
|
|
70752
70752
|
const missing = /<(?:\w+:)?c\b(?![^>]*\sr\s*=)[^>]*>/.test(xml) || /<(?:\w+:)?row\b(?![^>]*\sr\s*=)[^>]*>/.test(xml);
|
|
@@ -74298,9 +74298,9 @@ function describeWindow(sinceMs, untilMs) {
|
|
|
74298
74298
|
if (sinceMs != null && untilMs != null) return `${f(sinceMs)} \u2013 ${f(untilMs)}`;
|
|
74299
74299
|
return sinceMs != null ? `since ${f(sinceMs)}` : `until ${f(untilMs)}`;
|
|
74300
74300
|
}
|
|
74301
|
-
function summarizeRuns(
|
|
74301
|
+
function summarizeRuns(runs4) {
|
|
74302
74302
|
let totalTests = 0, passed = 0, failed = 0, skipped = 0, rateSum = 0, rated = 0, duration = 0, timed = 0;
|
|
74303
|
-
for (const r of
|
|
74303
|
+
for (const r of runs4) {
|
|
74304
74304
|
const s = r.summary;
|
|
74305
74305
|
if (!s) continue;
|
|
74306
74306
|
totalTests += s.total || 0;
|
|
@@ -74317,9 +74317,9 @@ function summarizeRuns(runs3) {
|
|
|
74317
74317
|
}
|
|
74318
74318
|
}
|
|
74319
74319
|
const round12 = (n) => Math.round(n * 10) / 10;
|
|
74320
|
-
const times =
|
|
74320
|
+
const times = runs4.map((r) => Date.parse(r.startTime)).filter(Number.isFinite);
|
|
74321
74321
|
return {
|
|
74322
|
-
runs:
|
|
74322
|
+
runs: runs4.length,
|
|
74323
74323
|
totalTests,
|
|
74324
74324
|
passed,
|
|
74325
74325
|
failed,
|
|
@@ -74406,8 +74406,8 @@ async function handleAutomationReport(args2) {
|
|
|
74406
74406
|
// ── Runs ────────────────────────────────────────────────────────────
|
|
74407
74407
|
case "list_runs": {
|
|
74408
74408
|
const inWindow = resultsStore.runsIn({ sinceMs: win.sinceMs, untilMs: win.untilMs });
|
|
74409
|
-
const
|
|
74410
|
-
return ok({ total: inWindow.length, returned:
|
|
74409
|
+
const runs4 = inWindow.slice(0, limit ?? 20);
|
|
74410
|
+
return ok({ total: inWindow.length, returned: runs4.length, window: scope.window, runs: runs4.map(runRow) }, format2);
|
|
74411
74411
|
}
|
|
74412
74412
|
case "get_run": {
|
|
74413
74413
|
const runId = String(args2.runId || args2.id || "");
|
|
@@ -74532,15 +74532,15 @@ async function handleAutomationReport(args2) {
|
|
|
74532
74532
|
// ── High-level summary ──────────────────────────────────────────────
|
|
74533
74533
|
case "summary": {
|
|
74534
74534
|
const inScope = resultsStore.runsIn(statsWindow);
|
|
74535
|
-
const
|
|
74536
|
-
if (
|
|
74535
|
+
const runs4 = windowed ? limit ? inScope.slice(0, limit) : inScope : inScope.slice(0, limit ?? 20);
|
|
74536
|
+
if (runs4.length === 0) {
|
|
74537
74537
|
return ok({ ...scope, runs: 0, message: "No finished runs in the requested window." }, format2);
|
|
74538
74538
|
}
|
|
74539
74539
|
const all = resultsStore.runsIn({ sinceMs: win.sinceMs, untilMs: win.untilMs });
|
|
74540
74540
|
return ok({
|
|
74541
74541
|
...scope,
|
|
74542
|
-
basis: windowed ? "every finished run in the window" : `the newest ${
|
|
74543
|
-
...summarizeRuns(
|
|
74542
|
+
basis: windowed ? "every finished run in the window" : `the newest ${runs4.length} finished runs`,
|
|
74543
|
+
...summarizeRuns(runs4),
|
|
74544
74544
|
note: `passRatePct = passed \xF7 executed tests across these runs. avgRunPassRatePct = the average of each run's own pass rate (how the Results page's "Avg Pass Rate" is computed).`,
|
|
74545
74545
|
leftOut: {
|
|
74546
74546
|
unfinished: all.filter((r) => r.status === "running" || r.status === "cancelled").length,
|
|
@@ -74954,12 +74954,12 @@ async function handleSuitesReport(args2) {
|
|
|
74954
74954
|
if (!ref) return err3("suiteId (or name) is required for get_suite_runs.");
|
|
74955
74955
|
const s = findSuite(ref);
|
|
74956
74956
|
if (!s) return err3(`Suite "${ref}" not found. Use list_suites to see available suites.`);
|
|
74957
|
-
let
|
|
74957
|
+
let runs4 = (s.history || []).map(runRow2);
|
|
74958
74958
|
if (s.lastRun && !(s.history || []).some((r) => r.id === s.lastRun.id)) {
|
|
74959
|
-
|
|
74959
|
+
runs4 = [runRow2(s.lastRun), ...runs4];
|
|
74960
74960
|
}
|
|
74961
|
-
if (limit)
|
|
74962
|
-
return ok3({ note: HISTORY_NOTE, suiteId: s.id, suiteName: s.name, runCount:
|
|
74961
|
+
if (limit) runs4 = runs4.slice(0, limit);
|
|
74962
|
+
return ok3({ note: HISTORY_NOTE, suiteId: s.id, suiteName: s.name, runCount: runs4.length, runs: runs4 }, format2);
|
|
74963
74963
|
}
|
|
74964
74964
|
case "get_suite_run": {
|
|
74965
74965
|
const ref = String(args2.suiteId || args2.name || "");
|
|
@@ -76004,11 +76004,11 @@ function mdHeight(doc, m, w) {
|
|
|
76004
76004
|
return PAD + markdownBlocks(m.content).reduce((h, b) => h + mdBlockHeight(doc, b, w - PAD * 2), 0) + PAD - 4;
|
|
76005
76005
|
}
|
|
76006
76006
|
function drawRuns(doc, text3, x, y, w, size, color, baseBold = false) {
|
|
76007
|
-
const
|
|
76007
|
+
const runs4 = inlineRuns(text3);
|
|
76008
76008
|
doc.fillColor(color);
|
|
76009
|
-
|
|
76009
|
+
runs4.forEach((r, i) => {
|
|
76010
76010
|
const font = r.code ? F.mono : r.bold || baseBold ? F.bold : F.regular;
|
|
76011
|
-
const opts = { width: w, lineGap: 1.5, continued: i <
|
|
76011
|
+
const opts = { width: w, lineGap: 1.5, continued: i < runs4.length - 1 };
|
|
76012
76012
|
doc.font(font).fontSize(r.code ? size - 0.6 : size).fillColor(r.bold ? REPORT_THEME.heading : color);
|
|
76013
76013
|
if (i === 0) doc.text(pdfSafe(r.text), x, y, opts);
|
|
76014
76014
|
else doc.text(pdfSafe(r.text), opts);
|
|
@@ -76615,10 +76615,10 @@ function scopeFor2(sinceMs, untilMs, fallbackCount = 20) {
|
|
|
76615
76615
|
const windowed = sinceMs != null || untilMs != null;
|
|
76616
76616
|
const window2 = { sinceMs, untilMs, excludeOrigins: VERIFICATION_ORIGINS, finishedOnly: true };
|
|
76617
76617
|
const all = resultsStore2.runsIn(window2);
|
|
76618
|
-
const
|
|
76619
|
-
const span2 =
|
|
76620
|
-
const label4 = windowed ? describeWindow(sinceMs, untilMs) : `Last ${
|
|
76621
|
-
return { window: window2, runs:
|
|
76618
|
+
const runs4 = windowed ? all : all.slice(0, fallbackCount);
|
|
76619
|
+
const span2 = runs4.length > 0 ? describeWindow(Date.parse(runs4[runs4.length - 1].startTime), Date.parse(runs4[0].startTime)) : "no runs";
|
|
76620
|
+
const label4 = windowed ? describeWindow(sinceMs, untilMs) : `Last ${runs4.length} runs (${span2})`;
|
|
76621
|
+
return { window: window2, runs: runs4, label: label4, windowed };
|
|
76622
76622
|
}
|
|
76623
76623
|
function runLabel(r, i) {
|
|
76624
76624
|
const t = Date.parse(r.startTime || r.timestamp || "");
|
|
@@ -76708,16 +76708,16 @@ function buildQaDaily(scope) {
|
|
|
76708
76708
|
cells.push({ type: "chart", title: "Test status", chartType: "doughnut", labels: ["Passed", "Failed", "Skipped"], data: [sum.passed, sum.failed, sum.skipped], colorScheme: "status", span: 6 });
|
|
76709
76709
|
}
|
|
76710
76710
|
if (recent.length > 0) {
|
|
76711
|
-
const
|
|
76711
|
+
const runs4 = recent.slice(0, 12).reverse();
|
|
76712
76712
|
cells.push({
|
|
76713
76713
|
type: "chart",
|
|
76714
76714
|
title: "Results per run",
|
|
76715
76715
|
chartType: "stacked_bar",
|
|
76716
|
-
labels:
|
|
76716
|
+
labels: runs4.map(runLabel),
|
|
76717
76717
|
datasets: [
|
|
76718
|
-
{ label: "Passed", data:
|
|
76719
|
-
{ label: "Failed", data:
|
|
76720
|
-
{ label: "Skipped", data:
|
|
76718
|
+
{ label: "Passed", data: runs4.map((r) => r.summary?.passed ?? 0) },
|
|
76719
|
+
{ label: "Failed", data: runs4.map((r) => r.summary?.failed ?? 0) },
|
|
76720
|
+
{ label: "Skipped", data: runs4.map((r) => r.summary?.skipped ?? 0) }
|
|
76721
76721
|
],
|
|
76722
76722
|
colorScheme: "status",
|
|
76723
76723
|
span: 6
|
|
@@ -76735,12 +76735,12 @@ function buildQaDaily(scope) {
|
|
|
76735
76735
|
return { title: "QA Daily Report", cells };
|
|
76736
76736
|
}
|
|
76737
76737
|
function buildRelease(scope, baselineRunId) {
|
|
76738
|
-
const
|
|
76739
|
-
const latest =
|
|
76738
|
+
const runs4 = scope.runs;
|
|
76739
|
+
const latest = runs4[0];
|
|
76740
76740
|
if (!latest) {
|
|
76741
76741
|
return { title: "Release Readiness Report", cells: [{ type: "markdown", content: "## No data\nNo finished runs found. Run at least one test suite before generating a release report." }] };
|
|
76742
76742
|
}
|
|
76743
|
-
const baseline = baselineRunId ? resultsStore2.getRun(baselineRunId) : resultsStore2.getBaseline()?.run ??
|
|
76743
|
+
const baseline = baselineRunId ? resultsStore2.getRun(baselineRunId) : resultsStore2.getBaseline()?.run ?? runs4[1];
|
|
76744
76744
|
const cmp = baseline ? resultsStore2.getRunComparison(baseline.runId, latest.runId) : null;
|
|
76745
76745
|
const latestRate = latest.summary?.passRate ?? 0;
|
|
76746
76746
|
const cells = [
|
|
@@ -77731,20 +77731,20 @@ function cell(v, fallback = "\u2014") {
|
|
|
77731
77731
|
const s = String(v ?? "").trim();
|
|
77732
77732
|
return s ? s.replace(/\|/g, "\\|") : fallback;
|
|
77733
77733
|
}
|
|
77734
|
-
function statusBadge(status,
|
|
77734
|
+
function statusBadge(status, runs4) {
|
|
77735
77735
|
const s = String(status || "").toLowerCase();
|
|
77736
77736
|
if (s.startsWith("auto") || s === "green" || s === "passed") return "\u2705 automated";
|
|
77737
77737
|
if (s.startsWith("quar") || s === "failed") return "\u26A0 quarantined";
|
|
77738
77738
|
if (s.startsWith("skip")) return "\u23ED skipped";
|
|
77739
|
-
const passed =
|
|
77740
|
-
const total =
|
|
77739
|
+
const passed = runs4?.passed ?? 0;
|
|
77740
|
+
const total = runs4?.total ?? 0;
|
|
77741
77741
|
if (total > 0 && passed >= 2 && passed === total) return "\u2705 automated";
|
|
77742
77742
|
if (total > 0) return "\u26A0 quarantined";
|
|
77743
77743
|
return "\u23ED skipped";
|
|
77744
77744
|
}
|
|
77745
|
-
function verifiedCell(
|
|
77746
|
-
const passed =
|
|
77747
|
-
const total =
|
|
77745
|
+
function verifiedCell(runs4) {
|
|
77746
|
+
const passed = runs4?.passed;
|
|
77747
|
+
const total = runs4?.total;
|
|
77748
77748
|
if (typeof passed !== "number" || typeof total !== "number") return "not recorded";
|
|
77749
77749
|
return `${passed}/${total} green`;
|
|
77750
77750
|
}
|
|
@@ -78287,7 +78287,7 @@ function makeScorer(df, total) {
|
|
|
78287
78287
|
function exploreRuns(projectPath2) {
|
|
78288
78288
|
const root = join68(projectPath2, ".testver", "explore");
|
|
78289
78289
|
if (!existsSync67(root)) return [];
|
|
78290
|
-
const
|
|
78290
|
+
const runs4 = [];
|
|
78291
78291
|
let names = [];
|
|
78292
78292
|
try {
|
|
78293
78293
|
names = readdirSync33(root);
|
|
@@ -78327,9 +78327,9 @@ function exploreRuns(projectPath2) {
|
|
|
78327
78327
|
}
|
|
78328
78328
|
} catch {
|
|
78329
78329
|
}
|
|
78330
|
-
|
|
78330
|
+
runs4.push({ id: n, dir, files, pages });
|
|
78331
78331
|
}
|
|
78332
|
-
return
|
|
78332
|
+
return runs4;
|
|
78333
78333
|
}
|
|
78334
78334
|
function runTime(run2, plan) {
|
|
78335
78335
|
for (const k of ["startedAt", "started_at", "createdAt", "created_at", "date"]) {
|
|
@@ -78741,7 +78741,7 @@ function indexAutomation(lib, linked) {
|
|
|
78741
78741
|
}
|
|
78742
78742
|
async function getIndex(projectPath2) {
|
|
78743
78743
|
const store4 = tmStore4;
|
|
78744
|
-
const
|
|
78744
|
+
const runs4 = exploreRuns(projectPath2);
|
|
78745
78745
|
const sources = toArray(store4.listSourceSummaries({ status: "active" }), "sources");
|
|
78746
78746
|
let lib = null;
|
|
78747
78747
|
let libProblem = "";
|
|
@@ -78752,7 +78752,7 @@ async function getIndex(projectPath2) {
|
|
|
78752
78752
|
}
|
|
78753
78753
|
const key2 = [
|
|
78754
78754
|
resolve18(projectPath2),
|
|
78755
|
-
|
|
78755
|
+
runs4.map((r) => `${r.id}:${r.files.map((f) => `${f.name}@${f.mtime}:${f.size}`).join(",")}`).join(";"),
|
|
78756
78756
|
store4.knowledgeFingerprint(),
|
|
78757
78757
|
resultsStore3?.changeStamp() ?? "",
|
|
78758
78758
|
lib?.stamp ?? libProblem,
|
|
@@ -78768,7 +78768,7 @@ async function getIndex(projectPath2) {
|
|
|
78768
78768
|
problems.push(`defects: ${e.message}`);
|
|
78769
78769
|
}
|
|
78770
78770
|
const isFiled = filedMatcher(defects);
|
|
78771
|
-
for (const run2 of
|
|
78771
|
+
for (const run2 of runs4) {
|
|
78772
78772
|
try {
|
|
78773
78773
|
entries.push(...indexRun(run2, isFiled));
|
|
78774
78774
|
} catch (e) {
|
|
@@ -78832,7 +78832,7 @@ async function getIndex(projectPath2) {
|
|
|
78832
78832
|
entries,
|
|
78833
78833
|
df: documentFrequencies(entries),
|
|
78834
78834
|
problems,
|
|
78835
|
-
totals: { runs:
|
|
78835
|
+
totals: { runs: runs4.length, testCases, documents, requirements, openDefects, resolvedDefects, automated, automatedLinked }
|
|
78836
78836
|
};
|
|
78837
78837
|
indexCache = { key: key2, index };
|
|
78838
78838
|
return index;
|
|
@@ -79332,9 +79332,9 @@ function median(xs) {
|
|
|
79332
79332
|
const m = Math.floor(s.length / 2);
|
|
79333
79333
|
return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2;
|
|
79334
79334
|
}
|
|
79335
|
-
function clusterOf(
|
|
79336
|
-
const failed =
|
|
79337
|
-
const passed =
|
|
79335
|
+
function clusterOf(runs4, key2, noun) {
|
|
79336
|
+
const failed = runs4.filter((r) => isFailing(r.status));
|
|
79337
|
+
const passed = runs4.filter((r) => r.status === "passed");
|
|
79338
79338
|
if (failed.length < 2 || passed.length === 0) return void 0;
|
|
79339
79339
|
const values = new Set(failed.map(key2));
|
|
79340
79340
|
if (values.size !== 1) return void 0;
|
|
@@ -79347,7 +79347,7 @@ function testRunHistory(testName) {
|
|
|
79347
79347
|
if (!resultsStore3) return void 0;
|
|
79348
79348
|
const entries = resultsStore3.getTestHistory(testName);
|
|
79349
79349
|
if (entries.length === 0) return void 0;
|
|
79350
|
-
const
|
|
79350
|
+
const runs4 = entries.map((h) => {
|
|
79351
79351
|
const failed2 = isFailing(h.status);
|
|
79352
79352
|
const error = failed2 ? firstLine(resultsStore3.getRun(h.runId)?.tests.find((t) => t.name === testName)?.errorMessage, 140) : "";
|
|
79353
79353
|
return {
|
|
@@ -79360,36 +79360,36 @@ function testRunHistory(testName) {
|
|
|
79360
79360
|
error: error || void 0
|
|
79361
79361
|
};
|
|
79362
79362
|
});
|
|
79363
|
-
const passed =
|
|
79364
|
-
const failed =
|
|
79365
|
-
const outcomes =
|
|
79363
|
+
const passed = runs4.filter((r) => r.status === "passed").length;
|
|
79364
|
+
const failed = runs4.filter((r) => isFailing(r.status)).length;
|
|
79365
|
+
const outcomes = runs4.filter((r) => r.status === "passed" || isFailing(r.status)).map((r) => r.status === "passed");
|
|
79366
79366
|
let changes = 0;
|
|
79367
79367
|
for (let i = 1; i < outcomes.length; i++) if (outcomes[i] !== outcomes[i - 1]) changes++;
|
|
79368
79368
|
const flakyRow = resultsStore3.getFlaky().find((f) => f.testName === testName);
|
|
79369
79369
|
let failingSince;
|
|
79370
|
-
if (isFailing(
|
|
79370
|
+
if (isFailing(runs4[0]?.status)) {
|
|
79371
79371
|
let n = 0;
|
|
79372
|
-
while (n <
|
|
79373
|
-
failingSince = { at:
|
|
79372
|
+
while (n < runs4.length && isFailing(runs4[n].status)) n++;
|
|
79373
|
+
failingSince = { at: runs4[n - 1].at, count: n };
|
|
79374
79374
|
}
|
|
79375
|
-
const passDurations =
|
|
79376
|
-
const latest =
|
|
79375
|
+
const passDurations = runs4.slice(1).filter((r) => r.status === "passed" && r.duration).map((r) => r.duration);
|
|
79376
|
+
const latest = runs4[0]?.duration;
|
|
79377
79377
|
const duration = latest && passDurations.length >= 2 ? (() => {
|
|
79378
79378
|
const med = median(passDurations);
|
|
79379
79379
|
return { latest, median: med, slower: latest > med * 1.5 && latest - med > 1e3 };
|
|
79380
79380
|
})() : void 0;
|
|
79381
79381
|
return {
|
|
79382
|
-
runs:
|
|
79382
|
+
runs: runs4,
|
|
79383
79383
|
changes,
|
|
79384
|
-
total:
|
|
79384
|
+
total: runs4.length,
|
|
79385
79385
|
passed,
|
|
79386
79386
|
failed,
|
|
79387
|
-
skipped:
|
|
79387
|
+
skipped: runs4.length - passed - failed,
|
|
79388
79388
|
flaky: flakyRow ? { rate: flakyRow.flakinessRate } : void 0,
|
|
79389
|
-
lastPassedAt:
|
|
79389
|
+
lastPassedAt: runs4.find((r) => r.status === "passed")?.at,
|
|
79390
79390
|
failingSince,
|
|
79391
79391
|
duration,
|
|
79392
|
-
pattern: clusterOf(
|
|
79392
|
+
pattern: clusterOf(runs4, (r) => r.browser, "on") ?? clusterOf(runs4, (r) => r.where, "when run")
|
|
79393
79393
|
};
|
|
79394
79394
|
}
|
|
79395
79395
|
function secs(ms) {
|
|
@@ -85811,8 +85811,8 @@ async function readTestDataColumns(projectPath2, relFile) {
|
|
|
85811
85811
|
const byExt = { csv: "csv", tsv: "tsv", xlsx: "xlsx", xls: "xlsx", json: "json", yaml: "yaml", yml: "yaml", properties: "properties", env: "env", xml: "xml" };
|
|
85812
85812
|
const format2 = byExt[ext];
|
|
85813
85813
|
if (!format2) return { error: "Test data must be a CSV, Excel, JSON, YAML, properties or XML file." };
|
|
85814
|
-
const { existsSync:
|
|
85815
|
-
if (!
|
|
85814
|
+
const { existsSync: existsSync128 } = await import("fs");
|
|
85815
|
+
if (!existsSync128(abs)) return { error: `File not found: ${rel}` };
|
|
85816
85816
|
const { previewDataSource: previewDataSource2 } = await Promise.resolve().then(() => (init_preview(), preview_exports));
|
|
85817
85817
|
const { maskPreview: maskPreview2 } = await Promise.resolve().then(() => (init_mask(), mask_exports));
|
|
85818
85818
|
const preview = maskPreview2(await previewDataSource2(projectPath2, rel, format2));
|
|
@@ -90596,10 +90596,10 @@ var init_test_results_store = __esm({
|
|
|
90596
90596
|
}
|
|
90597
90597
|
/** The visible runs a window selects (newest first). No window = all of them. */
|
|
90598
90598
|
runsIn(w) {
|
|
90599
|
-
const
|
|
90600
|
-
if (!w) return
|
|
90599
|
+
const runs4 = this.visibleRuns();
|
|
90600
|
+
if (!w) return runs4;
|
|
90601
90601
|
const exclude = new Set(w.excludeOrigins ?? []);
|
|
90602
|
-
return
|
|
90602
|
+
return runs4.filter((r) => {
|
|
90603
90603
|
const t = Date.parse(r.startTime) || 0;
|
|
90604
90604
|
if (w.sinceMs != null && t < w.sinceMs) return false;
|
|
90605
90605
|
if (w.untilMs != null && t > w.untilMs) return false;
|
|
@@ -91199,13 +91199,14 @@ var init_test_results_store = __esm({
|
|
|
91199
91199
|
// src/ui/store/chat-history-store.ts
|
|
91200
91200
|
import { readFileSync as readFileSync65, mkdirSync as mkdirSync28, existsSync as existsSync75 } from "fs";
|
|
91201
91201
|
import { join as join78 } from "path";
|
|
91202
|
-
var LEGACY_USER_ID, MAX_SESSIONS, MAX_MESSAGES_PER_SESSION, ChatHistoryStore;
|
|
91202
|
+
var PENDING_RUN_SLIM_BYTES, LEGACY_USER_ID, MAX_SESSIONS, MAX_MESSAGES_PER_SESSION, ChatHistoryStore;
|
|
91203
91203
|
var init_chat_history_store = __esm({
|
|
91204
91204
|
"src/ui/store/chat-history-store.ts"() {
|
|
91205
91205
|
"use strict";
|
|
91206
91206
|
init_utils();
|
|
91207
91207
|
init_chat_mode();
|
|
91208
91208
|
init_atomic_write();
|
|
91209
|
+
PENDING_RUN_SLIM_BYTES = 4 * 1024 * 1024;
|
|
91209
91210
|
LEGACY_USER_ID = "local-default-user";
|
|
91210
91211
|
MAX_SESSIONS = 50;
|
|
91211
91212
|
MAX_MESSAGES_PER_SESSION = 100;
|
|
@@ -91285,6 +91286,7 @@ var init_chat_history_store = __esm({
|
|
|
91285
91286
|
const session = this.data.sessions.find((s) => s.id === sessionId);
|
|
91286
91287
|
if (!session) return;
|
|
91287
91288
|
if (!this.isOwnedBy(session, userId)) return;
|
|
91289
|
+
if (message.requestId && session.messages.some((m) => m.role === message.role && m.requestId === message.requestId)) return;
|
|
91288
91290
|
session.messages.push(message);
|
|
91289
91291
|
session.messageCount = session.messages.length;
|
|
91290
91292
|
session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -91305,12 +91307,45 @@ var init_chat_history_store = __esm({
|
|
|
91305
91307
|
* Replace the session's fullTimeline (UI reconstruction data) —
|
|
91306
91308
|
* only if it belongs to THIS user.
|
|
91307
91309
|
*/
|
|
91308
|
-
saveTimeline(id, fullTimeline, userId) {
|
|
91310
|
+
saveTimeline(id, fullTimeline, userId, runId) {
|
|
91309
91311
|
const session = this.data.sessions.find((s) => s.id === id);
|
|
91310
91312
|
if (!session) return false;
|
|
91311
91313
|
if (!this.isOwnedBy(session, userId)) return false;
|
|
91312
91314
|
session.fullTimeline = fullTimeline;
|
|
91313
91315
|
session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
91316
|
+
if (runId) {
|
|
91317
|
+
session.savedRunIds = [...(session.savedRunIds ?? []).filter((r) => r !== runId), runId].slice(-20);
|
|
91318
|
+
if (session.pendingRun?.requestId === runId) delete session.pendingRun;
|
|
91319
|
+
}
|
|
91320
|
+
this.save();
|
|
91321
|
+
return true;
|
|
91322
|
+
}
|
|
91323
|
+
/**
|
|
91324
|
+
* Keep a run that ended on its chat until a chat screen rebuilds it —
|
|
91325
|
+
* unless a screen already saved it. A newer run replaces an older one
|
|
91326
|
+
* (that one's reply is in `messages` already, or was never seen).
|
|
91327
|
+
*/
|
|
91328
|
+
storePendingRun(id, userId, run2) {
|
|
91329
|
+
const session = this.data.sessions.find((s) => s.id === id);
|
|
91330
|
+
if (!session || !this.isOwnedBy(session, userId)) return false;
|
|
91331
|
+
if (session.savedRunIds?.includes(run2.requestId)) return false;
|
|
91332
|
+
let events = run2.events;
|
|
91333
|
+
let bytes = events.reduce((n, e) => n + e.length, 0);
|
|
91334
|
+
if (bytes > PENDING_RUN_SLIM_BYTES) {
|
|
91335
|
+
events = events.map((raw) => {
|
|
91336
|
+
if (!raw.includes('"fullResult"') && !raw.includes('"fullArgs"')) return raw;
|
|
91337
|
+
try {
|
|
91338
|
+
const msg = JSON.parse(raw);
|
|
91339
|
+
delete msg.fullResult;
|
|
91340
|
+
delete msg.fullArgs;
|
|
91341
|
+
return JSON.stringify(msg);
|
|
91342
|
+
} catch {
|
|
91343
|
+
return raw;
|
|
91344
|
+
}
|
|
91345
|
+
});
|
|
91346
|
+
bytes = events.reduce((n, e) => n + e.length, 0);
|
|
91347
|
+
}
|
|
91348
|
+
session.pendingRun = { ...run2, events };
|
|
91314
91349
|
this.save();
|
|
91315
91350
|
return true;
|
|
91316
91351
|
}
|
|
@@ -96800,6 +96835,218 @@ var init_client_replay = __esm({
|
|
|
96800
96835
|
}
|
|
96801
96836
|
});
|
|
96802
96837
|
|
|
96838
|
+
// src/ui/services/chat-runs.ts
|
|
96839
|
+
var chat_runs_exports = {};
|
|
96840
|
+
__export(chat_runs_exports, {
|
|
96841
|
+
FINISHED_KEEP_MS: () => FINISHED_KEEP_MS,
|
|
96842
|
+
MAX_RUN_BYTES: () => MAX_RUN_BYTES,
|
|
96843
|
+
chatRunSnapshot: () => chatRunSnapshot,
|
|
96844
|
+
finishChatRun: () => finishChatRun,
|
|
96845
|
+
getChatRun: () => getChatRun,
|
|
96846
|
+
listChatRuns: () => listChatRuns,
|
|
96847
|
+
listRecordingsInProgress: () => listRecordingsInProgress,
|
|
96848
|
+
markRunSaved: () => markRunSaved,
|
|
96849
|
+
mayControlRun: () => mayControlRun,
|
|
96850
|
+
notifyChatRunsChanged: () => notifyChatRunsChanged,
|
|
96851
|
+
onChatRunsChanged: () => onChatRunsChanged,
|
|
96852
|
+
onRunFinished: () => onRunFinished,
|
|
96853
|
+
pruneChatRuns: () => pruneChatRuns,
|
|
96854
|
+
recordRunEvent: () => recordRunEvent,
|
|
96855
|
+
registerRecordingsSource: () => registerRecordingsSource,
|
|
96856
|
+
resetChatRunsForTests: () => resetChatRunsForTests,
|
|
96857
|
+
runningRunOwnerForClient: () => runningRunOwnerForClient,
|
|
96858
|
+
settleRunPermission: () => settleRunPermission,
|
|
96859
|
+
startChatRun: () => startChatRun,
|
|
96860
|
+
summarizeRun: () => summarizeRun
|
|
96861
|
+
});
|
|
96862
|
+
function changed() {
|
|
96863
|
+
for (const l of changeListeners) {
|
|
96864
|
+
try {
|
|
96865
|
+
l();
|
|
96866
|
+
} catch {
|
|
96867
|
+
}
|
|
96868
|
+
}
|
|
96869
|
+
}
|
|
96870
|
+
function registerRecordingsSource(kind, source2) {
|
|
96871
|
+
recordingSources.set(kind, source2);
|
|
96872
|
+
}
|
|
96873
|
+
function listRecordingsInProgress(userId) {
|
|
96874
|
+
const out = [];
|
|
96875
|
+
for (const [kind, source2] of recordingSources) {
|
|
96876
|
+
try {
|
|
96877
|
+
for (const clientId of source2(userId)) out.push({ kind, clientId });
|
|
96878
|
+
} catch {
|
|
96879
|
+
}
|
|
96880
|
+
}
|
|
96881
|
+
return out;
|
|
96882
|
+
}
|
|
96883
|
+
function notifyChatRunsChanged() {
|
|
96884
|
+
changed();
|
|
96885
|
+
}
|
|
96886
|
+
function onChatRunsChanged(listener) {
|
|
96887
|
+
changeListeners.add(listener);
|
|
96888
|
+
return () => {
|
|
96889
|
+
changeListeners.delete(listener);
|
|
96890
|
+
};
|
|
96891
|
+
}
|
|
96892
|
+
function onRunFinished(hook) {
|
|
96893
|
+
finishHooks.add(hook);
|
|
96894
|
+
return () => {
|
|
96895
|
+
finishHooks.delete(hook);
|
|
96896
|
+
};
|
|
96897
|
+
}
|
|
96898
|
+
function startChatRun(info, now = Date.now()) {
|
|
96899
|
+
const run2 = {
|
|
96900
|
+
...info,
|
|
96901
|
+
startedAt: now,
|
|
96902
|
+
status: "running",
|
|
96903
|
+
events: [],
|
|
96904
|
+
bytes: 0,
|
|
96905
|
+
nextSeq: 1,
|
|
96906
|
+
firstSeq: 1,
|
|
96907
|
+
truncated: false,
|
|
96908
|
+
pendingPermissions: /* @__PURE__ */ new Set(),
|
|
96909
|
+
saved: false
|
|
96910
|
+
};
|
|
96911
|
+
runs3.set(info.requestId, run2);
|
|
96912
|
+
changed();
|
|
96913
|
+
return run2;
|
|
96914
|
+
}
|
|
96915
|
+
function getChatRun(requestId) {
|
|
96916
|
+
return runs3.get(requestId);
|
|
96917
|
+
}
|
|
96918
|
+
function enforceLimits(run2) {
|
|
96919
|
+
if (run2.bytes > SLIM_AT_BYTES) {
|
|
96920
|
+
for (let i = 0; i < run2.events.length && run2.bytes > SLIM_AT_BYTES; i++) {
|
|
96921
|
+
const raw = run2.events[i];
|
|
96922
|
+
if (!raw.includes('"fullResult"') && !raw.includes('"fullArgs"')) continue;
|
|
96923
|
+
try {
|
|
96924
|
+
const msg = JSON.parse(raw);
|
|
96925
|
+
delete msg.fullResult;
|
|
96926
|
+
delete msg.fullArgs;
|
|
96927
|
+
const slim2 = JSON.stringify(msg);
|
|
96928
|
+
run2.bytes -= raw.length - slim2.length;
|
|
96929
|
+
run2.events[i] = slim2;
|
|
96930
|
+
} catch {
|
|
96931
|
+
}
|
|
96932
|
+
}
|
|
96933
|
+
}
|
|
96934
|
+
while (run2.bytes > MAX_RUN_BYTES && run2.events.length > 1) {
|
|
96935
|
+
run2.bytes -= run2.events.shift().length;
|
|
96936
|
+
run2.firstSeq++;
|
|
96937
|
+
run2.truncated = true;
|
|
96938
|
+
}
|
|
96939
|
+
}
|
|
96940
|
+
function recordRunEvent(requestId, message) {
|
|
96941
|
+
const run2 = runs3.get(requestId);
|
|
96942
|
+
if (!run2) return message;
|
|
96943
|
+
const type = message.type;
|
|
96944
|
+
if (typeof type !== "string" || LIVE_ONLY2.has(type)) return message;
|
|
96945
|
+
const numbered2 = { ...message, runSeq: run2.nextSeq++ };
|
|
96946
|
+
const data = JSON.stringify(numbered2);
|
|
96947
|
+
run2.events.push(data);
|
|
96948
|
+
run2.bytes += data.length;
|
|
96949
|
+
enforceLimits(run2);
|
|
96950
|
+
if (type === "ai-fix-permission") {
|
|
96951
|
+
const id = message.permissionId;
|
|
96952
|
+
if (typeof id === "string") {
|
|
96953
|
+
run2.pendingPermissions.add(id);
|
|
96954
|
+
changed();
|
|
96955
|
+
}
|
|
96956
|
+
}
|
|
96957
|
+
return numbered2;
|
|
96958
|
+
}
|
|
96959
|
+
function settleRunPermission(requestId, permissionId) {
|
|
96960
|
+
const run2 = runs3.get(requestId);
|
|
96961
|
+
if (run2?.pendingPermissions.delete(permissionId)) changed();
|
|
96962
|
+
}
|
|
96963
|
+
function finishChatRun(requestId, status, now = Date.now()) {
|
|
96964
|
+
const run2 = runs3.get(requestId);
|
|
96965
|
+
if (!run2 || run2.status !== "running") return;
|
|
96966
|
+
run2.status = status;
|
|
96967
|
+
run2.endedAt = now;
|
|
96968
|
+
run2.pendingPermissions.clear();
|
|
96969
|
+
for (const hook of finishHooks) {
|
|
96970
|
+
try {
|
|
96971
|
+
hook(run2);
|
|
96972
|
+
} catch {
|
|
96973
|
+
}
|
|
96974
|
+
}
|
|
96975
|
+
changed();
|
|
96976
|
+
}
|
|
96977
|
+
function summarizeRun(run2) {
|
|
96978
|
+
return {
|
|
96979
|
+
requestId: run2.requestId,
|
|
96980
|
+
kind: run2.kind ?? "chat",
|
|
96981
|
+
meta: run2.meta,
|
|
96982
|
+
saved: run2.saved,
|
|
96983
|
+
sessionId: run2.sessionId,
|
|
96984
|
+
mode: run2.mode,
|
|
96985
|
+
userText: run2.userText,
|
|
96986
|
+
clientId: run2.clientId,
|
|
96987
|
+
startedAt: run2.startedAt,
|
|
96988
|
+
endedAt: run2.endedAt,
|
|
96989
|
+
status: run2.status,
|
|
96990
|
+
waitingForApproval: run2.pendingPermissions.size > 0
|
|
96991
|
+
};
|
|
96992
|
+
}
|
|
96993
|
+
function listChatRuns(userId) {
|
|
96994
|
+
return [...runs3.values()].filter((r) => r.userId === userId).sort((a, b) => b.startedAt - a.startedAt).map(summarizeRun);
|
|
96995
|
+
}
|
|
96996
|
+
function chatRunSnapshot(requestId, userId, after = 0) {
|
|
96997
|
+
const run2 = runs3.get(requestId);
|
|
96998
|
+
if (!run2 || run2.userId !== userId) return null;
|
|
96999
|
+
const events = [];
|
|
97000
|
+
const from = Math.max(0, Math.floor(after) + 1 - run2.firstSeq);
|
|
97001
|
+
for (const raw of run2.events.slice(from)) {
|
|
97002
|
+
try {
|
|
97003
|
+
events.push(JSON.parse(raw));
|
|
97004
|
+
} catch {
|
|
97005
|
+
}
|
|
97006
|
+
}
|
|
97007
|
+
return { run: summarizeRun(run2), events, truncated: run2.truncated, pendingPermissionIds: [...run2.pendingPermissions] };
|
|
97008
|
+
}
|
|
97009
|
+
function markRunSaved(requestId, userId) {
|
|
97010
|
+
const run2 = runs3.get(requestId);
|
|
97011
|
+
if (!run2 || run2.userId !== userId) return false;
|
|
97012
|
+
run2.saved = true;
|
|
97013
|
+
return true;
|
|
97014
|
+
}
|
|
97015
|
+
function mayControlRun(requestId, userId) {
|
|
97016
|
+
const run2 = runs3.get(requestId);
|
|
97017
|
+
return !run2 || run2.userId === (userId || "");
|
|
97018
|
+
}
|
|
97019
|
+
function runningRunOwnerForClient(clientId) {
|
|
97020
|
+
for (const run2 of runs3.values()) {
|
|
97021
|
+
if (run2.status === "running" && run2.clientId === clientId) return run2.userId;
|
|
97022
|
+
}
|
|
97023
|
+
return void 0;
|
|
97024
|
+
}
|
|
97025
|
+
function pruneChatRuns(now = Date.now()) {
|
|
97026
|
+
for (const [id, run2] of runs3) {
|
|
97027
|
+
if (run2.status !== "running" && run2.endedAt !== void 0 && now - run2.endedAt > FINISHED_KEEP_MS) runs3.delete(id);
|
|
97028
|
+
}
|
|
97029
|
+
}
|
|
97030
|
+
function resetChatRunsForTests() {
|
|
97031
|
+
runs3.clear();
|
|
97032
|
+
changeListeners.clear();
|
|
97033
|
+
finishHooks.clear();
|
|
97034
|
+
}
|
|
97035
|
+
var FINISHED_KEEP_MS, MAX_RUN_BYTES, SLIM_AT_BYTES, LIVE_ONLY2, runs3, changeListeners, finishHooks, recordingSources;
|
|
97036
|
+
var init_chat_runs = __esm({
|
|
97037
|
+
"src/ui/services/chat-runs.ts"() {
|
|
97038
|
+
"use strict";
|
|
97039
|
+
FINISHED_KEEP_MS = 30 * 6e4;
|
|
97040
|
+
MAX_RUN_BYTES = 16 * 1024 * 1024;
|
|
97041
|
+
SLIM_AT_BYTES = 10 * 1024 * 1024;
|
|
97042
|
+
LIVE_ONLY2 = /* @__PURE__ */ new Set(["ai-browser-screenshot", "ai-cursor-action"]);
|
|
97043
|
+
runs3 = /* @__PURE__ */ new Map();
|
|
97044
|
+
changeListeners = /* @__PURE__ */ new Set();
|
|
97045
|
+
finishHooks = /* @__PURE__ */ new Set();
|
|
97046
|
+
recordingSources = /* @__PURE__ */ new Map();
|
|
97047
|
+
}
|
|
97048
|
+
});
|
|
97049
|
+
|
|
96803
97050
|
// src/core/tools/tool-action-kinds.ts
|
|
96804
97051
|
function isReadOnlyToolCall(toolName, args2) {
|
|
96805
97052
|
const action = String(args2?.action || "");
|
|
@@ -97043,9 +97290,10 @@ function unregisterRequestPermissionMode(requestId) {
|
|
|
97043
97290
|
function isAutoApproving(requestId) {
|
|
97044
97291
|
return requestPermissionModes.get(requestId)?.mode === "auto";
|
|
97045
97292
|
}
|
|
97046
|
-
function setRequestPermissionMode(requestId, clientId, mode) {
|
|
97293
|
+
function setRequestPermissionMode(requestId, clientId, mode, userId) {
|
|
97047
97294
|
const entry2 = requestPermissionModes.get(requestId);
|
|
97048
|
-
|
|
97295
|
+
const ownRun = !!userId && getChatRun(requestId)?.userId === userId;
|
|
97296
|
+
if (!entry2 || entry2.clientId !== clientId && !ownRun) return false;
|
|
97049
97297
|
entry2.mode = mode;
|
|
97050
97298
|
if (mode === "auto") {
|
|
97051
97299
|
for (const [id, pending] of pendingPermissions) {
|
|
@@ -97168,6 +97416,20 @@ function formatToolArgs(toolName, args2) {
|
|
|
97168
97416
|
} catch {
|
|
97169
97417
|
}
|
|
97170
97418
|
}
|
|
97419
|
+
if (toolName.startsWith("api_")) {
|
|
97420
|
+
const keep = ["collection", "folder", "request", "name", "method", "url", "environment", "environment_name", "collection_name", "file_path", "data_file"];
|
|
97421
|
+
const out = {};
|
|
97422
|
+
for (const k of keep) {
|
|
97423
|
+
const v = args2[k];
|
|
97424
|
+
if (typeof v === "string" && v) out[k] = k === "url" ? v.replace(/([?&](?:token|key|apikey|api_key|access_token|password|secret)=)[^&#]*/gi, "$1\u2026") : v;
|
|
97425
|
+
}
|
|
97426
|
+
if (Object.keys(out).length) {
|
|
97427
|
+
try {
|
|
97428
|
+
return JSON.stringify(out);
|
|
97429
|
+
} catch {
|
|
97430
|
+
}
|
|
97431
|
+
}
|
|
97432
|
+
}
|
|
97171
97433
|
for (const v of Object.values(args2)) {
|
|
97172
97434
|
if (typeof v === "string" && v.length > 0) return v.length > 80 ? v.slice(0, 77) + "..." : v;
|
|
97173
97435
|
}
|
|
@@ -97343,12 +97605,14 @@ function releaseOrchestrator(orchestrator) {
|
|
|
97343
97605
|
runningOrchestrators.delete(orchestrator);
|
|
97344
97606
|
}
|
|
97345
97607
|
async function streamScopedWithToolEvents(orchestrator, wss, prompt, requestId, options) {
|
|
97346
|
-
const emit = (msg) => sendTo(wss, options?.clientId, msg);
|
|
97608
|
+
const emit = (msg) => sendTo(wss, options?.clientId, recordRunEvent(requestId, msg));
|
|
97347
97609
|
if (runningOrchestrators.has(orchestrator) || orchestrator.isRunning()) {
|
|
97348
97610
|
emit({ type: "ai-fix-error", requestId, message: "Another AI request is already in progress. Please wait for it to complete." });
|
|
97611
|
+
finishChatRun(requestId, "error");
|
|
97349
97612
|
return;
|
|
97350
97613
|
}
|
|
97351
97614
|
runningOrchestrators.add(orchestrator);
|
|
97615
|
+
let outcome = "error";
|
|
97352
97616
|
registerRequestPermissionMode(requestId, options?.clientId, options?.permissionMode ?? "manual");
|
|
97353
97617
|
if (options?.skillInstructionsOverride !== void 0) {
|
|
97354
97618
|
orchestrator.setSkillInstructionsOverride(options.skillInstructionsOverride);
|
|
@@ -97462,6 +97726,7 @@ async function streamScopedWithToolEvents(orchestrator, wss, prompt, requestId,
|
|
|
97462
97726
|
const settle = (r) => {
|
|
97463
97727
|
clearInterval(ticker);
|
|
97464
97728
|
pendingPermissions.delete(permissionId);
|
|
97729
|
+
settleRunPermission(requestId, permissionId);
|
|
97465
97730
|
resolve36(r);
|
|
97466
97731
|
};
|
|
97467
97732
|
const ticker = setInterval(() => {
|
|
@@ -97730,6 +97995,7 @@ FINAL ATTEMPT: reply with ONLY the required markdown text. Do NOT call any tools
|
|
|
97730
97995
|
}
|
|
97731
97996
|
}
|
|
97732
97997
|
if (inactivityTimer) clearTimeout(inactivityTimer);
|
|
97998
|
+
outcome = aborted ? "stopped" : timedOut || sawStreamError ? "error" : "done";
|
|
97733
97999
|
if (!timedOut) {
|
|
97734
98000
|
await reportDetectedChanges();
|
|
97735
98001
|
emit({ type: "ai-fix-done", requestId });
|
|
@@ -97738,6 +98004,7 @@ FINAL ATTEMPT: reply with ONLY the required markdown text. Do NOT call any tools
|
|
|
97738
98004
|
await reportDetectedChanges();
|
|
97739
98005
|
emit({ type: "ai-fix-error", requestId, message: String(error) });
|
|
97740
98006
|
} finally {
|
|
98007
|
+
finishChatRun(requestId, outcome);
|
|
97741
98008
|
activeStreams.delete(requestId);
|
|
97742
98009
|
unregisterRequestPermissionMode(requestId);
|
|
97743
98010
|
orchestrator.setPermissionCallback(origPermission);
|
|
@@ -97833,6 +98100,7 @@ var init_shared_streaming = __esm({
|
|
|
97833
98100
|
"src/ui/routes/shared-streaming.ts"() {
|
|
97834
98101
|
"use strict";
|
|
97835
98102
|
init_client_replay();
|
|
98103
|
+
init_chat_runs();
|
|
97836
98104
|
init_permissions();
|
|
97837
98105
|
init_tool_action_kinds();
|
|
97838
98106
|
init_whole_suite_guard();
|
|
@@ -112029,30 +112297,102 @@ var init_session_prompt = __esm({
|
|
|
112029
112297
|
}
|
|
112030
112298
|
});
|
|
112031
112299
|
|
|
112300
|
+
// src/ui/store/pending-runs-store.ts
|
|
112301
|
+
import { existsSync as existsSync91, mkdirSync as mkdirSync40, readFileSync as readFileSync74 } from "fs";
|
|
112302
|
+
import { join as join93 } from "path";
|
|
112303
|
+
function slim(events) {
|
|
112304
|
+
const bytes = events.reduce((n, e) => n + e.length, 0);
|
|
112305
|
+
if (bytes <= SLIM_BYTES) return events;
|
|
112306
|
+
return events.map((raw) => {
|
|
112307
|
+
if (!raw.includes('"fullResult"') && !raw.includes('"fullArgs"')) return raw;
|
|
112308
|
+
try {
|
|
112309
|
+
const msg = JSON.parse(raw);
|
|
112310
|
+
delete msg.fullResult;
|
|
112311
|
+
delete msg.fullArgs;
|
|
112312
|
+
return JSON.stringify(msg);
|
|
112313
|
+
} catch {
|
|
112314
|
+
return raw;
|
|
112315
|
+
}
|
|
112316
|
+
});
|
|
112317
|
+
}
|
|
112318
|
+
var MAX_RUNS2, KEEP_MS, SLIM_BYTES, PendingRunsStore;
|
|
112319
|
+
var init_pending_runs_store = __esm({
|
|
112320
|
+
"src/ui/store/pending-runs-store.ts"() {
|
|
112321
|
+
"use strict";
|
|
112322
|
+
init_utils();
|
|
112323
|
+
init_atomic_write();
|
|
112324
|
+
MAX_RUNS2 = 30;
|
|
112325
|
+
KEEP_MS = 14 * 24 * 36e5;
|
|
112326
|
+
SLIM_BYTES = 4 * 1024 * 1024;
|
|
112327
|
+
PendingRunsStore = class {
|
|
112328
|
+
runs = [];
|
|
112329
|
+
filePath;
|
|
112330
|
+
constructor(projectPath2) {
|
|
112331
|
+
const dir = getTestverDir(projectPath2);
|
|
112332
|
+
if (!existsSync91(dir)) mkdirSync40(dir, { recursive: true });
|
|
112333
|
+
this.filePath = join93(dir, "ai-pending-runs.json");
|
|
112334
|
+
try {
|
|
112335
|
+
if (existsSync91(this.filePath)) {
|
|
112336
|
+
const parsed = JSON.parse(readFileSync74(this.filePath, "utf-8"));
|
|
112337
|
+
this.runs = Array.isArray(parsed?.runs) ? parsed.runs : [];
|
|
112338
|
+
}
|
|
112339
|
+
} catch (e) {
|
|
112340
|
+
setAsideUnreadable(this.filePath, e);
|
|
112341
|
+
this.runs = [];
|
|
112342
|
+
}
|
|
112343
|
+
}
|
|
112344
|
+
put(run2, now = Date.now()) {
|
|
112345
|
+
this.runs = [{ ...run2, events: slim(run2.events) }, ...this.runs.filter((r) => r.requestId !== run2.requestId)].filter((r) => now - (r.endedAt ?? r.startedAt) <= KEEP_MS).slice(0, MAX_RUNS2);
|
|
112346
|
+
this.save();
|
|
112347
|
+
}
|
|
112348
|
+
/** This user's kept runs (of one recording, when given), oldest first. */
|
|
112349
|
+
list(userId, sessionId) {
|
|
112350
|
+
return this.runs.filter((r) => r.userId === userId && (!sessionId || r.sessionId === sessionId)).sort((a, b) => a.startedAt - b.startedAt);
|
|
112351
|
+
}
|
|
112352
|
+
get(requestId, userId) {
|
|
112353
|
+
return this.runs.find((r) => r.requestId === requestId && r.userId === userId);
|
|
112354
|
+
}
|
|
112355
|
+
remove(requestId, userId) {
|
|
112356
|
+
const before = this.runs.length;
|
|
112357
|
+
this.runs = this.runs.filter((r) => !(r.requestId === requestId && r.userId === userId));
|
|
112358
|
+
if (this.runs.length === before) return false;
|
|
112359
|
+
this.save();
|
|
112360
|
+
return true;
|
|
112361
|
+
}
|
|
112362
|
+
save() {
|
|
112363
|
+
try {
|
|
112364
|
+
writeFileAtomicSync(this.filePath, JSON.stringify({ runs: this.runs }));
|
|
112365
|
+
} catch {
|
|
112366
|
+
}
|
|
112367
|
+
}
|
|
112368
|
+
};
|
|
112369
|
+
}
|
|
112370
|
+
});
|
|
112371
|
+
|
|
112032
112372
|
// src/ui/services/knowledge-inventory.ts
|
|
112033
112373
|
var knowledge_inventory_exports = {};
|
|
112034
112374
|
__export(knowledge_inventory_exports, {
|
|
112035
112375
|
buildKnowledgeInventory: () => buildKnowledgeInventory
|
|
112036
112376
|
});
|
|
112037
|
-
import { existsSync as
|
|
112038
|
-
import { join as
|
|
112377
|
+
import { existsSync as existsSync92, readFileSync as readFileSync75, readdirSync as readdirSync37, statSync as statSync37 } from "fs";
|
|
112378
|
+
import { join as join94 } from "path";
|
|
112039
112379
|
function countJson(path2, key2) {
|
|
112040
112380
|
try {
|
|
112041
|
-
if (!
|
|
112042
|
-
return toArray(JSON.parse(
|
|
112381
|
+
if (!existsSync92(path2)) return 0;
|
|
112382
|
+
return toArray(JSON.parse(readFileSync75(path2, "utf-8")), key2).length;
|
|
112043
112383
|
} catch {
|
|
112044
112384
|
return 0;
|
|
112045
112385
|
}
|
|
112046
112386
|
}
|
|
112047
112387
|
function buildKnowledgeInventory(projectPath2, tmStore5) {
|
|
112048
112388
|
const inv = JSON.parse(JSON.stringify(EMPTY2));
|
|
112049
|
-
const exploreRoot =
|
|
112050
|
-
if (
|
|
112389
|
+
const exploreRoot = join94(projectPath2, ".testver", "explore");
|
|
112390
|
+
if (existsSync92(exploreRoot)) {
|
|
112051
112391
|
let latest = null;
|
|
112052
112392
|
try {
|
|
112053
112393
|
for (const name2 of readdirSync37(exploreRoot)) {
|
|
112054
112394
|
if (name2 === "auth") continue;
|
|
112055
|
-
const dir =
|
|
112395
|
+
const dir = join94(exploreRoot, name2);
|
|
112056
112396
|
let at2 = 0;
|
|
112057
112397
|
try {
|
|
112058
112398
|
const st = statSync37(dir);
|
|
@@ -112062,8 +112402,8 @@ function buildKnowledgeInventory(projectPath2, tmStore5) {
|
|
|
112062
112402
|
continue;
|
|
112063
112403
|
}
|
|
112064
112404
|
inv.observed.runs++;
|
|
112065
|
-
const pagesDir =
|
|
112066
|
-
if (
|
|
112405
|
+
const pagesDir = join94(dir, "pages");
|
|
112406
|
+
if (existsSync92(pagesDir)) {
|
|
112067
112407
|
try {
|
|
112068
112408
|
inv.observed.pages += readdirSync37(pagesDir).filter((n) => n.endsWith(".json")).length;
|
|
112069
112409
|
} catch {
|
|
@@ -112073,7 +112413,7 @@ function buildKnowledgeInventory(projectPath2, tmStore5) {
|
|
|
112073
112413
|
inv.observed.notes += readdirSync37(dir).filter((n) => /\.(md|markdown|txt)$/i.test(n)).length;
|
|
112074
112414
|
} catch {
|
|
112075
112415
|
}
|
|
112076
|
-
inv.observed.findings += countJson(
|
|
112416
|
+
inv.observed.findings += countJson(join94(dir, "findings.json"), "findings");
|
|
112077
112417
|
if (!latest || at2 > latest.at) latest = { id: name2, dir, at: at2 };
|
|
112078
112418
|
}
|
|
112079
112419
|
} catch {
|
|
@@ -112087,7 +112427,7 @@ function buildKnowledgeInventory(projectPath2, tmStore5) {
|
|
|
112087
112427
|
inv.observed.hasReport = false;
|
|
112088
112428
|
}
|
|
112089
112429
|
try {
|
|
112090
|
-
const access = JSON.parse(
|
|
112430
|
+
const access = JSON.parse(readFileSync75(join94(latest.dir, "access.json"), "utf-8"));
|
|
112091
112431
|
const roles = toStringArray(access?.roles);
|
|
112092
112432
|
if (roles.length > 0) inv.observed.roles = roles;
|
|
112093
112433
|
} catch {
|
|
@@ -112138,202 +112478,6 @@ var init_knowledge_inventory = __esm({
|
|
|
112138
112478
|
}
|
|
112139
112479
|
});
|
|
112140
112480
|
|
|
112141
|
-
// src/ui/services/api-test-prompt-builder.ts
|
|
112142
|
-
var api_test_prompt_builder_exports = {};
|
|
112143
|
-
__export(api_test_prompt_builder_exports, {
|
|
112144
|
-
buildApiTestPrompt: () => buildApiTestPrompt
|
|
112145
|
-
});
|
|
112146
|
-
function buildApiTestPrompt(opts) {
|
|
112147
|
-
const { requests, responses, projectPath: projectPath2, frameworkHint, testName } = opts;
|
|
112148
|
-
const MAX_ATTEMPTS = 3;
|
|
112149
|
-
const requestDetails = requests.map((req, i) => {
|
|
112150
|
-
const resp = responses?.[i];
|
|
112151
|
-
const lines = [];
|
|
112152
|
-
lines.push(`### Request ${i + 1}: ${req.method} ${req.url}`);
|
|
112153
|
-
lines.push(`- **Name:** ${req.name}`);
|
|
112154
|
-
lines.push(`- **Method:** ${req.method}`);
|
|
112155
|
-
lines.push(`- **URL:** ${req.url}`);
|
|
112156
|
-
if (req.headers.length > 0) {
|
|
112157
|
-
lines.push(`- **Headers:**`);
|
|
112158
|
-
for (const h of req.headers.filter((h2) => h2.enabled)) {
|
|
112159
|
-
lines.push(` - \`${h.key}: ${h.value}\``);
|
|
112160
|
-
}
|
|
112161
|
-
}
|
|
112162
|
-
if (req.queryParams.length > 0) {
|
|
112163
|
-
lines.push(`- **Query Params:**`);
|
|
112164
|
-
for (const p2 of req.queryParams.filter((p3) => p3.enabled)) {
|
|
112165
|
-
lines.push(` - \`${p2.key}=${p2.value}\``);
|
|
112166
|
-
}
|
|
112167
|
-
}
|
|
112168
|
-
if (req.body.type !== "none") {
|
|
112169
|
-
lines.push(`- **Body Type:** ${req.body.type}`);
|
|
112170
|
-
if (req.body.raw) {
|
|
112171
|
-
const truncated = req.body.raw.length > 2e3 ? req.body.raw.slice(0, 2e3) + "\n...(truncated)" : req.body.raw;
|
|
112172
|
-
lines.push(`- **Body Content:**
|
|
112173
|
-
\`\`\`
|
|
112174
|
-
${truncated}
|
|
112175
|
-
\`\`\``);
|
|
112176
|
-
}
|
|
112177
|
-
if (req.body.graphqlVariables) {
|
|
112178
|
-
lines.push(`- **GraphQL Variables:**
|
|
112179
|
-
\`\`\`json
|
|
112180
|
-
${req.body.graphqlVariables}
|
|
112181
|
-
\`\`\``);
|
|
112182
|
-
}
|
|
112183
|
-
}
|
|
112184
|
-
if (req.auth.type !== "none") {
|
|
112185
|
-
lines.push(`- **Auth Type:** ${req.auth.type}`);
|
|
112186
|
-
if (req.auth.type === "bearer") lines.push(` - Token: \`{{token}}\` (use variable substitution)`);
|
|
112187
|
-
if (req.auth.type === "basic") lines.push(` - Username/Password (use environment variables)`);
|
|
112188
|
-
if (req.auth.type === "api-key") lines.push(` - Key: \`${req.auth.apiKeyName}\` in ${req.auth.apiKeyIn || "header"}`);
|
|
112189
|
-
}
|
|
112190
|
-
if (req.validations.length > 0) {
|
|
112191
|
-
lines.push(`- **Expected Validations:**`);
|
|
112192
|
-
for (const v of req.validations.filter((v2) => v2.enabled)) {
|
|
112193
|
-
lines.push(` - ${v.type}${v.target ? ` (${v.target})` : ""} ${v.operator} \`${v.expected}\``);
|
|
112194
|
-
}
|
|
112195
|
-
}
|
|
112196
|
-
if (resp) {
|
|
112197
|
-
lines.push(`
|
|
112198
|
-
#### Sample Response (for assertion reference)`);
|
|
112199
|
-
lines.push(`- **Status:** ${resp.status} ${resp.statusText}`);
|
|
112200
|
-
lines.push(`- **Duration:** ${resp.duration}ms`);
|
|
112201
|
-
const truncBody = resp.body.length > 3e3 ? resp.body.slice(0, 3e3) + "\n...(truncated)" : resp.body;
|
|
112202
|
-
lines.push(`- **Response Body:**
|
|
112203
|
-
\`\`\`
|
|
112204
|
-
${truncBody}
|
|
112205
|
-
\`\`\``);
|
|
112206
|
-
const headerEntries = Object.entries(resp.headers);
|
|
112207
|
-
if (headerEntries.length > 0) {
|
|
112208
|
-
lines.push(`- **Response Headers:**`);
|
|
112209
|
-
for (const [k, v] of headerEntries.slice(0, 15)) {
|
|
112210
|
-
lines.push(` - \`${k}: ${v}\``);
|
|
112211
|
-
}
|
|
112212
|
-
}
|
|
112213
|
-
}
|
|
112214
|
-
return lines.join("\n");
|
|
112215
|
-
}).join("\n\n");
|
|
112216
|
-
return `You are a test automation expert. The user has designed API test scenarios using the testver API Testing workspace and wants you to generate **framework-native API test source code** that integrates with their existing test project.
|
|
112217
|
-
|
|
112218
|
-
## CRITICAL RULES (MUST FOLLOW)
|
|
112219
|
-
1. **Generate REAL framework-native test code** \u2014 NOT pseudocode, NOT Postman collections, NOT standalone scripts
|
|
112220
|
-
2. **Reuse existing project patterns** \u2014 match the project's test framework, assertion library, helper utilities, and coding style exactly
|
|
112221
|
-
3. **DO NOT create new helper/utility files** unless absolutely necessary \u2014 use existing HTTP client wrappers, auth helpers, etc.
|
|
112222
|
-
4. **The generated test must be executable** with the project's existing test runner command
|
|
112223
|
-
5. **Use the project's existing assertion patterns** \u2014 if they use \`expect().toBe()\`, use that; if they use \`assert\`, use that
|
|
112224
|
-
6. **Store secrets in environment variables** \u2014 never hardcode tokens/passwords in test code
|
|
112225
|
-
7. **Match naming conventions** \u2014 file names, test descriptions, folder structure must follow project conventions
|
|
112226
|
-
|
|
112227
|
-
## API Requests to Convert to Tests
|
|
112228
|
-
|
|
112229
|
-
${requestDetails}
|
|
112230
|
-
|
|
112231
|
-
${testName && cleanTestTitle(testName) ? `## Suggested Test Name: ${cleanTestTitle(testName)}` : ""}
|
|
112232
|
-
${frameworkHint ? `## Framework Hint: ${frameworkHint}` : ""}
|
|
112233
|
-
|
|
112234
|
-
## Project Path: ${projectPath2}
|
|
112235
|
-
|
|
112236
|
-
## MANDATORY WORKFLOW \u2014 Follow These Steps In Order
|
|
112237
|
-
|
|
112238
|
-
### Phase 1: Project Discovery (DO NOT SKIP)
|
|
112239
|
-
|
|
112240
|
-
You MUST thoroughly scan the project before writing any code.
|
|
112241
|
-
|
|
112242
|
-
**Step 1.1: Scan project structure**
|
|
112243
|
-
- Use \`list_directory\` on the project root
|
|
112244
|
-
- Use \`glob_search\` to find existing test files (\`**/*.spec.ts\`, \`**/*.test.ts\`, \`**/*.spec.js\`, \`**/*.test.js\`, \`**/*.py\`, \`**/*.java\`, \`**/*.cs\`)
|
|
112245
|
-
- Use \`glob_search\` to find API test files specifically (\`**/*api*\`, \`**/*request*\`, \`**/*endpoint*\`)
|
|
112246
|
-
- Use \`glob_search\` to find utility/helper files (\`**/utils/**\`, \`**/helpers/**\`, \`**/support/**\`)
|
|
112247
|
-
- Read \`package.json\`, \`pom.xml\`, \`requirements.txt\`, or equivalent to identify framework
|
|
112248
|
-
|
|
112249
|
-
**Step 1.2: Identify API testing patterns**
|
|
112250
|
-
- Search for existing API/HTTP test files \u2014 \`grep\` for \`request.get\`, \`cy.request\`, \`fetch\`, \`supertest\`, \`requests.get\`, \`RestAssured\`, \`HttpClient\`
|
|
112251
|
-
- Read existing API test files to understand patterns (assertions, setup, teardown)
|
|
112252
|
-
- Look for HTTP client wrappers, base URLs, auth helpers
|
|
112253
|
-
- Identify how environment variables are used for API keys, base URLs, etc.
|
|
112254
|
-
|
|
112255
|
-
**Step 1.3: Understand project conventions**
|
|
112256
|
-
- Read config file (playwright.config, cypress.config, jest.config, vitest.config, etc.)
|
|
112257
|
-
- Read tsconfig/eslint/prettier configs to understand style requirements
|
|
112258
|
-
- Note the test runner command (\`npx playwright test\`, \`npx cypress run\`, \`pytest\`, \`mvn test\`, etc.)
|
|
112259
|
-
|
|
112260
|
-
### Phase 2: Plan the Code
|
|
112261
|
-
|
|
112262
|
-
Based on your discovery:
|
|
112263
|
-
1. **What can be reused?** \u2014 existing HTTP clients, auth helpers, base URLs, assertion patterns
|
|
112264
|
-
2. **What needs to be created?** \u2014 new test file, potentially new API helper if none exists
|
|
112265
|
-
3. **Where should the test go?** \u2014 match existing folder structure
|
|
112266
|
-
4. **What test runner command?** \u2014 how to run just this test
|
|
112267
|
-
|
|
112268
|
-
Write your plan as a summary.
|
|
112269
|
-
|
|
112270
|
-
### Phase 3: Generate the Code
|
|
112271
|
-
|
|
112272
|
-
Create the test file(s) using \`write_file\` or \`edit_file\`:
|
|
112273
|
-
|
|
112274
|
-
**Framework-specific API testing patterns to follow:**
|
|
112275
|
-
|
|
112276
|
-
- **Playwright:** \`const response = await request.get(url)\`, \`expect(response.status()).toBe(200)\`, \`expect(await response.json()).toHaveProperty('id')\`
|
|
112277
|
-
- **Cypress:** \`cy.request('GET', url).then(response => { expect(response.status).to.eq(200) })\`
|
|
112278
|
-
- **Jest/Vitest + supertest:** \`const res = await request(app).get(url).expect(200)\`
|
|
112279
|
-
- **Jest/Vitest + fetch:** \`const res = await fetch(url); expect(res.status).toBe(200)\`
|
|
112280
|
-
- **Python/pytest + requests:** \`response = requests.get(url); assert response.status_code == 200\`
|
|
112281
|
-
- **Java/RestAssured:** \`given().when().get(url).then().statusCode(200).body("id", equalTo(1))\`
|
|
112282
|
-
- **C#/NUnit + HttpClient:** \`var response = await _client.GetAsync(url); Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK))\`
|
|
112283
|
-
|
|
112284
|
-
Include appropriate assertions for:
|
|
112285
|
-
- Status code
|
|
112286
|
-
- Response body structure (JSON path validation)
|
|
112287
|
-
- Response headers if relevant
|
|
112288
|
-
- Response time if validation rules were specified
|
|
112289
|
-
- Content type
|
|
112290
|
-
|
|
112291
|
-
### Phase 4: Run & Verify
|
|
112292
|
-
|
|
112293
|
-
- Determine the correct test runner command from package.json/config
|
|
112294
|
-
- Run ONLY the new test using framework-specific grep/filter
|
|
112295
|
-
- Check if it passes
|
|
112296
|
-
|
|
112297
|
-
### Phase 5: Self-Healing Loop (up to ${MAX_ATTEMPTS} total attempts)
|
|
112298
|
-
|
|
112299
|
-
If the test fails:
|
|
112300
|
-
1. Read the error output carefully
|
|
112301
|
-
2. Re-read the test file and any relevant helpers
|
|
112302
|
-
3. Diagnose the issue (wrong import, wrong assertion, missing setup, auth issue)
|
|
112303
|
-
4. Fix the test using \`edit_file\`
|
|
112304
|
-
5. Re-run and verify
|
|
112305
|
-
|
|
112306
|
-
Each attempt must try something different from the previous one.
|
|
112307
|
-
|
|
112308
|
-
## OUTPUT FORMAT
|
|
112309
|
-
|
|
112310
|
-
\`\`\`
|
|
112311
|
-
### Project Analysis
|
|
112312
|
-
[Summary of discovered framework, API testing patterns, reusable code]
|
|
112313
|
-
|
|
112314
|
-
### Plan
|
|
112315
|
-
[What to reuse vs. create]
|
|
112316
|
-
|
|
112317
|
-
### Implementation
|
|
112318
|
-
[Tool calls to create/modify files]
|
|
112319
|
-
|
|
112320
|
-
### Attempt 1 of ${MAX_ATTEMPTS}
|
|
112321
|
-
[Test execution and results]
|
|
112322
|
-
|
|
112323
|
-
### Final Result
|
|
112324
|
-
**Status:** PASS / FAIL
|
|
112325
|
-
**Files created/modified:** [list]
|
|
112326
|
-
**Test command:** [command to run the test]
|
|
112327
|
-
**Reused from project:** [what existing code was leveraged]
|
|
112328
|
-
\`\`\``;
|
|
112329
|
-
}
|
|
112330
|
-
var init_api_test_prompt_builder = __esm({
|
|
112331
|
-
"src/ui/services/api-test-prompt-builder.ts"() {
|
|
112332
|
-
"use strict";
|
|
112333
|
-
init_test_titles();
|
|
112334
|
-
}
|
|
112335
|
-
});
|
|
112336
|
-
|
|
112337
112481
|
// src/ui/services/upload-types.ts
|
|
112338
112482
|
function isApiPayload(fileName) {
|
|
112339
112483
|
const lower = fileName.toLowerCase();
|
|
@@ -112500,28 +112644,28 @@ import multer from "multer";
|
|
|
112500
112644
|
import { readFile as readFile14 } from "fs/promises";
|
|
112501
112645
|
import { extname as extname17 } from "path";
|
|
112502
112646
|
import { tmpdir as tmpdir5 } from "os";
|
|
112503
|
-
import { join as
|
|
112504
|
-
import { mkdtempSync, existsSync as
|
|
112647
|
+
import { join as join95 } from "path";
|
|
112648
|
+
import { mkdtempSync, existsSync as existsSync93, unlinkSync as unlinkSync8, readdirSync as readdirSync38, statSync as statSync38, mkdirSync as mkdirSync41, copyFileSync as copyFileSync4, readFileSync as readFileSync76 } from "fs";
|
|
112505
112649
|
function uploadMode(req) {
|
|
112506
112650
|
const m = req.query?.mode;
|
|
112507
112651
|
return typeof m === "string" ? m : void 0;
|
|
112508
112652
|
}
|
|
112509
112653
|
function saveUploadToProject(tempPath, originalName, projectPath2) {
|
|
112510
|
-
const dir =
|
|
112511
|
-
|
|
112654
|
+
const dir = join95(projectPath2, ".testver", "uploads");
|
|
112655
|
+
mkdirSync41(dir, { recursive: true });
|
|
112512
112656
|
const safe = (originalName.split(/[\\/]/).pop() || "file").replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^\.+/, "") || "file";
|
|
112513
112657
|
const dot = safe.lastIndexOf(".");
|
|
112514
112658
|
const stem3 = dot > 0 ? safe.slice(0, dot) : safe;
|
|
112515
112659
|
const ext = dot > 0 ? safe.slice(dot) : "";
|
|
112516
|
-
const incoming =
|
|
112660
|
+
const incoming = readFileSync76(tempPath);
|
|
112517
112661
|
for (let n = 1; n < 1e3; n++) {
|
|
112518
112662
|
const name2 = n === 1 ? safe : `${stem3}-${n}${ext}`;
|
|
112519
|
-
const full =
|
|
112520
|
-
if (!
|
|
112663
|
+
const full = join95(dir, name2);
|
|
112664
|
+
if (!existsSync93(full)) {
|
|
112521
112665
|
copyFileSync4(tempPath, full);
|
|
112522
112666
|
return `.testver/uploads/${name2}`;
|
|
112523
112667
|
}
|
|
112524
|
-
if (
|
|
112668
|
+
if (readFileSync76(full).equals(incoming)) return `.testver/uploads/${name2}`;
|
|
112525
112669
|
}
|
|
112526
112670
|
throw new Error("too many files with this name in .testver/uploads");
|
|
112527
112671
|
}
|
|
@@ -112711,13 +112855,13 @@ var init_api_upload = __esm({
|
|
|
112711
112855
|
"use strict";
|
|
112712
112856
|
init_audit_helper();
|
|
112713
112857
|
init_upload_types();
|
|
112714
|
-
uploadDir = mkdtempSync(
|
|
112858
|
+
uploadDir = mkdtempSync(join95(tmpdir5(), "testver-uploads-"));
|
|
112715
112859
|
setInterval(() => {
|
|
112716
112860
|
try {
|
|
112717
|
-
if (!
|
|
112861
|
+
if (!existsSync93(uploadDir)) return;
|
|
112718
112862
|
const now = Date.now();
|
|
112719
112863
|
for (const file of readdirSync38(uploadDir)) {
|
|
112720
|
-
const fp =
|
|
112864
|
+
const fp = join95(uploadDir, file);
|
|
112721
112865
|
try {
|
|
112722
112866
|
const stat6 = statSync38(fp);
|
|
112723
112867
|
if (now - stat6.mtimeMs > 30 * 60 * 1e3) {
|
|
@@ -112775,8 +112919,12 @@ __export(api_ai_exports, {
|
|
|
112775
112919
|
mountAIRoutes: () => mountAIRoutes
|
|
112776
112920
|
});
|
|
112777
112921
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
112778
|
-
import { readFileSync as
|
|
112779
|
-
import { join as
|
|
112922
|
+
import { readFileSync as readFileSync77, existsSync as existsSync94 } from "fs";
|
|
112923
|
+
import { join as join96 } from "path";
|
|
112924
|
+
function callerUserId(req) {
|
|
112925
|
+
const id = req?.user?.id;
|
|
112926
|
+
return typeof id === "string" && id ? id : "local-default-user";
|
|
112927
|
+
}
|
|
112780
112928
|
function extractClientId(req) {
|
|
112781
112929
|
const headerVal = req?.headers?.["x-client-id"];
|
|
112782
112930
|
if (typeof headerVal === "string" && headerVal.length > 0) return headerVal;
|
|
@@ -112808,9 +112956,9 @@ function buildAttachedTestBlock(t, projectPath2) {
|
|
|
112808
112956
|
const runCommand = attachedRunCommand(t, projectPath2);
|
|
112809
112957
|
if (runCommand) out.push(`\u2022 Run command: ${runCommand}`);
|
|
112810
112958
|
try {
|
|
112811
|
-
const abs =
|
|
112812
|
-
if (
|
|
112813
|
-
const all =
|
|
112959
|
+
const abs = join96(projectPath2, t.file);
|
|
112960
|
+
if (existsSync94(abs) && typeof t.line === "number") {
|
|
112961
|
+
const all = readFileSync77(abs, "utf-8").split("\n");
|
|
112814
112962
|
const start = Math.max(0, t.line - 3);
|
|
112815
112963
|
const end = Math.min(all.length, (t.endLine || t.line) + 3);
|
|
112816
112964
|
out.push("");
|
|
@@ -112846,8 +112994,102 @@ function buildReportingTestBlock(t) {
|
|
|
112846
112994
|
out.push("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
112847
112995
|
return out.join("\n");
|
|
112848
112996
|
}
|
|
112849
|
-
function mountAIRoutes(app, wss, options, skillRegistry, mcpClientManager) {
|
|
112997
|
+
function mountAIRoutes(app, wss, options, skillRegistry, mcpClientManager, chatHistoryStore) {
|
|
112850
112998
|
const orchestrator = options.orchestrator;
|
|
112999
|
+
onChatRunsChanged(() => {
|
|
113000
|
+
const data = JSON.stringify({ type: "chat-runs-changed" });
|
|
113001
|
+
for (const client of wss.clients) {
|
|
113002
|
+
if (client.readyState === 1) client.send(data);
|
|
113003
|
+
}
|
|
113004
|
+
});
|
|
113005
|
+
if (chatHistoryStore) {
|
|
113006
|
+
onRunFinished((run2) => {
|
|
113007
|
+
if (!run2.sessionId || (run2.kind ?? "chat") !== "chat") return;
|
|
113008
|
+
chatHistoryStore.storePendingRun(run2.sessionId, run2.userId, {
|
|
113009
|
+
requestId: run2.requestId,
|
|
113010
|
+
userText: run2.userText,
|
|
113011
|
+
status: run2.status,
|
|
113012
|
+
truncated: run2.truncated,
|
|
113013
|
+
events: run2.events
|
|
113014
|
+
});
|
|
113015
|
+
});
|
|
113016
|
+
}
|
|
113017
|
+
const pendingRuns = new PendingRunsStore(options.projectPath);
|
|
113018
|
+
onRunFinished((run2) => {
|
|
113019
|
+
if ((run2.kind ?? "chat") === "chat" || run2.saved) return;
|
|
113020
|
+
pendingRuns.put({
|
|
113021
|
+
requestId: run2.requestId,
|
|
113022
|
+
userId: run2.userId,
|
|
113023
|
+
kind: run2.kind,
|
|
113024
|
+
sessionId: run2.sessionId,
|
|
113025
|
+
mode: run2.mode,
|
|
113026
|
+
userText: run2.userText,
|
|
113027
|
+
meta: run2.meta,
|
|
113028
|
+
status: run2.status,
|
|
113029
|
+
startedAt: run2.startedAt,
|
|
113030
|
+
endedAt: run2.endedAt,
|
|
113031
|
+
truncated: run2.truncated,
|
|
113032
|
+
events: run2.events
|
|
113033
|
+
});
|
|
113034
|
+
});
|
|
113035
|
+
const pruneRuns = setInterval(() => pruneChatRuns(), 6e4);
|
|
113036
|
+
pruneRuns.unref?.();
|
|
113037
|
+
const storedSummary = (r) => ({
|
|
113038
|
+
requestId: r.requestId,
|
|
113039
|
+
kind: r.kind,
|
|
113040
|
+
meta: r.meta,
|
|
113041
|
+
saved: false,
|
|
113042
|
+
sessionId: r.sessionId,
|
|
113043
|
+
mode: r.mode,
|
|
113044
|
+
userText: r.userText,
|
|
113045
|
+
startedAt: r.startedAt,
|
|
113046
|
+
endedAt: r.endedAt,
|
|
113047
|
+
status: r.status,
|
|
113048
|
+
waitingForApproval: false,
|
|
113049
|
+
stored: true
|
|
113050
|
+
});
|
|
113051
|
+
app.get("/api/ai/runs", (req, res) => {
|
|
113052
|
+
const userId = callerUserId(req);
|
|
113053
|
+
const sessionId = typeof req.query.sessionId === "string" && req.query.sessionId ? req.query.sessionId : void 0;
|
|
113054
|
+
let runs4 = listChatRuns(userId).map((r) => ({ ...r, tabOpen: !!r.clientId && isClientConnected(wss, r.clientId) }));
|
|
113055
|
+
if (sessionId) {
|
|
113056
|
+
runs4 = runs4.filter((r) => r.sessionId === sessionId);
|
|
113057
|
+
for (const p2 of pendingRuns.list(userId, sessionId)) {
|
|
113058
|
+
if (!runs4.some((r) => r.requestId === p2.requestId)) runs4.push(storedSummary(p2));
|
|
113059
|
+
}
|
|
113060
|
+
}
|
|
113061
|
+
const recordings = listRecordingsInProgress(userId).map((r) => ({ ...r, tabOpen: isClientConnected(wss, r.clientId) }));
|
|
113062
|
+
res.json({ runs: runs4, recordings });
|
|
113063
|
+
});
|
|
113064
|
+
app.get("/api/ai/runs/:requestId", (req, res) => {
|
|
113065
|
+
const after = Number(req.query.after);
|
|
113066
|
+
const userId = callerUserId(req);
|
|
113067
|
+
const snap = chatRunSnapshot(String(req.params.requestId), userId, Number.isFinite(after) && after > 0 ? after : 0);
|
|
113068
|
+
if (snap) {
|
|
113069
|
+
res.json(snap);
|
|
113070
|
+
return;
|
|
113071
|
+
}
|
|
113072
|
+
const kept = pendingRuns.get(String(req.params.requestId), userId);
|
|
113073
|
+
if (!kept) {
|
|
113074
|
+
res.status(404).json({ error: "Run not found" });
|
|
113075
|
+
return;
|
|
113076
|
+
}
|
|
113077
|
+
const events = [];
|
|
113078
|
+
for (const raw of kept.events) {
|
|
113079
|
+
try {
|
|
113080
|
+
events.push(JSON.parse(raw));
|
|
113081
|
+
} catch {
|
|
113082
|
+
}
|
|
113083
|
+
}
|
|
113084
|
+
res.json({ run: storedSummary(kept), events, truncated: kept.truncated, pendingPermissionIds: [] });
|
|
113085
|
+
});
|
|
113086
|
+
app.post("/api/ai/runs/:requestId/saved", (req, res) => {
|
|
113087
|
+
const userId = callerUserId(req);
|
|
113088
|
+
const id = String(req.params.requestId);
|
|
113089
|
+
const known = markRunSaved(id, userId);
|
|
113090
|
+
const removed = pendingRuns.remove(id, userId);
|
|
113091
|
+
res.json({ status: known || removed ? "ok" : "not_found" });
|
|
113092
|
+
});
|
|
112851
113093
|
app.get("/api/ai/knowledge", async (_req, res) => {
|
|
112852
113094
|
try {
|
|
112853
113095
|
const { buildKnowledgeInventory: buildKnowledgeInventory2 } = await Promise.resolve().then(() => (init_knowledge_inventory(), knowledge_inventory_exports));
|
|
@@ -112922,10 +113164,10 @@ function mountAIRoutes(app, wss, options, skillRegistry, mcpClientManager) {
|
|
|
112922
113164
|
return;
|
|
112923
113165
|
}
|
|
112924
113166
|
const { resolve: resolve36, sep: sep10 } = await import("path");
|
|
112925
|
-
const { existsSync:
|
|
113167
|
+
const { existsSync: existsSync128, readFileSync: readFileSync103, statSync: statSync49 } = await import("fs");
|
|
112926
113168
|
const runDir = resolve36(options.projectPath, ".testver", "explore", run2);
|
|
112927
113169
|
const full = resolve36(runDir, file);
|
|
112928
|
-
if (!full.startsWith(runDir + sep10) || !
|
|
113170
|
+
if (!full.startsWith(runDir + sep10) || !existsSync128(full) || !statSync49(full).isFile()) {
|
|
112929
113171
|
res.status(404).json({ error: "That file is not part of the run" });
|
|
112930
113172
|
return;
|
|
112931
113173
|
}
|
|
@@ -112939,7 +113181,7 @@ function mountAIRoutes(app, wss, options, skillRegistry, mcpClientManager) {
|
|
|
112939
113181
|
return;
|
|
112940
113182
|
}
|
|
112941
113183
|
const { redactSecrets: redactSecrets3 } = await Promise.resolve().then(() => (init_utils(), utils_exports));
|
|
112942
|
-
let content =
|
|
113184
|
+
let content = readFileSync103(full, "utf-8");
|
|
112943
113185
|
if (/\.json$/i.test(file)) {
|
|
112944
113186
|
try {
|
|
112945
113187
|
content = JSON.stringify(JSON.parse(content), null, 2);
|
|
@@ -113016,28 +113258,6 @@ ${LOCATOR_COMMENT_RULE}`,
|
|
|
113016
113258
|
res.status(500).json({ error: String(error) });
|
|
113017
113259
|
}
|
|
113018
113260
|
});
|
|
113019
|
-
app.post("/api/ai/generate-api-test", async (req, res) => {
|
|
113020
|
-
try {
|
|
113021
|
-
const { requestId, apiRequests, responses, testName, frameworkHint } = req.body;
|
|
113022
|
-
if (!requestId || !apiRequests || !Array.isArray(apiRequests) || apiRequests.length === 0) {
|
|
113023
|
-
res.status(400).json({ error: "requestId and apiRequests[] required" });
|
|
113024
|
-
return;
|
|
113025
|
-
}
|
|
113026
|
-
const { buildApiTestPrompt: buildApiTestPrompt2 } = await Promise.resolve().then(() => (init_api_test_prompt_builder(), api_test_prompt_builder_exports));
|
|
113027
|
-
const fullPrompt = buildApiTestPrompt2({
|
|
113028
|
-
requests: apiRequests,
|
|
113029
|
-
responses: responses || void 0,
|
|
113030
|
-
projectPath: options.projectPath,
|
|
113031
|
-
frameworkHint: frameworkHint || void 0,
|
|
113032
|
-
testName: testName || void 0
|
|
113033
|
-
});
|
|
113034
|
-
const tabOrchestrator = await resolveTabOrchestrator(req);
|
|
113035
|
-
streamScopedWithToolEvents(tabOrchestrator, wss, fullPrompt, requestId, { clientId: extractClientId(req) });
|
|
113036
|
-
res.json({ status: "streaming", requestId });
|
|
113037
|
-
} catch (error) {
|
|
113038
|
-
res.status(500).json({ error: String(error) });
|
|
113039
|
-
}
|
|
113040
|
-
});
|
|
113041
113261
|
app.post("/api/ai/generate-api-scenarios", async (req, res) => {
|
|
113042
113262
|
try {
|
|
113043
113263
|
const { requestId, endpoints, specSummary: _specSummary, selectedEndpoints, existingCollections } = req.body;
|
|
@@ -113235,7 +113455,7 @@ User question: ${message}` : message;
|
|
|
113235
113455
|
});
|
|
113236
113456
|
app.post("/api/ai/chat-stream", async (req, res) => {
|
|
113237
113457
|
try {
|
|
113238
|
-
const { requestId, message, history, fileContext, uploadedFileIds, model, provider, mode: rawMode, attachedTest, skillSlugs, mcpServerIds, permissionMode: rawPermissionMode } = req.body;
|
|
113458
|
+
const { requestId, message, history, fileContext, uploadedFileIds, model, provider, mode: rawMode, attachedTest, skillSlugs, mcpServerIds, permissionMode: rawPermissionMode, sessionId, displayText } = req.body;
|
|
113239
113459
|
const permissionMode = isPermissionMode(rawPermissionMode) ? rawPermissionMode : "manual";
|
|
113240
113460
|
const clientId = extractClientId(req);
|
|
113241
113461
|
const tabOrchestrator = options.orchestratorPool ? await options.orchestratorPool.getFor(clientId) : orchestrator;
|
|
@@ -113246,6 +113466,18 @@ User question: ${message}` : message;
|
|
|
113246
113466
|
return;
|
|
113247
113467
|
}
|
|
113248
113468
|
const mode = isValidChatMode(rawMode) ? rawMode : DEFAULT_CHAT_MODE;
|
|
113469
|
+
if (getChatRun(requestId)) {
|
|
113470
|
+
res.status(409).json({ error: "requestId already in use" });
|
|
113471
|
+
return;
|
|
113472
|
+
}
|
|
113473
|
+
startChatRun({
|
|
113474
|
+
requestId,
|
|
113475
|
+
userId: callerUserId(req),
|
|
113476
|
+
clientId: typeof clientId === "string" ? clientId : void 0,
|
|
113477
|
+
sessionId: typeof sessionId === "string" && sessionId ? sessionId : void 0,
|
|
113478
|
+
mode,
|
|
113479
|
+
userText: typeof displayText === "string" ? displayText.slice(0, 2e4) : String(message).slice(0, 2e4)
|
|
113480
|
+
});
|
|
113249
113481
|
let resolvedUploads = [];
|
|
113250
113482
|
if (mode !== "ask" && uploadedFileIds && Array.isArray(uploadedFileIds)) {
|
|
113251
113483
|
const { getUploadedFile: getUploadedFile2 } = await Promise.resolve().then(() => (init_api_upload(), api_upload_exports));
|
|
@@ -113334,11 +113566,11 @@ ${lines.join("\n")}`;
|
|
|
113334
113566
|
const { sendTo: sendTo3 } = await Promise.resolve().then(() => (init_shared_streaming(), shared_streaming_exports));
|
|
113335
113567
|
const cid = typeof clientId === "string" ? clientId : void 0;
|
|
113336
113568
|
const plural2 = failedNames.length > 1;
|
|
113337
|
-
sendTo3(wss, cid, {
|
|
113569
|
+
sendTo3(wss, cid, recordRunEvent(requestId, {
|
|
113338
113570
|
type: "ai-mcp-notice",
|
|
113339
113571
|
requestId,
|
|
113340
113572
|
text: `\u26A0\uFE0F Could not connect to MCP server${plural2 ? "s" : ""}: ${failedNames.join(", ")}. Their tools are unavailable for this message \u2014 check ${plural2 ? "them" : "it"} in Settings \u2192 MCP Servers.`
|
|
113341
|
-
});
|
|
113573
|
+
}));
|
|
113342
113574
|
} catch {
|
|
113343
113575
|
}
|
|
113344
113576
|
}
|
|
@@ -113408,6 +113640,7 @@ ${sourcesBlock}` : "") + mcpHint;
|
|
|
113408
113640
|
}
|
|
113409
113641
|
res.json({ status: "streaming", requestId, mode, permissionMode });
|
|
113410
113642
|
} catch (error) {
|
|
113643
|
+
if (typeof req.body?.requestId === "string") finishChatRun(req.body.requestId, "error");
|
|
113411
113644
|
res.status(500).json({ error: String(error) });
|
|
113412
113645
|
}
|
|
113413
113646
|
});
|
|
@@ -113418,6 +113651,11 @@ ${sourcesBlock}` : "") + mcpHint;
|
|
|
113418
113651
|
res.status(400).json({ error: "requestId is required" });
|
|
113419
113652
|
return;
|
|
113420
113653
|
}
|
|
113654
|
+
if (!mayControlRun(requestId, callerUserId(req))) {
|
|
113655
|
+
res.status(404).json({ error: "Run not found" });
|
|
113656
|
+
return;
|
|
113657
|
+
}
|
|
113658
|
+
if (getChatRun(requestId)?.status === "running") recordRunEvent(requestId, { type: "ai-fix-stopped", requestId });
|
|
113421
113659
|
for (const [id, pending] of pendingPermissions) {
|
|
113422
113660
|
if (pending.requestId === requestId) {
|
|
113423
113661
|
pendingPermissions.delete(id);
|
|
@@ -113437,7 +113675,7 @@ ${sourcesBlock}` : "") + mcpHint;
|
|
|
113437
113675
|
return;
|
|
113438
113676
|
}
|
|
113439
113677
|
const clientId = extractClientId(req);
|
|
113440
|
-
const updated = setRequestPermissionMode(requestId, typeof clientId === "string" ? clientId : void 0, permissionMode);
|
|
113678
|
+
const updated = setRequestPermissionMode(requestId, typeof clientId === "string" ? clientId : void 0, permissionMode, callerUserId(req));
|
|
113441
113679
|
res.json({ status: updated ? "updated" : "not_active", requestId, permissionMode });
|
|
113442
113680
|
});
|
|
113443
113681
|
app.post("/api/ai/chat-reset", async (req, res) => {
|
|
@@ -113459,6 +113697,7 @@ ${sourcesBlock}` : "") + mcpHint;
|
|
|
113459
113697
|
if (msg.type === "ai-fix-permission-response") {
|
|
113460
113698
|
const permId = msg.permissionId;
|
|
113461
113699
|
const pending = pendingPermissions.get(permId);
|
|
113700
|
+
if (pending && !mayControlRun(pending.requestId, ws.__user?.id || "local-default-user")) return;
|
|
113462
113701
|
if (pending) {
|
|
113463
113702
|
pendingPermissions.delete(permId);
|
|
113464
113703
|
pending.resolve({
|
|
@@ -114183,6 +114422,8 @@ var init_api_ai = __esm({
|
|
|
114183
114422
|
init_test_scanner();
|
|
114184
114423
|
init_test_run_command();
|
|
114185
114424
|
init_session_prompt();
|
|
114425
|
+
init_chat_runs();
|
|
114426
|
+
init_pending_runs_store();
|
|
114186
114427
|
ALL_BROWSER_TOOLS = [
|
|
114187
114428
|
"browser_launch",
|
|
114188
114429
|
"browser_navigate",
|
|
@@ -114469,7 +114710,7 @@ Focus: REST/GraphQL API tests, request/response validation, schema checks, colle
|
|
|
114469
114710
|
|
|
114470
114711
|
**Auth:** apply the collection's/environment's auth profile (Bearer, API key, Basic, OAuth2) via the environment \u2014 do not paste tokens into request bodies. OAuth2 client credentials is built in (\`auth_type\` on \`api_request\`, or the collection default via \`api_set_collection_settings\`) \u2014 the token is fetched and cached for you. For other OAuth2 flows (password, a login endpoint), obtain the token in a first chain step with an extract rule, store it as a variable, and reference it downstream.
|
|
114471
114712
|
|
|
114472
|
-
**Sending & validating:** \`api_request\` for a
|
|
114713
|
+
**Sending & validating:** a request that is already saved in a collection is sent with \`api_send_collection_request\` (it runs with the collection's environment, auth and validations, and the user sees which saved request ran); \`api_request\` is only for a one-off call to an endpoint that is not saved. Validate BEYOND the status code \u2014 assert the response shape with \`api_validate_schema\` (JSON Schema/OpenAPI) or field checks via \`api_add_validation\`; extract values with JSONPath/JMESPath for reuse. Check status, headers, and body \u2014 not just 200 OK.
|
|
114473
114714
|
|
|
114474
114715
|
**Chains:** for multi-step flows (auth \u2192 create \u2192 read \u2192 delete) use \`api_run_chain\` so extracted variables pass between steps, instead of manually orchestrating sequential \`api_request\` calls.
|
|
114475
114716
|
|
|
@@ -114710,7 +114951,7 @@ __export(report_generator_exports, {
|
|
|
114710
114951
|
executedOnLabel: () => executedOnLabel,
|
|
114711
114952
|
generateHtmlReport: () => generateHtmlReport
|
|
114712
114953
|
});
|
|
114713
|
-
import { readFileSync as
|
|
114954
|
+
import { readFileSync as readFileSync78, existsSync as existsSync95, statSync as statSync39 } from "fs";
|
|
114714
114955
|
import { resolve as resolve25, relative as relative35, isAbsolute as isAbsolute22 } from "path";
|
|
114715
114956
|
function esc(text3) {
|
|
114716
114957
|
return String(text3 ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
@@ -114742,10 +114983,10 @@ function embedScreenshot(path2, projectPath2, maxBytes) {
|
|
|
114742
114983
|
const fullPath = resolve25(projectPath2, path2);
|
|
114743
114984
|
const rel = relative35(resolve25(projectPath2), fullPath);
|
|
114744
114985
|
if (rel.startsWith("..") || isAbsolute22(rel)) return null;
|
|
114745
|
-
if (!
|
|
114986
|
+
if (!existsSync95(fullPath)) return null;
|
|
114746
114987
|
if (statSync39(fullPath).size > maxBytes) return null;
|
|
114747
114988
|
const ext = /\.jpe?g$/i.test(path2) ? "jpeg" : "png";
|
|
114748
|
-
return `data:image/${ext};base64,${
|
|
114989
|
+
return `data:image/${ext};base64,${readFileSync78(fullPath).toString("base64")}`;
|
|
114749
114990
|
} catch {
|
|
114750
114991
|
return null;
|
|
114751
114992
|
}
|
|
@@ -114764,8 +115005,8 @@ ${t.errorMessage || ""}`;
|
|
|
114764
115005
|
const rel = relative35(root, abs);
|
|
114765
115006
|
if (rel.startsWith("..") || isAbsolute22(rel)) continue;
|
|
114766
115007
|
try {
|
|
114767
|
-
if (!
|
|
114768
|
-
const src =
|
|
115008
|
+
if (!existsSync95(abs) || statSync39(abs).size > 2e6) continue;
|
|
115009
|
+
const src = readFileSync78(abs, "utf-8").split(/\r?\n/);
|
|
114769
115010
|
const line = Number(m[2]);
|
|
114770
115011
|
if (!line || line > src.length) continue;
|
|
114771
115012
|
const from = Math.max(1, line - 2), to = Math.min(src.length, line + 2);
|
|
@@ -115302,7 +115543,7 @@ ${g ? `<div style="font-size:14px;line-height:1.55;margin-top:4px">${esc(g.asses
|
|
|
115302
115543
|
}
|
|
115303
115544
|
function reportSecrets(projectPath2) {
|
|
115304
115545
|
try {
|
|
115305
|
-
if (!projectPath2 || !
|
|
115546
|
+
if (!projectPath2 || !existsSync95(resolve25(projectPath2, ".testver", "cloud-config.json"))) return [];
|
|
115306
115547
|
return vendorSecretsFrom(new CloudConfigStore(projectPath2));
|
|
115307
115548
|
} catch {
|
|
115308
115549
|
return [];
|
|
@@ -115678,11 +115919,11 @@ var api_results_exports = {};
|
|
|
115678
115919
|
__export(api_results_exports, {
|
|
115679
115920
|
mountResultsRoutes: () => mountResultsRoutes
|
|
115680
115921
|
});
|
|
115681
|
-
import { existsSync as
|
|
115682
|
-
import { join as
|
|
115922
|
+
import { existsSync as existsSync96, statSync as statSync40, createReadStream, readFileSync as readFileSync79 } from "fs";
|
|
115923
|
+
import { join as join97, extname as extname18, resolve as resolve26 } from "path";
|
|
115683
115924
|
async function storedLogSecrets(projectPath2) {
|
|
115684
115925
|
try {
|
|
115685
|
-
if (!
|
|
115926
|
+
if (!existsSync96(join97(resolve26(projectPath2), ".testver", "cloud-config.json"))) return [];
|
|
115686
115927
|
const { CloudConfigStore: CloudConfigStore4 } = await Promise.resolve().then(() => (init_cloud_config_store(), cloud_config_store_exports));
|
|
115687
115928
|
return vendorSecretsFrom(new CloudConfigStore4(resolve26(projectPath2)));
|
|
115688
115929
|
} catch {
|
|
@@ -115698,9 +115939,9 @@ function mountResultsRoutes(app, resultsStore4, artifactFetcher, projectRoot = p
|
|
|
115698
115939
|
const source2 = sourceRaw === "cloud" || sourceRaw === "local" ? sourceRaw : void 0;
|
|
115699
115940
|
const { runs: stored, total: storedTotal } = resultsStore4.getRunHistory(limit, offset, { status, source: source2 });
|
|
115700
115941
|
const live = offset === 0 && (!status || status === "all" || status === "running") ? listLiveRuns().filter((r) => !source2 || source2 === "cloud" === ranOnCloud(r)) : [];
|
|
115701
|
-
const
|
|
115942
|
+
const runs4 = [...live, ...stored];
|
|
115702
115943
|
const total = storedTotal + live.length;
|
|
115703
|
-
const summary2 =
|
|
115944
|
+
const summary2 = runs4.map((r) => ({
|
|
115704
115945
|
runId: r.runId,
|
|
115705
115946
|
framework: r.framework,
|
|
115706
115947
|
command: r.command,
|
|
@@ -115955,7 +116196,7 @@ function mountResultsRoutes(app, resultsStore4, artifactFetcher, projectRoot = p
|
|
|
115955
116196
|
try {
|
|
115956
116197
|
const { scanAllTests: scanAllTests2 } = await Promise.resolve().then(() => (init_test_scanner(), test_scanner_exports));
|
|
115957
116198
|
const { generateHumanSteps: generateHumanSteps2 } = await Promise.resolve().then(() => (init_step_generator(), step_generator_exports));
|
|
115958
|
-
const { readFileSync:
|
|
116199
|
+
const { readFileSync: readFileSync103, existsSync: existsSync128 } = await import("fs");
|
|
115959
116200
|
const { resolve: resolve36, basename: basename31 } = await import("path");
|
|
115960
116201
|
const scanResult = scanAllTests2(run2.projectPath);
|
|
115961
116202
|
const allScannedTests = scanResult.suites.flatMap((s) => s.tests);
|
|
@@ -115968,8 +116209,8 @@ function mountResultsRoutes(app, resultsStore4, artifactFetcher, projectRoot = p
|
|
|
115968
116209
|
);
|
|
115969
116210
|
if (matchedTest?.line) {
|
|
115970
116211
|
const fullPath = resolve36(run2.projectPath, matchedTest.file);
|
|
115971
|
-
if (
|
|
115972
|
-
const content =
|
|
116212
|
+
if (existsSync128(fullPath)) {
|
|
116213
|
+
const content = readFileSync103(fullPath, "utf-8");
|
|
115973
116214
|
const allLines = content.split("\n");
|
|
115974
116215
|
const endLine = Math.min(matchedTest.endLine || matchedTest.line + 50, allLines.length);
|
|
115975
116216
|
const source2 = allLines.slice(matchedTest.line - 1, endLine).join("\n");
|
|
@@ -115982,13 +116223,13 @@ function mountResultsRoutes(app, resultsStore4, artifactFetcher, projectRoot = p
|
|
|
115982
116223
|
}
|
|
115983
116224
|
} catch {
|
|
115984
116225
|
}
|
|
115985
|
-
const outputDir =
|
|
116226
|
+
const outputDir = join97(resolve26(run2.projectPath), ".testver", "output");
|
|
115986
116227
|
const readOutput = (id) => {
|
|
115987
116228
|
try {
|
|
115988
|
-
const outputPath =
|
|
115989
|
-
if (!
|
|
115990
|
-
const indexPath =
|
|
115991
|
-
return { text:
|
|
116229
|
+
const outputPath = join97(outputDir, `${id}.txt`);
|
|
116230
|
+
if (!existsSync96(outputPath)) return null;
|
|
116231
|
+
const indexPath = join97(outputDir, `${id}-index.json`);
|
|
116232
|
+
return { text: readFileSync79(outputPath, "utf-8"), index: existsSync96(indexPath) ? JSON.parse(readFileSync79(indexPath, "utf-8")) : void 0 };
|
|
115992
116233
|
} catch {
|
|
115993
116234
|
return null;
|
|
115994
116235
|
}
|
|
@@ -116052,13 +116293,13 @@ function mountResultsRoutes(app, resultsStore4, artifactFetcher, projectRoot = p
|
|
|
116052
116293
|
res.status(404).json({ error: "Run not found" });
|
|
116053
116294
|
return;
|
|
116054
116295
|
}
|
|
116055
|
-
const outputDir =
|
|
116056
|
-
const outputPath =
|
|
116057
|
-
if (!
|
|
116296
|
+
const outputDir = join97(resolve26(run2.projectPath), ".testver", "output");
|
|
116297
|
+
const outputPath = join97(outputDir, `${run2.runId}.txt`);
|
|
116298
|
+
if (!existsSync96(outputPath)) {
|
|
116058
116299
|
res.status(404).json({ error: "Console output not available for this run" });
|
|
116059
116300
|
return;
|
|
116060
116301
|
}
|
|
116061
|
-
const fullContent = redactSecrets2(
|
|
116302
|
+
const fullContent = redactSecrets2(readFileSync79(outputPath, "utf-8"), await storedLogSecrets(run2.projectPath));
|
|
116062
116303
|
const testName = req.query.testName;
|
|
116063
116304
|
if (testName) {
|
|
116064
116305
|
const testNameLower = testName.toLowerCase();
|
|
@@ -116097,11 +116338,11 @@ function mountResultsRoutes(app, resultsStore4, artifactFetcher, projectRoot = p
|
|
|
116097
116338
|
lines.push(matchedTest.stackTrace);
|
|
116098
116339
|
lines.push("");
|
|
116099
116340
|
}
|
|
116100
|
-
const indexPath =
|
|
116341
|
+
const indexPath = join97(outputDir, `${run2.runId}-index.json`);
|
|
116101
116342
|
let rawSection = "";
|
|
116102
|
-
if (
|
|
116343
|
+
if (existsSync96(indexPath)) {
|
|
116103
116344
|
try {
|
|
116104
|
-
const index = JSON.parse(
|
|
116345
|
+
const index = JSON.parse(readFileSync79(indexPath, "utf-8"));
|
|
116105
116346
|
const match = index.find(
|
|
116106
116347
|
(e) => e.testName.toLowerCase() === testNameLower || e.testName.toLowerCase().includes(testNameLower) || testNameLower.includes(e.testName.toLowerCase())
|
|
116107
116348
|
);
|
|
@@ -116342,8 +116583,8 @@ var init_api_results = __esm({
|
|
|
116342
116583
|
});
|
|
116343
116584
|
|
|
116344
116585
|
// src/ui/services/step-resolver.ts
|
|
116345
|
-
import { readFileSync as
|
|
116346
|
-
import { resolve as resolve27, relative as relative36, extname as extname19, join as
|
|
116586
|
+
import { readFileSync as readFileSync80, existsSync as existsSync97, readdirSync as readdirSync39 } from "fs";
|
|
116587
|
+
import { resolve as resolve27, relative as relative36, extname as extname19, join as join98 } from "path";
|
|
116347
116588
|
function isStepDefFile(name2, pathLower) {
|
|
116348
116589
|
const ext = extname19(name2).toLowerCase();
|
|
116349
116590
|
if (!STEP_DEF_EXTENSIONS.has(ext)) return false;
|
|
@@ -116364,7 +116605,7 @@ function findStepDefFiles(projectPath2, dir, depth = 0) {
|
|
|
116364
116605
|
const entries = readdirSync39(currentDir, { withFileTypes: true });
|
|
116365
116606
|
for (const entry2 of entries) {
|
|
116366
116607
|
if (entry2.name.startsWith(".") && entry2.name !== ".") continue;
|
|
116367
|
-
const fullPath =
|
|
116608
|
+
const fullPath = join98(currentDir, entry2.name);
|
|
116368
116609
|
if (entry2.isDirectory()) {
|
|
116369
116610
|
if (EXCLUDED_DIRS.has(entry2.name)) continue;
|
|
116370
116611
|
results.push(...findStepDefFiles(projectPath2, fullPath, depth + 1));
|
|
@@ -116578,10 +116819,10 @@ function resolveStepDefinition(projectPath2, stepText2, _stepKeyword) {
|
|
|
116578
116819
|
const normalizedStep = stepText2.trim();
|
|
116579
116820
|
for (const file of stepDefFiles) {
|
|
116580
116821
|
const fullPath = resolve27(projectPath2, file);
|
|
116581
|
-
if (!
|
|
116822
|
+
if (!existsSync97(fullPath)) continue;
|
|
116582
116823
|
let content;
|
|
116583
116824
|
try {
|
|
116584
|
-
content =
|
|
116825
|
+
content = readFileSync80(fullPath, "utf-8");
|
|
116585
116826
|
} catch {
|
|
116586
116827
|
continue;
|
|
116587
116828
|
}
|
|
@@ -116613,10 +116854,10 @@ function resolveStepDefinitions(projectPath2, steps2) {
|
|
|
116613
116854
|
const allDefs = [];
|
|
116614
116855
|
for (const file of stepDefFiles) {
|
|
116615
116856
|
const fullPath = resolve27(projectPath2, file);
|
|
116616
|
-
if (!
|
|
116857
|
+
if (!existsSync97(fullPath)) continue;
|
|
116617
116858
|
let content;
|
|
116618
116859
|
try {
|
|
116619
|
-
content =
|
|
116860
|
+
content = readFileSync80(fullPath, "utf-8");
|
|
116620
116861
|
} catch {
|
|
116621
116862
|
continue;
|
|
116622
116863
|
}
|
|
@@ -116693,19 +116934,19 @@ var init_step_resolver = __esm({
|
|
|
116693
116934
|
});
|
|
116694
116935
|
|
|
116695
116936
|
// src/ui/store/test-lifecycle-store.ts
|
|
116696
|
-
import { readFileSync as
|
|
116697
|
-
import { join as
|
|
116937
|
+
import { readFileSync as readFileSync81, existsSync as existsSync98, mkdirSync as mkdirSync42 } from "fs";
|
|
116938
|
+
import { join as join99, dirname as dirname31 } from "path";
|
|
116698
116939
|
function isLifecycleStatus(v) {
|
|
116699
116940
|
return typeof v === "string" && TEST_LIFECYCLE_STATUSES.includes(v);
|
|
116700
116941
|
}
|
|
116701
116942
|
function fileFor4(projectPath2) {
|
|
116702
|
-
return
|
|
116943
|
+
return join99(projectPath2, ".testver", "test-lifecycle.json");
|
|
116703
116944
|
}
|
|
116704
116945
|
function getLifecycleMap(projectPath2) {
|
|
116705
116946
|
try {
|
|
116706
116947
|
const p2 = fileFor4(projectPath2);
|
|
116707
|
-
if (!
|
|
116708
|
-
const raw = JSON.parse(
|
|
116948
|
+
if (!existsSync98(p2)) return {};
|
|
116949
|
+
const raw = JSON.parse(readFileSync81(p2, "utf-8"));
|
|
116709
116950
|
const src = raw && typeof raw.statuses === "object" ? raw.statuses : {};
|
|
116710
116951
|
const out = {};
|
|
116711
116952
|
for (const [k, v] of Object.entries(src)) if (isLifecycleStatus(v)) out[k] = v;
|
|
@@ -116717,7 +116958,7 @@ function getLifecycleMap(projectPath2) {
|
|
|
116717
116958
|
function save5(projectPath2, map) {
|
|
116718
116959
|
try {
|
|
116719
116960
|
const p2 = fileFor4(projectPath2);
|
|
116720
|
-
if (!
|
|
116961
|
+
if (!existsSync98(dirname31(p2))) mkdirSync42(dirname31(p2), { recursive: true });
|
|
116721
116962
|
writeFileAtomicSync(p2, JSON.stringify({ statuses: map }, null, 2));
|
|
116722
116963
|
} catch {
|
|
116723
116964
|
}
|
|
@@ -116755,8 +116996,8 @@ var api_explorer_exports = {};
|
|
|
116755
116996
|
__export(api_explorer_exports, {
|
|
116756
116997
|
mountExplorerRoutes: () => mountExplorerRoutes
|
|
116757
116998
|
});
|
|
116758
|
-
import { readFileSync as
|
|
116759
|
-
import { resolve as resolve28, basename as basename27, join as
|
|
116999
|
+
import { readFileSync as readFileSync82, existsSync as existsSync99, statSync as statSync41 } from "fs";
|
|
117000
|
+
import { resolve as resolve28, basename as basename27, join as join100 } from "path";
|
|
116760
117001
|
import { createHash as createHash16 } from "crypto";
|
|
116761
117002
|
function mountExplorerRoutes(app, _scanner, options, resultsStore4) {
|
|
116762
117003
|
const { projectPath: projectPath2 } = options;
|
|
@@ -116819,9 +117060,9 @@ function mountExplorerRoutes(app, _scanner, options, resultsStore4) {
|
|
|
116819
117060
|
if (isRacyMtime(Number(stamp2.split("\0")[1]))) h.update(`racy\0${Math.random()}
|
|
116820
117061
|
`);
|
|
116821
117062
|
if (rel === "package.json" || rel.endsWith("/package.json")) {
|
|
116822
|
-
const dir = rel === "package.json" ? projectPath2 :
|
|
117063
|
+
const dir = rel === "package.json" ? projectPath2 : join100(projectPath2, rel.slice(0, -"/package.json".length));
|
|
116823
117064
|
try {
|
|
116824
|
-
const st = statSync41(
|
|
117065
|
+
const st = statSync41(join100(dir, "node_modules", "cypress", "package.json"));
|
|
116825
117066
|
h.update(`cy:${rel}\0${st.size}\0${st.mtimeMs}
|
|
116826
117067
|
`);
|
|
116827
117068
|
} catch {
|
|
@@ -116912,7 +117153,7 @@ function mountExplorerRoutes(app, _scanner, options, resultsStore4) {
|
|
|
116912
117153
|
res.status(403).json({ error: "Path traversal not allowed" });
|
|
116913
117154
|
return;
|
|
116914
117155
|
}
|
|
116915
|
-
if (!
|
|
117156
|
+
if (!existsSync99(fullPath)) {
|
|
116916
117157
|
res.status(404).json({ error: "File not found" });
|
|
116917
117158
|
return;
|
|
116918
117159
|
}
|
|
@@ -116939,7 +117180,7 @@ function mountExplorerRoutes(app, _scanner, options, resultsStore4) {
|
|
|
116939
117180
|
endLine = matchedTest.endLine || startLine + 50;
|
|
116940
117181
|
if (!framework) framework = matchedTest.framework;
|
|
116941
117182
|
fullPath = resolve28(projectPath2, matchedTest.file);
|
|
116942
|
-
if (!
|
|
117183
|
+
if (!existsSync99(fullPath)) {
|
|
116943
117184
|
res.status(404).json({ error: "Source file not found" });
|
|
116944
117185
|
return;
|
|
116945
117186
|
}
|
|
@@ -116947,7 +117188,7 @@ function mountExplorerRoutes(app, _scanner, options, resultsStore4) {
|
|
|
116947
117188
|
res.status(400).json({ error: "Either startLine or testName is required" });
|
|
116948
117189
|
return;
|
|
116949
117190
|
}
|
|
116950
|
-
const content =
|
|
117191
|
+
const content = readFileSync82(fullPath, "utf-8");
|
|
116951
117192
|
const allLines = content.split("\n");
|
|
116952
117193
|
const actualEnd = Math.min(endLine, allLines.length);
|
|
116953
117194
|
const slicedLines = allLines.slice(startLine - 1, actualEnd);
|
|
@@ -117609,7 +117850,7 @@ var api_cicd_exports = {};
|
|
|
117609
117850
|
__export(api_cicd_exports, {
|
|
117610
117851
|
mountCICDRoutes: () => mountCICDRoutes
|
|
117611
117852
|
});
|
|
117612
|
-
import { existsSync as
|
|
117853
|
+
import { existsSync as existsSync100, mkdirSync as mkdirSync43, writeFileSync as writeFileSync25 } from "fs";
|
|
117613
117854
|
import { dirname as dirname32, resolve as resolve29, relative as relative37, isAbsolute as isAbsolute23 } from "path";
|
|
117614
117855
|
function mountCICDRoutes(app, _scanner, options) {
|
|
117615
117856
|
const { projectPath: projectPath2 } = options;
|
|
@@ -117627,7 +117868,7 @@ function mountCICDRoutes(app, _scanner, options) {
|
|
|
117627
117868
|
res.status(400).json({ error: error instanceof Error ? error.message : String(error) });
|
|
117628
117869
|
return;
|
|
117629
117870
|
}
|
|
117630
|
-
const exists =
|
|
117871
|
+
const exists = existsSync100(resolve29(projectRoot, result.filePath));
|
|
117631
117872
|
audit(req, "cicd.generate", { resourceType: "cicd", details: { platform: platform4, mapping: cicdOptions?.delegate?.mapping } });
|
|
117632
117873
|
res.json({ ...result, exists });
|
|
117633
117874
|
});
|
|
@@ -117653,13 +117894,13 @@ function mountCICDRoutes(app, _scanner, options) {
|
|
|
117653
117894
|
res.status(413).json({ error: "Content too large (max 1 MB)" });
|
|
117654
117895
|
return;
|
|
117655
117896
|
}
|
|
117656
|
-
const exists =
|
|
117897
|
+
const exists = existsSync100(fullPath);
|
|
117657
117898
|
if (exists && overwrite !== true) {
|
|
117658
117899
|
res.status(409).json({ error: `${filePath3} already exists in this project`, exists: true, filePath: filePath3 });
|
|
117659
117900
|
return;
|
|
117660
117901
|
}
|
|
117661
117902
|
const dir = dirname32(fullPath);
|
|
117662
|
-
if (!
|
|
117903
|
+
if (!existsSync100(dir)) mkdirSync43(dir, { recursive: true });
|
|
117663
117904
|
writeFileSync25(fullPath, content, "utf-8");
|
|
117664
117905
|
audit(req, "cicd.generate", {
|
|
117665
117906
|
resourceType: "cicd",
|
|
@@ -118513,11 +118754,11 @@ function mountCIRoutes(app, resultsStore4, options, systemConfig) {
|
|
|
118513
118754
|
try {
|
|
118514
118755
|
await ready;
|
|
118515
118756
|
const limit = Math.max(1, Math.min(parseInt(String(req.query.limit || "50"), 10) || 50, 200));
|
|
118516
|
-
const
|
|
118757
|
+
const runs4 = [];
|
|
118517
118758
|
for (const r of ciStore.listRuns(limit)) {
|
|
118518
118759
|
const resolved = isTerminal(r.state) ? r : await resolveStatus(r);
|
|
118519
118760
|
const ahs = resolved.runId ? resultsStore4.getRun(resolved.runId)?.autoHealSummary : void 0;
|
|
118520
|
-
|
|
118761
|
+
runs4.push({
|
|
118521
118762
|
...resolved,
|
|
118522
118763
|
queuePosition: resolved.state === "queued" ? queuePositionOf(resolved.id) : void 0,
|
|
118523
118764
|
// Resolved execution environment — powers the CI Runs env filter
|
|
@@ -118527,7 +118768,7 @@ function mountCIRoutes(app, resultsStore4, options, systemConfig) {
|
|
|
118527
118768
|
autoHeal: ahs && ahs.healed + ahs.suggested + ahs.reverted > 0 ? { healed: ahs.healed, suggested: ahs.suggested, reverted: ahs.reverted } : void 0
|
|
118528
118769
|
});
|
|
118529
118770
|
}
|
|
118530
|
-
res.json({ runs:
|
|
118771
|
+
res.json({ runs: runs4, total: ciStore.listRuns(500).length });
|
|
118531
118772
|
} catch (error) {
|
|
118532
118773
|
res.status(500).json({ error: String(error) });
|
|
118533
118774
|
}
|
|
@@ -118550,9 +118791,9 @@ function mountCIRoutes(app, resultsStore4, options, systemConfig) {
|
|
|
118550
118791
|
}
|
|
118551
118792
|
});
|
|
118552
118793
|
const verdicts = (list) => list.filter((r) => ["passed", "failed", "error"].includes(r.state));
|
|
118553
|
-
const aggregateBy = (
|
|
118794
|
+
const aggregateBy = (runs4, keyOf) => {
|
|
118554
118795
|
const groups = /* @__PURE__ */ new Map();
|
|
118555
|
-
for (const r of
|
|
118796
|
+
for (const r of runs4) {
|
|
118556
118797
|
const key2 = keyOf(r);
|
|
118557
118798
|
if (!key2) continue;
|
|
118558
118799
|
const g = groups.get(key2) || [];
|
|
@@ -124823,6 +125064,7 @@ var api_recorder_exports = {};
|
|
|
124823
125064
|
__export(api_recorder_exports, {
|
|
124824
125065
|
DISCONNECT_GRACE_MS: () => DISCONNECT_GRACE_MS,
|
|
124825
125066
|
actionForUi: () => actionForUi,
|
|
125067
|
+
activeWebRecordings: () => activeWebRecordings,
|
|
124826
125068
|
appendReusableHelpers: () => appendReusableHelpers,
|
|
124827
125069
|
cancelDisconnectFlush: () => cancelDisconnectFlush,
|
|
124828
125070
|
flushRecordingOnDisconnect: () => flushRecordingOnDisconnect,
|
|
@@ -125006,6 +125248,13 @@ function getEntry(clientId, create = false) {
|
|
|
125006
125248
|
}
|
|
125007
125249
|
return e;
|
|
125008
125250
|
}
|
|
125251
|
+
function activeWebRecordings(userId) {
|
|
125252
|
+
const out = [];
|
|
125253
|
+
for (const [clientId, entry2] of recorderByClientId) {
|
|
125254
|
+
if (entry2.recorder?.isRecording() && (entry2.userId || "local-default-user") === userId) out.push(clientId);
|
|
125255
|
+
}
|
|
125256
|
+
return out;
|
|
125257
|
+
}
|
|
125009
125258
|
async function flushRecordingOnDisconnect(clientId, opts = {}) {
|
|
125010
125259
|
if (!clientId) return;
|
|
125011
125260
|
const entry2 = recorderByClientId.get(clientId);
|
|
@@ -125040,6 +125289,7 @@ async function flushRecordingOnDisconnect(clientId, opts = {}) {
|
|
|
125040
125289
|
entry2.recorder = null;
|
|
125041
125290
|
entry2.unsubDisconnect = void 0;
|
|
125042
125291
|
recorderByClientId.delete(clientId);
|
|
125292
|
+
notifyChatRunsChanged();
|
|
125043
125293
|
}
|
|
125044
125294
|
};
|
|
125045
125295
|
if (opts.immediate) {
|
|
@@ -125806,15 +126056,15 @@ function mountRecorderRoutes(app, wss, options) {
|
|
|
125806
126056
|
res.status(400).json({ error: "Choose a test inside this project to add the recorded steps to." });
|
|
125807
126057
|
return;
|
|
125808
126058
|
}
|
|
125809
|
-
const { readFileSync:
|
|
125810
|
-
if (!
|
|
126059
|
+
const { readFileSync: readFileSync103, existsSync: existsSync128 } = await import("fs");
|
|
126060
|
+
if (!existsSync128(fullPath)) {
|
|
125811
126061
|
res.status(404).json({ error: `The test to add the steps to no longer exists: ${targetTestFile}. Pick another test or generate a new one.` });
|
|
125812
126062
|
return;
|
|
125813
126063
|
}
|
|
125814
126064
|
const targetRel = toProjectRel(projectPath2, fullPath);
|
|
125815
126065
|
mergeContext = {
|
|
125816
126066
|
targetFile: targetRel,
|
|
125817
|
-
targetContent:
|
|
126067
|
+
targetContent: readFileSync103(fullPath, "utf-8"),
|
|
125818
126068
|
insertPosition: insertPosition || "auto",
|
|
125819
126069
|
userGuidance: userGuidance || void 0
|
|
125820
126070
|
};
|
|
@@ -125839,6 +126089,17 @@ function mountRecorderRoutes(app, wss, options) {
|
|
|
125839
126089
|
mergeContext
|
|
125840
126090
|
);
|
|
125841
126091
|
rememberRequest(requestId, callerUid, clientId);
|
|
126092
|
+
if (!getChatRun(requestId)) {
|
|
126093
|
+
startChatRun({
|
|
126094
|
+
requestId,
|
|
126095
|
+
userId: callerUid,
|
|
126096
|
+
clientId,
|
|
126097
|
+
kind: "record-web",
|
|
126098
|
+
mode: "record-web",
|
|
126099
|
+
sessionId: entry2.lastSession.id,
|
|
126100
|
+
meta: { analyzeOnly: !!analyzeOnly, followUp: false, testName: typeof testName === "string" ? testName : void 0, mergeMode: !!mergeContext }
|
|
126101
|
+
});
|
|
126102
|
+
}
|
|
125842
126103
|
res.json({ status: "streaming", requestId });
|
|
125843
126104
|
const writtenFilesInThisRun = [];
|
|
125844
126105
|
const sessionSnapshot = entry2.lastSession;
|
|
@@ -125886,7 +126147,8 @@ function mountRecorderRoutes(app, wss, options) {
|
|
|
125886
126147
|
logger35.info(analyzeOnly ? "Analysis complete (awaiting user confirmation)" : "Code generation complete");
|
|
125887
126148
|
} catch (error) {
|
|
125888
126149
|
logger35.error("Failed to generate code:", error);
|
|
125889
|
-
|
|
126150
|
+
if (typeof req.body?.requestId === "string") finishChatRun(req.body.requestId, "error");
|
|
126151
|
+
if (!res.headersSent) res.status(500).json({ error: String(error) });
|
|
125890
126152
|
}
|
|
125891
126153
|
});
|
|
125892
126154
|
app.post("/api/recorder/abort", (req, res) => {
|
|
@@ -125900,6 +126162,7 @@ function mountRecorderRoutes(app, wss, options) {
|
|
|
125900
126162
|
res.status(403).json({ error: "Not your generation." });
|
|
125901
126163
|
return;
|
|
125902
126164
|
}
|
|
126165
|
+
if (getChatRun(requestId)?.status === "running") recordRunEvent(requestId, { type: "ai-fix-stopped", requestId });
|
|
125903
126166
|
const aborted = abortActiveStream(requestId);
|
|
125904
126167
|
logger35.info(`Stop requested for ${requestId} \u2014 ${aborted ? "aborted" : "not found"}`);
|
|
125905
126168
|
res.json({ status: aborted ? "stopped" : "not_active", requestId });
|
|
@@ -125918,7 +126181,8 @@ function mountRecorderRoutes(app, wss, options) {
|
|
|
125918
126181
|
model,
|
|
125919
126182
|
provider,
|
|
125920
126183
|
proceedAfterAnalysis,
|
|
125921
|
-
sessionId
|
|
126184
|
+
sessionId,
|
|
126185
|
+
displayText
|
|
125922
126186
|
} = req.body || {};
|
|
125923
126187
|
if (!requestId || !prompt) {
|
|
125924
126188
|
res.status(400).json({ error: "requestId and prompt are required" });
|
|
@@ -126019,6 +126283,19 @@ function mountRecorderRoutes(app, wss, options) {
|
|
|
126019
126283
|
sections.push(prompt);
|
|
126020
126284
|
const fullPrompt = sections.join("\n");
|
|
126021
126285
|
rememberRequest(requestId, callerUid, clientId);
|
|
126286
|
+
if (!getChatRun(requestId)) {
|
|
126287
|
+
const runRecording = typeof sessionId === "string" && sessionId || generation?.sessionId || entry2.lastSession?.id;
|
|
126288
|
+
startChatRun({
|
|
126289
|
+
requestId,
|
|
126290
|
+
userId: callerUid,
|
|
126291
|
+
clientId,
|
|
126292
|
+
kind: "record-web",
|
|
126293
|
+
mode: "record-web",
|
|
126294
|
+
sessionId: runRecording || void 0,
|
|
126295
|
+
userText: typeof displayText === "string" ? displayText.slice(0, 2e4) : void 0,
|
|
126296
|
+
meta: { analyzeOnly: false, followUp: true, proceedAfterAnalysis: !!proceedAfterAnalysis }
|
|
126297
|
+
});
|
|
126298
|
+
}
|
|
126022
126299
|
res.json({ status: "streaming", requestId });
|
|
126023
126300
|
const writtenFilesInThisRun = [];
|
|
126024
126301
|
let sessionSnapshot = entry2.lastSession;
|
|
@@ -126069,7 +126346,8 @@ function mountRecorderRoutes(app, wss, options) {
|
|
|
126069
126346
|
logger35.info("Follow-up generation complete");
|
|
126070
126347
|
} catch (error) {
|
|
126071
126348
|
logger35.error("Failed to process follow-up:", error);
|
|
126072
|
-
|
|
126349
|
+
if (typeof req.body?.requestId === "string") finishChatRun(req.body.requestId, "error");
|
|
126350
|
+
if (!res.headersSent) res.status(500).json({ error: String(error) });
|
|
126073
126351
|
}
|
|
126074
126352
|
});
|
|
126075
126353
|
app.post("/api/recorder/playback", async (req, res) => {
|
|
@@ -126871,6 +127149,7 @@ var logger35, EXCLUDED_TOOLS_FOR_RECORDER, recorderByClientId, requestOwners, DI
|
|
|
126871
127149
|
var init_api_recorder = __esm({
|
|
126872
127150
|
"src/ui/routes/api-recorder.ts"() {
|
|
126873
127151
|
"use strict";
|
|
127152
|
+
init_chat_runs();
|
|
126874
127153
|
init_recorder2();
|
|
126875
127154
|
init_formatter();
|
|
126876
127155
|
init_shared_streaming();
|
|
@@ -126943,7 +127222,8 @@ var init_api_recorder = __esm({
|
|
|
126943
127222
|
]);
|
|
126944
127223
|
recorderByClientId = /* @__PURE__ */ new Map();
|
|
126945
127224
|
requestOwners = /* @__PURE__ */ new Map();
|
|
126946
|
-
DISCONNECT_GRACE_MS = 6e4;
|
|
127225
|
+
DISCONNECT_GRACE_MS = 5 * 6e4;
|
|
127226
|
+
registerRecordingsSource("record-web", activeWebRecordings);
|
|
126947
127227
|
}
|
|
126948
127228
|
});
|
|
126949
127229
|
|
|
@@ -127769,7 +128049,7 @@ var api_chat_history_exports = {};
|
|
|
127769
128049
|
__export(api_chat_history_exports, {
|
|
127770
128050
|
mountChatHistoryRoutes: () => mountChatHistoryRoutes
|
|
127771
128051
|
});
|
|
127772
|
-
function
|
|
128052
|
+
function callerUserId2(req) {
|
|
127773
128053
|
const u = req.user;
|
|
127774
128054
|
if (u?.id && typeof u.id === "string") return u.id;
|
|
127775
128055
|
return "local-default-user";
|
|
@@ -127777,7 +128057,7 @@ function callerUserId(req) {
|
|
|
127777
128057
|
function mountChatHistoryRoutes(app, chatHistoryStore) {
|
|
127778
128058
|
app.get("/api/chat/sessions", (req, res) => {
|
|
127779
128059
|
try {
|
|
127780
|
-
const sessions = chatHistoryStore.listSessions(
|
|
128060
|
+
const sessions = chatHistoryStore.listSessions(callerUserId2(req));
|
|
127781
128061
|
res.json({ sessions, count: sessions.length });
|
|
127782
128062
|
} catch (error) {
|
|
127783
128063
|
res.status(500).json({ error: String(error) });
|
|
@@ -127785,7 +128065,7 @@ function mountChatHistoryRoutes(app, chatHistoryStore) {
|
|
|
127785
128065
|
});
|
|
127786
128066
|
app.get("/api/chat/sessions/:id", (req, res) => {
|
|
127787
128067
|
try {
|
|
127788
|
-
const session = chatHistoryStore.getSession(req.params.id,
|
|
128068
|
+
const session = chatHistoryStore.getSession(req.params.id, callerUserId2(req));
|
|
127789
128069
|
if (!session) {
|
|
127790
128070
|
res.status(404).json({ error: "Session not found" });
|
|
127791
128071
|
return;
|
|
@@ -127803,7 +128083,7 @@ function mountChatHistoryRoutes(app, chatHistoryStore) {
|
|
|
127803
128083
|
return;
|
|
127804
128084
|
}
|
|
127805
128085
|
const resolvedMode = isValidChatMode(mode) ? mode : DEFAULT_CHAT_MODE;
|
|
127806
|
-
const session = chatHistoryStore.createSession(id, title || "New Chat", resolvedMode,
|
|
128086
|
+
const session = chatHistoryStore.createSession(id, title || "New Chat", resolvedMode, callerUserId2(req));
|
|
127807
128087
|
res.json(session);
|
|
127808
128088
|
} catch (error) {
|
|
127809
128089
|
res.status(500).json({ error: String(error) });
|
|
@@ -127816,7 +128096,7 @@ function mountChatHistoryRoutes(app, chatHistoryStore) {
|
|
|
127816
128096
|
res.status(400).json({ error: "valid mode required (web | api | reporting)" });
|
|
127817
128097
|
return;
|
|
127818
128098
|
}
|
|
127819
|
-
const ok6 = chatHistoryStore.updateMode(req.params.id, mode,
|
|
128099
|
+
const ok6 = chatHistoryStore.updateMode(req.params.id, mode, callerUserId2(req));
|
|
127820
128100
|
if (!ok6) {
|
|
127821
128101
|
res.status(404).json({ error: "Session not found" });
|
|
127822
128102
|
return;
|
|
@@ -127833,7 +128113,7 @@ function mountChatHistoryRoutes(app, chatHistoryStore) {
|
|
|
127833
128113
|
res.status(400).json({ error: "permissionMode must be 'manual' or 'auto'" });
|
|
127834
128114
|
return;
|
|
127835
128115
|
}
|
|
127836
|
-
const ok6 = chatHistoryStore.updatePermissionMode(req.params.id, permissionMode,
|
|
128116
|
+
const ok6 = chatHistoryStore.updatePermissionMode(req.params.id, permissionMode, callerUserId2(req));
|
|
127837
128117
|
if (!ok6) {
|
|
127838
128118
|
res.status(404).json({ error: "Session not found" });
|
|
127839
128119
|
return;
|
|
@@ -127845,7 +128125,7 @@ function mountChatHistoryRoutes(app, chatHistoryStore) {
|
|
|
127845
128125
|
});
|
|
127846
128126
|
app.post("/api/chat/sessions/:id/messages", (req, res) => {
|
|
127847
128127
|
try {
|
|
127848
|
-
const { role, content } = req.body;
|
|
128128
|
+
const { role, content, requestId } = req.body;
|
|
127849
128129
|
if (!role || !content) {
|
|
127850
128130
|
res.status(400).json({ error: "role and content required" });
|
|
127851
128131
|
return;
|
|
@@ -127853,8 +128133,9 @@ function mountChatHistoryRoutes(app, chatHistoryStore) {
|
|
|
127853
128133
|
chatHistoryStore.addMessage(req.params.id, {
|
|
127854
128134
|
role,
|
|
127855
128135
|
content,
|
|
127856
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
127857
|
-
|
|
128136
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
128137
|
+
...typeof requestId === "string" && requestId ? { requestId } : {}
|
|
128138
|
+
}, callerUserId2(req));
|
|
127858
128139
|
res.json({ status: "ok" });
|
|
127859
128140
|
} catch (error) {
|
|
127860
128141
|
res.status(500).json({ error: String(error) });
|
|
@@ -127862,12 +128143,12 @@ function mountChatHistoryRoutes(app, chatHistoryStore) {
|
|
|
127862
128143
|
});
|
|
127863
128144
|
app.put("/api/chat/sessions/:id/timeline", (req, res) => {
|
|
127864
128145
|
try {
|
|
127865
|
-
const { fullTimeline } = req.body || {};
|
|
128146
|
+
const { fullTimeline, runId } = req.body || {};
|
|
127866
128147
|
if (!Array.isArray(fullTimeline)) {
|
|
127867
128148
|
res.status(400).json({ error: "fullTimeline (array) required" });
|
|
127868
128149
|
return;
|
|
127869
128150
|
}
|
|
127870
|
-
const ok6 = chatHistoryStore.saveTimeline(req.params.id, fullTimeline,
|
|
128151
|
+
const ok6 = chatHistoryStore.saveTimeline(req.params.id, fullTimeline, callerUserId2(req), typeof runId === "string" && runId ? runId : void 0);
|
|
127871
128152
|
if (!ok6) {
|
|
127872
128153
|
res.status(404).json({ error: "Session not found" });
|
|
127873
128154
|
return;
|
|
@@ -127884,7 +128165,7 @@ function mountChatHistoryRoutes(app, chatHistoryStore) {
|
|
|
127884
128165
|
res.status(400).json({ error: "title required" });
|
|
127885
128166
|
return;
|
|
127886
128167
|
}
|
|
127887
|
-
const ok6 = chatHistoryStore.renameSession(req.params.id, title,
|
|
128168
|
+
const ok6 = chatHistoryStore.renameSession(req.params.id, title, callerUserId2(req));
|
|
127888
128169
|
if (!ok6) {
|
|
127889
128170
|
res.status(404).json({ error: "Session not found" });
|
|
127890
128171
|
return;
|
|
@@ -127896,7 +128177,7 @@ function mountChatHistoryRoutes(app, chatHistoryStore) {
|
|
|
127896
128177
|
});
|
|
127897
128178
|
app.delete("/api/chat/sessions/:id", (req, res) => {
|
|
127898
128179
|
try {
|
|
127899
|
-
const ok6 = chatHistoryStore.deleteSession(req.params.id,
|
|
128180
|
+
const ok6 = chatHistoryStore.deleteSession(req.params.id, callerUserId2(req));
|
|
127900
128181
|
if (!ok6) {
|
|
127901
128182
|
res.status(404).json({ error: "Session not found" });
|
|
127902
128183
|
return;
|
|
@@ -127908,7 +128189,7 @@ function mountChatHistoryRoutes(app, chatHistoryStore) {
|
|
|
127908
128189
|
});
|
|
127909
128190
|
app.delete("/api/chat/sessions", (req, res) => {
|
|
127910
128191
|
try {
|
|
127911
|
-
chatHistoryStore.clearAll(
|
|
128192
|
+
chatHistoryStore.clearAll(callerUserId2(req));
|
|
127912
128193
|
res.json({ status: "cleared" });
|
|
127913
128194
|
} catch (error) {
|
|
127914
128195
|
res.status(500).json({ error: String(error) });
|
|
@@ -127923,8 +128204,8 @@ var init_api_chat_history = __esm({
|
|
|
127923
128204
|
});
|
|
127924
128205
|
|
|
127925
128206
|
// src/ui/services/cloud-analyzer.ts
|
|
127926
|
-
import { readFileSync as
|
|
127927
|
-
import { join as
|
|
128207
|
+
import { readFileSync as readFileSync83, readdirSync as readdirSync40, statSync as statSync42, existsSync as existsSync101 } from "fs";
|
|
128208
|
+
import { join as join101, relative as relative38 } from "path";
|
|
127928
128209
|
function sniffCdpFramework(projectPath2) {
|
|
127929
128210
|
const manifests = [
|
|
127930
128211
|
{ file: "pom.xml", playwright: "com.microsoft.playwright", selenium: "org.seleniumhq", framework: "playwright-java", language: "java" },
|
|
@@ -127935,9 +128216,9 @@ function sniffCdpFramework(projectPath2) {
|
|
|
127935
128216
|
];
|
|
127936
128217
|
for (const m of manifests) {
|
|
127937
128218
|
try {
|
|
127938
|
-
const p2 =
|
|
127939
|
-
if (!
|
|
127940
|
-
const content =
|
|
128219
|
+
const p2 = join101(projectPath2, m.file);
|
|
128220
|
+
if (!existsSync101(p2)) continue;
|
|
128221
|
+
const content = readFileSync83(p2, "utf-8");
|
|
127941
128222
|
if (content.includes(m.playwright) && !content.includes(m.selenium)) {
|
|
127942
128223
|
return { framework: m.framework, language: m.language };
|
|
127943
128224
|
}
|
|
@@ -127946,21 +128227,21 @@ function sniffCdpFramework(projectPath2) {
|
|
|
127946
128227
|
}
|
|
127947
128228
|
try {
|
|
127948
128229
|
for (const name2 of readdirSync40(projectPath2)) {
|
|
127949
|
-
const full =
|
|
128230
|
+
const full = join101(projectPath2, name2);
|
|
127950
128231
|
const csprojs = [];
|
|
127951
128232
|
if (name2.endsWith(".csproj")) csprojs.push(full);
|
|
127952
128233
|
else if (!name2.startsWith(".") && name2 !== "bin" && name2 !== "obj") {
|
|
127953
128234
|
try {
|
|
127954
128235
|
if (statSync42(full).isDirectory()) {
|
|
127955
128236
|
for (const inner of readdirSync40(full)) {
|
|
127956
|
-
if (inner.endsWith(".csproj")) csprojs.push(
|
|
128237
|
+
if (inner.endsWith(".csproj")) csprojs.push(join101(full, inner));
|
|
127957
128238
|
}
|
|
127958
128239
|
}
|
|
127959
128240
|
} catch {
|
|
127960
128241
|
}
|
|
127961
128242
|
}
|
|
127962
128243
|
for (const f of csprojs) {
|
|
127963
|
-
const content =
|
|
128244
|
+
const content = readFileSync83(f, "utf-8");
|
|
127964
128245
|
if (content.includes("Microsoft.Playwright") && !content.includes("Selenium.WebDriver")) {
|
|
127965
128246
|
return { framework: "playwright-csharp", language: "csharp" };
|
|
127966
128247
|
}
|
|
@@ -128034,7 +128315,7 @@ function analyzeCloudReadiness(projectPath2, detectedFramework, _provider) {
|
|
|
128034
128315
|
result.hookFileAbsolute = hookInfo.filePath;
|
|
128035
128316
|
let content;
|
|
128036
128317
|
try {
|
|
128037
|
-
content =
|
|
128318
|
+
content = readFileSync83(hookInfo.filePath, "utf-8");
|
|
128038
128319
|
} catch {
|
|
128039
128320
|
return result;
|
|
128040
128321
|
}
|
|
@@ -128054,7 +128335,7 @@ function findHookFile(projectPath2, detectedFramework) {
|
|
|
128054
128335
|
const files = resolveGlob(projectPath2, glob11);
|
|
128055
128336
|
for (const filePath3 of files) {
|
|
128056
128337
|
try {
|
|
128057
|
-
const content =
|
|
128338
|
+
const content = readFileSync83(filePath3, "utf-8");
|
|
128058
128339
|
const matchCount = pattern.contentIndicators.filter((ind) => content.includes(ind)).length;
|
|
128059
128340
|
if (matchCount >= 1 && (!pattern.construction || pattern.construction.test(content))) {
|
|
128060
128341
|
return { filePath: filePath3, framework: pattern.framework, language: pattern.language };
|
|
@@ -128079,7 +128360,7 @@ function resolveGlob(basePath, pattern) {
|
|
|
128079
128360
|
const entries = readdirSync40(currentPath, { withFileTypes: true });
|
|
128080
128361
|
for (const entry2 of entries) {
|
|
128081
128362
|
if (entry2.isDirectory() && !entry2.name.startsWith(".") && entry2.name !== "node_modules" && entry2.name !== "dist") {
|
|
128082
|
-
walk3(
|
|
128363
|
+
walk3(join101(currentPath, entry2.name), partIndex);
|
|
128083
128364
|
}
|
|
128084
128365
|
}
|
|
128085
128366
|
} catch {
|
|
@@ -128090,7 +128371,7 @@ function resolveGlob(basePath, pattern) {
|
|
|
128090
128371
|
const entries = readdirSync40(currentPath, { withFileTypes: true });
|
|
128091
128372
|
for (const entry2 of entries) {
|
|
128092
128373
|
if (regex.test(entry2.name)) {
|
|
128093
|
-
const fullPath =
|
|
128374
|
+
const fullPath = join101(currentPath, entry2.name);
|
|
128094
128375
|
if (partIndex === parts.length - 1) {
|
|
128095
128376
|
if (entry2.isFile()) results.push(fullPath);
|
|
128096
128377
|
} else if (entry2.isDirectory()) {
|
|
@@ -128101,8 +128382,8 @@ function resolveGlob(basePath, pattern) {
|
|
|
128101
128382
|
} catch {
|
|
128102
128383
|
}
|
|
128103
128384
|
} else {
|
|
128104
|
-
const fullPath =
|
|
128105
|
-
if (
|
|
128385
|
+
const fullPath = join101(currentPath, part);
|
|
128386
|
+
if (existsSync101(fullPath)) {
|
|
128106
128387
|
if (partIndex === parts.length - 1) {
|
|
128107
128388
|
try {
|
|
128108
128389
|
if (statSync42(fullPath).isFile()) results.push(fullPath);
|
|
@@ -129112,7 +129393,38 @@ var api_api_testing_exports = {};
|
|
|
129112
129393
|
__export(api_api_testing_exports, {
|
|
129113
129394
|
mountApiTestingRoutes: () => mountApiTestingRoutes
|
|
129114
129395
|
});
|
|
129115
|
-
|
|
129396
|
+
import { execFile as execFile2 } from "child_process";
|
|
129397
|
+
import { existsSync as existsSync102 } from "fs";
|
|
129398
|
+
import { join as join102 } from "path";
|
|
129399
|
+
function mountApiTestingRoutes(app, store4, projectPath2) {
|
|
129400
|
+
app.get("/api/api-testing/storage", (_req, res) => {
|
|
129401
|
+
const file = ".testver/api-collections.json";
|
|
129402
|
+
if (!projectPath2) {
|
|
129403
|
+
res.json({ file, exists: true, git: "unknown" });
|
|
129404
|
+
return;
|
|
129405
|
+
}
|
|
129406
|
+
const exists = existsSync102(join102(projectPath2, file));
|
|
129407
|
+
const git2 = (args2) => new Promise((resolve36) => {
|
|
129408
|
+
execFile2("git", args2, { cwd: projectPath2, timeout: 5e3, windowsHide: true }, (err5, stdout) => {
|
|
129409
|
+
resolve36({ code: err5 ? typeof err5.code === "number" ? err5.code : 1 : 0, out: String(stdout || "") });
|
|
129410
|
+
});
|
|
129411
|
+
});
|
|
129412
|
+
void (async () => {
|
|
129413
|
+
const repo = await git2(["rev-parse", "--is-inside-work-tree"]);
|
|
129414
|
+
if (repo.code !== 0 || repo.out.trim() !== "true") {
|
|
129415
|
+
res.json({ file, exists, git: "no-repo" });
|
|
129416
|
+
return;
|
|
129417
|
+
}
|
|
129418
|
+
const tracked2 = await git2(["ls-files", "--", file]);
|
|
129419
|
+
if (tracked2.out.trim()) {
|
|
129420
|
+
const st = await git2(["status", "--porcelain", "--", file]);
|
|
129421
|
+
res.json({ file, exists, git: "tracked", uncommitted: !!st.out.trim() });
|
|
129422
|
+
return;
|
|
129423
|
+
}
|
|
129424
|
+
const ignored = await git2(["check-ignore", "-q", "--", file]);
|
|
129425
|
+
res.json({ file, exists, git: ignored.code === 0 ? "ignored" : "untracked" });
|
|
129426
|
+
})().catch(() => res.json({ file, exists, git: "unknown" }));
|
|
129427
|
+
});
|
|
129116
129428
|
app.get("/api/api-testing/collections", (_req, res) => {
|
|
129117
129429
|
const collections = store4.getCollections();
|
|
129118
129430
|
const summaries = collections.map((c2) => ({
|
|
@@ -129600,7 +129912,7 @@ function resolveAuthContext(req) {
|
|
|
129600
129912
|
};
|
|
129601
129913
|
}
|
|
129602
129914
|
function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
129603
|
-
async function
|
|
129915
|
+
async function changed2() {
|
|
129604
129916
|
gitCache.invalidateAll();
|
|
129605
129917
|
try {
|
|
129606
129918
|
await opts.onWrite?.();
|
|
@@ -129608,7 +129920,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
129608
129920
|
}
|
|
129609
129921
|
}
|
|
129610
129922
|
function failWrite(res, error) {
|
|
129611
|
-
void
|
|
129923
|
+
void changed2();
|
|
129612
129924
|
sendGitError(res, error);
|
|
129613
129925
|
}
|
|
129614
129926
|
async function commitIdentityFor(req, amend) {
|
|
@@ -129767,9 +130079,9 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
129767
130079
|
res.status(404).json({ error: "Run not found" });
|
|
129768
130080
|
return;
|
|
129769
130081
|
}
|
|
129770
|
-
const { runs:
|
|
129771
|
-
const currentIdx =
|
|
129772
|
-
const previousRun = currentIdx >= 0 && currentIdx <
|
|
130082
|
+
const { runs: runs4 } = resultsStore4.getRunHistory(100, 0);
|
|
130083
|
+
const currentIdx = runs4.findIndex((r) => r.runId === runId);
|
|
130084
|
+
const previousRun = currentIdx >= 0 && currentIdx < runs4.length - 1 ? resultsStore4.getRun(runs4[currentIdx + 1].runId) : null;
|
|
129773
130085
|
const correlations = await gitService.correlateFailures(currentRun, previousRun || null);
|
|
129774
130086
|
res.json({ correlations, available: true });
|
|
129775
130087
|
} catch {
|
|
@@ -129815,7 +130127,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
129815
130127
|
return;
|
|
129816
130128
|
}
|
|
129817
130129
|
const result = await gitService.stageFiles(files, { includeTestver: includeTestver === true });
|
|
129818
|
-
await
|
|
130130
|
+
await changed2();
|
|
129819
130131
|
res.json(result);
|
|
129820
130132
|
} catch (error) {
|
|
129821
130133
|
failWrite(res, error);
|
|
@@ -129833,7 +130145,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
129833
130145
|
return;
|
|
129834
130146
|
}
|
|
129835
130147
|
const result = await gitService.unstageFiles(files);
|
|
129836
|
-
await
|
|
130148
|
+
await changed2();
|
|
129837
130149
|
res.json(result);
|
|
129838
130150
|
} catch (error) {
|
|
129839
130151
|
failWrite(res, error);
|
|
@@ -129867,7 +130179,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
129867
130179
|
committer: identity.committer,
|
|
129868
130180
|
includeTestver: includeTestver === true
|
|
129869
130181
|
});
|
|
129870
|
-
await
|
|
130182
|
+
await changed2();
|
|
129871
130183
|
audit(req, "git.commit", {
|
|
129872
130184
|
resourceType: "git",
|
|
129873
130185
|
details: {
|
|
@@ -129915,7 +130227,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
129915
130227
|
return;
|
|
129916
130228
|
}
|
|
129917
130229
|
const result = await gitService.discardFiles(files, scope === "unstaged" ? "unstaged" : "all", { includeTestver: includeTestver === true });
|
|
129918
|
-
await
|
|
130230
|
+
await changed2();
|
|
129919
130231
|
audit(req, "git.discard", { resourceType: "git", details: { count: files.length, ...scope === "unstaged" ? { scope } : {} } });
|
|
129920
130232
|
res.json(result);
|
|
129921
130233
|
} catch (error) {
|
|
@@ -129942,7 +130254,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
129942
130254
|
}
|
|
129943
130255
|
const { message, includeUntracked } = req.body || {};
|
|
129944
130256
|
const result = await gitService.stashSave(message, includeUntracked !== false);
|
|
129945
|
-
await
|
|
130257
|
+
await changed2();
|
|
129946
130258
|
audit(req, "git.stash_save", { resourceType: "git", details: { message: (message || "").slice(0, 100) } });
|
|
129947
130259
|
res.json(result);
|
|
129948
130260
|
} catch (error) {
|
|
@@ -129957,7 +130269,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
129957
130269
|
}
|
|
129958
130270
|
const { ref, sha: sha3 } = req.body || {};
|
|
129959
130271
|
const result = await gitService.stashPop(ref, sha3);
|
|
129960
|
-
await
|
|
130272
|
+
await changed2();
|
|
129961
130273
|
audit(req, "git.stash_pop", { resourceType: "git", details: { ref } });
|
|
129962
130274
|
res.json(result);
|
|
129963
130275
|
} catch (error) {
|
|
@@ -129972,7 +130284,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
129972
130284
|
}
|
|
129973
130285
|
const { ref, sha: sha3 } = req.body || {};
|
|
129974
130286
|
const result = await gitService.stashDrop(ref, sha3);
|
|
129975
|
-
await
|
|
130287
|
+
await changed2();
|
|
129976
130288
|
audit(req, "git.stash_drop", { resourceType: "git", details: { ref } });
|
|
129977
130289
|
res.json(result);
|
|
129978
130290
|
} catch (error) {
|
|
@@ -129986,7 +130298,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
129986
130298
|
return;
|
|
129987
130299
|
}
|
|
129988
130300
|
const result = await gitService.backOutStashApply();
|
|
129989
|
-
await
|
|
130301
|
+
await changed2();
|
|
129990
130302
|
audit(req, "git.stash_back_out", { resourceType: "git", details: { files: result.restored.length, stash: result.stash.slice(0, 100) } });
|
|
129991
130303
|
res.json(result);
|
|
129992
130304
|
} catch (error) {
|
|
@@ -130002,7 +130314,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
130002
130314
|
const { remote } = req.body || {};
|
|
130003
130315
|
const auth = resolveAuthContext(req);
|
|
130004
130316
|
const result = await gitService.fetchRemote(remote, auth);
|
|
130005
|
-
await
|
|
130317
|
+
await changed2();
|
|
130006
130318
|
audit(req, "git.fetch", { resourceType: "git", details: { remote } });
|
|
130007
130319
|
res.json(result);
|
|
130008
130320
|
} catch (error) {
|
|
@@ -130018,7 +130330,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
130018
130330
|
const { remote, branch } = req.body || {};
|
|
130019
130331
|
const auth = resolveAuthContext(req);
|
|
130020
130332
|
const result = await gitService.pull(remote, branch, auth);
|
|
130021
|
-
await
|
|
130333
|
+
await changed2();
|
|
130022
130334
|
audit(req, "git.pull", { resourceType: "git", details: { remote, branch } });
|
|
130023
130335
|
res.json(result);
|
|
130024
130336
|
} catch (error) {
|
|
@@ -130034,7 +130346,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
130034
130346
|
const { remote, branch } = req.body || {};
|
|
130035
130347
|
const auth = resolveAuthContext(req);
|
|
130036
130348
|
const result = await gitService.push(remote, branch, auth);
|
|
130037
|
-
await
|
|
130349
|
+
await changed2();
|
|
130038
130350
|
audit(req, "git.push", { resourceType: "git", details: { remote, branch, ...result.published ? { published: result.published } : {} } });
|
|
130039
130351
|
res.json(result);
|
|
130040
130352
|
} catch (error) {
|
|
@@ -130067,14 +130379,14 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
130067
130379
|
const { path: filePath3, content, delete: deleteFile, side } = req.body || {};
|
|
130068
130380
|
if ((side === "ours" || side === "theirs") && typeof filePath3 === "string") {
|
|
130069
130381
|
const result2 = await gitService.resolveConflictWithSide(filePath3, side);
|
|
130070
|
-
await
|
|
130382
|
+
await changed2();
|
|
130071
130383
|
audit(req, "git.conflict_resolve", { resourceType: "git", details: { path: filePath3, side } });
|
|
130072
130384
|
res.json(result2);
|
|
130073
130385
|
return;
|
|
130074
130386
|
}
|
|
130075
130387
|
if (deleteFile === true && typeof filePath3 === "string") {
|
|
130076
130388
|
const result2 = await gitService.deleteConflictedFile(filePath3);
|
|
130077
|
-
await
|
|
130389
|
+
await changed2();
|
|
130078
130390
|
audit(req, "git.conflict_resolve", { resourceType: "git", details: { path: filePath3, deleted: true } });
|
|
130079
130391
|
res.json(result2);
|
|
130080
130392
|
return;
|
|
@@ -130084,7 +130396,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
130084
130396
|
return;
|
|
130085
130397
|
}
|
|
130086
130398
|
const result = await gitService.resolveConflictedFile(filePath3, content);
|
|
130087
|
-
await
|
|
130399
|
+
await changed2();
|
|
130088
130400
|
audit(req, "git.conflict_resolve", { resourceType: "git", details: { path: filePath3 } });
|
|
130089
130401
|
res.json(result);
|
|
130090
130402
|
} catch (error) {
|
|
@@ -130098,7 +130410,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
130098
130410
|
return;
|
|
130099
130411
|
}
|
|
130100
130412
|
const result = await gitService.abortOperation();
|
|
130101
|
-
await
|
|
130413
|
+
await changed2();
|
|
130102
130414
|
audit(req, "git.operation_abort", { resourceType: "git", details: { operation: result.aborted } });
|
|
130103
130415
|
res.json(result);
|
|
130104
130416
|
} catch (error) {
|
|
@@ -130112,7 +130424,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
130112
130424
|
return;
|
|
130113
130425
|
}
|
|
130114
130426
|
const result = await gitService.continueOperation();
|
|
130115
|
-
await
|
|
130427
|
+
await changed2();
|
|
130116
130428
|
audit(req, "git.operation_continue", { resourceType: "git", details: { operation: result.continued, stoppedAgain: result.conflictedPaths.length > 0 } });
|
|
130117
130429
|
res.json(result);
|
|
130118
130430
|
} catch (error) {
|
|
@@ -130126,7 +130438,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
130126
130438
|
return;
|
|
130127
130439
|
}
|
|
130128
130440
|
const result = await gitService.skipOperationStep();
|
|
130129
|
-
await
|
|
130441
|
+
await changed2();
|
|
130130
130442
|
audit(req, "git.operation_skip", { resourceType: "git", details: { operation: result.skipped, stoppedAgain: result.conflictedPaths.length > 0 } });
|
|
130131
130443
|
res.json(result);
|
|
130132
130444
|
} catch (error) {
|
|
@@ -130157,7 +130469,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
130157
130469
|
return;
|
|
130158
130470
|
}
|
|
130159
130471
|
const result = await gitService.createBranch(name2.trim(), checkout !== false);
|
|
130160
|
-
await
|
|
130472
|
+
await changed2();
|
|
130161
130473
|
audit(req, "git.branch_create", { resourceType: "git", details: { name: name2.trim() } });
|
|
130162
130474
|
res.json(result);
|
|
130163
130475
|
} catch (error) {
|
|
@@ -130176,7 +130488,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
130176
130488
|
return;
|
|
130177
130489
|
}
|
|
130178
130490
|
const result = await gitService.deleteBranch(name2.trim());
|
|
130179
|
-
await
|
|
130491
|
+
await changed2();
|
|
130180
130492
|
audit(req, "git.branch_delete", { resourceType: "git", details: { name: result.deleted } });
|
|
130181
130493
|
res.json(result);
|
|
130182
130494
|
} catch (error) {
|
|
@@ -130195,7 +130507,7 @@ function mountGitRoutes(app, gitService, gitCache, resultsStore4, opts = {}) {
|
|
|
130195
130507
|
return;
|
|
130196
130508
|
}
|
|
130197
130509
|
const result = await gitService.switchBranch(name2.trim());
|
|
130198
|
-
await
|
|
130510
|
+
await changed2();
|
|
130199
130511
|
audit(req, "git.branch_switch", {
|
|
130200
130512
|
resourceType: "git",
|
|
130201
130513
|
details: { name: result.branch, ...result.tracking ? { tracking: result.tracking, created: !!result.created } : {} }
|
|
@@ -130607,11 +130919,11 @@ var api_skills_exports = {};
|
|
|
130607
130919
|
__export(api_skills_exports, {
|
|
130608
130920
|
mountSkillRoutes: () => mountSkillRoutes
|
|
130609
130921
|
});
|
|
130610
|
-
import { existsSync as
|
|
130611
|
-
import { join as
|
|
130922
|
+
import { existsSync as existsSync103, mkdirSync as mkdirSync44, writeFileSync as writeFileSync26, unlinkSync as unlinkSync9, readdirSync as readdirSync41 } from "fs";
|
|
130923
|
+
import { join as join103 } from "path";
|
|
130612
130924
|
function getSkillsDir() {
|
|
130613
|
-
const dir =
|
|
130614
|
-
if (!
|
|
130925
|
+
const dir = join103(getTestverDir(), "skills");
|
|
130926
|
+
if (!existsSync103(dir)) mkdirSync44(dir, { recursive: true });
|
|
130615
130927
|
return dir;
|
|
130616
130928
|
}
|
|
130617
130929
|
function slugify2(name2) {
|
|
@@ -130721,7 +131033,7 @@ function mountSkillRoutes(app, wss, skillRegistry, _skillsConfigStore, orchestra
|
|
|
130721
131033
|
for (const file of files) {
|
|
130722
131034
|
if (file.endsWith(".md")) {
|
|
130723
131035
|
try {
|
|
130724
|
-
unlinkSync9(
|
|
131036
|
+
unlinkSync9(join103(skillsDir, file));
|
|
130725
131037
|
} catch {
|
|
130726
131038
|
}
|
|
130727
131039
|
}
|
|
@@ -130749,7 +131061,7 @@ function mountSkillRoutes(app, wss, skillRegistry, _skillsConfigStore, orchestra
|
|
|
130749
131061
|
return;
|
|
130750
131062
|
}
|
|
130751
131063
|
const skillsDir = getSkillsDir();
|
|
130752
|
-
const filePath3 =
|
|
131064
|
+
const filePath3 = join103(skillsDir, `${slug}.md`);
|
|
130753
131065
|
writeFileSync26(filePath3, content, "utf-8");
|
|
130754
131066
|
const skill = skillRegistry.registerCustom(slug, content, filePath3);
|
|
130755
131067
|
res.status(201).json({
|
|
@@ -130781,7 +131093,7 @@ function mountSkillRoutes(app, wss, skillRegistry, _skillsConfigStore, orchestra
|
|
|
130781
131093
|
return;
|
|
130782
131094
|
}
|
|
130783
131095
|
const skillsDir = getSkillsDir();
|
|
130784
|
-
const filePath3 =
|
|
131096
|
+
const filePath3 = join103(skillsDir, `${slug}.md`);
|
|
130785
131097
|
writeFileSync26(filePath3, content, "utf-8");
|
|
130786
131098
|
const skill = skillRegistry.updateFromContent(slug, content);
|
|
130787
131099
|
res.json({
|
|
@@ -130808,9 +131120,9 @@ function mountSkillRoutes(app, wss, skillRegistry, _skillsConfigStore, orchestra
|
|
|
130808
131120
|
return;
|
|
130809
131121
|
}
|
|
130810
131122
|
const skillsDir = getSkillsDir();
|
|
130811
|
-
const filePath3 =
|
|
131123
|
+
const filePath3 = join103(skillsDir, `${slug}.md`);
|
|
130812
131124
|
try {
|
|
130813
|
-
if (
|
|
131125
|
+
if (existsSync103(filePath3)) unlinkSync9(filePath3);
|
|
130814
131126
|
} catch {
|
|
130815
131127
|
}
|
|
130816
131128
|
skillRegistry.unregister(slug);
|
|
@@ -130871,7 +131183,7 @@ function mountSkillRoutes(app, wss, skillRegistry, _skillsConfigStore, orchestra
|
|
|
130871
131183
|
return;
|
|
130872
131184
|
}
|
|
130873
131185
|
const skillsDir = getSkillsDir();
|
|
130874
|
-
const filePath3 =
|
|
131186
|
+
const filePath3 = join103(skillsDir, `${slug}.md`);
|
|
130875
131187
|
writeFileSync26(filePath3, content, "utf-8");
|
|
130876
131188
|
let skill;
|
|
130877
131189
|
if (existing && existing.source === "user") {
|
|
@@ -130940,7 +131252,7 @@ function mountSkillRoutes(app, wss, skillRegistry, _skillsConfigStore, orchestra
|
|
|
130940
131252
|
return;
|
|
130941
131253
|
}
|
|
130942
131254
|
const skillsDir = getSkillsDir();
|
|
130943
|
-
const filePath3 =
|
|
131255
|
+
const filePath3 = join103(skillsDir, `${slug}.md`);
|
|
130944
131256
|
writeFileSync26(filePath3, content, "utf-8");
|
|
130945
131257
|
let skill;
|
|
130946
131258
|
if (existing && existing.source === "user") {
|
|
@@ -131293,8 +131605,8 @@ var skills_config_store_exports = {};
|
|
|
131293
131605
|
__export(skills_config_store_exports, {
|
|
131294
131606
|
SkillsConfigStore: () => SkillsConfigStore
|
|
131295
131607
|
});
|
|
131296
|
-
import { readFileSync as
|
|
131297
|
-
import { join as
|
|
131608
|
+
import { readFileSync as readFileSync84, mkdirSync as mkdirSync45, existsSync as existsSync104, unlinkSync as unlinkSync10 } from "fs";
|
|
131609
|
+
import { join as join104 } from "path";
|
|
131298
131610
|
var EMPTY_CONFIG, SkillsConfigStore;
|
|
131299
131611
|
var init_skills_config_store = __esm({
|
|
131300
131612
|
"src/ui/store/skills-config-store.ts"() {
|
|
@@ -131307,8 +131619,8 @@ var init_skills_config_store = __esm({
|
|
|
131307
131619
|
filePath;
|
|
131308
131620
|
constructor() {
|
|
131309
131621
|
const dir = getTestverDir();
|
|
131310
|
-
if (!
|
|
131311
|
-
this.filePath =
|
|
131622
|
+
if (!existsSync104(dir)) mkdirSync45(dir, { recursive: true });
|
|
131623
|
+
this.filePath = join104(dir, "skills-config.json");
|
|
131312
131624
|
this.load();
|
|
131313
131625
|
}
|
|
131314
131626
|
getAll() {
|
|
@@ -131340,15 +131652,15 @@ var init_skills_config_store = __esm({
|
|
|
131340
131652
|
reset() {
|
|
131341
131653
|
this.data = { disabled: [], enabled: [], custom: {} };
|
|
131342
131654
|
try {
|
|
131343
|
-
if (
|
|
131655
|
+
if (existsSync104(this.filePath)) unlinkSync10(this.filePath);
|
|
131344
131656
|
} catch {
|
|
131345
131657
|
}
|
|
131346
131658
|
}
|
|
131347
131659
|
// ── Private ──────────────────────────────────────────────────────────────
|
|
131348
131660
|
load() {
|
|
131349
131661
|
try {
|
|
131350
|
-
if (
|
|
131351
|
-
const raw =
|
|
131662
|
+
if (existsSync104(this.filePath)) {
|
|
131663
|
+
const raw = readFileSync84(this.filePath, "utf-8");
|
|
131352
131664
|
const parsed = JSON.parse(raw);
|
|
131353
131665
|
this.data = {
|
|
131354
131666
|
disabled: Array.isArray(parsed.disabled) ? parsed.disabled : [],
|
|
@@ -131380,8 +131692,8 @@ __export(api_collections_store_exports, {
|
|
|
131380
131692
|
ApiCollectionsStore: () => ApiCollectionsStore,
|
|
131381
131693
|
callEndpoint: () => callEndpoint
|
|
131382
131694
|
});
|
|
131383
|
-
import { readFileSync as
|
|
131384
|
-
import { join as
|
|
131695
|
+
import { readFileSync as readFileSync85, mkdirSync as mkdirSync46, existsSync as existsSync105 } from "fs";
|
|
131696
|
+
import { join as join105 } from "path";
|
|
131385
131697
|
function callEndpoint(url) {
|
|
131386
131698
|
if (!url) return "<unknown>";
|
|
131387
131699
|
try {
|
|
@@ -131407,13 +131719,13 @@ var init_api_collections_store = __esm({
|
|
|
131407
131719
|
callLogPath;
|
|
131408
131720
|
constructor(projectPath2) {
|
|
131409
131721
|
const dir = getTestverDir(projectPath2);
|
|
131410
|
-
if (!
|
|
131411
|
-
this.filePath =
|
|
131412
|
-
this.callLogPath =
|
|
131722
|
+
if (!existsSync105(dir)) mkdirSync46(dir, { recursive: true });
|
|
131723
|
+
this.filePath = join105(dir, "api-collections.json");
|
|
131724
|
+
this.callLogPath = join105(dir, "api-call-log.json");
|
|
131413
131725
|
this.load();
|
|
131414
131726
|
try {
|
|
131415
|
-
if (
|
|
131416
|
-
const parsed = JSON.parse(
|
|
131727
|
+
if (existsSync105(this.callLogPath)) {
|
|
131728
|
+
const parsed = JSON.parse(readFileSync85(this.callLogPath, "utf-8"));
|
|
131417
131729
|
this.callLog = Array.isArray(parsed) ? parsed : [];
|
|
131418
131730
|
}
|
|
131419
131731
|
} catch (e) {
|
|
@@ -131662,8 +131974,8 @@ var init_api_collections_store = __esm({
|
|
|
131662
131974
|
// ── Persistence ─────────────────────────────────────────────────────────
|
|
131663
131975
|
load() {
|
|
131664
131976
|
try {
|
|
131665
|
-
if (
|
|
131666
|
-
const raw =
|
|
131977
|
+
if (existsSync105(this.filePath)) {
|
|
131978
|
+
const raw = readFileSync85(this.filePath, "utf-8");
|
|
131667
131979
|
const parsed = JSON.parse(raw);
|
|
131668
131980
|
this.data = {
|
|
131669
131981
|
collections: Array.isArray(parsed.collections) ? parsed.collections : [],
|
|
@@ -131696,7 +132008,7 @@ var init_api_collections_store = __esm({
|
|
|
131696
132008
|
save() {
|
|
131697
132009
|
try {
|
|
131698
132010
|
const dir = getTestverDir();
|
|
131699
|
-
if (!
|
|
132011
|
+
if (!existsSync105(dir)) mkdirSync46(dir, { recursive: true });
|
|
131700
132012
|
writeFileAtomicSync(this.filePath, JSON.stringify(this.data, null, 2));
|
|
131701
132013
|
} catch {
|
|
131702
132014
|
}
|
|
@@ -131711,8 +132023,8 @@ __export(mcp_config_store_exports, {
|
|
|
131711
132023
|
BUILTIN_MCP_PRESETS: () => BUILTIN_MCP_PRESETS,
|
|
131712
132024
|
MCPConfigStore: () => MCPConfigStore
|
|
131713
132025
|
});
|
|
131714
|
-
import { readFileSync as
|
|
131715
|
-
import { join as
|
|
132026
|
+
import { readFileSync as readFileSync86, mkdirSync as mkdirSync47, existsSync as existsSync106 } from "fs";
|
|
132027
|
+
import { join as join106 } from "path";
|
|
131716
132028
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
131717
132029
|
function obfuscateValues(envVars) {
|
|
131718
132030
|
const result = {};
|
|
@@ -131851,8 +132163,8 @@ var init_mcp_config_store = __esm({
|
|
|
131851
132163
|
filePath;
|
|
131852
132164
|
constructor() {
|
|
131853
132165
|
const dir = getTestverDir();
|
|
131854
|
-
if (!
|
|
131855
|
-
this.filePath =
|
|
132166
|
+
if (!existsSync106(dir)) mkdirSync47(dir, { recursive: true });
|
|
132167
|
+
this.filePath = join106(dir, "mcp-config.json");
|
|
131856
132168
|
this.load();
|
|
131857
132169
|
}
|
|
131858
132170
|
// ── Server Management ──────────────────────────────────────────────────
|
|
@@ -131932,8 +132244,8 @@ var init_mcp_config_store = __esm({
|
|
|
131932
132244
|
// ── Persistence ──────────────────────────────────────────────────────────
|
|
131933
132245
|
load() {
|
|
131934
132246
|
try {
|
|
131935
|
-
if (
|
|
131936
|
-
const raw =
|
|
132247
|
+
if (existsSync106(this.filePath)) {
|
|
132248
|
+
const raw = readFileSync86(this.filePath, "utf-8");
|
|
131937
132249
|
const parsed = JSON.parse(raw);
|
|
131938
132250
|
this.data = {
|
|
131939
132251
|
servers: Array.isArray(parsed.servers) ? parsed.servers : []
|
|
@@ -131947,7 +132259,7 @@ var init_mcp_config_store = __esm({
|
|
|
131947
132259
|
save() {
|
|
131948
132260
|
try {
|
|
131949
132261
|
const dir = getTestverDir();
|
|
131950
|
-
if (!
|
|
132262
|
+
if (!existsSync106(dir)) mkdirSync47(dir, { recursive: true });
|
|
131951
132263
|
writeFileAtomicSync(this.filePath, JSON.stringify(this.data, null, 2));
|
|
131952
132264
|
} catch {
|
|
131953
132265
|
}
|
|
@@ -132756,8 +133068,8 @@ var coverage_exports = {};
|
|
|
132756
133068
|
__export(coverage_exports, {
|
|
132757
133069
|
getCoverageOverlay: () => getCoverageOverlay
|
|
132758
133070
|
});
|
|
132759
|
-
import { existsSync as
|
|
132760
|
-
import { join as
|
|
133071
|
+
import { existsSync as existsSync107, readFileSync as readFileSync87, statSync as statSync43 } from "fs";
|
|
133072
|
+
import { join as join107 } from "path";
|
|
132761
133073
|
import { glob as glob9 } from "glob";
|
|
132762
133074
|
async function getCoverageOverlay(projectPath2, symbols) {
|
|
132763
133075
|
const found = await discover(projectPath2);
|
|
@@ -132765,7 +133077,7 @@ async function getCoverageOverlay(projectPath2, symbols) {
|
|
|
132765
133077
|
if (!found) return empty;
|
|
132766
133078
|
let content;
|
|
132767
133079
|
try {
|
|
132768
|
-
content =
|
|
133080
|
+
content = readFileSync87(join107(projectPath2, found.rel), "utf-8");
|
|
132769
133081
|
} catch {
|
|
132770
133082
|
return empty;
|
|
132771
133083
|
}
|
|
@@ -132805,8 +133117,8 @@ async function getCoverageOverlay(projectPath2, symbols) {
|
|
|
132805
133117
|
}
|
|
132806
133118
|
async function discover(projectPath2) {
|
|
132807
133119
|
for (const rel of CANDIDATES) {
|
|
132808
|
-
const full =
|
|
132809
|
-
if (
|
|
133120
|
+
const full = join107(projectPath2, rel);
|
|
133121
|
+
if (existsSync107(full) && safeIsFile(full)) {
|
|
132810
133122
|
return { rel, format: formatOf2(rel) };
|
|
132811
133123
|
}
|
|
132812
133124
|
}
|
|
@@ -132817,7 +133129,7 @@ async function discover(projectPath2) {
|
|
|
132817
133129
|
nodir: true
|
|
132818
133130
|
});
|
|
132819
133131
|
if (hits.length) {
|
|
132820
|
-
hits.sort((a, b) => mtime(
|
|
133132
|
+
hits.sort((a, b) => mtime(join107(projectPath2, b)) - mtime(join107(projectPath2, a)));
|
|
132821
133133
|
const rel = hits[0];
|
|
132822
133134
|
return { rel, format: formatOf2(rel) };
|
|
132823
133135
|
}
|
|
@@ -132925,7 +133237,7 @@ var api_codemap_exports = {};
|
|
|
132925
133237
|
__export(api_codemap_exports, {
|
|
132926
133238
|
mountCodeMapRoutes: () => mountCodeMapRoutes
|
|
132927
133239
|
});
|
|
132928
|
-
import { existsSync as
|
|
133240
|
+
import { existsSync as existsSync108, readFileSync as readFileSync88 } from "fs";
|
|
132929
133241
|
import { resolve as resolve31 } from "path";
|
|
132930
133242
|
function mountCodeMapRoutes(app, options) {
|
|
132931
133243
|
const projectPath2 = options.projectPath;
|
|
@@ -133469,8 +133781,8 @@ function readRange(projectPath2, file, start, end) {
|
|
|
133469
133781
|
const full = resolve31(projectPath2, file);
|
|
133470
133782
|
const rel = full.replace(/\\/g, "/");
|
|
133471
133783
|
if (!rel.startsWith(projectPath2.replace(/\\/g, "/"))) return "";
|
|
133472
|
-
if (!
|
|
133473
|
-
const lines =
|
|
133784
|
+
if (!existsSync108(full)) return "";
|
|
133785
|
+
const lines = readFileSync88(full, "utf-8").split(/\r?\n/);
|
|
133474
133786
|
return lines.slice(Math.max(0, start - 1), Math.min(lines.length, end)).join("\n");
|
|
133475
133787
|
} catch {
|
|
133476
133788
|
return "";
|
|
@@ -133487,7 +133799,7 @@ var api_datamap_exports = {};
|
|
|
133487
133799
|
__export(api_datamap_exports, {
|
|
133488
133800
|
mountDataMapRoutes: () => mountDataMapRoutes
|
|
133489
133801
|
});
|
|
133490
|
-
import { existsSync as
|
|
133802
|
+
import { existsSync as existsSync109, statSync as statSync44 } from "fs";
|
|
133491
133803
|
import { resolve as resolve32, relative as relative39, extname as extname20 } from "path";
|
|
133492
133804
|
import { glob as glob10 } from "glob";
|
|
133493
133805
|
function mountDataMapRoutes(app, options) {
|
|
@@ -133503,7 +133815,7 @@ function mountDataMapRoutes(app, options) {
|
|
|
133503
133815
|
const rel = relative39(projectPath2, abs).replace(/\\/g, "/");
|
|
133504
133816
|
if (raw.includes("\0") || rel === "" || !isInside(resolve32(projectPath2), abs)) return { ok: false, error: "Path is outside the project" };
|
|
133505
133817
|
if (isTestverInternalPath(abs, projectPath2)) return { ok: false, error: TESTVER_PATH_REFUSED };
|
|
133506
|
-
if (!
|
|
133818
|
+
if (!existsSync109(abs) || !statSync44(abs).isFile()) return { ok: false, error: "File not found" };
|
|
133507
133819
|
return { ok: true, rel };
|
|
133508
133820
|
}
|
|
133509
133821
|
app.get("/api/datamap", async (req, res) => {
|
|
@@ -133681,7 +133993,7 @@ var api_auto_heal_exports = {};
|
|
|
133681
133993
|
__export(api_auto_heal_exports, {
|
|
133682
133994
|
mountAutoHealRoutes: () => mountAutoHealRoutes
|
|
133683
133995
|
});
|
|
133684
|
-
import { join as
|
|
133996
|
+
import { join as join108 } from "path";
|
|
133685
133997
|
function mountAutoHealRoutes(app, resultsStore4, options, systemConfig) {
|
|
133686
133998
|
const reviewWindowMs = () => (systemConfig?.getAutoHeal().reviewWindowDays ?? 7) * 24 * 60 * 6e4;
|
|
133687
133999
|
const isExpired = (at2) => {
|
|
@@ -133694,7 +134006,7 @@ function mountAutoHealRoutes(app, resultsStore4, options, systemConfig) {
|
|
|
133694
134006
|
let content = fileCache.get(p2.file);
|
|
133695
134007
|
if (content === void 0) {
|
|
133696
134008
|
try {
|
|
133697
|
-
content = readTextFile(
|
|
134009
|
+
content = readTextFile(join108(options.projectPath, p2.file)).text;
|
|
133698
134010
|
} catch {
|
|
133699
134011
|
content = null;
|
|
133700
134012
|
}
|
|
@@ -133712,7 +134024,7 @@ function mountAutoHealRoutes(app, resultsStore4, options, systemConfig) {
|
|
|
133712
134024
|
let content = fileCache.get(p2.file);
|
|
133713
134025
|
if (content === void 0) {
|
|
133714
134026
|
try {
|
|
133715
|
-
content = readTextFile(
|
|
134027
|
+
content = readTextFile(join108(options.projectPath, p2.file)).text;
|
|
133716
134028
|
} catch {
|
|
133717
134029
|
content = null;
|
|
133718
134030
|
}
|
|
@@ -133729,10 +134041,10 @@ function mountAutoHealRoutes(app, resultsStore4, options, systemConfig) {
|
|
|
133729
134041
|
return out;
|
|
133730
134042
|
};
|
|
133731
134043
|
const allRuns = (limit) => {
|
|
133732
|
-
const { runs:
|
|
134044
|
+
const { runs: runs4 } = resultsStore4.getRunHistory(limit, 0);
|
|
133733
134045
|
const out = [];
|
|
133734
134046
|
const seen = /* @__PURE__ */ new Set();
|
|
133735
|
-
for (const r of
|
|
134047
|
+
for (const r of runs4) {
|
|
133736
134048
|
if (!seen.has(r.runId)) {
|
|
133737
134049
|
seen.add(r.runId);
|
|
133738
134050
|
out.push(r);
|
|
@@ -135830,6 +136142,10 @@ var init_recorder_pool = __esm({
|
|
|
135830
136142
|
if (!clientId) return void 0;
|
|
135831
136143
|
return this.pool.get(clientId)?.recorder;
|
|
135832
136144
|
}
|
|
136145
|
+
/** The tabs that have a recorder. */
|
|
136146
|
+
clientIds() {
|
|
136147
|
+
return [...this.pool.keys()].filter((k) => !k.startsWith("eph_"));
|
|
136148
|
+
}
|
|
135833
136149
|
evict(clientId) {
|
|
135834
136150
|
return this.pool.delete(clientId);
|
|
135835
136151
|
}
|
|
@@ -136727,8 +137043,8 @@ var init_formatters = __esm({
|
|
|
136727
137043
|
});
|
|
136728
137044
|
|
|
136729
137045
|
// src/mobile/recording-history-store.ts
|
|
136730
|
-
import { existsSync as
|
|
136731
|
-
import { join as
|
|
137046
|
+
import { existsSync as existsSync110, mkdirSync as mkdirSync48, readFileSync as readFileSync89, readdirSync as readdirSync42, renameSync as renameSync5, unlinkSync as unlinkSync11, writeFileSync as writeFileSync27 } from "fs";
|
|
137047
|
+
import { join as join109 } from "path";
|
|
136732
137048
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
136733
137049
|
function writeAtomic2(path2, content) {
|
|
136734
137050
|
const tmp = `${path2}.tmp-${process.pid}-${Date.now()}`;
|
|
@@ -136796,9 +137112,9 @@ var init_recording_history_store = __esm({
|
|
|
136796
137112
|
indexPath;
|
|
136797
137113
|
index = { recordings: [] };
|
|
136798
137114
|
constructor(projectPath2) {
|
|
136799
|
-
this.dir =
|
|
136800
|
-
if (!
|
|
136801
|
-
this.indexPath =
|
|
137115
|
+
this.dir = join109(getTestverDir(projectPath2), "mobile-recordings");
|
|
137116
|
+
if (!existsSync110(this.dir)) mkdirSync48(this.dir, { recursive: true });
|
|
137117
|
+
this.indexPath = join109(this.dir, "index.json");
|
|
136802
137118
|
this.load();
|
|
136803
137119
|
}
|
|
136804
137120
|
list(filters = {}) {
|
|
@@ -136817,10 +137133,10 @@ var init_recording_history_store = __esm({
|
|
|
136817
137133
|
}
|
|
136818
137134
|
/** A recording — with `userId`, only when it is that user's (same answer as "missing"). */
|
|
136819
137135
|
get(id, userId) {
|
|
136820
|
-
const path2 =
|
|
136821
|
-
if (!
|
|
137136
|
+
const path2 = join109(this.dir, `${safeFilename(id)}.json`);
|
|
137137
|
+
if (!existsSync110(path2)) return null;
|
|
136822
137138
|
try {
|
|
136823
|
-
const rec = JSON.parse(
|
|
137139
|
+
const rec = JSON.parse(readFileSync89(path2, "utf-8"));
|
|
136824
137140
|
if (userId !== void 0 && !ownedBy(rec, userId)) return null;
|
|
136825
137141
|
return rec;
|
|
136826
137142
|
} catch (err5) {
|
|
@@ -136861,7 +137177,7 @@ var init_recording_history_store = __esm({
|
|
|
136861
137177
|
fullTimeline: input.fullTimeline ?? existing?.fullTimeline,
|
|
136862
137178
|
settings: input.settings === null ? void 0 : input.settings ?? existing?.settings
|
|
136863
137179
|
};
|
|
136864
|
-
writeAtomic2(
|
|
137180
|
+
writeAtomic2(join109(this.dir, `${safeFilename(id)}.json`), JSON.stringify(rec, null, 2));
|
|
136865
137181
|
const { actions, sessionInfo, generatedSpecPath, generatedHealingPath, fullTimeline, settings, ...summary2 } = rec;
|
|
136866
137182
|
void actions;
|
|
136867
137183
|
void sessionInfo;
|
|
@@ -136883,7 +137199,7 @@ var init_recording_history_store = __esm({
|
|
|
136883
137199
|
if (patch.outcome !== void 0) rec.outcome = patch.outcome;
|
|
136884
137200
|
if (patch.status !== void 0) rec.status = patch.status;
|
|
136885
137201
|
rec.updatedAt = Date.now();
|
|
136886
|
-
writeAtomic2(
|
|
137202
|
+
writeAtomic2(join109(this.dir, `${safeFilename(id)}.json`), JSON.stringify(rec, null, 2));
|
|
136887
137203
|
const idx = this.index.recordings.findIndex((r) => r.id === id);
|
|
136888
137204
|
if (idx >= 0) {
|
|
136889
137205
|
const { actions, sessionInfo, generatedSpecPath, generatedHealingPath, fullTimeline, settings, ...summary2 } = rec;
|
|
@@ -136899,9 +137215,9 @@ var init_recording_history_store = __esm({
|
|
|
136899
137215
|
return rec;
|
|
136900
137216
|
}
|
|
136901
137217
|
delete(id, userId) {
|
|
136902
|
-
if (userId !== void 0 &&
|
|
136903
|
-
const path2 =
|
|
136904
|
-
if (
|
|
137218
|
+
if (userId !== void 0 && existsSync110(join109(this.dir, `${safeFilename(id)}.json`)) && !this.get(id, userId)) return false;
|
|
137219
|
+
const path2 = join109(this.dir, `${safeFilename(id)}.json`);
|
|
137220
|
+
if (existsSync110(path2)) {
|
|
136905
137221
|
try {
|
|
136906
137222
|
unlinkSync11(path2);
|
|
136907
137223
|
} catch {
|
|
@@ -136918,8 +137234,8 @@ var init_recording_history_store = __esm({
|
|
|
136918
137234
|
// ── Persistence ────────────────────────────────────────────────────────
|
|
136919
137235
|
load() {
|
|
136920
137236
|
try {
|
|
136921
|
-
if (
|
|
136922
|
-
const raw =
|
|
137237
|
+
if (existsSync110(this.indexPath)) {
|
|
137238
|
+
const raw = readFileSync89(this.indexPath, "utf-8");
|
|
136923
137239
|
const parsed = JSON.parse(raw);
|
|
136924
137240
|
if (Array.isArray(parsed.recordings)) this.index = parsed;
|
|
136925
137241
|
return;
|
|
@@ -136928,7 +137244,7 @@ var init_recording_history_store = __esm({
|
|
|
136928
137244
|
for (const name2 of readdirSync42(this.dir)) {
|
|
136929
137245
|
if (!name2.endsWith(".json") || name2 === "index.json") continue;
|
|
136930
137246
|
try {
|
|
136931
|
-
const rec = JSON.parse(
|
|
137247
|
+
const rec = JSON.parse(readFileSync89(join109(this.dir, name2), "utf-8"));
|
|
136932
137248
|
const { actions, sessionInfo, generatedSpecPath, generatedHealingPath, fullTimeline, ...summary2 } = rec;
|
|
136933
137249
|
void actions;
|
|
136934
137250
|
void sessionInfo;
|
|
@@ -136958,12 +137274,12 @@ var init_recording_history_store = __esm({
|
|
|
136958
137274
|
});
|
|
136959
137275
|
|
|
136960
137276
|
// src/mobile/ai-codegen.ts
|
|
136961
|
-
import { existsSync as
|
|
136962
|
-
import { dirname as dirname33, join as
|
|
137277
|
+
import { existsSync as existsSync111, readdirSync as readdirSync43, readFileSync as readFileSync90, statSync as statSync45 } from "fs";
|
|
137278
|
+
import { dirname as dirname33, join as join110, relative as relative40 } from "path";
|
|
136963
137279
|
function readSample(fullPath, maxBytes = 3500) {
|
|
136964
137280
|
try {
|
|
136965
|
-
if (!
|
|
136966
|
-
const raw =
|
|
137281
|
+
if (!existsSync111(fullPath)) return null;
|
|
137282
|
+
const raw = readFileSync90(fullPath, "utf-8");
|
|
136967
137283
|
if (raw.length <= maxBytes) return { content: raw, truncated: false };
|
|
136968
137284
|
return { content: raw.slice(0, maxBytes), truncated: true };
|
|
136969
137285
|
} catch {
|
|
@@ -136983,7 +137299,7 @@ function pickSmallest(paths) {
|
|
|
136983
137299
|
return best?.path;
|
|
136984
137300
|
}
|
|
136985
137301
|
function findFiles2(rootDir, pattern, maxDepth = 3, cap2 = 30) {
|
|
136986
|
-
if (!
|
|
137302
|
+
if (!existsSync111(rootDir)) return [];
|
|
136987
137303
|
const out = [];
|
|
136988
137304
|
const walk3 = (d, depth) => {
|
|
136989
137305
|
if (depth > maxDepth || out.length >= cap2) return;
|
|
@@ -136996,7 +137312,7 @@ function findFiles2(rootDir, pattern, maxDepth = 3, cap2 = 30) {
|
|
|
136996
137312
|
for (const name2 of entries) {
|
|
136997
137313
|
if (out.length >= cap2) return;
|
|
136998
137314
|
if (name2 === "node_modules" || name2 === ".git" || name2 === "dist" || name2 === "build") continue;
|
|
136999
|
-
const p2 =
|
|
137315
|
+
const p2 = join110(d, name2);
|
|
137000
137316
|
try {
|
|
137001
137317
|
const s = statSync45(p2);
|
|
137002
137318
|
if (s.isDirectory()) walk3(p2, depth + 1);
|
|
@@ -137010,9 +137326,9 @@ function findFiles2(rootDir, pattern, maxDepth = 3, cap2 = 30) {
|
|
|
137010
137326
|
}
|
|
137011
137327
|
function summarizePackageDeps(projectPath2) {
|
|
137012
137328
|
try {
|
|
137013
|
-
const pkgPath =
|
|
137014
|
-
if (!
|
|
137015
|
-
const pkg = JSON.parse(
|
|
137329
|
+
const pkgPath = join110(projectPath2, "package.json");
|
|
137330
|
+
if (!existsSync111(pkgPath)) return void 0;
|
|
137331
|
+
const pkg = JSON.parse(readFileSync90(pkgPath, "utf-8"));
|
|
137016
137332
|
const all = { ...pkg.dependencies || {}, ...pkg.devDependencies || {} };
|
|
137017
137333
|
const RELEVANT = ["webdriverio", "@wdio", "appium", "mocha", "jest", "cucumber", "@cucumber", "jasmine", "chai", "expect", "allure", "cypress", "playwright", "selenium", "typescript", "ts-node"];
|
|
137018
137334
|
const filtered = Object.entries(all).filter(([name2]) => RELEVANT.some((kw) => name2.toLowerCase().includes(kw))).sort(([a], [b]) => a.localeCompare(b));
|
|
@@ -137024,9 +137340,9 @@ function summarizePackageDeps(projectPath2) {
|
|
|
137024
137340
|
}
|
|
137025
137341
|
function detectFrameworkVersion(projectPath2) {
|
|
137026
137342
|
try {
|
|
137027
|
-
const pkgPath =
|
|
137028
|
-
if (!
|
|
137029
|
-
const pkg = JSON.parse(
|
|
137343
|
+
const pkgPath = join110(projectPath2, "package.json");
|
|
137344
|
+
if (!existsSync111(pkgPath)) return {};
|
|
137345
|
+
const pkg = JSON.parse(readFileSync90(pkgPath, "utf-8"));
|
|
137030
137346
|
const all = { ...pkg.dependencies || {}, ...pkg.devDependencies || {} };
|
|
137031
137347
|
let framework;
|
|
137032
137348
|
if (all.webdriverio) framework = `WebdriverIO ${all.webdriverio}`;
|
|
@@ -137047,17 +137363,17 @@ function inspectProject(projectPath2) {
|
|
|
137047
137363
|
hasPomXml: false,
|
|
137048
137364
|
sampleTestPaths: []
|
|
137049
137365
|
};
|
|
137050
|
-
const exists = (rel) =>
|
|
137366
|
+
const exists = (rel) => existsSync111(join110(projectPath2, rel));
|
|
137051
137367
|
const read5 = (rel) => {
|
|
137052
137368
|
try {
|
|
137053
|
-
return
|
|
137369
|
+
return readFileSync90(join110(projectPath2, rel), "utf-8");
|
|
137054
137370
|
} catch {
|
|
137055
137371
|
return "";
|
|
137056
137372
|
}
|
|
137057
137373
|
};
|
|
137058
137374
|
const list = (rel) => {
|
|
137059
137375
|
try {
|
|
137060
|
-
return readdirSync43(
|
|
137376
|
+
return readdirSync43(join110(projectPath2, rel));
|
|
137061
137377
|
} catch {
|
|
137062
137378
|
return [];
|
|
137063
137379
|
}
|
|
@@ -137071,7 +137387,7 @@ function inspectProject(projectPath2) {
|
|
|
137071
137387
|
const javaRunner = !javaBuild ? void 0 : /testng/i.test(javaBuild) ? "testng" : /junit/i.test(javaBuild) ? "junit" : "testng";
|
|
137072
137388
|
const csprojs = [
|
|
137073
137389
|
...list(".").filter((f) => f.endsWith(".csproj")),
|
|
137074
|
-
...list(".").filter((d) => !d.startsWith(".") && d !== "node_modules" && d !== "bin" && d !== "obj").flatMap((d) => list(d).filter((f) => f.endsWith(".csproj")).map((f) =>
|
|
137390
|
+
...list(".").filter((d) => !d.startsWith(".") && d !== "node_modules" && d !== "bin" && d !== "obj").flatMap((d) => list(d).filter((f) => f.endsWith(".csproj")).map((f) => join110(d, f)))
|
|
137075
137391
|
];
|
|
137076
137392
|
const dotnet = csprojs.map(read5).join("\n");
|
|
137077
137393
|
const dotnetRunner = !csprojs.length ? void 0 : /xunit/i.test(dotnet) ? "xunit" : /MSTest/i.test(dotnet) ? "mstest" : "nunit";
|
|
@@ -137086,7 +137402,7 @@ function inspectProject(projectPath2) {
|
|
|
137086
137402
|
const testCandidates = ["tests/mobile", "tests", "test", "src/tests", "e2e", "spec", "specs"];
|
|
137087
137403
|
const allTestFiles = [];
|
|
137088
137404
|
for (const dir of testCandidates) {
|
|
137089
|
-
allTestFiles.push(...findFiles2(
|
|
137405
|
+
allTestFiles.push(...findFiles2(join110(projectPath2, dir), /\.(spec|test)\.(ts|js|py|java|cs)$|^test_.+\.py$|_test\.py$|(Test|Tests|IT)\.(java|kt|cs)$/));
|
|
137090
137406
|
}
|
|
137091
137407
|
hints.sampleTestPaths = [...new Set(allTestFiles)].slice(0, 8);
|
|
137092
137408
|
const dirCount = /* @__PURE__ */ new Map();
|
|
@@ -137122,17 +137438,17 @@ function inspectProject(projectPath2) {
|
|
|
137122
137438
|
];
|
|
137123
137439
|
const PAGE_FILE = /Page\.(ts|js|py|java|cs|kt)$|_page\.(ts|js|py)$|Screen\.(ts|js|py|java|cs|kt)$|\.screen\.(ts|js)$|_screen\.py$/;
|
|
137124
137440
|
for (const d of pageDirs) {
|
|
137125
|
-
if (
|
|
137441
|
+
if (existsSync111(join110(projectPath2, d))) {
|
|
137126
137442
|
hints.pageObjectDir = d;
|
|
137127
137443
|
break;
|
|
137128
137444
|
}
|
|
137129
137445
|
}
|
|
137130
137446
|
let pageObjectCandidates = [];
|
|
137131
137447
|
if (hints.pageObjectDir) {
|
|
137132
|
-
pageObjectCandidates = findFiles2(
|
|
137448
|
+
pageObjectCandidates = findFiles2(join110(projectPath2, hints.pageObjectDir), PAGE_FILE);
|
|
137133
137449
|
} else {
|
|
137134
137450
|
for (const dir of testCandidates) {
|
|
137135
|
-
pageObjectCandidates.push(...findFiles2(
|
|
137451
|
+
pageObjectCandidates.push(...findFiles2(join110(projectPath2, dir), PAGE_FILE, 4, 10));
|
|
137136
137452
|
}
|
|
137137
137453
|
}
|
|
137138
137454
|
pageObjectCandidates = [...new Set(pageObjectCandidates)];
|
|
@@ -137144,13 +137460,13 @@ function inspectProject(projectPath2) {
|
|
|
137144
137460
|
}
|
|
137145
137461
|
const helperDirs = ["tests/mobile/helpers", "tests/helpers", "tests/support", "tests/fixtures", "tests/mobile/fixtures", "test/support", "test/helpers", "test/fixtures", "src/helpers", "src/support", "helpers", "support"];
|
|
137146
137462
|
for (const d of helperDirs) {
|
|
137147
|
-
if (
|
|
137463
|
+
if (existsSync111(join110(projectPath2, d))) {
|
|
137148
137464
|
hints.helperDir = d;
|
|
137149
137465
|
break;
|
|
137150
137466
|
}
|
|
137151
137467
|
}
|
|
137152
137468
|
if (hints.helperDir) {
|
|
137153
|
-
const helpers = findFiles2(
|
|
137469
|
+
const helpers = findFiles2(join110(projectPath2, hints.helperDir), /\.(ts|js|py|java|cs)$/, 3, 8);
|
|
137154
137470
|
const embedHelper = pickSmallest(helpers);
|
|
137155
137471
|
if (embedHelper) {
|
|
137156
137472
|
hints.sampleHelper = relative40(projectPath2, embedHelper);
|
|
@@ -137204,9 +137520,9 @@ function formatActionForPrompt(a, n) {
|
|
|
137204
137520
|
}
|
|
137205
137521
|
function readMergeTarget(projectPath2, relPath) {
|
|
137206
137522
|
try {
|
|
137207
|
-
const full =
|
|
137208
|
-
if (!
|
|
137209
|
-
const raw =
|
|
137523
|
+
const full = join110(projectPath2, relPath);
|
|
137524
|
+
if (!existsSync111(full)) return null;
|
|
137525
|
+
const raw = readFileSync90(full, "utf-8");
|
|
137210
137526
|
const MAX = 8192;
|
|
137211
137527
|
if (raw.length <= MAX) return { content: raw, truncated: false };
|
|
137212
137528
|
return { content: raw.slice(0, MAX), truncated: true };
|
|
@@ -137483,8 +137799,8 @@ function listMobileTestFiles(projectPath2) {
|
|
|
137483
137799
|
};
|
|
137484
137800
|
const matchTest = (name2) => /\.(spec|test)\.(ts|js)$/.test(name2) || /^test_.+\.py$/.test(name2) || /.+_test\.py$/.test(name2) || /(Test|Tests|IT)\.(java|cs)$/.test(name2);
|
|
137485
137801
|
for (const dir of candidates) {
|
|
137486
|
-
const full =
|
|
137487
|
-
if (!
|
|
137802
|
+
const full = join110(projectPath2, dir);
|
|
137803
|
+
if (!existsSync111(full)) continue;
|
|
137488
137804
|
try {
|
|
137489
137805
|
const st = statSync45(full);
|
|
137490
137806
|
if (!st.isDirectory()) continue;
|
|
@@ -137498,7 +137814,7 @@ function listMobileTestFiles(projectPath2) {
|
|
|
137498
137814
|
}
|
|
137499
137815
|
for (const e of entries) {
|
|
137500
137816
|
if (e === "node_modules" || e === ".git") continue;
|
|
137501
|
-
const p2 =
|
|
137817
|
+
const p2 = join110(d, e);
|
|
137502
137818
|
if (SEEN.has(p2)) continue;
|
|
137503
137819
|
try {
|
|
137504
137820
|
const s = statSync45(p2);
|
|
@@ -137510,7 +137826,7 @@ function listMobileTestFiles(projectPath2) {
|
|
|
137510
137826
|
let tests = [];
|
|
137511
137827
|
if (s.size < 1e5) {
|
|
137512
137828
|
try {
|
|
137513
|
-
const content =
|
|
137829
|
+
const content = readFileSync90(p2, "utf-8");
|
|
137514
137830
|
testCount = countTests(content, language);
|
|
137515
137831
|
tests = extractTestCases(content, language);
|
|
137516
137832
|
} catch {
|
|
@@ -137553,6 +137869,7 @@ var init_ai_codegen = __esm({
|
|
|
137553
137869
|
// src/ui/routes/api-mobile.ts
|
|
137554
137870
|
var api_mobile_exports = {};
|
|
137555
137871
|
__export(api_mobile_exports, {
|
|
137872
|
+
activeMobileRecordings: () => activeMobileRecordings,
|
|
137556
137873
|
cancelMobileClientGone: () => cancelMobileClientGone,
|
|
137557
137874
|
ensureAdbPump: () => ensureAdbPump,
|
|
137558
137875
|
mountMobileRoutes: () => mountMobileRoutes,
|
|
@@ -137560,8 +137877,8 @@ __export(api_mobile_exports, {
|
|
|
137560
137877
|
setMobileClientOwners: () => setMobileClientOwners
|
|
137561
137878
|
});
|
|
137562
137879
|
import multer2 from "multer";
|
|
137563
|
-
import { join as
|
|
137564
|
-
import { mkdirSync as
|
|
137880
|
+
import { join as join111 } from "path";
|
|
137881
|
+
import { mkdirSync as mkdirSync49, writeFileSync as writeFileSync28, existsSync as existsSync112 } from "fs";
|
|
137565
137882
|
async function fetchExternalScreenshotOnce(ext) {
|
|
137566
137883
|
const url = `${ext.hubProtocol}://${ext.hubHost}:${ext.hubPort}${ext.hubPath}/session/${ext.sessionId}/screenshot`;
|
|
137567
137884
|
const headers = {};
|
|
@@ -137742,6 +138059,9 @@ function mobileAuth(req) {
|
|
|
137742
138059
|
}
|
|
137743
138060
|
return { userId: "local-default-user", isAdmin: true };
|
|
137744
138061
|
}
|
|
138062
|
+
function activeMobileRecordings(userId) {
|
|
138063
|
+
return listActiveMobileRecordings?.(userId) ?? [];
|
|
138064
|
+
}
|
|
137745
138065
|
function scheduleMobileClientGone(clientId, graceMs) {
|
|
137746
138066
|
if (!clientId || !onClientGone) return;
|
|
137747
138067
|
cancelMobileClientGone(clientId);
|
|
@@ -137799,6 +138119,11 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
137799
138119
|
}
|
|
137800
138120
|
return recorderPoolSingleton;
|
|
137801
138121
|
};
|
|
138122
|
+
listActiveMobileRecordings = (userId) => {
|
|
138123
|
+
const pool = recorderPoolSingleton;
|
|
138124
|
+
if (!pool) return [];
|
|
138125
|
+
return pool.clientIds().filter((cid) => pool.peek(cid)?.isRecording() && (mobileRecordingOwners.get(cid) || "local-default-user") === userId);
|
|
138126
|
+
};
|
|
137802
138127
|
let secretsGuarded = false;
|
|
137803
138128
|
const secretSink = (field, value) => {
|
|
137804
138129
|
const projectPath2 = options.projectPath;
|
|
@@ -137860,6 +138185,7 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
137860
138185
|
logger41.warn(`Saving the recording of a closed tab failed: ${err5.message}`);
|
|
137861
138186
|
}
|
|
137862
138187
|
recorderPool()?.evict(clientId);
|
|
138188
|
+
notifyChatRunsChanged();
|
|
137863
138189
|
const mgr = mPool?.peek(clientId);
|
|
137864
138190
|
if (mgr && !mgr.isLockedForRun()) {
|
|
137865
138191
|
try {
|
|
@@ -138412,6 +138738,8 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
138412
138738
|
const recorder = pool.getFor(clientId);
|
|
138413
138739
|
recorder.start();
|
|
138414
138740
|
wireCapture(clientId, recorder);
|
|
138741
|
+
mobileRecordingOwners.set(clientId, mobileAuth(req).userId);
|
|
138742
|
+
notifyChatRunsChanged();
|
|
138415
138743
|
res.json({ status: "recording", startedAt: recorder.getStartedAt(), actions: [] });
|
|
138416
138744
|
});
|
|
138417
138745
|
app.post("/api/mobile/recording/pause", (req, res) => {
|
|
@@ -138764,6 +139092,7 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
138764
139092
|
}
|
|
138765
139093
|
recorder.stop();
|
|
138766
139094
|
recorder.onActionRecorded(null);
|
|
139095
|
+
notifyChatRunsChanged();
|
|
138767
139096
|
await recorder.flushEnrichments();
|
|
138768
139097
|
const liveInfo = mPool.peek(clientId)?.getSessionInfo() ?? null;
|
|
138769
139098
|
const sessionInfo = liveInfo ?? recorder.getSessionSnapshot();
|
|
@@ -138789,10 +139118,10 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
138789
139118
|
}
|
|
138790
139119
|
const testName = String(req.body?.testName || `Recorded ${(/* @__PURE__ */ new Date()).toISOString().slice(0, 16)}`);
|
|
138791
139120
|
const result = formatRecording(formatterId, recorder.getActions(), sessionInfo, testName);
|
|
138792
|
-
const targetDir =
|
|
138793
|
-
if (!
|
|
138794
|
-
const specPath =
|
|
138795
|
-
const healingPath =
|
|
139121
|
+
const targetDir = join111(options.projectPath, "tests", "mobile");
|
|
139122
|
+
if (!existsSync112(targetDir)) mkdirSync49(targetDir, { recursive: true });
|
|
139123
|
+
const specPath = join111(targetDir, result.specFilename);
|
|
139124
|
+
const healingPath = join111(targetDir, result.healingFilename);
|
|
138796
139125
|
writeFileSync28(specPath, result.specSource, "utf-8");
|
|
138797
139126
|
writeFileSync28(healingPath, result.healingJson, "utf-8");
|
|
138798
139127
|
logger41.info(`Recording saved \u2192 ${specPath}`);
|
|
@@ -139063,6 +139392,17 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
139063
139392
|
return res.status(400).json({ error: "targetTestFile must be a file inside the project." });
|
|
139064
139393
|
}
|
|
139065
139394
|
rememberRequest(requestId, mobileAuth(req).userId, clientId);
|
|
139395
|
+
if (!getChatRun(requestId)) {
|
|
139396
|
+
startChatRun({
|
|
139397
|
+
requestId,
|
|
139398
|
+
userId: mobileAuth(req).userId,
|
|
139399
|
+
clientId,
|
|
139400
|
+
kind: "record-mobile",
|
|
139401
|
+
mode: "record-mobile",
|
|
139402
|
+
sessionId: typeof body.recordingId === "string" && body.recordingId ? body.recordingId : void 0,
|
|
139403
|
+
meta: { analyzeOnly, followUp: false, testName, device: sessionInfo.device }
|
|
139404
|
+
});
|
|
139405
|
+
}
|
|
139066
139406
|
const prompt = buildMobileCodegenPrompt({
|
|
139067
139407
|
actions: recorder.getActions(),
|
|
139068
139408
|
session: sessionInfo,
|
|
@@ -139143,7 +139483,8 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
139143
139483
|
}
|
|
139144
139484
|
}
|
|
139145
139485
|
} catch (err5) {
|
|
139146
|
-
if (wss) sendTo(wss, clientId, { type: "ai-fix-error", message: err5.message });
|
|
139486
|
+
if (wss) sendTo(wss, clientId, recordRunEvent(requestId, { type: "ai-fix-error", requestId, message: err5.message }));
|
|
139487
|
+
finishChatRun(requestId, "error");
|
|
139147
139488
|
}
|
|
139148
139489
|
});
|
|
139149
139490
|
app.post("/api/mobile/recording/generate/followup", async (req, res) => {
|
|
@@ -139160,6 +139501,18 @@ function mountMobileRoutes(app, options, wss) {
|
|
|
139160
139501
|
return res.status(400).json({ error: "Body must include prompt or proceedAfterAnalysis." });
|
|
139161
139502
|
}
|
|
139162
139503
|
rememberRequest(requestId, mobileAuth(req).userId, clientId);
|
|
139504
|
+
if (!getChatRun(requestId)) {
|
|
139505
|
+
startChatRun({
|
|
139506
|
+
requestId,
|
|
139507
|
+
userId: mobileAuth(req).userId,
|
|
139508
|
+
clientId,
|
|
139509
|
+
kind: "record-mobile",
|
|
139510
|
+
mode: "record-mobile",
|
|
139511
|
+
sessionId: typeof body.recordingId === "string" && body.recordingId ? body.recordingId : void 0,
|
|
139512
|
+
userText: typeof body.displayText === "string" ? body.displayText.slice(0, 2e4) : prompt || void 0,
|
|
139513
|
+
meta: { analyzeOnly: false, followUp: true, proceedAfterAnalysis }
|
|
139514
|
+
});
|
|
139515
|
+
}
|
|
139163
139516
|
res.json({ status: "streaming", requestId });
|
|
139164
139517
|
try {
|
|
139165
139518
|
const orchestrator = await options.orchestratorPool.getFor(clientId);
|
|
@@ -139341,13 +139694,15 @@ ${previousContext}`);
|
|
|
139341
139694
|
);
|
|
139342
139695
|
}
|
|
139343
139696
|
} catch (err5) {
|
|
139344
|
-
if (wss) sendTo(wss, clientId, { type: "ai-fix-error", message: err5.message });
|
|
139697
|
+
if (wss) sendTo(wss, clientId, recordRunEvent(requestId, { type: "ai-fix-error", requestId, message: err5.message }));
|
|
139698
|
+
finishChatRun(requestId, "error");
|
|
139345
139699
|
}
|
|
139346
139700
|
});
|
|
139347
139701
|
app.post("/api/mobile/recording/generate/stop", (req, res) => {
|
|
139348
139702
|
const requestId = String(req.body?.requestId || "");
|
|
139349
139703
|
if (!requestId) return res.status(400).json({ error: "requestId required." });
|
|
139350
139704
|
if (!mayStopRequest(requestId, req)) return res.status(403).json({ error: "Not your generation." });
|
|
139705
|
+
if (getChatRun(requestId)?.status === "running") recordRunEvent(requestId, { type: "ai-fix-stopped", requestId });
|
|
139351
139706
|
const stopped = abortActiveStream(requestId);
|
|
139352
139707
|
res.json({ status: stopped ? "stopped" : "not_active", requestId });
|
|
139353
139708
|
});
|
|
@@ -139473,10 +139828,11 @@ ${previousContext}`);
|
|
|
139473
139828
|
}
|
|
139474
139829
|
});
|
|
139475
139830
|
}
|
|
139476
|
-
var latestExternalFrames, externalFramePumps, FRAME_PUMP_INTERVAL_MS, adbPumps, ADB_PUMP_CAPTURE_TIMEOUT_MS, ADB_PUMP_IDLE_STOP_MS, ADB_FIRST_FRAME_WAIT_MS, ADB_FRESH_MS, ADB_UNCHANGED_WAIT_MS, logger41, MOBILE_PROVIDER_IDS, EXCLUDED_TOOLS_FOR_MOBILE_RECORDER, mobileClientOwnersRef, clientGoneTimers, onClientGone;
|
|
139831
|
+
var latestExternalFrames, externalFramePumps, FRAME_PUMP_INTERVAL_MS, adbPumps, ADB_PUMP_CAPTURE_TIMEOUT_MS, ADB_PUMP_IDLE_STOP_MS, ADB_FIRST_FRAME_WAIT_MS, ADB_FRESH_MS, ADB_UNCHANGED_WAIT_MS, logger41, MOBILE_PROVIDER_IDS, EXCLUDED_TOOLS_FOR_MOBILE_RECORDER, mobileClientOwnersRef, mobileRecordingOwners, listActiveMobileRecordings, clientGoneTimers, onClientGone;
|
|
139477
139832
|
var init_api_mobile = __esm({
|
|
139478
139833
|
"src/ui/routes/api-mobile.ts"() {
|
|
139479
139834
|
"use strict";
|
|
139835
|
+
init_chat_runs();
|
|
139480
139836
|
init_utils();
|
|
139481
139837
|
init_app_library();
|
|
139482
139838
|
init_providers2();
|
|
@@ -139584,6 +139940,9 @@ var init_api_mobile = __esm({
|
|
|
139584
139940
|
"api_add_validation"
|
|
139585
139941
|
]);
|
|
139586
139942
|
mobileClientOwnersRef = { current: /* @__PURE__ */ new Map() };
|
|
139943
|
+
mobileRecordingOwners = /* @__PURE__ */ new Map();
|
|
139944
|
+
listActiveMobileRecordings = null;
|
|
139945
|
+
registerRecordingsSource("record-mobile", activeMobileRecordings);
|
|
139587
139946
|
clientGoneTimers = /* @__PURE__ */ new Map();
|
|
139588
139947
|
onClientGone = null;
|
|
139589
139948
|
}
|
|
@@ -139702,8 +140061,8 @@ var remote_updates_service_exports = {};
|
|
|
139702
140061
|
__export(remote_updates_service_exports, {
|
|
139703
140062
|
RemoteUpdatesService: () => RemoteUpdatesService
|
|
139704
140063
|
});
|
|
139705
|
-
import { existsSync as
|
|
139706
|
-
import { join as
|
|
140064
|
+
import { existsSync as existsSync113, readFileSync as readFileSync91, mkdirSync as mkdirSync50 } from "fs";
|
|
140065
|
+
import { join as join112, basename as basename28 } from "path";
|
|
139707
140066
|
var FIRST_CHECK_DELAY_MS, RemoteUpdatesService;
|
|
139708
140067
|
var init_remote_updates_service = __esm({
|
|
139709
140068
|
"src/ui/services/remote-updates-service.ts"() {
|
|
@@ -139714,9 +140073,9 @@ var init_remote_updates_service = __esm({
|
|
|
139714
140073
|
RemoteUpdatesService = class _RemoteUpdatesService {
|
|
139715
140074
|
constructor(deps2) {
|
|
139716
140075
|
this.deps = deps2;
|
|
139717
|
-
this.file =
|
|
140076
|
+
this.file = join112(getTestverDir(deps2.projectPath), "remote-updates.json");
|
|
139718
140077
|
try {
|
|
139719
|
-
if (
|
|
140078
|
+
if (existsSync113(this.file)) this.persisted = JSON.parse(readFileSync91(this.file, "utf-8"));
|
|
139720
140079
|
} catch {
|
|
139721
140080
|
this.persisted = {};
|
|
139722
140081
|
}
|
|
@@ -139841,7 +140200,7 @@ var init_remote_updates_service = __esm({
|
|
|
139841
140200
|
save() {
|
|
139842
140201
|
try {
|
|
139843
140202
|
const dir = getTestverDir(this.deps.projectPath);
|
|
139844
|
-
if (!
|
|
140203
|
+
if (!existsSync113(dir)) mkdirSync50(dir, { recursive: true });
|
|
139845
140204
|
writeFileAtomicSync(this.file, JSON.stringify(this.persisted, null, 2));
|
|
139846
140205
|
} catch {
|
|
139847
140206
|
}
|
|
@@ -139935,8 +140294,8 @@ __export(ownership_store_exports, {
|
|
|
139935
140294
|
OwnershipStore: () => OwnershipStore
|
|
139936
140295
|
});
|
|
139937
140296
|
import Database5 from "better-sqlite3";
|
|
139938
|
-
import { existsSync as
|
|
139939
|
-
import { join as
|
|
140297
|
+
import { existsSync as existsSync114, mkdirSync as mkdirSync51 } from "fs";
|
|
140298
|
+
import { join as join113 } from "path";
|
|
139940
140299
|
var OwnershipStore;
|
|
139941
140300
|
var init_ownership_store = __esm({
|
|
139942
140301
|
"src/ui/store/ownership-store.ts"() {
|
|
@@ -139946,8 +140305,8 @@ var init_ownership_store = __esm({
|
|
|
139946
140305
|
db;
|
|
139947
140306
|
constructor(projectPath2) {
|
|
139948
140307
|
const dir = getTestverDir(projectPath2);
|
|
139949
|
-
if (!
|
|
139950
|
-
this.db = new Database5(
|
|
140308
|
+
if (!existsSync114(dir)) mkdirSync51(dir, { recursive: true });
|
|
140309
|
+
this.db = new Database5(join113(dir, "ownership.db"));
|
|
139951
140310
|
this.db.exec(`
|
|
139952
140311
|
CREATE TABLE IF NOT EXISTS ownership_cache (
|
|
139953
140312
|
test_key TEXT NOT NULL,
|
|
@@ -140331,8 +140690,8 @@ var skills_chat_history_store_exports = {};
|
|
|
140331
140690
|
__export(skills_chat_history_store_exports, {
|
|
140332
140691
|
SkillsChatHistoryStore: () => SkillsChatHistoryStore
|
|
140333
140692
|
});
|
|
140334
|
-
import { readFileSync as
|
|
140335
|
-
import { join as
|
|
140693
|
+
import { readFileSync as readFileSync92, mkdirSync as mkdirSync52, existsSync as existsSync115 } from "fs";
|
|
140694
|
+
import { join as join114 } from "path";
|
|
140336
140695
|
var MAX_SESSIONS2, MAX_MESSAGES_PER_SESSION2, SkillsChatHistoryStore;
|
|
140337
140696
|
var init_skills_chat_history_store = __esm({
|
|
140338
140697
|
"src/ui/store/skills-chat-history-store.ts"() {
|
|
@@ -140346,8 +140705,8 @@ var init_skills_chat_history_store = __esm({
|
|
|
140346
140705
|
filePath;
|
|
140347
140706
|
constructor(projectPath2) {
|
|
140348
140707
|
const dir = getTestverDir(projectPath2);
|
|
140349
|
-
if (!
|
|
140350
|
-
this.filePath =
|
|
140708
|
+
if (!existsSync115(dir)) mkdirSync52(dir, { recursive: true });
|
|
140709
|
+
this.filePath = join114(dir, "skills-chat-history.json");
|
|
140351
140710
|
this.load();
|
|
140352
140711
|
}
|
|
140353
140712
|
// ── Public API ───────────────────────────────────────────────────────────
|
|
@@ -140449,8 +140808,8 @@ var init_skills_chat_history_store = __esm({
|
|
|
140449
140808
|
// ── Persistence ──────────────────────────────────────────────────────────
|
|
140450
140809
|
load() {
|
|
140451
140810
|
try {
|
|
140452
|
-
if (
|
|
140453
|
-
const raw =
|
|
140811
|
+
if (existsSync115(this.filePath)) {
|
|
140812
|
+
const raw = readFileSync92(this.filePath, "utf-8");
|
|
140454
140813
|
const parsed = JSON.parse(raw);
|
|
140455
140814
|
this.data = {
|
|
140456
140815
|
sessions: Array.isArray(parsed.sessions) ? parsed.sessions : []
|
|
@@ -140464,8 +140823,8 @@ var init_skills_chat_history_store = __esm({
|
|
|
140464
140823
|
save() {
|
|
140465
140824
|
try {
|
|
140466
140825
|
const dir = getTestverDir();
|
|
140467
|
-
if (!
|
|
140468
|
-
|
|
140826
|
+
if (!existsSync115(dir)) {
|
|
140827
|
+
mkdirSync52(dir, { recursive: true });
|
|
140469
140828
|
}
|
|
140470
140829
|
writeFileAtomicSync(this.filePath, JSON.stringify(this.data));
|
|
140471
140830
|
} catch {
|
|
@@ -140476,9 +140835,9 @@ var init_skills_chat_history_store = __esm({
|
|
|
140476
140835
|
});
|
|
140477
140836
|
|
|
140478
140837
|
// src/ui/workflows/workflow-store.ts
|
|
140479
|
-
import { readFileSync as
|
|
140838
|
+
import { readFileSync as readFileSync93, mkdirSync as mkdirSync53, existsSync as existsSync116, unlinkSync as unlinkSync12 } from "fs";
|
|
140480
140839
|
import { randomBytes as randomBytes17 } from "crypto";
|
|
140481
|
-
import { join as
|
|
140840
|
+
import { join as join115 } from "path";
|
|
140482
140841
|
var EMPTY_DATA, MAX_WORKFLOWS, WorkflowStore;
|
|
140483
140842
|
var init_workflow_store = __esm({
|
|
140484
140843
|
"src/ui/workflows/workflow-store.ts"() {
|
|
@@ -140492,9 +140851,9 @@ var init_workflow_store = __esm({
|
|
|
140492
140851
|
dir;
|
|
140493
140852
|
indexPath;
|
|
140494
140853
|
constructor() {
|
|
140495
|
-
this.dir =
|
|
140496
|
-
if (!
|
|
140497
|
-
this.indexPath =
|
|
140854
|
+
this.dir = join115(getTestverDir(), "workflows");
|
|
140855
|
+
if (!existsSync116(this.dir)) mkdirSync53(this.dir, { recursive: true });
|
|
140856
|
+
this.indexPath = join115(this.dir, "index.json");
|
|
140498
140857
|
this.load();
|
|
140499
140858
|
}
|
|
140500
140859
|
// ── CRUD ─────────────────────────────────────────────────────────────────
|
|
@@ -140506,9 +140865,9 @@ var init_workflow_store = __esm({
|
|
|
140506
140865
|
get(id) {
|
|
140507
140866
|
const workflow = this.data.workflows[id];
|
|
140508
140867
|
if (!workflow) return void 0;
|
|
140509
|
-
const yamlPath =
|
|
140510
|
-
if (
|
|
140511
|
-
workflow.yaml =
|
|
140868
|
+
const yamlPath = join115(this.dir, `${id}.yaml`);
|
|
140869
|
+
if (existsSync116(yamlPath)) {
|
|
140870
|
+
workflow.yaml = readFileSync93(yamlPath, "utf-8");
|
|
140512
140871
|
}
|
|
140513
140872
|
return structuredClone(workflow);
|
|
140514
140873
|
}
|
|
@@ -140536,7 +140895,7 @@ var init_workflow_store = __esm({
|
|
|
140536
140895
|
}
|
|
140537
140896
|
this.data.workflows[id] = workflow;
|
|
140538
140897
|
try {
|
|
140539
|
-
writeFileAtomicSync(
|
|
140898
|
+
writeFileAtomicSync(join115(this.dir, `${id}.yaml`), yaml);
|
|
140540
140899
|
} catch (err5) {
|
|
140541
140900
|
console.warn(`[workflow-store] Failed to save YAML for '${id}':`, err5);
|
|
140542
140901
|
}
|
|
@@ -140547,9 +140906,9 @@ var init_workflow_store = __esm({
|
|
|
140547
140906
|
delete(id) {
|
|
140548
140907
|
if (!this.data.workflows[id]) return false;
|
|
140549
140908
|
delete this.data.workflows[id];
|
|
140550
|
-
const yamlPath =
|
|
140909
|
+
const yamlPath = join115(this.dir, `${id}.yaml`);
|
|
140551
140910
|
try {
|
|
140552
|
-
if (
|
|
140911
|
+
if (existsSync116(yamlPath)) unlinkSync12(yamlPath);
|
|
140553
140912
|
} catch {
|
|
140554
140913
|
}
|
|
140555
140914
|
this.saveIndex();
|
|
@@ -140699,10 +141058,10 @@ var init_workflow_store = __esm({
|
|
|
140699
141058
|
// ── Versioning ──────────────────────────────────────────────────────────
|
|
140700
141059
|
/** Get version history for a workflow (max 20 versions) */
|
|
140701
141060
|
getVersions(id) {
|
|
140702
|
-
const versionsPath =
|
|
141061
|
+
const versionsPath = join115(this.dir, `${id}.versions.json`);
|
|
140703
141062
|
try {
|
|
140704
|
-
if (
|
|
140705
|
-
return JSON.parse(
|
|
141063
|
+
if (existsSync116(versionsPath)) {
|
|
141064
|
+
return JSON.parse(readFileSync93(versionsPath, "utf-8"));
|
|
140706
141065
|
}
|
|
140707
141066
|
} catch {
|
|
140708
141067
|
}
|
|
@@ -140712,10 +141071,10 @@ var init_workflow_store = __esm({
|
|
|
140712
141071
|
saveVersion(id, comment) {
|
|
140713
141072
|
const workflow = this.data.workflows[id];
|
|
140714
141073
|
if (!workflow) return;
|
|
140715
|
-
const yamlPath =
|
|
141074
|
+
const yamlPath = join115(this.dir, `${id}.yaml`);
|
|
140716
141075
|
let currentYaml = "";
|
|
140717
141076
|
try {
|
|
140718
|
-
if (
|
|
141077
|
+
if (existsSync116(yamlPath)) currentYaml = readFileSync93(yamlPath, "utf-8");
|
|
140719
141078
|
} catch {
|
|
140720
141079
|
}
|
|
140721
141080
|
if (!currentYaml) return;
|
|
@@ -140727,7 +141086,7 @@ var init_workflow_store = __esm({
|
|
|
140727
141086
|
});
|
|
140728
141087
|
while (versions.length > 20) versions.pop();
|
|
140729
141088
|
try {
|
|
140730
|
-
writeFileAtomicSync(
|
|
141089
|
+
writeFileAtomicSync(join115(this.dir, `${id}.versions.json`), JSON.stringify(versions, null, 2));
|
|
140731
141090
|
} catch (err5) {
|
|
140732
141091
|
console.warn(`[workflow-store] Failed to save versions for '${id}':`, err5);
|
|
140733
141092
|
}
|
|
@@ -140741,8 +141100,8 @@ var init_workflow_store = __esm({
|
|
|
140741
141100
|
// ── Private ──────────────────────────────────────────────────────────────
|
|
140742
141101
|
load() {
|
|
140743
141102
|
try {
|
|
140744
|
-
if (
|
|
140745
|
-
const raw =
|
|
141103
|
+
if (existsSync116(this.indexPath)) {
|
|
141104
|
+
const raw = readFileSync93(this.indexPath, "utf-8");
|
|
140746
141105
|
const parsed = JSON.parse(raw);
|
|
140747
141106
|
this.data = {
|
|
140748
141107
|
workflows: parsed.workflows && typeof parsed.workflows === "object" ? parsed.workflows : {}
|
|
@@ -140769,8 +141128,8 @@ var init_workflow_store = __esm({
|
|
|
140769
141128
|
});
|
|
140770
141129
|
|
|
140771
141130
|
// src/ui/workflows/workflow-history.ts
|
|
140772
|
-
import { readFileSync as
|
|
140773
|
-
import { join as
|
|
141131
|
+
import { readFileSync as readFileSync94, mkdirSync as mkdirSync54, existsSync as existsSync117 } from "fs";
|
|
141132
|
+
import { join as join116 } from "path";
|
|
140774
141133
|
var MAX_RUNS_PER_WORKFLOW, MAX_TOTAL_RUNS, WorkflowHistoryStore;
|
|
140775
141134
|
var init_workflow_history = __esm({
|
|
140776
141135
|
"src/ui/workflows/workflow-history.ts"() {
|
|
@@ -140783,9 +141142,9 @@ var init_workflow_history = __esm({
|
|
|
140783
141142
|
data = { runs: [] };
|
|
140784
141143
|
filePath;
|
|
140785
141144
|
constructor() {
|
|
140786
|
-
const dir =
|
|
140787
|
-
if (!
|
|
140788
|
-
this.filePath =
|
|
141145
|
+
const dir = join116(getTestverDir(), "workflows");
|
|
141146
|
+
if (!existsSync117(dir)) mkdirSync54(dir, { recursive: true });
|
|
141147
|
+
this.filePath = join116(dir, "history.json");
|
|
140789
141148
|
this.load();
|
|
140790
141149
|
}
|
|
140791
141150
|
// ── Queries ──────────────────────────────────────────────────────────────
|
|
@@ -140803,19 +141162,19 @@ var init_workflow_history = __esm({
|
|
|
140803
141162
|
}
|
|
140804
141163
|
/** Get run statistics for a workflow */
|
|
140805
141164
|
getStats(workflowId) {
|
|
140806
|
-
const
|
|
140807
|
-
const completed =
|
|
140808
|
-
const failed =
|
|
140809
|
-
const aborted =
|
|
140810
|
-
const durations =
|
|
141165
|
+
const runs4 = this.data.runs.filter((r) => r.workflowId === workflowId);
|
|
141166
|
+
const completed = runs4.filter((r) => r.status === "completed");
|
|
141167
|
+
const failed = runs4.filter((r) => r.status === "failed");
|
|
141168
|
+
const aborted = runs4.filter((r) => r.status === "aborted");
|
|
141169
|
+
const durations = runs4.filter((r) => r.duration).map((r) => r.duration);
|
|
140811
141170
|
const avgDuration = durations.length > 0 ? durations.reduce((a, b) => a + b, 0) / durations.length : 0;
|
|
140812
141171
|
return {
|
|
140813
|
-
totalRuns:
|
|
141172
|
+
totalRuns: runs4.length,
|
|
140814
141173
|
completed: completed.length,
|
|
140815
141174
|
failed: failed.length,
|
|
140816
141175
|
aborted: aborted.length,
|
|
140817
141176
|
avgDuration: Math.round(avgDuration),
|
|
140818
|
-
successRate:
|
|
141177
|
+
successRate: runs4.length > 0 ? Math.round(completed.length / runs4.length * 100) : 0
|
|
140819
141178
|
};
|
|
140820
141179
|
}
|
|
140821
141180
|
// ── Mutations ────────────────────────────────────────────────────────────
|
|
@@ -140866,8 +141225,8 @@ var init_workflow_history = __esm({
|
|
|
140866
141225
|
// ── Private ──────────────────────────────────────────────────────────────
|
|
140867
141226
|
load() {
|
|
140868
141227
|
try {
|
|
140869
|
-
if (
|
|
140870
|
-
const raw =
|
|
141228
|
+
if (existsSync117(this.filePath)) {
|
|
141229
|
+
const raw = readFileSync94(this.filePath, "utf-8");
|
|
140871
141230
|
const parsed = JSON.parse(raw);
|
|
140872
141231
|
this.data = {
|
|
140873
141232
|
runs: Array.isArray(parsed.runs) ? parsed.runs : []
|
|
@@ -143433,9 +143792,9 @@ function mountWorkflowRoutes(app, wss, orchestrator, mcpClientManager, _schedule
|
|
|
143433
143792
|
try {
|
|
143434
143793
|
const id = req.params.id;
|
|
143435
143794
|
const limit = parseInt(req.query.limit) || 20;
|
|
143436
|
-
const
|
|
143795
|
+
const runs4 = historyStore.getByWorkflow(id, limit);
|
|
143437
143796
|
const stats = historyStore.getStats(id);
|
|
143438
|
-
res.json({ runs:
|
|
143797
|
+
res.json({ runs: runs4, stats });
|
|
143439
143798
|
} catch (err5) {
|
|
143440
143799
|
res.status(500).json({ error: String(err5) });
|
|
143441
143800
|
}
|
|
@@ -143454,8 +143813,8 @@ function mountWorkflowRoutes(app, wss, orchestrator, mcpClientManager, _schedule
|
|
|
143454
143813
|
});
|
|
143455
143814
|
app.get("/api/workflows/active/runs", (_req, res) => {
|
|
143456
143815
|
try {
|
|
143457
|
-
const
|
|
143458
|
-
res.json({ runs:
|
|
143816
|
+
const runs4 = engine.getActiveRuns();
|
|
143817
|
+
res.json({ runs: runs4 });
|
|
143459
143818
|
} catch (err5) {
|
|
143460
143819
|
res.status(500).json({ error: String(err5) });
|
|
143461
143820
|
}
|
|
@@ -143964,8 +144323,8 @@ var init_api_workflows = __esm({
|
|
|
143964
144323
|
});
|
|
143965
144324
|
|
|
143966
144325
|
// src/ui/store/cycle-run-settings-store.ts
|
|
143967
|
-
import { readFileSync as
|
|
143968
|
-
import { join as
|
|
144326
|
+
import { readFileSync as readFileSync95, mkdirSync as mkdirSync55, existsSync as existsSync118 } from "fs";
|
|
144327
|
+
import { join as join117 } from "path";
|
|
143969
144328
|
function normalizeHook2(h) {
|
|
143970
144329
|
if (!h) return void 0;
|
|
143971
144330
|
const command = String(h.command || "").trim();
|
|
@@ -143995,9 +144354,9 @@ var init_cycle_run_settings_store = __esm({
|
|
|
143995
144354
|
data = {};
|
|
143996
144355
|
constructor(projectPath2) {
|
|
143997
144356
|
this.dir = getTestverDir(projectPath2);
|
|
143998
|
-
this.filePath =
|
|
144357
|
+
this.filePath = join117(this.dir, "cycle-run-settings.json");
|
|
143999
144358
|
try {
|
|
144000
|
-
if (
|
|
144359
|
+
if (existsSync118(this.filePath)) this.data = JSON.parse(readFileSync95(this.filePath, "utf-8")) || {};
|
|
144001
144360
|
} catch (e) {
|
|
144002
144361
|
setAsideUnreadable(this.filePath, e);
|
|
144003
144362
|
this.data = {};
|
|
@@ -144026,7 +144385,7 @@ var init_cycle_run_settings_store = __esm({
|
|
|
144026
144385
|
abortOnSetupFailure: patch.abortOnSetupFailure ?? true
|
|
144027
144386
|
};
|
|
144028
144387
|
try {
|
|
144029
|
-
if (!
|
|
144388
|
+
if (!existsSync118(this.dir)) mkdirSync55(this.dir, { recursive: true });
|
|
144030
144389
|
writeFileAtomicSync(this.filePath, JSON.stringify(this.data, null, 2));
|
|
144031
144390
|
} catch {
|
|
144032
144391
|
}
|
|
@@ -144634,7 +144993,7 @@ function mountTestManagementRoutes(app, tmStore5, projectPath2) {
|
|
|
144634
144993
|
});
|
|
144635
144994
|
app.post("/api/tm/mappings/check-sync", async (_req, res) => {
|
|
144636
144995
|
try {
|
|
144637
|
-
const { existsSync:
|
|
144996
|
+
const { existsSync: existsSync128, readFileSync: readFileSync103 } = await import("fs");
|
|
144638
144997
|
const { createHash: createHash18 } = await import("crypto");
|
|
144639
144998
|
const mappings = tmStore5.listScriptMappings();
|
|
144640
144999
|
let syncedCount = 0;
|
|
@@ -144642,12 +145001,12 @@ function mountTestManagementRoutes(app, tmStore5, projectPath2) {
|
|
|
144642
145001
|
let missingCount = 0;
|
|
144643
145002
|
for (const m of mappings) {
|
|
144644
145003
|
const fullPath = m.scriptPath;
|
|
144645
|
-
if (!
|
|
145004
|
+
if (!existsSync128(fullPath)) {
|
|
144646
145005
|
tmStore5.updateMappingSyncStatus(m.testCaseId, "script_missing");
|
|
144647
145006
|
missingCount++;
|
|
144648
145007
|
continue;
|
|
144649
145008
|
}
|
|
144650
|
-
const content =
|
|
145009
|
+
const content = readFileSync103(fullPath, "utf-8");
|
|
144651
145010
|
const currentHash = createHash18("md5").update(content).digest("hex");
|
|
144652
145011
|
if (m.scriptHash && m.scriptHash !== currentHash) {
|
|
144653
145012
|
tmStore5.updateMappingSyncStatus(m.testCaseId, "script_updated", currentHash);
|
|
@@ -148165,8 +148524,8 @@ var init_requirement_groups = __esm({
|
|
|
148165
148524
|
});
|
|
148166
148525
|
|
|
148167
148526
|
// src/ui/services/project-test-data.ts
|
|
148168
|
-
import { existsSync as
|
|
148169
|
-
import { join as
|
|
148527
|
+
import { existsSync as existsSync119, readdirSync as readdirSync44, readFileSync as readFileSync96, statSync as statSync46 } from "fs";
|
|
148528
|
+
import { join as join118, relative as relative41, sep as sep9 } from "path";
|
|
148170
148529
|
function keysOfJson(text3) {
|
|
148171
148530
|
let data;
|
|
148172
148531
|
try {
|
|
@@ -148199,7 +148558,7 @@ function walk2(dir, root, out) {
|
|
|
148199
148558
|
for (const n of names.sort()) {
|
|
148200
148559
|
if (out.length >= MAX_FILES) return;
|
|
148201
148560
|
if (n.startsWith(".") || n === "node_modules") continue;
|
|
148202
|
-
const p2 =
|
|
148561
|
+
const p2 = join118(dir, n);
|
|
148203
148562
|
if (isTestverInternalPath(p2, root) || isTestverSecretPath(p2, root)) continue;
|
|
148204
148563
|
let st;
|
|
148205
148564
|
try {
|
|
@@ -148216,14 +148575,14 @@ function scanProjectTestData(projectPath2) {
|
|
|
148216
148575
|
if (hit && Date.now() - hit.at < 6e4) return hit.data;
|
|
148217
148576
|
const files = [];
|
|
148218
148577
|
for (const d of FIXTURE_DIRS) {
|
|
148219
|
-
const p2 =
|
|
148220
|
-
if (
|
|
148578
|
+
const p2 = join118(projectPath2, d);
|
|
148579
|
+
if (existsSync119(p2)) walk2(p2, projectPath2, files);
|
|
148221
148580
|
}
|
|
148222
148581
|
const fixtures = [];
|
|
148223
148582
|
for (const f of files) {
|
|
148224
148583
|
let text3 = "";
|
|
148225
148584
|
try {
|
|
148226
|
-
text3 =
|
|
148585
|
+
text3 = readFileSync96(f, "utf8").replace(/^/, "");
|
|
148227
148586
|
} catch {
|
|
148228
148587
|
continue;
|
|
148229
148588
|
}
|
|
@@ -148232,10 +148591,10 @@ function scanProjectTestData(projectPath2) {
|
|
|
148232
148591
|
}
|
|
148233
148592
|
const envNames = /* @__PURE__ */ new Set();
|
|
148234
148593
|
for (const e of ENV_FILES) {
|
|
148235
|
-
const p2 =
|
|
148236
|
-
if (!
|
|
148594
|
+
const p2 = join118(projectPath2, e);
|
|
148595
|
+
if (!existsSync119(p2)) continue;
|
|
148237
148596
|
try {
|
|
148238
|
-
for (const m of
|
|
148597
|
+
for (const m of readFileSync96(p2, "utf8").matchAll(/^\s*(?:export\s+)?([A-Z_][A-Z0-9_]*)\s*=/gm)) envNames.add(m[1]);
|
|
148239
148598
|
} catch {
|
|
148240
148599
|
}
|
|
148241
148600
|
}
|
|
@@ -148457,21 +148816,21 @@ data: ${JSON.stringify({ status })}
|
|
|
148457
148816
|
});
|
|
148458
148817
|
|
|
148459
148818
|
// src/ui/services/app-model.ts
|
|
148460
|
-
import { existsSync as
|
|
148461
|
-
import { join as
|
|
148819
|
+
import { existsSync as existsSync120, readdirSync as readdirSync45, readFileSync as readFileSync97, statSync as statSync47 } from "fs";
|
|
148820
|
+
import { join as join119 } from "path";
|
|
148462
148821
|
function readJson3(path2) {
|
|
148463
148822
|
try {
|
|
148464
|
-
if (!
|
|
148465
|
-
return JSON.parse(
|
|
148823
|
+
if (!existsSync120(path2)) return null;
|
|
148824
|
+
return JSON.parse(readFileSync97(path2, "utf-8"));
|
|
148466
148825
|
} catch {
|
|
148467
148826
|
return null;
|
|
148468
148827
|
}
|
|
148469
148828
|
}
|
|
148470
148829
|
function exploreRuns2(projectPath2) {
|
|
148471
|
-
const root =
|
|
148472
|
-
if (!
|
|
148830
|
+
const root = join119(projectPath2, ".testver", "explore");
|
|
148831
|
+
if (!existsSync120(root)) return [];
|
|
148473
148832
|
try {
|
|
148474
|
-
return readdirSync45(root).filter((n) => n !== "auth").map((n) => ({ id: n, dir:
|
|
148833
|
+
return readdirSync45(root).filter((n) => n !== "auth").map((n) => ({ id: n, dir: join119(root, n) })).filter((r) => {
|
|
148475
148834
|
try {
|
|
148476
148835
|
return statSync47(r.dir).isDirectory();
|
|
148477
148836
|
} catch {
|
|
@@ -148549,7 +148908,7 @@ function templateKey(template2) {
|
|
|
148549
148908
|
return template2.trim().toLowerCase().replace(/[?#].*$/, "").replace(/\/+$/, "") || "/";
|
|
148550
148909
|
}
|
|
148551
148910
|
function buildAppModel(projectPath2) {
|
|
148552
|
-
const
|
|
148911
|
+
const runs4 = exploreRuns2(projectPath2);
|
|
148553
148912
|
const mt = (p2) => {
|
|
148554
148913
|
try {
|
|
148555
148914
|
return statSync47(p2).mtimeMs;
|
|
@@ -148558,8 +148917,8 @@ function buildAppModel(projectPath2) {
|
|
|
148558
148917
|
}
|
|
148559
148918
|
};
|
|
148560
148919
|
const cacheKey = [
|
|
148561
|
-
...
|
|
148562
|
-
`auth:${mt(
|
|
148920
|
+
...runs4.map((r) => `${r.id}:${r.at}:${mt(join119(r.dir, "pages"))}:${mt(join119(r.dir, "plan.json"))}`),
|
|
148921
|
+
`auth:${mt(join119(projectPath2, ".testver", "explore", "auth"))}`
|
|
148563
148922
|
].join("|");
|
|
148564
148923
|
const hit = cache7.get(projectPath2);
|
|
148565
148924
|
if (hit && hit.key === cacheKey) return hit.model;
|
|
@@ -148568,13 +148927,13 @@ function buildAppModel(projectPath2) {
|
|
|
148568
148927
|
const runSummaries = [];
|
|
148569
148928
|
const roleOrder = [];
|
|
148570
148929
|
const matrix = /* @__PURE__ */ new Map();
|
|
148571
|
-
for (const run2 of
|
|
148930
|
+
for (const run2 of runs4) {
|
|
148572
148931
|
try {
|
|
148573
|
-
const plan = readJson3(
|
|
148932
|
+
const plan = readJson3(join119(run2.dir, "plan.json")) ?? {};
|
|
148574
148933
|
const role = String(plan.role || "guest");
|
|
148575
148934
|
let pageCount = 0;
|
|
148576
|
-
const pagesDir =
|
|
148577
|
-
if (
|
|
148935
|
+
const pagesDir = join119(run2.dir, "pages");
|
|
148936
|
+
if (existsSync120(pagesDir)) {
|
|
148578
148937
|
let names = [];
|
|
148579
148938
|
try {
|
|
148580
148939
|
names = readdirSync45(pagesDir).filter((n) => n.endsWith(".json"));
|
|
@@ -148582,7 +148941,7 @@ function buildAppModel(projectPath2) {
|
|
|
148582
148941
|
problems.push(`run ${run2.id}: pages/ unreadable (${err5.message})`);
|
|
148583
148942
|
}
|
|
148584
148943
|
for (const name2 of names) {
|
|
148585
|
-
const raw = readJson3(
|
|
148944
|
+
const raw = readJson3(join119(pagesDir, name2));
|
|
148586
148945
|
if (!raw) {
|
|
148587
148946
|
problems.push(`run ${run2.id}: pages/${name2} is not readable JSON`);
|
|
148588
148947
|
continue;
|
|
@@ -148603,7 +148962,7 @@ function buildAppModel(projectPath2) {
|
|
|
148603
148962
|
if (!existing) byTemplate.set(key2, page);
|
|
148604
148963
|
}
|
|
148605
148964
|
}
|
|
148606
|
-
const frontier = readJson3(
|
|
148965
|
+
const frontier = readJson3(join119(run2.dir, "frontier.json"));
|
|
148607
148966
|
const visited = [
|
|
148608
148967
|
...toArray(frontier?.visited ?? frontier, "visited"),
|
|
148609
148968
|
...toArray(frontier?.pages, "pages")
|
|
@@ -148626,7 +148985,7 @@ function buildAppModel(projectPath2) {
|
|
|
148626
148985
|
capturedAt: run2.at
|
|
148627
148986
|
});
|
|
148628
148987
|
}
|
|
148629
|
-
const access = readJson3(
|
|
148988
|
+
const access = readJson3(join119(run2.dir, "access.json"));
|
|
148630
148989
|
if (access) {
|
|
148631
148990
|
const declared = toStringArray(access.roles);
|
|
148632
148991
|
if (declared.length > 0 && roleOrder.length === 0) roleOrder.push(...declared);
|
|
@@ -148662,9 +149021,9 @@ function buildAppModel(projectPath2) {
|
|
|
148662
149021
|
forms: [],
|
|
148663
149022
|
roles: roles2,
|
|
148664
149023
|
capturedAs: "",
|
|
148665
|
-
runId:
|
|
149024
|
+
runId: runs4[0]?.id ?? "",
|
|
148666
149025
|
citation: "access.json",
|
|
148667
|
-
capturedAt:
|
|
149026
|
+
capturedAt: runs4[0]?.at ?? 0
|
|
148668
149027
|
});
|
|
148669
149028
|
}
|
|
148670
149029
|
const roles = uniq2([
|
|
@@ -148833,10 +149192,10 @@ function classifyAutomatable(input, model) {
|
|
|
148833
149192
|
}
|
|
148834
149193
|
function describeAppModel(model) {
|
|
148835
149194
|
if (model.isEmpty) return "No exploration data";
|
|
148836
|
-
const
|
|
149195
|
+
const runs4 = `${model.runs.length} run${model.runs.length === 1 ? "" : "s"}`;
|
|
148837
149196
|
const pages = `${model.pages.length} page${model.pages.length === 1 ? "" : "s"}`;
|
|
148838
149197
|
const roles = model.roles.length > 0 ? ` \xB7 ${model.roles.join(", ")}` : "";
|
|
148839
|
-
return `${
|
|
149198
|
+
return `${runs4} \xB7 ${pages}${roles}`;
|
|
148840
149199
|
}
|
|
148841
149200
|
var cache7, MAX_BLOCK_CHARS, NAVIGATION_VERBS, HARD_BLOCKERS, FALLBACK_MANUAL, FALLBACK_SETUP, DEFAULT_REASON;
|
|
148842
149201
|
var init_app_model = __esm({
|
|
@@ -151200,7 +151559,7 @@ function mountTMCoverageRoutes(app, tmStore5, aiService, projectFramework) {
|
|
|
151200
151559
|
const unmappedScripts = [];
|
|
151201
151560
|
try {
|
|
151202
151561
|
const { readdir: readdir3, open: open2 } = await import("fs/promises");
|
|
151203
|
-
const { join:
|
|
151562
|
+
const { join: join128, relative: relative44 } = await import("path");
|
|
151204
151563
|
const projectDir = process.cwd();
|
|
151205
151564
|
const mappedPaths = new Set(
|
|
151206
151565
|
tmStore5.db.prepare("SELECT script_path FROM tm_script_mappings").all().map((r) => r.script_path?.toLowerCase()).filter(Boolean)
|
|
@@ -151250,7 +151609,7 @@ function mountTMCoverageRoutes(app, tmStore5, aiService, projectFramework) {
|
|
|
151250
151609
|
entriesVisited++;
|
|
151251
151610
|
const entry2 = dirent.name;
|
|
151252
151611
|
if (ignoreDirs.has(entry2)) continue;
|
|
151253
|
-
const fullPath =
|
|
151612
|
+
const fullPath = join128(dir, entry2);
|
|
151254
151613
|
if (dirent.isDirectory()) {
|
|
151255
151614
|
await scanDir(fullPath, depth + 1);
|
|
151256
151615
|
} else if (testPatterns.some((p2) => p2.test(entry2))) {
|
|
@@ -154014,8 +154373,8 @@ __export(output_store_exports, {
|
|
|
154014
154373
|
OutputStore: () => OutputStore
|
|
154015
154374
|
});
|
|
154016
154375
|
import Database6 from "better-sqlite3";
|
|
154017
|
-
import { existsSync as
|
|
154018
|
-
import { join as
|
|
154376
|
+
import { existsSync as existsSync121, mkdirSync as mkdirSync56 } from "fs";
|
|
154377
|
+
import { join as join120 } from "path";
|
|
154019
154378
|
var OutputStore;
|
|
154020
154379
|
var init_output_store = __esm({
|
|
154021
154380
|
"src/ui/store/output-store.ts"() {
|
|
@@ -154025,8 +154384,8 @@ var init_output_store = __esm({
|
|
|
154025
154384
|
db;
|
|
154026
154385
|
constructor(projectPath2) {
|
|
154027
154386
|
const dir = getTestverDir(projectPath2);
|
|
154028
|
-
if (!
|
|
154029
|
-
const resolvedPath =
|
|
154387
|
+
if (!existsSync121(dir)) mkdirSync56(dir, { recursive: true });
|
|
154388
|
+
const resolvedPath = join120(dir, "output.db");
|
|
154030
154389
|
this.db = new Database6(resolvedPath);
|
|
154031
154390
|
this.initialize();
|
|
154032
154391
|
}
|
|
@@ -154157,9 +154516,9 @@ __export(api_output_exports, {
|
|
|
154157
154516
|
isPageRequest: () => isPageRequest,
|
|
154158
154517
|
mountOutputRoutes: () => mountOutputRoutes
|
|
154159
154518
|
});
|
|
154160
|
-
import { existsSync as
|
|
154519
|
+
import { existsSync as existsSync122, statSync as statSync48, readdirSync as readdirSync46, readFileSync as readFileSync98, createReadStream as createReadStream2 } from "fs";
|
|
154161
154520
|
import { promises as fsp2 } from "fs";
|
|
154162
|
-
import { resolve as resolve33, extname as extname21, join as
|
|
154521
|
+
import { resolve as resolve33, extname as extname21, join as join121, relative as relative42, isAbsolute as isAbsolute24 } from "path";
|
|
154163
154522
|
import { randomBytes as randomBytes19 } from "crypto";
|
|
154164
154523
|
import { watch } from "chokidar";
|
|
154165
154524
|
function normalizePath(p2) {
|
|
@@ -154197,7 +154556,7 @@ async function readDirRecursiveAsync(dirPath, rootPath, depth = 20, filterExts)
|
|
|
154197
154556
|
}
|
|
154198
154557
|
const built = await Promise.all(entries.map(async (entry2) => {
|
|
154199
154558
|
if (entry2.name.startsWith(".")) return null;
|
|
154200
|
-
const fullPath =
|
|
154559
|
+
const fullPath = join121(dirPath, entry2.name);
|
|
154201
154560
|
const relPath = normalizePath(relative42(rootPath, fullPath));
|
|
154202
154561
|
if (entry2.isDirectory()) {
|
|
154203
154562
|
const children = await readDirRecursiveAsync(fullPath, rootPath, depth - 1, filterExts);
|
|
@@ -154261,13 +154620,13 @@ function searchFiles(rootPath, query, maxResults = 200) {
|
|
|
154261
154620
|
const lowerQuery = query.toLowerCase();
|
|
154262
154621
|
function walk3(dirPath) {
|
|
154263
154622
|
if (results.length >= maxResults) return;
|
|
154264
|
-
if (!
|
|
154623
|
+
if (!existsSync122(dirPath)) return;
|
|
154265
154624
|
try {
|
|
154266
154625
|
const entries = readdirSync46(dirPath, { withFileTypes: true });
|
|
154267
154626
|
for (const entry2 of entries) {
|
|
154268
154627
|
if (results.length >= maxResults) return;
|
|
154269
154628
|
if (entry2.name.startsWith(".")) continue;
|
|
154270
|
-
const fullPath =
|
|
154629
|
+
const fullPath = join121(dirPath, entry2.name);
|
|
154271
154630
|
if (entry2.isDirectory()) {
|
|
154272
154631
|
walk3(fullPath);
|
|
154273
154632
|
} else if (entry2.isFile() && entry2.name.toLowerCase().includes(lowerQuery)) {
|
|
@@ -154299,15 +154658,15 @@ function detectOutputFolders(projectPath2) {
|
|
|
154299
154658
|
if (seen.has(relPath)) return;
|
|
154300
154659
|
seen.add(relPath);
|
|
154301
154660
|
const fullPath = resolve33(projectPath2, relPath);
|
|
154302
|
-
detected.push({ path: relPath, label: label4, framework, exists:
|
|
154661
|
+
detected.push({ path: relPath, label: label4, framework, exists: existsSync122(fullPath) });
|
|
154303
154662
|
};
|
|
154304
154663
|
const pwConfigs = ["playwright.config.ts", "playwright.config.js", "playwright.config.mjs"];
|
|
154305
154664
|
for (const cfg of pwConfigs) {
|
|
154306
|
-
if (
|
|
154665
|
+
if (existsSync122(join121(projectPath2, cfg))) {
|
|
154307
154666
|
addIfNew("test-results", "Test Results", "Playwright");
|
|
154308
154667
|
addIfNew("playwright-report", "Playwright Report", "Playwright");
|
|
154309
154668
|
try {
|
|
154310
|
-
const content =
|
|
154669
|
+
const content = readFileSync98(join121(projectPath2, cfg), "utf-8");
|
|
154311
154670
|
const outputMatch = content.match(/outputDir\s*:\s*['"]([^'"]+)['"]/);
|
|
154312
154671
|
if (outputMatch) addIfNew(outputMatch[1], "Test Results", "Playwright");
|
|
154313
154672
|
const reportMatch = content.match(/outputFolder\s*:\s*['"]([^'"]+)['"]/);
|
|
@@ -154319,7 +154678,7 @@ function detectOutputFolders(projectPath2) {
|
|
|
154319
154678
|
}
|
|
154320
154679
|
const cyConfigs = ["cypress.config.ts", "cypress.config.js", "cypress.json"];
|
|
154321
154680
|
for (const cfg of cyConfigs) {
|
|
154322
|
-
if (
|
|
154681
|
+
if (existsSync122(join121(projectPath2, cfg))) {
|
|
154323
154682
|
addIfNew("cypress/screenshots", "Screenshots", "Cypress");
|
|
154324
154683
|
addIfNew("cypress/videos", "Videos", "Cypress");
|
|
154325
154684
|
addIfNew("cypress/downloads", "Downloads", "Cypress");
|
|
@@ -154328,13 +154687,13 @@ function detectOutputFolders(projectPath2) {
|
|
|
154328
154687
|
}
|
|
154329
154688
|
const wdioConfigs = findWdioConfigs(projectPath2).slice(0, 1);
|
|
154330
154689
|
for (const cfg of wdioConfigs) {
|
|
154331
|
-
if (
|
|
154690
|
+
if (existsSync122(join121(projectPath2, cfg))) {
|
|
154332
154691
|
try {
|
|
154333
|
-
const content =
|
|
154692
|
+
const content = readFileSync98(join121(projectPath2, cfg), "utf-8");
|
|
154334
154693
|
const outputMatch = content.match(/outputDir\s*:\s*['"]([^'"]+)['"]/);
|
|
154335
154694
|
if (outputMatch) {
|
|
154336
154695
|
const out = outputMatch[1];
|
|
154337
|
-
addIfNew(isAbsolute24(out) ? out :
|
|
154696
|
+
addIfNew(isAbsolute24(out) ? out : join121(cfg, "..", out).replace(/\\/g, "/"), "WDIO Output", "WebdriverIO");
|
|
154338
154697
|
}
|
|
154339
154698
|
} catch {
|
|
154340
154699
|
}
|
|
@@ -154354,7 +154713,7 @@ function detectOutputFolders(projectPath2) {
|
|
|
154354
154713
|
{ path: "logs", label: "Logs" }
|
|
154355
154714
|
];
|
|
154356
154715
|
for (const dir of commonDirs) {
|
|
154357
|
-
if (
|
|
154716
|
+
if (existsSync122(resolve33(projectPath2, dir.path))) {
|
|
154358
154717
|
addIfNew(dir.path, dir.label, "");
|
|
154359
154718
|
}
|
|
154360
154719
|
}
|
|
@@ -154372,7 +154731,7 @@ function mountOutputRoutes(app, outputStore, wss, options) {
|
|
|
154372
154731
|
}
|
|
154373
154732
|
function startWatching(folderId, folderPath) {
|
|
154374
154733
|
if (watchers.has(folderId)) return;
|
|
154375
|
-
if (!
|
|
154734
|
+
if (!existsSync122(folderPath)) return;
|
|
154376
154735
|
try {
|
|
154377
154736
|
const watcher = watch(folderPath, {
|
|
154378
154737
|
ignoreInitial: true,
|
|
@@ -154471,7 +154830,7 @@ function mountOutputRoutes(app, outputStore, wss, options) {
|
|
|
154471
154830
|
return;
|
|
154472
154831
|
}
|
|
154473
154832
|
const resolved = resolveFolder(folder.path, folder.isAbsolute, projectPath2);
|
|
154474
|
-
if (!
|
|
154833
|
+
if (!existsSync122(resolved)) {
|
|
154475
154834
|
res.json({ files: [], folderPath: normalizePath(resolved), exists: false });
|
|
154476
154835
|
return;
|
|
154477
154836
|
}
|
|
@@ -154536,7 +154895,7 @@ function mountOutputRoutes(app, outputStore, wss, options) {
|
|
|
154536
154895
|
res.status(403).json({ error: "Path traversal not allowed" });
|
|
154537
154896
|
return;
|
|
154538
154897
|
}
|
|
154539
|
-
if (!
|
|
154898
|
+
if (!existsSync122(fullPath)) {
|
|
154540
154899
|
res.status(404).json({ error: "File not found" });
|
|
154541
154900
|
return;
|
|
154542
154901
|
}
|
|
@@ -154563,7 +154922,7 @@ function mountOutputRoutes(app, outputStore, wss, options) {
|
|
|
154563
154922
|
}
|
|
154564
154923
|
if (!download && (ext === ".html" || ext === ".htm") && isPageRequest(req) && stat6.size <= 64 * 1024 * 1024) {
|
|
154565
154924
|
try {
|
|
154566
|
-
const body = withSandboxStorageBytes(
|
|
154925
|
+
const body = withSandboxStorageBytes(readFileSync98(fullPath));
|
|
154567
154926
|
if (body) {
|
|
154568
154927
|
res.setHeader("Content-Length", body.length);
|
|
154569
154928
|
res.end(body);
|
|
@@ -154595,7 +154954,7 @@ function mountOutputRoutes(app, outputStore, wss, options) {
|
|
|
154595
154954
|
const allResults = [];
|
|
154596
154955
|
for (const folder of folders) {
|
|
154597
154956
|
const resolved = resolveFolder(folder.path, folder.isAbsolute, projectPath2);
|
|
154598
|
-
if (!
|
|
154957
|
+
if (!existsSync122(resolved)) continue;
|
|
154599
154958
|
const results = searchFiles(resolved, query, 50);
|
|
154600
154959
|
for (const r of results) {
|
|
154601
154960
|
allResults.push({ ...r, folderId: folder.id, folderLabel: folder.label });
|
|
@@ -154637,10 +154996,10 @@ function mountOutputRoutes(app, outputStore, wss, options) {
|
|
|
154637
154996
|
}
|
|
154638
154997
|
const fullPath = resolve33(folderRoot, normalizedPath);
|
|
154639
154998
|
if (!isPathSafe(fullPath, folderRoot, projectPath2)) continue;
|
|
154640
|
-
if (!
|
|
154999
|
+
if (!existsSync122(fullPath)) continue;
|
|
154641
155000
|
const stat6 = statSync48(fullPath);
|
|
154642
155001
|
if (stat6.isDirectory()) {
|
|
154643
|
-
archive.directory(fullPath, relPath, (entry2) => isTestverInternalPath(
|
|
155002
|
+
archive.directory(fullPath, relPath, (entry2) => isTestverInternalPath(join121(fullPath, entry2.name), projectPath2) ? false : entry2);
|
|
154644
155003
|
} else {
|
|
154645
155004
|
archive.file(fullPath, { name: relPath });
|
|
154646
155005
|
}
|
|
@@ -155177,8 +155536,8 @@ __export(api_documents_exports, {
|
|
|
155177
155536
|
mountDocumentRoutes: () => mountDocumentRoutes,
|
|
155178
155537
|
sandboxActiveContent: () => sandboxActiveContent
|
|
155179
155538
|
});
|
|
155180
|
-
import { existsSync as
|
|
155181
|
-
import { join as
|
|
155539
|
+
import { existsSync as existsSync123, mkdirSync as mkdirSync57, writeFileSync as writeFileSync29, readFileSync as readFileSync99 } from "fs";
|
|
155540
|
+
import { join as join122, basename as basename30 } from "path";
|
|
155182
155541
|
function sandboxActiveContent(res) {
|
|
155183
155542
|
res.setHeader(
|
|
155184
155543
|
"Content-Security-Policy",
|
|
@@ -155187,8 +155546,8 @@ function sandboxActiveContent(res) {
|
|
|
155187
155546
|
}
|
|
155188
155547
|
function mountDocumentRoutes(app, tmStore5, projectPath2) {
|
|
155189
155548
|
const docService = new DocumentService(tmStore5);
|
|
155190
|
-
const outputDir =
|
|
155191
|
-
if (!
|
|
155549
|
+
const outputDir = join122(projectPath2, ".testver", "documents");
|
|
155550
|
+
if (!existsSync123(outputDir)) mkdirSync57(outputDir, { recursive: true });
|
|
155192
155551
|
app.post("/api/documents/generate", async (req, res) => {
|
|
155193
155552
|
try {
|
|
155194
155553
|
const { type, format: format2, params } = req.body;
|
|
@@ -155264,7 +155623,7 @@ function mountDocumentRoutes(app, tmStore5, projectPath2) {
|
|
|
155264
155623
|
}
|
|
155265
155624
|
const ts = Date.now();
|
|
155266
155625
|
const safeFilename2 = `${ts}-${filename}`;
|
|
155267
|
-
const filePath3 =
|
|
155626
|
+
const filePath3 = join122(outputDir, safeFilename2);
|
|
155268
155627
|
if (buffer) {
|
|
155269
155628
|
writeFileSync29(filePath3, buffer);
|
|
155270
155629
|
} else if (csvContent) {
|
|
@@ -155300,7 +155659,7 @@ function mountDocumentRoutes(app, tmStore5, projectPath2) {
|
|
|
155300
155659
|
} else {
|
|
155301
155660
|
res.setHeader("Content-Disposition", `attachment; filename="${originalName}"`);
|
|
155302
155661
|
}
|
|
155303
|
-
res.send(
|
|
155662
|
+
res.send(readFileSync99(filePath3));
|
|
155304
155663
|
} catch (error) {
|
|
155305
155664
|
res.status(500).json({ error: String(error) });
|
|
155306
155665
|
}
|
|
@@ -156079,10 +156438,10 @@ __export(trace_viewer_exports, {
|
|
|
156079
156438
|
traceViewerCandidates: () => traceViewerCandidates,
|
|
156080
156439
|
traceViewerHandler: () => traceViewerHandler
|
|
156081
156440
|
});
|
|
156082
|
-
import { existsSync as
|
|
156441
|
+
import { existsSync as existsSync124, mkdirSync as mkdirSync58, readdirSync as readdirSync47, readFileSync as readFileSync100, renameSync as renameSync6, rmSync as rmSync6, writeFileSync as writeFileSync30 } from "fs";
|
|
156083
156442
|
import { createRequire as createRequire5 } from "module";
|
|
156084
156443
|
import { homedir as homedir4 } from "os";
|
|
156085
|
-
import { dirname as dirname34, join as
|
|
156444
|
+
import { dirname as dirname34, join as join123 } from "path";
|
|
156086
156445
|
function compareVersions(a, b) {
|
|
156087
156446
|
const parse = (v) => {
|
|
156088
156447
|
const [core = "", pre] = v.split("-", 2);
|
|
@@ -156099,10 +156458,10 @@ function compareVersions(a, b) {
|
|
|
156099
156458
|
return x.pre < y.pre ? -1 : 1;
|
|
156100
156459
|
}
|
|
156101
156460
|
function fromPackageRoot(root, source2) {
|
|
156102
|
-
const dir =
|
|
156103
|
-
if (!
|
|
156461
|
+
const dir = join123(root, "lib", "vite", "traceViewer");
|
|
156462
|
+
if (!existsSync124(join123(dir, "index.html"))) return void 0;
|
|
156104
156463
|
try {
|
|
156105
|
-
const version = String(JSON.parse(
|
|
156464
|
+
const version = String(JSON.parse(readFileSync100(join123(root, "package.json"), "utf-8")).version || "");
|
|
156106
156465
|
return version ? { dir, version, source: source2 } : void 0;
|
|
156107
156466
|
} catch {
|
|
156108
156467
|
return void 0;
|
|
@@ -156121,25 +156480,25 @@ function traceViewerCandidates(projectPath2, testverCoreRoot) {
|
|
|
156121
156480
|
if (c2 && !out.some((o) => o.dir === c2.dir)) out.push(c2);
|
|
156122
156481
|
};
|
|
156123
156482
|
if (testverCoreRoot) add(fromPackageRoot(testverCoreRoot, "testver"));
|
|
156124
|
-
const anchor =
|
|
156125
|
-
if (
|
|
156483
|
+
const anchor = join123(projectPath2, "package.json");
|
|
156484
|
+
if (existsSync124(anchor)) {
|
|
156126
156485
|
const core = resolvePackage(anchor, "playwright-core");
|
|
156127
156486
|
if (core) add(fromPackageRoot(core, "project-node"));
|
|
156128
156487
|
for (const top of ["@playwright/test", "playwright"]) {
|
|
156129
156488
|
const pkg = resolvePackage(anchor, top);
|
|
156130
|
-
const viaTop = pkg ? resolvePackage(
|
|
156489
|
+
const viaTop = pkg ? resolvePackage(join123(pkg, "package.json"), "playwright-core") : void 0;
|
|
156131
156490
|
if (viaTop) add(fromPackageRoot(viaTop, "project-node"));
|
|
156132
156491
|
}
|
|
156133
156492
|
}
|
|
156134
156493
|
for (const venv of [".venv", "venv", "env"]) {
|
|
156135
|
-
const base =
|
|
156136
|
-
if (!
|
|
156137
|
-
const sites = [
|
|
156494
|
+
const base = join123(projectPath2, venv);
|
|
156495
|
+
if (!existsSync124(base)) continue;
|
|
156496
|
+
const sites = [join123(base, "Lib", "site-packages")];
|
|
156138
156497
|
try {
|
|
156139
|
-
for (const d of readdirSync47(
|
|
156498
|
+
for (const d of readdirSync47(join123(base, "lib"))) if (/^python\d/.test(d)) sites.push(join123(base, "lib", d, "site-packages"));
|
|
156140
156499
|
} catch {
|
|
156141
156500
|
}
|
|
156142
|
-
for (const site of sites) add(fromPackageRoot(
|
|
156501
|
+
for (const site of sites) add(fromPackageRoot(join123(site, "playwright", "driver", "package"), "project-python"));
|
|
156143
156502
|
}
|
|
156144
156503
|
let seen = 0;
|
|
156145
156504
|
const walk3 = (dir, depth) => {
|
|
@@ -156153,14 +156512,14 @@ function traceViewerCandidates(projectPath2, testverCoreRoot) {
|
|
|
156153
156512
|
for (const e of entries) {
|
|
156154
156513
|
if (!e.isDirectory()) continue;
|
|
156155
156514
|
if (e.name === ".playwright") {
|
|
156156
|
-
add(fromPackageRoot(
|
|
156515
|
+
add(fromPackageRoot(join123(dir, e.name, "package"), "project-dotnet"));
|
|
156157
156516
|
continue;
|
|
156158
156517
|
}
|
|
156159
156518
|
if (SKIP2.has(e.name) || e.name.startsWith(".") && e.name !== ".playwright") continue;
|
|
156160
|
-
walk3(
|
|
156519
|
+
walk3(join123(dir, e.name), depth + 1);
|
|
156161
156520
|
}
|
|
156162
156521
|
};
|
|
156163
|
-
if (
|
|
156522
|
+
if (existsSync124(projectPath2) && readdirSync47(projectPath2).some((f) => /\.(csproj|sln)$/i.test(f) || f === "tests")) walk3(projectPath2, 0);
|
|
156164
156523
|
return out;
|
|
156165
156524
|
}
|
|
156166
156525
|
function newestTraceViewer(candidates) {
|
|
@@ -156172,16 +156531,16 @@ function newestTraceViewer(candidates) {
|
|
|
156172
156531
|
}
|
|
156173
156532
|
function javaJarRoots() {
|
|
156174
156533
|
const home = homedir4();
|
|
156175
|
-
let m2 =
|
|
156534
|
+
let m2 = join123(home, ".m2", "repository");
|
|
156176
156535
|
try {
|
|
156177
|
-
const local = /<localRepository>\s*([^<]+?)\s*<\/localRepository>/.exec(
|
|
156536
|
+
const local = /<localRepository>\s*([^<]+?)\s*<\/localRepository>/.exec(readFileSync100(join123(home, ".m2", "settings.xml"), "utf-8"))?.[1];
|
|
156178
156537
|
if (local) m2 = local.replace("${user.home}", home);
|
|
156179
156538
|
} catch {
|
|
156180
156539
|
}
|
|
156181
|
-
const gradle = process.env.GRADLE_USER_HOME ||
|
|
156540
|
+
const gradle = process.env.GRADLE_USER_HOME || join123(home, ".gradle");
|
|
156182
156541
|
return [
|
|
156183
|
-
|
|
156184
|
-
|
|
156542
|
+
join123(m2, "com", "microsoft", "playwright", "driver-bundle"),
|
|
156543
|
+
join123(gradle, "caches", "modules-2", "files-2.1", "com.microsoft.playwright", "driver-bundle")
|
|
156185
156544
|
];
|
|
156186
156545
|
}
|
|
156187
156546
|
function javaDriverJars(roots = javaJarRoots()) {
|
|
@@ -156195,15 +156554,15 @@ function javaDriverJars(roots = javaJarRoots()) {
|
|
|
156195
156554
|
}
|
|
156196
156555
|
for (const v of versions) {
|
|
156197
156556
|
if (!/^\d+\.\d+/.test(v)) continue;
|
|
156198
|
-
const direct =
|
|
156199
|
-
if (
|
|
156557
|
+
const direct = join123(root, v, `driver-bundle-${v}.jar`);
|
|
156558
|
+
if (existsSync124(direct)) {
|
|
156200
156559
|
out.push({ jar: direct, version: v });
|
|
156201
156560
|
continue;
|
|
156202
156561
|
}
|
|
156203
156562
|
try {
|
|
156204
|
-
for (const h of readdirSync47(
|
|
156205
|
-
const jar =
|
|
156206
|
-
if (
|
|
156563
|
+
for (const h of readdirSync47(join123(root, v))) {
|
|
156564
|
+
const jar = join123(root, v, h, `driver-bundle-${v}.jar`);
|
|
156565
|
+
if (existsSync124(jar)) {
|
|
156207
156566
|
out.push({ jar, version: v });
|
|
156208
156567
|
break;
|
|
156209
156568
|
}
|
|
@@ -156230,12 +156589,12 @@ function extractJavaTraceViewer(jar, dest) {
|
|
|
156230
156589
|
else if (x.name.startsWith(prefix) && !x.name.endsWith("/")) rel = `lib/vite/traceViewer/${x.name.slice(prefix.length)}`;
|
|
156231
156590
|
else continue;
|
|
156232
156591
|
if (/[\\:]/.test(rel) || rel.split("/").some((seg) => seg === "" || seg === "." || seg === "..")) continue;
|
|
156233
|
-
const out =
|
|
156234
|
-
|
|
156592
|
+
const out = join123(tmp, ...rel.split("/"));
|
|
156593
|
+
mkdirSync58(dirname34(out), { recursive: true });
|
|
156235
156594
|
writeFileSync30(out, zip.read(x, MAX_VIEWER_FILE));
|
|
156236
156595
|
}
|
|
156237
|
-
if (!
|
|
156238
|
-
|
|
156596
|
+
if (!existsSync124(join123(tmp, "lib", "vite", "traceViewer", "index.html")) || !existsSync124(join123(tmp, "package.json"))) throw new Error("no viewer");
|
|
156597
|
+
mkdirSync58(dirname34(dest), { recursive: true });
|
|
156239
156598
|
rmSync6(dest, { recursive: true, force: true });
|
|
156240
156599
|
renameSync6(tmp, dest);
|
|
156241
156600
|
return true;
|
|
@@ -156251,10 +156610,10 @@ function extractJavaTraceViewer(jar, dest) {
|
|
|
156251
156610
|
}
|
|
156252
156611
|
function javaTraceViewerCandidates(projectPath2, opts = {}) {
|
|
156253
156612
|
if (!detectPlaywrightStacks(projectPath2).includes("playwright-java")) return [];
|
|
156254
|
-
const cacheRoot = opts.cacheRoot ??
|
|
156613
|
+
const cacheRoot = opts.cacheRoot ?? join123(getTestverDir(), "trace-viewers");
|
|
156255
156614
|
return javaDriverJars(opts.jarRoots).map(({ jar, version }) => {
|
|
156256
|
-
const root =
|
|
156257
|
-
return { dir:
|
|
156615
|
+
const root = join123(cacheRoot, `playwright-java-${version}`);
|
|
156616
|
+
return { dir: join123(root, "lib", "vite", "traceViewer"), version, source: "project-java", jar, root };
|
|
156258
156617
|
});
|
|
156259
156618
|
}
|
|
156260
156619
|
function currentTraceViewer(projectPath2, testverCoreRoot, now = Date.now(), javaOpts = {}) {
|
|
@@ -156263,7 +156622,7 @@ function currentTraceViewer(projectPath2, testverCoreRoot, now = Date.now(), jav
|
|
|
156263
156622
|
const all = [...traceViewerCandidates(projectPath2, testverCoreRoot), ...javaTraceViewerCandidates(projectPath2, javaOpts)];
|
|
156264
156623
|
let viewer = newestTraceViewer(all);
|
|
156265
156624
|
while (viewer?.jar && viewer.root) {
|
|
156266
|
-
const ready =
|
|
156625
|
+
const ready = existsSync124(join123(viewer.dir, "index.html")) || extractJavaTraceViewer(viewer.jar, viewer.root);
|
|
156267
156626
|
const unpacked = ready ? fromPackageRoot(viewer.root, "project-java") : void 0;
|
|
156268
156627
|
if (unpacked) {
|
|
156269
156628
|
viewer = unpacked;
|
|
@@ -156329,9 +156688,9 @@ var init_client_resume = __esm({
|
|
|
156329
156688
|
|
|
156330
156689
|
// src/ui/server.ts
|
|
156331
156690
|
import { createServer as createServer3 } from "http";
|
|
156332
|
-
import { join as
|
|
156691
|
+
import { join as join124, dirname as dirname35, relative as relative43 } from "path";
|
|
156333
156692
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
156334
|
-
import { existsSync as
|
|
156693
|
+
import { existsSync as existsSync125, readFileSync as readFileSync101, mkdirSync as mkdirSync59, unlinkSync as unlinkSync13 } from "fs";
|
|
156335
156694
|
async function createUIServer(options) {
|
|
156336
156695
|
const PROFILE = process.env.TESTVER_PROFILE_BOOT === "1";
|
|
156337
156696
|
const bootT0 = Date.now();
|
|
@@ -156630,18 +156989,18 @@ async function createUIServer(options) {
|
|
|
156630
156989
|
ensureAuthFilesIgnored2(options.projectPath);
|
|
156631
156990
|
}
|
|
156632
156991
|
const MAX_ACTIVITIES = 25;
|
|
156633
|
-
const activityFilePath =
|
|
156992
|
+
const activityFilePath = join124(getTestverDir(options.projectPath), "activity.json");
|
|
156634
156993
|
let activityBuffer = [];
|
|
156635
156994
|
try {
|
|
156636
|
-
const legacyGlobalActivity =
|
|
156637
|
-
if (legacyGlobalActivity !== activityFilePath &&
|
|
156995
|
+
const legacyGlobalActivity = join124(getTestverDir(), "activity.json");
|
|
156996
|
+
if (legacyGlobalActivity !== activityFilePath && existsSync125(legacyGlobalActivity)) {
|
|
156638
156997
|
unlinkSync13(legacyGlobalActivity);
|
|
156639
156998
|
}
|
|
156640
156999
|
} catch {
|
|
156641
157000
|
}
|
|
156642
157001
|
try {
|
|
156643
|
-
if (
|
|
156644
|
-
activityBuffer = JSON.parse(
|
|
157002
|
+
if (existsSync125(activityFilePath)) {
|
|
157003
|
+
activityBuffer = JSON.parse(readFileSync101(activityFilePath, "utf-8"));
|
|
156645
157004
|
if (activityBuffer.length > MAX_ACTIVITIES) activityBuffer.length = MAX_ACTIVITIES;
|
|
156646
157005
|
}
|
|
156647
157006
|
} catch {
|
|
@@ -156654,7 +157013,7 @@ async function createUIServer(options) {
|
|
|
156654
157013
|
activitySaveTimer = null;
|
|
156655
157014
|
try {
|
|
156656
157015
|
const dir = getTestverDir(options.projectPath);
|
|
156657
|
-
if (!
|
|
157016
|
+
if (!existsSync125(dir)) mkdirSync59(dir, { recursive: true });
|
|
156658
157017
|
writeFileAtomicSync(activityFilePath, JSON.stringify(activityBuffer));
|
|
156659
157018
|
} catch {
|
|
156660
157019
|
}
|
|
@@ -156786,7 +157145,7 @@ async function createUIServer(options) {
|
|
|
156786
157145
|
mountSystemRoutes2(app, systemConfigStore, options.projectPath, () => remoteUpdatesService?.reschedule());
|
|
156787
157146
|
}
|
|
156788
157147
|
mountRunnerRoutes2(app, wss, scanner, options, resultsStore4, cloudConfigStore, localMobileConfigStore, artifactFetcher, pushActivity, gitService, systemConfigStore);
|
|
156789
|
-
mountAIRoutes2(app, wss, options, skillRegistry, mcpClientManager);
|
|
157148
|
+
mountAIRoutes2(app, wss, options, skillRegistry, mcpClientManager, chatHistoryStore);
|
|
156790
157149
|
mountBrowserRoutes2(app, wss, options);
|
|
156791
157150
|
mountRecorderRoutes2(app, wss, options);
|
|
156792
157151
|
mountResultsRoutes2(app, resultsStore4, artifactFetcher, options.projectPath);
|
|
@@ -156832,7 +157191,7 @@ async function createUIServer(options) {
|
|
|
156832
157191
|
setMobileClientOwners2(clientIdToUserId);
|
|
156833
157192
|
const { mountLocalMobileRoutes: mountLocalMobileRoutes2 } = await Promise.resolve().then(() => (init_api_local_mobile(), api_local_mobile_exports));
|
|
156834
157193
|
mountLocalMobileRoutes2(app, options);
|
|
156835
|
-
mountApiTestingRoutes2(app, apiCollectionsStore);
|
|
157194
|
+
mountApiTestingRoutes2(app, apiCollectionsStore, options.projectPath);
|
|
156836
157195
|
const { RemoteUpdatesService: RemoteUpdatesService2 } = await Promise.resolve().then(() => (init_remote_updates_service(), remote_updates_service_exports));
|
|
156837
157196
|
remoteUpdatesService = new RemoteUpdatesService2({
|
|
156838
157197
|
gitService,
|
|
@@ -156991,7 +157350,7 @@ async function createUIServer(options) {
|
|
|
156991
157350
|
function getServerPackageVersion() {
|
|
156992
157351
|
try {
|
|
156993
157352
|
const dir = dirname35(fileURLToPath5(import.meta.url));
|
|
156994
|
-
return JSON.parse(
|
|
157353
|
+
return JSON.parse(readFileSync101(join124(dir, "..", "package.json"), "utf-8")).version || "0.0.0";
|
|
156995
157354
|
} catch {
|
|
156996
157355
|
return "0.0.0";
|
|
156997
157356
|
}
|
|
@@ -157017,12 +157376,12 @@ async function createUIServer(options) {
|
|
|
157017
157376
|
});
|
|
157018
157377
|
app.get("/api/activity", (_req, res) => res.json({ activities: activityBuffer }));
|
|
157019
157378
|
const staticCandidates = [
|
|
157020
|
-
|
|
157379
|
+
join124(__dirname, "static"),
|
|
157021
157380
|
// development (src/ui/static)
|
|
157022
|
-
|
|
157381
|
+
join124(__dirname, "..", "src", "ui", "static")
|
|
157023
157382
|
// bundled (dist/../src/ui/static)
|
|
157024
157383
|
];
|
|
157025
|
-
const staticDir = staticCandidates.find((d) =>
|
|
157384
|
+
const staticDir = staticCandidates.find((d) => existsSync125(d)) ?? staticCandidates[0];
|
|
157026
157385
|
try {
|
|
157027
157386
|
const { createRequire: createRequire6 } = await import("module");
|
|
157028
157387
|
const req = createRequire6(import.meta.url);
|
|
@@ -157035,12 +157394,12 @@ async function createUIServer(options) {
|
|
|
157035
157394
|
app.use("/trace-viewer", traceViewerHandler2((dir) => express.static(dir), options.projectPath, testverCoreRoot));
|
|
157036
157395
|
} catch {
|
|
157037
157396
|
}
|
|
157038
|
-
if (
|
|
157397
|
+
if (existsSync125(staticDir)) {
|
|
157039
157398
|
app.use(compressedAssets(staticDir));
|
|
157040
157399
|
app.use(express.static(staticDir));
|
|
157041
157400
|
app.get("*", (_req, res) => {
|
|
157042
|
-
const indexPath =
|
|
157043
|
-
if (
|
|
157401
|
+
const indexPath = join124(staticDir, "index.html");
|
|
157402
|
+
if (existsSync125(indexPath)) {
|
|
157044
157403
|
res.sendFile(indexPath);
|
|
157045
157404
|
} else {
|
|
157046
157405
|
res.status(404).json({ error: "UI not built. Run: pnpm run build:ui" });
|
|
@@ -157076,17 +157435,32 @@ async function createUIServer(options) {
|
|
|
157076
157435
|
clientIdToUserId.delete(clientId);
|
|
157077
157436
|
void Promise.resolve().then(() => (init_api_recorder(), api_recorder_exports)).then(({ flushRecordingOnDisconnect: flushRecordingOnDisconnect2 }) => flushRecordingOnDisconnect2(clientId)).catch(() => {
|
|
157078
157437
|
});
|
|
157079
|
-
void Promise.resolve().then(() => (init_api_mobile(), api_mobile_exports)).then(({ scheduleMobileClientGone: scheduleMobileClientGone2 }) => scheduleMobileClientGone2(clientId, MOBILE_GONE_MS)).catch(() => {
|
|
157438
|
+
const releaseMobileLater = () => void Promise.resolve().then(() => (init_api_mobile(), api_mobile_exports)).then(({ scheduleMobileClientGone: scheduleMobileClientGone2 }) => scheduleMobileClientGone2(clientId, MOBILE_GONE_MS)).catch(() => {
|
|
157080
157439
|
});
|
|
157440
|
+
void Promise.resolve().then(() => (init_chat_runs(), chat_runs_exports)).then(({ runningRunOwnerForClient: runningRunOwnerForClient2 }) => {
|
|
157441
|
+
if (!runningRunOwnerForClient2(clientId)) {
|
|
157442
|
+
releaseMobileLater();
|
|
157443
|
+
return;
|
|
157444
|
+
}
|
|
157445
|
+
const wait = setInterval(() => {
|
|
157446
|
+
if (runningRunOwnerForClient2(clientId)) return;
|
|
157447
|
+
clearInterval(wait);
|
|
157448
|
+
const back = [...wss.clients].some((c2) => c2.__clientId === clientId && c2.readyState === 1);
|
|
157449
|
+
if (!back) releaseMobileLater();
|
|
157450
|
+
}, 1e4);
|
|
157451
|
+
wait.unref?.();
|
|
157452
|
+
}).catch(() => releaseMobileLater());
|
|
157081
157453
|
});
|
|
157082
157454
|
const adoptClientId = async (userId) => {
|
|
157083
157455
|
const { decideResume: decideResume2 } = await Promise.resolve().then(() => (init_client_resume(), client_resume_exports));
|
|
157084
157456
|
const holder = requestedId ? [...wss.clients].find((c2) => c2 !== ws && c2.__clientId === requestedId) : void 0;
|
|
157457
|
+
const { runningRunOwnerForClient: runningRunOwnerForClient2 } = await Promise.resolve().then(() => (init_chat_runs(), chat_runs_exports));
|
|
157458
|
+
const runOwner = requestedId ? runningRunOwnerForClient2(requestedId) : void 0;
|
|
157085
157459
|
const decision = decideResume2({
|
|
157086
157460
|
requested: requestedId,
|
|
157087
157461
|
userId,
|
|
157088
157462
|
holder: holder ? { userId: holder.__user?.id || clientIdToUserId.get(requestedId), open: holder.readyState === 1 } : null,
|
|
157089
|
-
closed: recentlyClosedClients.get(requestedId) || null,
|
|
157463
|
+
closed: (runOwner ? { userId: runOwner, closedAt: Date.now() } : null) || recentlyClosedClients.get(requestedId) || null,
|
|
157090
157464
|
now: Date.now(),
|
|
157091
157465
|
windowMs: RESUME_WINDOW_MS
|
|
157092
157466
|
});
|
|
@@ -157268,7 +157642,7 @@ async function createUIServer(options) {
|
|
|
157268
157642
|
app.serverPort = actualPort;
|
|
157269
157643
|
app.serverHost = host;
|
|
157270
157644
|
setPublicUrlPort(actualPort);
|
|
157271
|
-
setPublicUrlStore(
|
|
157645
|
+
setPublicUrlStore(join124(getTestverDir(options.projectPath), "public-url.json"));
|
|
157272
157646
|
scheduler.setPort(actualPort);
|
|
157273
157647
|
scheduler.setWss(wss);
|
|
157274
157648
|
scheduler.start();
|
|
@@ -157579,8 +157953,8 @@ __export(server_log_exports, {
|
|
|
157579
157953
|
pruneOldLogs: () => pruneOldLogs,
|
|
157580
157954
|
startServerLog: () => startServerLog
|
|
157581
157955
|
});
|
|
157582
|
-
import { closeSync as closeSync4, existsSync as
|
|
157583
|
-
import { join as
|
|
157956
|
+
import { closeSync as closeSync4, existsSync as existsSync126, mkdirSync as mkdirSync60, openSync as openSync4, readdirSync as readdirSync48, unlinkSync as unlinkSync14, writeSync as writeSync2 } from "fs";
|
|
157957
|
+
import { join as join125 } from "path";
|
|
157584
157958
|
import { format } from "util";
|
|
157585
157959
|
function logFileName(d) {
|
|
157586
157960
|
return `testver-${logDay(d)}.log`;
|
|
@@ -157598,7 +157972,7 @@ function pruneOldLogs(dir, now, days = LOG_RETENTION_DAYS) {
|
|
|
157598
157972
|
const m = FILE_RE.exec(name2);
|
|
157599
157973
|
if (!m || `${m[1]}-${m[2]}-${m[3]}` >= oldestKept) continue;
|
|
157600
157974
|
try {
|
|
157601
|
-
unlinkSync14(
|
|
157975
|
+
unlinkSync14(join125(dir, name2));
|
|
157602
157976
|
deleted.push(name2);
|
|
157603
157977
|
} catch {
|
|
157604
157978
|
}
|
|
@@ -157608,7 +157982,7 @@ function pruneOldLogs(dir, now, days = LOG_RETENTION_DAYS) {
|
|
|
157608
157982
|
function inContainer() {
|
|
157609
157983
|
if (process.env.container || process.env.KUBERNETES_SERVICE_HOST) return true;
|
|
157610
157984
|
try {
|
|
157611
|
-
return
|
|
157985
|
+
return existsSync126("/.dockerenv") || existsSync126("/run/.containerenv");
|
|
157612
157986
|
} catch {
|
|
157613
157987
|
return false;
|
|
157614
157988
|
}
|
|
@@ -157631,8 +158005,8 @@ function startServerLog(opts) {
|
|
|
157631
158005
|
closeSync4(fd);
|
|
157632
158006
|
fd = null;
|
|
157633
158007
|
}
|
|
157634
|
-
|
|
157635
|
-
fd = openSync4(
|
|
158008
|
+
mkdirSync60(opts.dir, { recursive: true });
|
|
158009
|
+
fd = openSync4(join125(opts.dir, logFileName(d)), "a");
|
|
157636
158010
|
day2 = today;
|
|
157637
158011
|
pruneOldLogs(opts.dir, d, days);
|
|
157638
158012
|
return true;
|
|
@@ -157709,8 +158083,8 @@ var users_cli_exports = {};
|
|
|
157709
158083
|
__export(users_cli_exports, {
|
|
157710
158084
|
runUsersCommand: () => runUsersCommand
|
|
157711
158085
|
});
|
|
157712
|
-
import { existsSync as
|
|
157713
|
-
import { join as
|
|
158086
|
+
import { existsSync as existsSync127 } from "fs";
|
|
158087
|
+
import { join as join126, resolve as resolve34 } from "path";
|
|
157714
158088
|
import { userInfo } from "os";
|
|
157715
158089
|
async function runUsersCommand(args2, cwd, out = console.log) {
|
|
157716
158090
|
const sub = args2[0];
|
|
@@ -157732,7 +158106,7 @@ async function runUsersCommand(args2, cwd, out = console.log) {
|
|
|
157732
158106
|
out(USAGE);
|
|
157733
158107
|
return sub === void 0 || sub === "help" ? 0 : 1;
|
|
157734
158108
|
}
|
|
157735
|
-
if (!
|
|
158109
|
+
if (!existsSync127(join126(project, ".testver", "users.db"))) {
|
|
157736
158110
|
out(`No Testver accounts in ${project} (.testver/users.db not found). Run this from the project folder Testver serves, or pass --project <path>.`);
|
|
157737
158111
|
return 1;
|
|
157738
158112
|
}
|
|
@@ -158449,8 +158823,8 @@ URL: ${url}
|
|
|
158449
158823
|
|
|
158450
158824
|
// src/index.ts
|
|
158451
158825
|
import { configDotenv } from "dotenv";
|
|
158452
|
-
import { join as
|
|
158453
|
-
import { readFileSync as
|
|
158826
|
+
import { join as join127, resolve as resolve35 } from "path";
|
|
158827
|
+
import { readFileSync as readFileSync102 } from "fs";
|
|
158454
158828
|
import chalk4 from "chalk";
|
|
158455
158829
|
|
|
158456
158830
|
// src/repl/repl.ts
|
|
@@ -159767,7 +160141,7 @@ var workingDirectory = process.cwd();
|
|
|
159767
160141
|
function getPackageVersion() {
|
|
159768
160142
|
try {
|
|
159769
160143
|
const pkgPath = resolve35(import.meta.dirname || ".", "..", "package.json");
|
|
159770
|
-
return JSON.parse(
|
|
160144
|
+
return JSON.parse(readFileSync102(pkgPath, "utf-8")).version || "0.0.0";
|
|
159771
160145
|
} catch {
|
|
159772
160146
|
return "0.0.0";
|
|
159773
160147
|
}
|
|
@@ -159853,25 +160227,25 @@ if (args.includes("--help") || args.includes("-h")) {
|
|
|
159853
160227
|
if (args[0] === "deploy") {
|
|
159854
160228
|
const subcommand = args[1] || "help";
|
|
159855
160229
|
(async () => {
|
|
159856
|
-
const { existsSync:
|
|
160230
|
+
const { existsSync: existsSync128, writeFileSync: writeFileSync31, mkdirSync: mkdirSync61 } = await import("fs");
|
|
159857
160231
|
const { execSync, spawnSync } = await import("child_process");
|
|
159858
|
-
const { join:
|
|
160232
|
+
const { join: join128 } = await import("path");
|
|
159859
160233
|
const CONTAINER_NAME = "testver-dashboard";
|
|
159860
160234
|
const DOCKER_IMAGE = "testver/dashboard";
|
|
159861
|
-
const deployDir =
|
|
160235
|
+
const deployDir = join128(workingDirectory, ".testver-deploy");
|
|
159862
160236
|
const ensureDeployEnvSafety = async () => {
|
|
159863
|
-
const { readFileSync:
|
|
160237
|
+
const { readFileSync: readFileSync103, appendFileSync: appendFileSync2 } = await import("fs");
|
|
159864
160238
|
const { randomBytes: randomBytes20 } = await import("crypto");
|
|
159865
160239
|
const { ensureTwoFactorKeyLine: ensureTwoFactorKeyLine2, ensureGitignoreLine: ensureGitignoreLine2 } = await Promise.resolve().then(() => (init_deploy_env(), deploy_env_exports));
|
|
159866
|
-
const envFile =
|
|
159867
|
-
const envText =
|
|
160240
|
+
const envFile = join128(deployDir, ".env");
|
|
160241
|
+
const envText = existsSync128(envFile) ? readFileSync103(envFile, "utf-8") : "";
|
|
159868
160242
|
const addition = ensureTwoFactorKeyLine2(envText, () => randomBytes20(32).toString("hex"));
|
|
159869
160243
|
if (addition) {
|
|
159870
160244
|
appendFileSync2(envFile, addition);
|
|
159871
160245
|
console.log(" \u2705 TESTVER_2FA_KEY added to .testver-deploy/.env \u2014 it keeps two-factor sign-in working across container rebuilds; back this file up and never change the value");
|
|
159872
160246
|
}
|
|
159873
|
-
const gitignore =
|
|
159874
|
-
const giAddition = ensureGitignoreLine2(
|
|
160247
|
+
const gitignore = join128(deployDir, ".gitignore");
|
|
160248
|
+
const giAddition = ensureGitignoreLine2(existsSync128(gitignore) ? readFileSync103(gitignore, "utf-8") : "", ".env");
|
|
159875
160249
|
if (giAddition) appendFileSync2(gitignore, giAddition);
|
|
159876
160250
|
};
|
|
159877
160251
|
const cmdExists = (cmd) => {
|
|
@@ -159919,7 +160293,7 @@ if (args[0] === "deploy") {
|
|
|
159919
160293
|
}
|
|
159920
160294
|
console.log(" \u2705 Docker found");
|
|
159921
160295
|
const composeCmd = cmdExists("docker-compose") ? "docker-compose" : "docker compose";
|
|
159922
|
-
if (!
|
|
160296
|
+
if (!existsSync128(deployDir)) mkdirSync61(deployDir, { recursive: true });
|
|
159923
160297
|
const getFlag2 = (name2) => {
|
|
159924
160298
|
for (let i = 2; i < args.length; i++) {
|
|
159925
160299
|
if (args[i] === `--${name2}`) return args[i + 1];
|
|
@@ -159965,7 +160339,7 @@ if (args[0] === "deploy") {
|
|
|
159965
160339
|
volumes:
|
|
159966
160340
|
testver-data:
|
|
159967
160341
|
`;
|
|
159968
|
-
writeFileSync31(
|
|
160342
|
+
writeFileSync31(join128(deployDir, "docker-compose.yml"), compose);
|
|
159969
160343
|
console.log(" \u2705 docker-compose.yml created (using published image)");
|
|
159970
160344
|
} else {
|
|
159971
160345
|
const dockerfile = `FROM node:22-slim
|
|
@@ -159979,7 +160353,7 @@ HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 CMD curl
|
|
|
159979
160353
|
ENV TESTVER_HOST=0.0.0.0 TESTVER_PORT=${port} NODE_ENV=production
|
|
159980
160354
|
CMD ["testver", "serve", "--host", "0.0.0.0", "--port", "${port}"]
|
|
159981
160355
|
`;
|
|
159982
|
-
writeFileSync31(
|
|
160356
|
+
writeFileSync31(join128(deployDir, "Dockerfile"), dockerfile);
|
|
159983
160357
|
console.log(" \u2705 Dockerfile created");
|
|
159984
160358
|
const compose = `services:
|
|
159985
160359
|
testver:
|
|
@@ -160000,11 +160374,11 @@ CMD ["testver", "serve", "--host", "0.0.0.0", "--port", "${port}"]
|
|
|
160000
160374
|
volumes:
|
|
160001
160375
|
testver-data:
|
|
160002
160376
|
`;
|
|
160003
|
-
writeFileSync31(
|
|
160377
|
+
writeFileSync31(join128(deployDir, "docker-compose.yml"), compose);
|
|
160004
160378
|
console.log(" \u2705 docker-compose.yml created (local build)");
|
|
160005
160379
|
}
|
|
160006
|
-
const envFile =
|
|
160007
|
-
if (!
|
|
160380
|
+
const envFile = join128(deployDir, ".env");
|
|
160381
|
+
if (!existsSync128(envFile)) {
|
|
160008
160382
|
const envContent = [
|
|
160009
160383
|
`TESTVER_PORT=${port}`,
|
|
160010
160384
|
`OPENAI_API_KEY=${process.env.OPENAI_API_KEY || ""}`,
|
|
@@ -160106,7 +160480,7 @@ volumes:
|
|
|
160106
160480
|
}
|
|
160107
160481
|
console.log(` \u2705 Domain: ${domain}`);
|
|
160108
160482
|
const port = "3700";
|
|
160109
|
-
if (!
|
|
160483
|
+
if (!existsSync128(deployDir)) mkdirSync61(deployDir, { recursive: true });
|
|
160110
160484
|
const projectPath2 = workingDirectory.replace(/\\/g, "/");
|
|
160111
160485
|
console.log(`
|
|
160112
160486
|
\u{1F4E6} Checking for published image (${DOCKER_IMAGE})...`);
|
|
@@ -160138,7 +160512,7 @@ volumes:
|
|
|
160138
160512
|
volumes:
|
|
160139
160513
|
testver-data:
|
|
160140
160514
|
`;
|
|
160141
|
-
writeFileSync31(
|
|
160515
|
+
writeFileSync31(join128(deployDir, "docker-compose.yml"), compose);
|
|
160142
160516
|
} else {
|
|
160143
160517
|
const dockerfile = `FROM node:22-slim
|
|
160144
160518
|
RUN apt-get update && apt-get install -y --no-install-recommends curl git && rm -rf /var/lib/apt/lists/*
|
|
@@ -160151,7 +160525,7 @@ HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 CMD curl
|
|
|
160151
160525
|
ENV TESTVER_HOST=0.0.0.0 TESTVER_PORT=${port} NODE_ENV=production
|
|
160152
160526
|
CMD ["testver", "serve", "--host", "0.0.0.0", "--port", "${port}"]
|
|
160153
160527
|
`;
|
|
160154
|
-
writeFileSync31(
|
|
160528
|
+
writeFileSync31(join128(deployDir, "Dockerfile"), dockerfile);
|
|
160155
160529
|
const compose = `services:
|
|
160156
160530
|
testver:
|
|
160157
160531
|
build: .
|
|
@@ -160171,10 +160545,10 @@ CMD ["testver", "serve", "--host", "0.0.0.0", "--port", "${port}"]
|
|
|
160171
160545
|
volumes:
|
|
160172
160546
|
testver-data:
|
|
160173
160547
|
`;
|
|
160174
|
-
writeFileSync31(
|
|
160548
|
+
writeFileSync31(join128(deployDir, "docker-compose.yml"), compose);
|
|
160175
160549
|
}
|
|
160176
|
-
const envFile =
|
|
160177
|
-
if (!
|
|
160550
|
+
const envFile = join128(deployDir, ".env");
|
|
160551
|
+
if (!existsSync128(envFile)) {
|
|
160178
160552
|
writeFileSync31(envFile, [
|
|
160179
160553
|
`TESTVER_PORT=${port}`,
|
|
160180
160554
|
`OPENAI_API_KEY=${process.env.OPENAI_API_KEY || ""}`,
|
|
@@ -160225,7 +160599,7 @@ server {
|
|
|
160225
160599
|
}
|
|
160226
160600
|
}
|
|
160227
160601
|
`;
|
|
160228
|
-
const nginxPath =
|
|
160602
|
+
const nginxPath = join128(deployDir, "testver-nginx.conf");
|
|
160229
160603
|
writeFileSync31(nginxPath, nginxConf);
|
|
160230
160604
|
console.log(" \u2705 Nginx config created");
|
|
160231
160605
|
try {
|
|
@@ -160335,7 +160709,7 @@ server {
|
|
|
160335
160709
|
} else if (subcommand === "stop") {
|
|
160336
160710
|
console.log("\n \u{1F6D1} Stopping Testver deployment...\n");
|
|
160337
160711
|
const composeCmd = cmdExists("docker-compose") ? "docker-compose" : "docker compose";
|
|
160338
|
-
if (
|
|
160712
|
+
if (existsSync128(join128(deployDir, "docker-compose.yml"))) {
|
|
160339
160713
|
run2(`${composeCmd} down`, { cwd: deployDir });
|
|
160340
160714
|
} else {
|
|
160341
160715
|
try {
|
|
@@ -160351,7 +160725,7 @@ server {
|
|
|
160351
160725
|
} else if (subcommand === "restart") {
|
|
160352
160726
|
console.log("\n \u{1F504} Restarting Testver...\n");
|
|
160353
160727
|
const composeCmd = cmdExists("docker-compose") ? "docker-compose" : "docker compose";
|
|
160354
|
-
if (
|
|
160728
|
+
if (existsSync128(join128(deployDir, "docker-compose.yml"))) {
|
|
160355
160729
|
run2(`${composeCmd} restart`, { cwd: deployDir });
|
|
160356
160730
|
} else {
|
|
160357
160731
|
try {
|
|
@@ -160362,7 +160736,7 @@ server {
|
|
|
160362
160736
|
console.log("\n \u2705 Testver restarted.\n");
|
|
160363
160737
|
} else if (subcommand === "logs") {
|
|
160364
160738
|
const composeCmd = cmdExists("docker-compose") ? "docker-compose" : "docker compose";
|
|
160365
|
-
if (
|
|
160739
|
+
if (existsSync128(join128(deployDir, "docker-compose.yml"))) {
|
|
160366
160740
|
try {
|
|
160367
160741
|
execSync(`${composeCmd} logs -f --tail 100`, { cwd: deployDir, stdio: "inherit" });
|
|
160368
160742
|
} catch {
|
|
@@ -160376,7 +160750,7 @@ server {
|
|
|
160376
160750
|
} else if (subcommand === "update") {
|
|
160377
160751
|
console.log("\n \u{1F4E6} Updating Testver...\n");
|
|
160378
160752
|
const composeCmd = cmdExists("docker-compose") ? "docker-compose" : "docker compose";
|
|
160379
|
-
if (
|
|
160753
|
+
if (existsSync128(join128(deployDir, "docker-compose.yml"))) {
|
|
160380
160754
|
await ensureDeployEnvSafety();
|
|
160381
160755
|
console.log(" \u{1F528} Rebuilding container with latest Testver...\n");
|
|
160382
160756
|
run2(`${composeCmd} build --no-cache`, { cwd: deployDir });
|
|
@@ -160400,13 +160774,13 @@ server {
|
|
|
160400
160774
|
const host = pmFlag("host") || "";
|
|
160401
160775
|
const appName = (pmFlag("name") || basename31(workingDirectory) || "testver").replace(/[^A-Za-z0-9._-]/g, "-");
|
|
160402
160776
|
const outName = "testver.pm2.config.js";
|
|
160403
|
-
const outPath =
|
|
160777
|
+
const outPath = join128(workingDirectory, outName);
|
|
160404
160778
|
let scriptPath = process.argv[1] || "testver";
|
|
160405
160779
|
try {
|
|
160406
160780
|
scriptPath = realpathSync3(scriptPath);
|
|
160407
160781
|
} catch {
|
|
160408
160782
|
}
|
|
160409
|
-
if (!pmHas("print") &&
|
|
160783
|
+
if (!pmHas("print") && existsSync128(outPath) && !pmHas("force")) {
|
|
160410
160784
|
console.log(`
|
|
160411
160785
|
\u26A0\uFE0F ${outName} already exists here. Use --force to overwrite, or --name for a second instance.
|
|
160412
160786
|
`);
|
|
@@ -160437,7 +160811,7 @@ module.exports = {
|
|
|
160437
160811
|
console.log(config);
|
|
160438
160812
|
} else {
|
|
160439
160813
|
try {
|
|
160440
|
-
|
|
160814
|
+
mkdirSync61(join128(workingDirectory, ".testver", "logs"), { recursive: true });
|
|
160441
160815
|
} catch {
|
|
160442
160816
|
}
|
|
160443
160817
|
writeFileSync31(outPath, config, "utf-8");
|
|
@@ -160654,7 +161028,7 @@ module.exports = {
|
|
|
160654
161028
|
const { createBootProgress: createBootProgress2, slowStartHint: slowStartHint2 } = await Promise.resolve().then(() => (init_boot_progress(), boot_progress_exports));
|
|
160655
161029
|
const { startServerLog: startServerLog2 } = await Promise.resolve().then(() => (init_server_log(), server_log_exports));
|
|
160656
161030
|
const { getTestverDir: getTestverDir2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
|
|
160657
|
-
const serverLog = startServerLog2({ dir:
|
|
161031
|
+
const serverLog = startServerLog2({ dir: join127(getTestverDir2(workingDirectory), "logs") });
|
|
160658
161032
|
serverLog.note(`testver serve v${getPackageVersion()} \u2014 project ${workingDirectory}`);
|
|
160659
161033
|
const boot = createBootProgress2();
|
|
160660
161034
|
try {
|
|
@@ -160715,7 +161089,7 @@ module.exports = {
|
|
|
160715
161089
|
show2(kv("Host", bindAddr, (s) => c2.white(s)));
|
|
160716
161090
|
show2(kv("Project", projectShown, (s) => c2.white(s)));
|
|
160717
161091
|
show2(kv("Health", "/api/health", (s) => c2.white(s)));
|
|
160718
|
-
if (serverLog.writable) show2(kv("Logs",
|
|
161092
|
+
if (serverLog.writable) show2(kv("Logs", join127(".testver", "logs"), (s) => c2.white(s)));
|
|
160719
161093
|
show2(blank);
|
|
160720
161094
|
show2(rail(" " + c2.dim("Press ") + c2.bold("Ctrl+C") + c2.dim(" to stop"), " Press Ctrl+C to stop".length));
|
|
160721
161095
|
show2(blank);
|