digital-ai-testing-mcp 2.3.1 → 2.3.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/api/access-level.d.ts +3 -2
- package/dist/api/access-level.d.ts.map +1 -1
- package/dist/api/access-level.js +3 -2
- package/dist/api/access-level.js.map +1 -1
- package/dist/api/browser-events.d.ts +37 -1
- package/dist/api/browser-events.d.ts.map +1 -1
- package/dist/api/browser-events.js +104 -3
- package/dist/api/browser-events.js.map +1 -1
- package/dist/api/browser-inspection.d.ts +9 -1
- package/dist/api/browser-inspection.d.ts.map +1 -1
- package/dist/api/browser-inspection.js +19 -1
- package/dist/api/browser-inspection.js.map +1 -1
- package/dist/api/reporter-projects.d.ts +12 -0
- package/dist/api/reporter-projects.d.ts.map +1 -1
- package/dist/api/reporter-projects.js +56 -1
- package/dist/api/reporter-projects.js.map +1 -1
- package/dist/api/reporting.d.ts +6 -0
- package/dist/api/reporting.d.ts.map +1 -1
- package/dist/api/reporting.js +21 -4
- package/dist/api/reporting.js.map +1 -1
- package/dist/api/virtual-devices.d.ts +12 -0
- package/dist/api/virtual-devices.d.ts.map +1 -1
- package/dist/api/virtual-devices.js +38 -1
- package/dist/api/virtual-devices.js.map +1 -1
- package/dist/api/webdriver.d.ts +16 -0
- package/dist/api/webdriver.d.ts.map +1 -1
- package/dist/api/webdriver.js +112 -4
- package/dist/api/webdriver.js.map +1 -1
- package/dist/tools/boilerplate-tools.d.ts.map +1 -1
- package/dist/tools/boilerplate-tools.js +47 -7
- package/dist/tools/boilerplate-tools.js.map +1 -1
- package/dist/tools/coverage-tools.d.ts.map +1 -1
- package/dist/tools/coverage-tools.js +2 -1
- package/dist/tools/coverage-tools.js.map +1 -1
- package/dist/tools/device-health-tool.d.ts.map +1 -1
- package/dist/tools/device-health-tool.js +4 -2
- package/dist/tools/device-health-tool.js.map +1 -1
- package/dist/tools/device-tools.d.ts.map +1 -1
- package/dist/tools/device-tools.js +3 -2
- package/dist/tools/device-tools.js.map +1 -1
- package/dist/tools/inspection-tools.d.ts +8 -0
- package/dist/tools/inspection-tools.d.ts.map +1 -1
- package/dist/tools/inspection-tools.js +75 -3
- package/dist/tools/inspection-tools.js.map +1 -1
- package/dist/tools/meta-tools.d.ts.map +1 -1
- package/dist/tools/meta-tools.js +13 -3
- package/dist/tools/meta-tools.js.map +1 -1
- package/dist/tools/reporting-tools.d.ts +18 -0
- package/dist/tools/reporting-tools.d.ts.map +1 -1
- package/dist/tools/reporting-tools.js +155 -36
- package/dist/tools/reporting-tools.js.map +1 -1
- package/dist/tools/web-inspection-tools.d.ts.map +1 -1
- package/dist/tools/web-inspection-tools.js +12 -9
- package/dist/tools/web-inspection-tools.js.map +1 -1
- package/dist/types/digital-ai.d.ts +1 -0
- package/dist/types/digital-ai.d.ts.map +1 -1
- package/dist/utils/device-health.d.ts +2 -0
- package/dist/utils/device-health.d.ts.map +1 -1
- package/dist/utils/device-health.js +5 -0
- package/dist/utils/device-health.js.map +1 -1
- package/dist/utils/device-resolver.d.ts +2 -0
- package/dist/utils/device-resolver.d.ts.map +1 -1
- package/dist/utils/device-resolver.js +3 -3
- package/dist/utils/device-resolver.js.map +1 -1
- package/dist/utils/remediation.d.ts.map +1 -1
- package/dist/utils/remediation.js +10 -4
- package/dist/utils/remediation.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { getTestById, getTestByUuid, shareTestReport, getRootCauseAnalysis, RCA_MAX_ATTEMPTS, getTestByReportApiId, listTests, listTestsSortedDesc, getGroupedTests, getDistinctKeyValues, deleteTests, downloadTestAttachments, downloadTestVideo, getTestVideoInfo, extractAttachmentLog, summarizeTestFailures, } from '../api/reporting.js';
|
|
2
|
+
import { getTestById, getScopedTest, getTestByUuid, shareTestReport, getRootCauseAnalysis, RCA_MAX_ATTEMPTS, getTestByReportApiId, listTests, listTestsSortedDesc, getGroupedTests, getDistinctKeyValues, deleteTests, downloadTestAttachments, downloadTestVideo, getTestVideoInfo, extractAttachmentLog, summarizeTestFailures, } from '../api/reporting.js';
|
|
3
3
|
import { normaliseDeviceOs } from '../api/transactions.js';
|
|
4
|
+
import { REPORTER_PROJECT_ID_DESC, resolveReporterProjectName } from '../api/reporter-projects.js';
|
|
4
5
|
import { serverFsDownloadNotice, serverFsOutputParam, commandGeneratorNotice, localPlatformParamNotice } from '../utils/locality.js';
|
|
5
6
|
import { checkDeleteAllowed, serverSortAvailable } from '../api/access-level.js';
|
|
6
7
|
import { checkDestructiveGuard } from '../utils/destructive-guard.js';
|
|
@@ -12,7 +13,56 @@ import { commandPayload } from '../utils/command-payload.js';
|
|
|
12
13
|
import { parseReportRef } from '../utils/report-ref.js';
|
|
13
14
|
import { selectLogLines, DEFAULT_LOG_CONTEXT, DEFAULT_LOG_MAX_CHARS } from '../utils/log-view.js';
|
|
14
15
|
import { getRunningTestRequests } from '../api/test-requests.js';
|
|
16
|
+
import { getAllProjects } from '../api/projects.js';
|
|
15
17
|
import { countsFromPivotRow, tallyStatuses, passRate, statusOutcome, unknownStatusCount, PASS_RATE_BASIS } from '../utils/test-status.js';
|
|
18
|
+
/**
|
|
19
|
+
* Where does the lookback cutoff fall in the newest-first record order? Probes single records (limit 1, page = index+1)
|
|
20
|
+
* instead of extrapolating a rate. Returns neededRecords (rounded up, 5% headroom) when the window fits under maxCap,
|
|
21
|
+
* else fittingLookbackDays read from the record AT maxCap. About 10 tiny requests. Throws if the platform stops sorting.
|
|
22
|
+
*/
|
|
23
|
+
export async function measureTrendWindow(cutoffTs, scannedUpTo, maxCap, projectId, projectName) {
|
|
24
|
+
const at = async (index) => {
|
|
25
|
+
const b = await listTests({ limit: 1, page: index + 1, returnTotalCount: false, sort: [{ property: 'start_time', descending: true }] }, projectId, projectName);
|
|
26
|
+
if (b.sortApplied !== true)
|
|
27
|
+
throw new Error('sort not applied');
|
|
28
|
+
const r = b.data?.[0];
|
|
29
|
+
return r ? new Date(r.start_time).getTime() : null;
|
|
30
|
+
};
|
|
31
|
+
const atCap = await at(maxCap - 1);
|
|
32
|
+
if (atCap !== null && atCap >= cutoffTs) {
|
|
33
|
+
return { fittingLookbackDays: Math.max(1, Math.floor((Date.now() - atCap) / 86_400_000)) };
|
|
34
|
+
}
|
|
35
|
+
// Records [0, scannedUpTo) are in the window; the record at hi is out of it (or past the end).
|
|
36
|
+
let lo = scannedUpTo;
|
|
37
|
+
let hi = maxCap - 1;
|
|
38
|
+
while (hi - lo > 50) {
|
|
39
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
40
|
+
const t = await at(mid);
|
|
41
|
+
if (t !== null && t >= cutoffTs)
|
|
42
|
+
lo = mid + 1;
|
|
43
|
+
else
|
|
44
|
+
hi = mid;
|
|
45
|
+
}
|
|
46
|
+
return { neededRecords: Math.min(maxCap, Math.ceil((hi * 1.05) / 500) * 500) };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Names the project a delete runs in. A reporter projectId is resolved to a name before the delete, and reporter IDs
|
|
50
|
+
* differ from the cloud IDs list_projects shows — the preview must say which project the id landed on, so a mixed-up
|
|
51
|
+
* id is visible BEFORE confirmDeletion.
|
|
52
|
+
*/
|
|
53
|
+
const deleteScopeLabel = (projectName) => (projectName ? ` in project "${projectName}"` : '');
|
|
54
|
+
/**
|
|
55
|
+
* A reporter project_id FILTER only matches inside the project the call is scoped to: for another project's id the
|
|
56
|
+
* platform answers 0 records with no reason (verified live 2026-11-13 — project_id = 89 from the Default scope gave 0,
|
|
57
|
+
* the same project by name 3.1M). An empty result with that filter therefore gets a note pointing at the parameters
|
|
58
|
+
* that do scope the call (intake 2026-11-14: the projectId PARAMETER was fixed, the filter still answered silently).
|
|
59
|
+
*/
|
|
60
|
+
export function projectIdFilterNote(filter, resultCount) {
|
|
61
|
+
if (resultCount > 0 || !filter?.some((f) => f.property === 'project_id'))
|
|
62
|
+
return undefined;
|
|
63
|
+
return 'Note: a project_id filter only matches inside the project this call is scoped to — for another project it ' +
|
|
64
|
+
'returns nothing, as here. To query another project, drop the filter and pass projectId (the reporter project id) or projectName.';
|
|
65
|
+
}
|
|
16
66
|
export function registerReportingTools(server) {
|
|
17
67
|
// ─── get_test_report ───────────────────────────────────────────────────────
|
|
18
68
|
server.tool('get_test_report', 'Retrieve a full test execution report by UUID, numeric test ID, or the report URL printed in tearDown (digitalai:reportUrl — e.g. .../reporter/video-report/<uuid>). ' +
|
|
@@ -207,7 +257,8 @@ export function registerReportingTools(server) {
|
|
|
207
257
|
}
|
|
208
258
|
});
|
|
209
259
|
// ─── list_test_reports ─────────────────────────────────────────────────────
|
|
210
|
-
server.tool('list_test_reports', 'Search and list test execution reports. Supports filtering, sorting, and pagination. ' +
|
|
260
|
+
server.tool('list_test_reports', 'Search and list test execution reports. Supports filtering, sorting, and pagination. Results are newest first ' +
|
|
261
|
+
'(start_time descending) unless you pass sort. ' +
|
|
211
262
|
'For date-range filtering use startDate/endDate — server-side start_time filtering is CSRF-blocked. ' +
|
|
212
263
|
'When the user asks for "my reports" / "reports linked to my account", filter by user immediately: ' +
|
|
213
264
|
'[{"property":"user","operator":"=","value":"<email from get_my_account_info>"}] — do not return a global count first. ' +
|
|
@@ -252,7 +303,8 @@ export function registerReportingTools(server) {
|
|
|
252
303
|
'"success" (boolean true/false), ' +
|
|
253
304
|
'"accessibility_report" (JSON boolean true/false, NOT the string "true" — that 400s; true = runs with an Axe accessibility scan), ' +
|
|
254
305
|
'"test_id" (number), ' +
|
|
255
|
-
'"project_id" (number
|
|
306
|
+
'"project_id" (number — matches only INSIDE the project the call is scoped to; for another project it ' +
|
|
307
|
+
'returns 0 records, so pass the projectId or projectName parameter instead), ' +
|
|
256
308
|
'"device.os" ("Android"/"iOS" — case-sensitive), ' +
|
|
257
309
|
'"test.framework" (exact, case-sensitive: "Appium Server", "Appium Grid", "Selenium", "Espresso", "XCUITest", ' +
|
|
258
310
|
'"Maestro", "Playwright", "Cypress", "Mobile Studio Manual", … — get_distinct_test_key_values(["test.framework"]) ' +
|
|
@@ -295,7 +347,7 @@ export function registerReportingTools(server) {
|
|
|
295
347
|
.string()
|
|
296
348
|
.optional()
|
|
297
349
|
.describe('ISO 8601 end of date range, e.g. "2025-06-01T00:00:00Z". Defaults to now when startDate is provided.'),
|
|
298
|
-
projectId: z.number().int().optional().describe(
|
|
350
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
299
351
|
projectName: z.string().optional().describe('Scope results to this project name.'),
|
|
300
352
|
outputFormat: outputFormatParam,
|
|
301
353
|
}, async ({ fields, limit, page, searchValue, filter, sort, keys, returnTotalCount, startDate, endDate, projectId, projectName, outputFormat }) => {
|
|
@@ -377,10 +429,12 @@ export function registerReportingTools(server) {
|
|
|
377
429
|
const header = matched.length === 0
|
|
378
430
|
? `${totalLine}No tests found in range ${rangeLabel} (date filter applied client-side).`
|
|
379
431
|
: `${totalLine}${matched.length} test(s) shown for range ${rangeLabel} (date filter applied client-side):\n`;
|
|
432
|
+
const rangeNote = projectIdFilterNote(filter, matched.length);
|
|
380
433
|
return respond(outputFormat, {
|
|
381
434
|
reports: shape(matched),
|
|
382
435
|
...(wantTotal && { total: matchedCount, totalCapped: countCapped }),
|
|
383
|
-
|
|
436
|
+
...(rangeNote && { note: rangeNote }),
|
|
437
|
+
}, header + (matched.length > 0 ? '\n' + render(matched) : '') + (rangeNote ? `\n\n${rangeNote}` : ''));
|
|
384
438
|
}
|
|
385
439
|
const request = {
|
|
386
440
|
limit: targetLimit,
|
|
@@ -391,7 +445,21 @@ export function registerReportingTools(server) {
|
|
|
391
445
|
...(sort && { sort }),
|
|
392
446
|
...(keys && { keys }),
|
|
393
447
|
};
|
|
394
|
-
|
|
448
|
+
// No sort given → newest first. Unsorted, the platform answered in storage order: "limit: 5" on a project that ran
|
|
449
|
+
// ~10k tests that day returned records from July and August (UAT 2026-11-14). Measured live the same day: the
|
|
450
|
+
// sorted request worked with every filter shape tried (plain, has_attachment, searchValue (+keys), custom key,
|
|
451
|
+
// status) and cost 1–1.5 s more. If the sorted request fails for any reason, the caller's unsorted request runs.
|
|
452
|
+
const defaultSort = !sort && serverSortAvailable();
|
|
453
|
+
let result;
|
|
454
|
+
try {
|
|
455
|
+
result = await listTests(defaultSort ? { ...request, sort: [{ property: 'start_time', descending: true }] } : request, projectId, projectName);
|
|
456
|
+
}
|
|
457
|
+
catch (e) {
|
|
458
|
+
if (!defaultSort)
|
|
459
|
+
throw e;
|
|
460
|
+
result = await listTests(request, projectId, projectName);
|
|
461
|
+
result = { ...result, sortApplied: false };
|
|
462
|
+
}
|
|
395
463
|
const reports = result.data ?? [];
|
|
396
464
|
const countLine = result.count !== undefined ? `Total matching: ${result.count}\n\n` : '';
|
|
397
465
|
// A requested sort the platform refused must never be presented as sorted output.
|
|
@@ -400,7 +468,8 @@ export function registerReportingTools(server) {
|
|
|
400
468
|
? 'The platform refused server-side sort for this credential — these results are in platform order, NOT the order requested. ' +
|
|
401
469
|
'For newest-first results use find_latest_test_for_name / list_active_test_executions, or pass startDate/endDate (scanned and ordered client-side).'
|
|
402
470
|
: undefined;
|
|
403
|
-
|
|
471
|
+
const emptyNote = projectIdFilterNote(filter, reports.length);
|
|
472
|
+
return respond(outputFormat, { reports: shape(reports), total: result.count, ...(sortRefused && { sortApplied: false, warning: sortWarning }), ...(emptyNote && { note: emptyNote }) }, (sortWarning ? `⚠️ ${sortWarning}\n\n` : '') + countLine + render(reports) + (emptyNote ? `\n\n${emptyNote}` : ''));
|
|
404
473
|
}
|
|
405
474
|
catch (e) {
|
|
406
475
|
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
@@ -436,7 +505,7 @@ export function registerReportingTools(server) {
|
|
|
436
505
|
.boolean()
|
|
437
506
|
.optional()
|
|
438
507
|
.describe('If true, adds totalRecords — the number of test records across all groups (the response\x27s count is the number of groups).'),
|
|
439
|
-
projectId: z.number().int().optional().describe(
|
|
508
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
440
509
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
441
510
|
outputFormat: outputFormatParam,
|
|
442
511
|
}, async ({ groupBy, pivotBy, filter, returnTotalCount, projectId, projectName, outputFormat }) => {
|
|
@@ -495,7 +564,7 @@ export function registerReportingTools(server) {
|
|
|
495
564
|
.array(z.string())
|
|
496
565
|
.min(1)
|
|
497
566
|
.describe('One or more key names, e.g. ["device.os", "browser", "environment"].'),
|
|
498
|
-
projectId: z.number().int().optional().describe(
|
|
567
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
499
568
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
500
569
|
outputFormat: outputFormatParam,
|
|
501
570
|
}, async ({ keys, projectId, projectName, outputFormat }) => {
|
|
@@ -552,9 +621,17 @@ export function registerReportingTools(server) {
|
|
|
552
621
|
.boolean()
|
|
553
622
|
.optional()
|
|
554
623
|
.describe('Must be true to confirm the permanent deletion.'),
|
|
555
|
-
projectId: z.number().int().optional().describe(
|
|
624
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
556
625
|
projectName: z.string().optional().describe('Exact project name (from list_projects) to scope the delete to a specific reporter instance.'),
|
|
557
626
|
}, async ({ ids, confirmDeletion, projectId, projectName }) => {
|
|
627
|
+
// Resolve a reporter projectId to its name FIRST: the gate (and the delete) must look at the project the
|
|
628
|
+
// records are in, not the default scope.
|
|
629
|
+
try {
|
|
630
|
+
projectName = await resolveReporterProjectName(projectId, projectName);
|
|
631
|
+
}
|
|
632
|
+
catch (e) {
|
|
633
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
634
|
+
}
|
|
558
635
|
const denied = await checkDeleteAllowed(projectName);
|
|
559
636
|
if (denied) {
|
|
560
637
|
return { content: [{ type: 'text', text: denied }], isError: true };
|
|
@@ -564,7 +641,10 @@ export function registerReportingTools(server) {
|
|
|
564
641
|
// Fetch details for all IDs so the guard shows a human-readable preview.
|
|
565
642
|
// If any ID cannot be resolved, block the deletion entirely rather than
|
|
566
643
|
// silently deleting records the caller cannot verify.
|
|
567
|
-
|
|
644
|
+
// GET /tests/{id} always answers from the default reporter scope, so with a project the preview reads the
|
|
645
|
+
// records through the project-scoped list — the same scope the delete runs in. Otherwise the preview could
|
|
646
|
+
// show the Default project's report N while the confirmed delete removes the other project's report N.
|
|
647
|
+
const results = await Promise.allSettled(ids.map(id => projectName ? getScopedTest(id, projectName) : getTestById(id)));
|
|
568
648
|
const failedIndices = results.reduce((acc, r, i) => (r.status === 'rejected' ? [...acc, i] : acc), []);
|
|
569
649
|
if (failedIndices.length > 0) {
|
|
570
650
|
const failedIds = failedIndices.map(i => ids[i]).join(', ');
|
|
@@ -572,7 +652,7 @@ export function registerReportingTools(server) {
|
|
|
572
652
|
content: [{
|
|
573
653
|
type: 'text',
|
|
574
654
|
text: `⛔ Cannot preview deletion: ${failedIndices.length} of the requested ID(s) could not be resolved ` +
|
|
575
|
-
`in the current reporter scope: [${failedIds}].\n\n` +
|
|
655
|
+
`in ${projectName ? `project "${projectName}"` : 'the current reporter scope'}: [${failedIds}].\n\n` +
|
|
576
656
|
`Verify these IDs exist and are accessible with the active credentials. ` +
|
|
577
657
|
`If they belong to a different project, switch to that project's profile ` +
|
|
578
658
|
`with switch_environment() and retry.\n\nNo changes were made.`,
|
|
@@ -588,17 +668,17 @@ export function registerReportingTools(server) {
|
|
|
588
668
|
const header = ` ${'ID'.padEnd(10)} ${'Status'.padEnd(12)} ${'Start (UTC)'.padEnd(20)} Name`;
|
|
589
669
|
const sep = ` ${'-'.repeat(9)} ${'-'.repeat(11)} ${'-'.repeat(19)} ${'-'.repeat(30)}`;
|
|
590
670
|
const table = [header, sep, ...rows].join('\n');
|
|
591
|
-
const guard = checkDestructiveGuard(confirmDeletion, `Delete ${ids.length} test report(s)`);
|
|
671
|
+
const guard = checkDestructiveGuard(confirmDeletion, `Delete ${ids.length} test report(s)${deleteScopeLabel(projectName)}`);
|
|
592
672
|
return { content: [{ type: 'text', text: `${guard}\n\nRecords that would be deleted:\n${table}` }] };
|
|
593
673
|
}
|
|
594
674
|
// >50 IDs — skip detail fetch, return guard with ID list
|
|
595
|
-
const guard = checkDestructiveGuard(confirmDeletion, `Delete ${ids.length} test report(s): [${ids.join(', ')}]`);
|
|
675
|
+
const guard = checkDestructiveGuard(confirmDeletion, `Delete ${ids.length} test report(s)${deleteScopeLabel(projectName)}: [${ids.join(', ')}]`);
|
|
596
676
|
return { content: [{ type: 'text', text: guard }] };
|
|
597
677
|
}
|
|
598
678
|
try {
|
|
599
679
|
await deleteTests(ids, projectId, projectName);
|
|
600
680
|
return {
|
|
601
|
-
content: [{ type: 'text', text: `✅ Successfully deleted ${ids.length} test report(s).` }],
|
|
681
|
+
content: [{ type: 'text', text: `✅ Successfully deleted ${ids.length} test report(s)${deleteScopeLabel(projectName)}.` }],
|
|
602
682
|
};
|
|
603
683
|
}
|
|
604
684
|
catch (e) {
|
|
@@ -606,7 +686,7 @@ export function registerReportingTools(server) {
|
|
|
606
686
|
}
|
|
607
687
|
});
|
|
608
688
|
// ─── delete_test_reports_by_name ──────────────────────────────────────────
|
|
609
|
-
server.tool('delete_test_reports_by_name', 'Find and permanently delete test execution records matching a name. Accepts exact match (name) or substring match (nameContains). Searches across all pages. Show a preview first via confirmDeletion: false, then re-call with confirmDeletion: true to execute. If you already have the numeric IDs (e.g. from a filtered list_test_reports call), use delete_test_reports instead — no name-matching ambiguity. Cloud Admin can always delete; a project-level key only when its project\x27s allowUsersDeleteTests setting is on (otherwise the tool refuses up front and explains how to get it enabled). IMPORTANT: always pass projectName (exact project name from list_projects) when using Cloud Admin access — without it the search spans the default reporter scope and tests from separate project reporter instances will not appear.
|
|
689
|
+
server.tool('delete_test_reports_by_name', 'Find and permanently delete test execution records matching a name. Accepts exact match (name) or substring match (nameContains). Searches across all pages. Show a preview first via confirmDeletion: false, then re-call with confirmDeletion: true to execute. If you already have the numeric IDs (e.g. from a filtered list_test_reports call), use delete_test_reports instead — no name-matching ambiguity. Cloud Admin can always delete; a project-level key only when its project\x27s allowUsersDeleteTests setting is on (otherwise the tool refuses up front and explains how to get it enabled). IMPORTANT: always pass projectName (exact project name from list_projects) when using Cloud Admin access — without it the search spans the default reporter scope and tests from separate project reporter instances will not appear. A reporter projectId is resolved to its project name.', {
|
|
610
690
|
name: z
|
|
611
691
|
.string()
|
|
612
692
|
.optional()
|
|
@@ -624,9 +704,17 @@ export function registerReportingTools(server) {
|
|
|
624
704
|
.int()
|
|
625
705
|
.optional()
|
|
626
706
|
.describe('Maximum records to show in preview (confirmDeletion: false). Defaults to 50. The deletion itself (confirmDeletion: true) always processes all matching records regardless of this limit.'),
|
|
627
|
-
projectId: z.number().int().optional().describe(
|
|
707
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
628
708
|
projectName: z.string().optional().describe('Exact project name (from list_projects) to scope the search. Required when the target project has its own reporter instance separate from the default scope.'),
|
|
629
709
|
}, async ({ name, nameContains, confirmDeletion, maxPreviewResults, projectId, projectName }) => {
|
|
710
|
+
// Resolve a reporter projectId to its name FIRST: the gate (and the delete) must look at the project the
|
|
711
|
+
// records are in, not the default scope.
|
|
712
|
+
try {
|
|
713
|
+
projectName = await resolveReporterProjectName(projectId, projectName);
|
|
714
|
+
}
|
|
715
|
+
catch (e) {
|
|
716
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
717
|
+
}
|
|
630
718
|
const denied = await checkDeleteAllowed(projectName);
|
|
631
719
|
if (denied) {
|
|
632
720
|
return { content: [{ type: 'text', text: denied }], isError: true };
|
|
@@ -653,7 +741,7 @@ export function registerReportingTools(server) {
|
|
|
653
741
|
return { content: [{ type: 'text', text: `No test reports found matching ${criterion}.` }] };
|
|
654
742
|
}
|
|
655
743
|
const total = typeof newest.count === 'number' && newest.count >= rows.length ? newest.count : rows.length;
|
|
656
|
-
const guard = checkDestructiveGuard(false, `Delete ${total} test report(s) matching "${name ?? nameContains}"`);
|
|
744
|
+
const guard = checkDestructiveGuard(false, `Delete ${total} test report(s) matching "${name ?? nameContains}"${deleteScopeLabel(projectName)}`);
|
|
657
745
|
const lines = rows.map((r) => ` ${r.test_id}: ${r.name} (${r.start_time?.slice(0, 10) ?? '?'})`);
|
|
658
746
|
const more = total > rows.length
|
|
659
747
|
? `\n\n⚠️ Showing the newest ${rows.length} of ${total} matches. confirmDeletion: true deletes all ${total}; narrow nameContains to delete fewer.`
|
|
@@ -686,7 +774,7 @@ export function registerReportingTools(server) {
|
|
|
686
774
|
return { content: [{ type: 'text', text: `No test reports found matching ${criterion}.` }] };
|
|
687
775
|
}
|
|
688
776
|
const countDesc = truncated ? `${previewCap}+ (preview capped at ${previewCap})` : `${allIds.length}`;
|
|
689
|
-
const guard = checkDestructiveGuard(confirmDeletion, `Delete ${countDesc} test report(s) matching "${name ?? nameContains}"`);
|
|
777
|
+
const guard = checkDestructiveGuard(confirmDeletion, `Delete ${countDesc} test report(s) matching "${name ?? nameContains}"${deleteScopeLabel(projectName)}`);
|
|
690
778
|
if (guard) {
|
|
691
779
|
const truncationNote = truncated
|
|
692
780
|
? `\n\n⚠️ Showing first ${previewCap} of ${previewCap}+ matches. Re-run with confirmDeletion: true to delete all matches, or use a more specific nameContains value to narrow the search.`
|
|
@@ -700,7 +788,7 @@ export function registerReportingTools(server) {
|
|
|
700
788
|
}
|
|
701
789
|
await deleteTests(allIds, projectId, projectName);
|
|
702
790
|
return {
|
|
703
|
-
content: [{ type: 'text', text: `✅ Deleted ${allIds.length} test report(s) matching "${name ?? nameContains}".` }],
|
|
791
|
+
content: [{ type: 'text', text: `✅ Deleted ${allIds.length} test report(s) matching "${name ?? nameContains}"${deleteScopeLabel(projectName)}.` }],
|
|
704
792
|
};
|
|
705
793
|
}
|
|
706
794
|
catch (e) {
|
|
@@ -872,7 +960,7 @@ export function registerReportingTools(server) {
|
|
|
872
960
|
.describe("Dimension to bucket by: 'errorClassification' (default, e.g. element_not_found), 'errorCategory' (e.g. assertion, device, network), or 'name'."),
|
|
873
961
|
nameFilter: z.string().optional().describe('Only include failures whose test name contains this substring (e.g. "Login").'),
|
|
874
962
|
maxReports: z.number().int().min(1).max(1000).optional().default(200).describe('Cap on failures analyzed (fan-out bound). Default 200. capped:true in the result means more failures exist beyond this.'),
|
|
875
|
-
projectId: z.number().int().optional().describe(
|
|
963
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
876
964
|
projectName: z.string().optional().describe('Scope to a project by name.'),
|
|
877
965
|
outputFormat: outputFormatParam,
|
|
878
966
|
}, async ({ startDate, endDate, groupBy, nameFilter, maxReports, projectId, projectName, outputFormat }) => {
|
|
@@ -914,7 +1002,7 @@ export function registerReportingTools(server) {
|
|
|
914
1002
|
// ─── find_latest_test_for_name ─────────────────────────────────────────────
|
|
915
1003
|
server.tool('find_latest_test_for_name', 'Return the most recent execution record for a test by name. Answers "did the last run of X pass?" without requiring a full list_test_reports query.', {
|
|
916
1004
|
name: z.string().describe('Exact or partial test name to search for.'),
|
|
917
|
-
projectId: z.number().int().optional().describe(
|
|
1005
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
918
1006
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
919
1007
|
outputFormat: outputFormatParam,
|
|
920
1008
|
}, async ({ name, projectId, projectName, outputFormat }) => {
|
|
@@ -942,7 +1030,7 @@ export function registerReportingTools(server) {
|
|
|
942
1030
|
.string()
|
|
943
1031
|
.optional()
|
|
944
1032
|
.describe('ISO 8601 end of the window. Defaults to now if omitted.'),
|
|
945
|
-
projectId: z.number().int().optional().describe(
|
|
1033
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
946
1034
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
947
1035
|
outputFormat: outputFormatParam,
|
|
948
1036
|
}, async ({ startDate, endDate, projectId, projectName, outputFormat }) => {
|
|
@@ -1020,9 +1108,17 @@ export function registerReportingTools(server) {
|
|
|
1020
1108
|
.boolean()
|
|
1021
1109
|
.optional()
|
|
1022
1110
|
.describe('Must be true to confirm the permanent deletion. Omit or set false to preview what would be deleted.'),
|
|
1023
|
-
projectId: z.number().int().optional().describe(
|
|
1111
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
1024
1112
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
1025
1113
|
}, async ({ beforeDate, confirmDeletion, projectId, projectName }) => {
|
|
1114
|
+
// Resolve a reporter projectId to its name FIRST: the gate (and the delete) must look at the project the
|
|
1115
|
+
// records are in, not the default scope.
|
|
1116
|
+
try {
|
|
1117
|
+
projectName = await resolveReporterProjectName(projectId, projectName);
|
|
1118
|
+
}
|
|
1119
|
+
catch (e) {
|
|
1120
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
1121
|
+
}
|
|
1026
1122
|
const denied = await checkDeleteAllowed(projectName);
|
|
1027
1123
|
if (denied) {
|
|
1028
1124
|
return { content: [{ type: 'text', text: denied }], isError: true };
|
|
@@ -1046,7 +1142,7 @@ export function registerReportingTools(server) {
|
|
|
1046
1142
|
if (allIds.length === 0) {
|
|
1047
1143
|
return { content: [{ type: 'text', text: `No test reports found before ${beforeDate}.` }] };
|
|
1048
1144
|
}
|
|
1049
|
-
const guard = checkDestructiveGuard(confirmDeletion, `Delete ${allIds.length} test report(s) started before ${beforeDate}`);
|
|
1145
|
+
const guard = checkDestructiveGuard(confirmDeletion, `Delete ${allIds.length} test report(s) started before ${beforeDate}${deleteScopeLabel(projectName)}`);
|
|
1050
1146
|
if (guard) {
|
|
1051
1147
|
return {
|
|
1052
1148
|
content: [{ type: 'text', text: `${guard}\n\nPreview: ${allIds.length} record(s) would be deleted (IDs ${allIds[0]}…${allIds[allIds.length - 1]}).` }],
|
|
@@ -1054,7 +1150,7 @@ export function registerReportingTools(server) {
|
|
|
1054
1150
|
}
|
|
1055
1151
|
await deleteTests(allIds, projectId, projectName);
|
|
1056
1152
|
return {
|
|
1057
|
-
content: [{ type: 'text', text: `✅ Deleted ${allIds.length} test report(s) started before ${beforeDate}.` }],
|
|
1153
|
+
content: [{ type: 'text', text: `✅ Deleted ${allIds.length} test report(s) started before ${beforeDate}${deleteScopeLabel(projectName)}.` }],
|
|
1058
1154
|
};
|
|
1059
1155
|
}
|
|
1060
1156
|
catch (e) {
|
|
@@ -1081,7 +1177,8 @@ export function registerReportingTools(server) {
|
|
|
1081
1177
|
.optional()
|
|
1082
1178
|
.default(12)
|
|
1083
1179
|
.describe('Fallback (reporter heuristic) only: ignore Incomplete records that started longer ago than this — they are abandoned or never-finalised runs, not running ones (default 12; test runs time out after 4 h by default).'),
|
|
1084
|
-
projectId: z.number().int().optional().describe('
|
|
1180
|
+
projectId: z.number().int().optional().describe('CLOUD project ID (as get_server_info / list_projects show) — matched against the platform\'s live list. ' +
|
|
1181
|
+
'The reporter fallback (whose IDs differ) is scoped by the matching project name instead.'),
|
|
1085
1182
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
1086
1183
|
outputFormat: outputFormatParam,
|
|
1087
1184
|
}, async ({ limit, maxAgeHours, projectId, projectName, outputFormat }) => {
|
|
@@ -1095,6 +1192,7 @@ export function registerReportingTools(server) {
|
|
|
1095
1192
|
liveError = e.message;
|
|
1096
1193
|
}
|
|
1097
1194
|
if (live) {
|
|
1195
|
+
// Here projectId is the CLOUD project id — the live list carries that one.
|
|
1098
1196
|
const scoped = live.filter((r) => (projectName === undefined || (r.projectName ?? '').toLowerCase() === projectName.toLowerCase()) &&
|
|
1099
1197
|
(projectId === undefined || r.projectId === projectId));
|
|
1100
1198
|
const shown = scoped.slice(0, limit ?? 50);
|
|
@@ -1112,6 +1210,16 @@ export function registerReportingTools(server) {
|
|
|
1112
1210
|
return respond(outputFormat, structured, lines.join('\n'));
|
|
1113
1211
|
}
|
|
1114
1212
|
try {
|
|
1213
|
+
// The reporter cannot scope by the CLOUD projectId (its ids differ) — map it to the project name, which both
|
|
1214
|
+
// sides share, so a projectId-only call is not silently answered for every project.
|
|
1215
|
+
let fallbackProjectName = projectName;
|
|
1216
|
+
if (!fallbackProjectName && projectId !== undefined) {
|
|
1217
|
+
const project = (await getAllProjects()).find((p) => Number(p.id) === projectId);
|
|
1218
|
+
if (!project) {
|
|
1219
|
+
return { content: [{ type: 'text', text: `Error: cloud project ID ${projectId} was not found in list_projects — pass projectName instead.` }], isError: true };
|
|
1220
|
+
}
|
|
1221
|
+
fallbackProjectName = project.name;
|
|
1222
|
+
}
|
|
1115
1223
|
// Fallback: active executions are Incomplete records with null duration.
|
|
1116
1224
|
// We fetch more than needed since not all Incomplete records are still running.
|
|
1117
1225
|
const result = await listTestsSortedDesc({
|
|
@@ -1119,7 +1227,8 @@ export function registerReportingTools(server) {
|
|
|
1119
1227
|
page: 1,
|
|
1120
1228
|
returnTotalCount: false,
|
|
1121
1229
|
filter: [{ property: 'status', operator: '=', value: 'Incomplete' }],
|
|
1122
|
-
},
|
|
1230
|
+
}, undefined, // projectId here is the cloud id — the reporter's ids differ; scoped by name instead
|
|
1231
|
+
fallbackProjectName);
|
|
1123
1232
|
// Incomplete + null duration also matches runs that were abandoned or never finalised — the UAT (2026-10-09)
|
|
1124
1233
|
// found every "active" execution was 3+ days old. Anything older than maxAgeHours is not running now.
|
|
1125
1234
|
const ageCutoff = Date.now() - (maxAgeHours ?? 12) * 3600_000;
|
|
@@ -1168,7 +1277,7 @@ export function registerReportingTools(server) {
|
|
|
1168
1277
|
.string()
|
|
1169
1278
|
.default('appVersion')
|
|
1170
1279
|
.describe('The test report metadata key that holds the app version, e.g. "appVersion" or "buildNumber".'),
|
|
1171
|
-
projectId: z.number().int().optional().describe(
|
|
1280
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
1172
1281
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
1173
1282
|
outputFormat: outputFormatParam,
|
|
1174
1283
|
}, async ({ versionKey, projectId, projectName, outputFormat }) => {
|
|
@@ -1187,7 +1296,7 @@ export function registerReportingTools(server) {
|
|
|
1187
1296
|
testName: z.string().describe('Exact or partial test name to look up.'),
|
|
1188
1297
|
maxRuns: z.number().int().min(1).max(200).optional().default(20)
|
|
1189
1298
|
.describe('Number of most-recent runs to retrieve (default: 20, max: 200).'),
|
|
1190
|
-
projectId: z.number().int().optional().describe(
|
|
1299
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
1191
1300
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
1192
1301
|
outputFormat: outputFormatParam,
|
|
1193
1302
|
}, async ({ testName, maxRuns, projectId, projectName, outputFormat }) => {
|
|
@@ -1267,7 +1376,7 @@ export function registerReportingTools(server) {
|
|
|
1267
1376
|
.describe('Minimum runs on each platform to include a test in the comparison (default: 3). Filters out tests barely run on one OS.'),
|
|
1268
1377
|
minDivergencePct: z.number().min(0).max(100).optional().default(20)
|
|
1269
1378
|
.describe('Minimum pass-rate gap (percentage points) to flag as divergent (default: 20).'),
|
|
1270
|
-
projectId: z.number().int().optional().describe(
|
|
1379
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
1271
1380
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
1272
1381
|
outputFormat: outputFormatParam,
|
|
1273
1382
|
}, async ({ minRunsPerPlatform, minDivergencePct, projectId, projectName, outputFormat }) => {
|
|
@@ -1338,7 +1447,7 @@ export function registerReportingTools(server) {
|
|
|
1338
1447
|
.describe('Hard cap on records fetched to protect against very large datasets (default: 5 000, max: 25 000). Increase if your project runs >165 tests/day and lookbackDays > 30.'),
|
|
1339
1448
|
bucketBy: z.enum(['day', 'week']).optional().default('day')
|
|
1340
1449
|
.describe('"day" (default) or "week". Weekly buckets are cleaner for 90-day views.'),
|
|
1341
|
-
projectId: z.number().int().optional().describe(
|
|
1450
|
+
projectId: z.number().int().optional().describe(REPORTER_PROJECT_ID_DESC),
|
|
1342
1451
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
1343
1452
|
outputFormat: outputFormatParam,
|
|
1344
1453
|
}, async ({ lookbackDays, maxRecords, bucketBy, projectId, projectName, outputFormat }) => {
|
|
@@ -1349,6 +1458,7 @@ export function registerReportingTools(server) {
|
|
|
1349
1458
|
let scanned = 0;
|
|
1350
1459
|
let scanCapped = false;
|
|
1351
1460
|
let done = false;
|
|
1461
|
+
let lastSorted = false;
|
|
1352
1462
|
while (!done && records.length < maxRecords) {
|
|
1353
1463
|
const wantSort = serverSortAvailable();
|
|
1354
1464
|
const batch = await listTests({ limit: 500, page: fetchPage, returnTotalCount: false,
|
|
@@ -1365,6 +1475,7 @@ export function registerReportingTools(server) {
|
|
|
1365
1475
|
break;
|
|
1366
1476
|
scanned += rows.length;
|
|
1367
1477
|
const isSorted = batch.sortApplied === true;
|
|
1478
|
+
lastSorted = isSorted;
|
|
1368
1479
|
for (const r of rows) {
|
|
1369
1480
|
const ts = new Date(r.start_time).getTime();
|
|
1370
1481
|
// Early-exit is only valid on server-sorted data; otherwise skip out-of-window rows and keep scanning.
|
|
@@ -1427,10 +1538,17 @@ export function registerReportingTools(server) {
|
|
|
1427
1538
|
const MAX_RECORDS = 25_000;
|
|
1428
1539
|
const coveredDays = Math.max((Date.now() - new Date(coveredFrom).getTime()) / 86_400_000, 1 / 24);
|
|
1429
1540
|
const estimatedNeeded = Math.ceil((records.length / coveredDays) * lookbackDays * 1.1 / 500) * 500;
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1541
|
+
// On sorted data, MEASURE where the cutoff falls instead of extrapolating: a rate taken from the newest days
|
|
1542
|
+
// missed a burst (UAT 2026-11-13 run 2 — the suggested 15,500 fell short because one older day had ~10k runs).
|
|
1543
|
+
const measured = scanCapped && lastSorted
|
|
1544
|
+
? await measureTrendWindow(cutoffTs, maxRecords, MAX_RECORDS, projectId, projectName).catch(() => null)
|
|
1433
1545
|
: null;
|
|
1546
|
+
const suggestedMaxRecords = !scanCapped ? null
|
|
1547
|
+
: measured?.neededRecords ?? (measured?.fittingLookbackDays != null ? MAX_RECORDS : Math.min(estimatedNeeded, MAX_RECORDS));
|
|
1548
|
+
const fittingLookbackDays = !scanCapped ? null
|
|
1549
|
+
: measured ? (measured.fittingLookbackDays ?? null)
|
|
1550
|
+
: estimatedNeeded > MAX_RECORDS ? Math.max(1, Math.floor((MAX_RECORDS / (records.length / coveredDays)) / 1.1)) : null;
|
|
1551
|
+
const suggestionBasis = measured ? 'measured' : 'estimated from the rate observed so far';
|
|
1434
1552
|
const structured = {
|
|
1435
1553
|
bucketBy,
|
|
1436
1554
|
lookbackDays,
|
|
@@ -1444,6 +1562,7 @@ export function registerReportingTools(server) {
|
|
|
1444
1562
|
? {
|
|
1445
1563
|
missingRange: { from: new Date(cutoffTs).toISOString(), to: coveredFrom },
|
|
1446
1564
|
suggestedMaxRecords,
|
|
1565
|
+
suggestionBasis,
|
|
1447
1566
|
...(fittingLookbackDays != null ? { fittingLookbackDays } : {}),
|
|
1448
1567
|
}
|
|
1449
1568
|
: {}),
|
|
@@ -1473,7 +1592,7 @@ export function registerReportingTools(server) {
|
|
|
1473
1592
|
`days before that are MISSING from this trend, not days with zero executions. ` +
|
|
1474
1593
|
(fittingLookbackDays != null
|
|
1475
1594
|
? `At this project's rate even the 25,000 maximum won't cover ${lookbackDays} days — use lookbackDays: ${fittingLookbackDays} with maxRecords: 25000, or bucketBy "week" over several shorter calls.`
|
|
1476
|
-
: `Re-run with maxRecords: ${suggestedMaxRecords} to cover the full ${lookbackDays}-day window (
|
|
1595
|
+
: `Re-run with maxRecords: ${suggestedMaxRecords} to cover the full ${lookbackDays}-day window (${suggestionBasis}).`));
|
|
1477
1596
|
}
|
|
1478
1597
|
return respond(outputFormat, structured, lines.join('\n'));
|
|
1479
1598
|
}
|