@midscene/test 1.12.5 → 1.12.6-beta-20260909034232.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/es/1~891.mjs +1 -3
  2. package/dist/es/1~891.mjs.map +1 -1
  3. package/dist/es/android/index.mjs +71 -4
  4. package/dist/es/android/index.mjs.map +1 -1
  5. package/dist/es/cli/index.mjs +499 -25
  6. package/dist/es/cli/index.mjs.map +1 -1
  7. package/dist/es/harmony/index.mjs +71 -4
  8. package/dist/es/harmony/index.mjs.map +1 -1
  9. package/dist/es/index.mjs +478 -25
  10. package/dist/es/index.mjs.map +1 -1
  11. package/dist/es/ios/index.mjs +71 -4
  12. package/dist/es/ios/index.mjs.map +1 -1
  13. package/dist/es/midscene/index.mjs +71 -4
  14. package/dist/es/midscene/index.mjs.map +1 -1
  15. package/dist/es/test-cli.mjs +500 -25
  16. package/dist/es/test-cli.mjs.map +1 -1
  17. package/dist/lib/0~458.js +1 -3
  18. package/dist/lib/0~458.js.map +1 -1
  19. package/dist/lib/android/index.js +72 -4
  20. package/dist/lib/android/index.js.map +1 -1
  21. package/dist/lib/cli/index.js +499 -25
  22. package/dist/lib/cli/index.js.map +1 -1
  23. package/dist/lib/harmony/index.js +72 -4
  24. package/dist/lib/harmony/index.js.map +1 -1
  25. package/dist/lib/index.js +494 -26
  26. package/dist/lib/index.js.map +1 -1
  27. package/dist/lib/ios/index.js +72 -4
  28. package/dist/lib/ios/index.js.map +1 -1
  29. package/dist/lib/midscene/index.js +72 -4
  30. package/dist/lib/midscene/index.js.map +1 -1
  31. package/dist/lib/test-cli.js +500 -25
  32. package/dist/lib/test-cli.js.map +1 -1
  33. package/dist/types/android/index.d.ts +13 -0
  34. package/dist/types/cli/index.d.ts +25 -1
  35. package/dist/types/harmony/index.d.ts +13 -0
  36. package/dist/types/index.d.ts +91 -0
  37. package/dist/types/ios/index.d.ts +13 -0
  38. package/dist/types/midscene/index.d.ts +20 -1
  39. package/dist/types/playwright/index.d.ts +13 -0
  40. package/package.json +11 -10
package/dist/es/index.mjs CHANGED
@@ -3,6 +3,7 @@ import { createHash, randomUUID } from "node:crypto";
3
3
  import { isAbsolute, sep } from "node:path";
4
4
  import { readFileSync } from "node:fs";
5
5
  import { JSON_SCHEMA, load } from "js-yaml";
6
+ import { getDebug } from "@midscene/shared/logger";
6
7
  function _define_property(obj, key, value) {
7
8
  if (key in obj) Object.defineProperty(obj, key, {
8
9
  value: value,
@@ -488,6 +489,30 @@ async function executeNode(step, execute, phase, stepIndex, options) {
488
489
  parentSignal?.removeEventListener('abort', abortFromParent);
489
490
  }
490
491
  }
492
+ function createNodeReportCollector(node) {
493
+ const traces = new Map();
494
+ let accepting = true;
495
+ return {
496
+ collector: Object.freeze({
497
+ addTrace (trace) {
498
+ if (!accepting) throw new NodeExecutionError(node, new Error('Report traces can only be added while the current Step is running.'));
499
+ if (!trace || 'object' != typeof trace || 'midscene-execution' !== trace.type) throw new NodeExecutionError(node, new TypeError('Report trace type must be "midscene-execution".'));
500
+ if ('string' != typeof trace.executionId || 0 === trace.executionId.trim().length) throw new NodeExecutionError(node, new TypeError('Report trace executionId must be non-empty.'));
501
+ const normalized = Object.freeze({
502
+ type: 'midscene-execution',
503
+ executionId: trace.executionId
504
+ });
505
+ traces.set(`${normalized.type}:${normalized.executionId}`, normalized);
506
+ }
507
+ }),
508
+ close () {
509
+ accepting = false;
510
+ return Object.freeze([
511
+ ...traces.values()
512
+ ]);
513
+ }
514
+ };
515
+ }
491
516
  async function parseNodeInput(node, input) {
492
517
  if (!node.inputSchema) return input;
493
518
  const parsed = await node.inputSchema.safeParseAsync(input);
@@ -497,32 +522,47 @@ async function parseNodeInput(node, input) {
497
522
  async function executeStep(step, node, target, context, execution = {}) {
498
523
  const phase = 'case' === target.scope ? target.case.phase : target.document.phase;
499
524
  const stepIndex = 'case' === target.scope ? target.case.stepIndex : target.document.stepIndex;
500
- return executeNode(step, async (signal)=>{
501
- const input = await parseNodeInput(node, step.input);
502
- signal.throwIfAborted();
503
- const common = {
504
- input,
505
- $: step.meta,
506
- signal,
507
- context,
508
- onTeardown: (teardown)=>{
509
- if (!execution.onTeardown) throw new NodeExecutionError(step.node, new Error('The current execution scope cannot register teardown.'));
510
- execution.onTeardown(step.node, teardown);
525
+ const reportCollector = createNodeReportCollector(step.node);
526
+ let result;
527
+ try {
528
+ result = await executeNode(step, async (signal)=>{
529
+ const input = await parseNodeInput(node, step.input);
530
+ signal.throwIfAborted();
531
+ const common = {
532
+ input,
533
+ $: step.meta,
534
+ signal,
535
+ context,
536
+ report: reportCollector.collector,
537
+ onTeardown: (teardown)=>{
538
+ if (!execution.onTeardown) throw new NodeExecutionError(step.node, new Error('The current execution scope cannot register teardown.'));
539
+ execution.onTeardown(step.node, teardown);
540
+ }
541
+ };
542
+ return 'case' === target.scope ? node.execute({
543
+ ...common,
544
+ scope: 'case',
545
+ case: target.case
546
+ }) : node.execute({
547
+ ...common,
548
+ scope: 'document',
549
+ document: target.document
550
+ });
551
+ }, phase, stepIndex, {
552
+ parentSignal: execution.signal,
553
+ defaultTimeoutMs: execution.defaultTimeoutMs
554
+ });
555
+ } finally{
556
+ const traces = reportCollector.close();
557
+ if (traces.length > 0 && result) result = {
558
+ ...result,
559
+ report: {
560
+ traces
511
561
  }
512
562
  };
513
- return 'case' === target.scope ? node.execute({
514
- ...common,
515
- scope: 'case',
516
- case: target.case
517
- }) : node.execute({
518
- ...common,
519
- scope: 'document',
520
- document: target.document
521
- });
522
- }, phase, stepIndex, {
523
- parentSignal: execution.signal,
524
- defaultTimeoutMs: execution.defaultTimeoutMs
525
- });
563
+ }
564
+ if (!result) throw new NodeExecutionError(step.node, new Error('Step execution completed without a result.'));
565
+ return result;
526
566
  }
527
567
  const reportPathsFromTeardown = (result)=>{
528
568
  if (void 0 === result) return [];
@@ -1232,6 +1272,419 @@ function collectWorkflowDocument(source, options) {
1232
1272
  cases
1233
1273
  };
1234
1274
  }
1235
- export { CaseExecutionError, CaseRunner, DuplicateNodeError, FatalDeviceError, NodeDefinitionError, NodeExecutionError, NodeInputValidationError, NodeNotFoundError, NodeRegistry, NodeScopeTeardownError, ProjectSetupError, ProjectTeardownError, StepTimeoutError, WorkflowDocumentExecutionError, WorkflowError, WorkflowLifecycleError, WorkflowParseError, collectWorkflowDocument, createCaseId, createCaseRunner, createDocumentRuntime, createProjectRuntime, createWorkflowDocumentId, defineNode, isFatalDeviceError, normalizeNodeExecutionError, normalizeStep, normalizeSteps, resolveWorkflowVariables, runWorkflowDocument, z };
1275
+ const MAX_DEPTH = 6;
1276
+ const MAX_STRING_LENGTH = 2000;
1277
+ const MAX_ARRAY_ITEMS = 50;
1278
+ const MAX_OBJECT_KEYS = 50;
1279
+ const MAX_SERIALIZED_BYTES = 65536;
1280
+ const TRUNCATED_VALUE = '[Truncated: display value exceeded 64 KiB]';
1281
+ const normalizedSecretKeys = [
1282
+ 'password',
1283
+ 'passwd',
1284
+ 'secret',
1285
+ 'token',
1286
+ 'authorization',
1287
+ 'cookie',
1288
+ 'apikey'
1289
+ ];
1290
+ const normalizedKey = (key)=>key.toLowerCase().replace(/[^a-z0-9]/g, '');
1291
+ const isSecretKey = (key)=>{
1292
+ const normalized = normalizedKey(key);
1293
+ return normalizedSecretKeys.some((secret)=>normalized.includes(secret));
1294
+ };
1295
+ const objectPath = (parent, key)=>/^[A-Za-z_$][\w$]*$/.test(key) ? `${parent}.${key}` : `${parent}[${JSON.stringify(key)}]`;
1296
+ const stringByteLength = (value)=>Buffer.byteLength(value, 'utf8');
1297
+ function sanitizeReportText(value, maximumLength = MAX_STRING_LENGTH) {
1298
+ return value.length <= maximumLength ? value : `${value.slice(0, maximumLength)}… [truncated]`;
1299
+ }
1300
+ function sanitizeReportValue(value) {
1301
+ const truncatedPaths = new Set();
1302
+ const redactedPaths = new Set();
1303
+ const ancestors = new WeakSet();
1304
+ let remainingBytes = MAX_SERIALIZED_BYTES;
1305
+ const consume = (path, text)=>{
1306
+ remainingBytes -= stringByteLength(text);
1307
+ if (remainingBytes >= 0) return true;
1308
+ truncatedPaths.add(path);
1309
+ return false;
1310
+ };
1311
+ const visit = (current, path, depth)=>{
1312
+ if (remainingBytes <= 0) {
1313
+ truncatedPaths.add(path);
1314
+ return '[Truncated: size limit]';
1315
+ }
1316
+ if (null === current || 'boolean' == typeof current) {
1317
+ consume(path, String(current));
1318
+ return current;
1319
+ }
1320
+ if ('string' == typeof current) {
1321
+ if (current.length > MAX_STRING_LENGTH) {
1322
+ truncatedPaths.add(path);
1323
+ const shortened = `${current.slice(0, MAX_STRING_LENGTH)}… [truncated]`;
1324
+ consume(path, shortened);
1325
+ return shortened;
1326
+ }
1327
+ consume(path, current);
1328
+ return current;
1329
+ }
1330
+ if ('number' == typeof current) {
1331
+ if (Number.isFinite(current)) {
1332
+ consume(path, String(current));
1333
+ return current;
1334
+ }
1335
+ truncatedPaths.add(path);
1336
+ return `[Unsupported number: ${String(current)}]`;
1337
+ }
1338
+ if ('bigint' == typeof current) {
1339
+ truncatedPaths.add(path);
1340
+ return `[Unsupported bigint: ${String(current)}]`;
1341
+ }
1342
+ if (void 0 === current || 'function' == typeof current || 'symbol' == typeof current) {
1343
+ truncatedPaths.add(path);
1344
+ return `[Unsupported ${typeof current}]`;
1345
+ }
1346
+ if (depth >= MAX_DEPTH) {
1347
+ truncatedPaths.add(path);
1348
+ return '[Truncated: maximum depth]';
1349
+ }
1350
+ if (current instanceof Date) {
1351
+ const date = Number.isNaN(current.getTime()) ? '[Invalid Date]' : current.toISOString();
1352
+ consume(path, date);
1353
+ return date;
1354
+ }
1355
+ if (ancestors.has(current)) {
1356
+ truncatedPaths.add(path);
1357
+ return '[Unsupported circular value]';
1358
+ }
1359
+ if (Array.isArray(current)) {
1360
+ ancestors.add(current);
1361
+ const output = [];
1362
+ const itemCount = Math.min(current.length, MAX_ARRAY_ITEMS);
1363
+ for(let index = 0; index < itemCount; index += 1){
1364
+ if (remainingBytes <= 0) break;
1365
+ output.push(visit(current[index], `${path}[${index}]`, depth + 1));
1366
+ }
1367
+ if (current.length > output.length) truncatedPaths.add(path);
1368
+ ancestors.delete(current);
1369
+ return output;
1370
+ }
1371
+ const prototype = Object.getPrototypeOf(current);
1372
+ if (prototype !== Object.prototype && null !== prototype) {
1373
+ truncatedPaths.add(path);
1374
+ const constructorName = current.constructor?.name ?? 'object';
1375
+ return `[Unsupported object: ${constructorName}]`;
1376
+ }
1377
+ ancestors.add(current);
1378
+ const output = {};
1379
+ const keys = Object.keys(current);
1380
+ for (const key of keys.slice(0, MAX_OBJECT_KEYS)){
1381
+ const childPath = objectPath(path, key);
1382
+ if (!consume(childPath, key)) break;
1383
+ if (isSecretKey(key)) {
1384
+ output[key] = '[REDACTED]';
1385
+ redactedPaths.add(childPath);
1386
+ } else output[key] = visit(current[key], childPath, depth + 1);
1387
+ if (remainingBytes <= 0) break;
1388
+ }
1389
+ if (keys.length > Object.keys(output).length) truncatedPaths.add(path);
1390
+ ancestors.delete(current);
1391
+ return output;
1392
+ };
1393
+ const sanitized = visit(value, '$', 0);
1394
+ const serialized = JSON.stringify(sanitized);
1395
+ if (void 0 === serialized || stringByteLength(serialized) > MAX_SERIALIZED_BYTES) return {
1396
+ value: TRUNCATED_VALUE,
1397
+ truncatedPaths: [
1398
+ '$'
1399
+ ]
1400
+ };
1401
+ return {
1402
+ value: sanitized,
1403
+ ...truncatedPaths.size > 0 ? {
1404
+ truncatedPaths: [
1405
+ ...truncatedPaths
1406
+ ]
1407
+ } : {},
1408
+ ...redactedPaths.size > 0 ? {
1409
+ redactedPaths: [
1410
+ ...redactedPaths
1411
+ ]
1412
+ } : {}
1413
+ };
1414
+ }
1415
+ function sanitizeReportError(error) {
1416
+ if (error instanceof Error) {
1417
+ const workflowLike = error;
1418
+ return {
1419
+ name: sanitizeReportText(error.name || 'Error', 200),
1420
+ message: sanitizeReportText(error.message || String(error)),
1421
+ ...'string' == typeof workflowLike.code ? {
1422
+ code: sanitizeReportText(workflowLike.code, 200)
1423
+ } : {},
1424
+ ...void 0 === workflowLike.details ? {} : {
1425
+ details: sanitizeReportValue(workflowLike.details)
1426
+ }
1427
+ };
1428
+ }
1429
+ return {
1430
+ name: 'Error',
1431
+ message: sanitizeReportText(String(error))
1432
+ };
1433
+ }
1434
+ const warnReport = getDebug('test-runner:report-assembler', {
1435
+ console: true
1436
+ });
1437
+ const exactMidsceneDetailNodes = new Set([
1438
+ 'aiAct',
1439
+ 'aiAssert',
1440
+ 'recordToReport'
1441
+ ]);
1442
+ const scopedExecutionKey = (scopeId, executionId)=>`${scopeId}\u0000${executionId}`;
1443
+ const reportSourcesForScope = (context, scopeId)=>context.sourcesByScope.get(scopeId) ?? [];
1444
+ const addDiagnostic = (context, diagnostic)=>{
1445
+ context.diagnostics.push(diagnostic);
1446
+ const key = JSON.stringify([
1447
+ diagnostic.code,
1448
+ diagnostic.scopeId,
1449
+ diagnostic.executionId
1450
+ ]);
1451
+ if (!context.warnedDiagnostics.has(key)) {
1452
+ context.warnedDiagnostics.add(key);
1453
+ warnReport(diagnostic.message);
1454
+ }
1455
+ };
1456
+ const buildStep = (step, scopeId, context)=>{
1457
+ const details = [];
1458
+ const unresolvedExecutionIds = [];
1459
+ for (const trace of step.report?.traces ?? []){
1460
+ const previousScope = context.tracedScopeByExecution.get(trace.executionId);
1461
+ if (previousScope && previousScope !== scopeId) throw new Error(`Agent execution ${trace.executionId} was traced by multiple test scopes (${previousScope}, ${scopeId}).`);
1462
+ context.tracedScopeByExecution.set(trace.executionId, scopeId);
1463
+ const detail = context.detailsByScopeAndExecution.get(scopedExecutionKey(scopeId, trace.executionId));
1464
+ if (detail) details.push(detail);
1465
+ else unresolvedExecutionIds.push(trace.executionId);
1466
+ }
1467
+ let agentDetailDiagnostic;
1468
+ if (unresolvedExecutionIds.length > 0) {
1469
+ agentDetailDiagnostic = `Agent detail could not be resolved for ${unresolvedExecutionIds.join(', ')}.`;
1470
+ const sources = reportSourcesForScope(context, scopeId);
1471
+ for (const executionId of unresolvedExecutionIds)addDiagnostic(context, {
1472
+ level: 'warning',
1473
+ code: 'agent-detail-unresolved',
1474
+ message: `Agent detail could not be resolved for execution ${executionId} in test scope ${scopeId}.`,
1475
+ scopeId,
1476
+ executionId,
1477
+ ...sources.length > 0 ? {
1478
+ sourcePaths: sources.map((source)=>source.sourcePath)
1479
+ } : {}
1480
+ });
1481
+ } else if (0 === details.length && exactMidsceneDetailNodes.has(step.node)) {
1482
+ agentDetailDiagnostic = 'This Agent did not expose a stable execution reference for the Step.';
1483
+ addDiagnostic(context, {
1484
+ level: 'warning',
1485
+ code: 'agent-detail-unavailable',
1486
+ message: `No stable Agent execution reference was captured for ${step.node} in test scope ${scopeId}.`,
1487
+ scopeId,
1488
+ ...reportSourcesForScope(context, scopeId).length > 0 ? {
1489
+ sourcePaths: reportSourcesForScope(context, scopeId).map((source)=>source.sourcePath)
1490
+ } : {}
1491
+ });
1492
+ }
1493
+ const prompt = 'string' == typeof step.input?.prompt ? step.input.prompt : void 0;
1494
+ return {
1495
+ id: `${scopeId}:${step.phase}:${step.stepIndex}`,
1496
+ phase: step.phase,
1497
+ stepIndex: step.stepIndex,
1498
+ node: step.node,
1499
+ ...prompt ? {
1500
+ title: sanitizeReportText(prompt, 240)
1501
+ } : {},
1502
+ status: step.status,
1503
+ continuedAfterError: step.continuedAfterError,
1504
+ startedAt: step.startedAt,
1505
+ endedAt: step.endedAt,
1506
+ durationMs: step.durationMs,
1507
+ input: sanitizeReportValue(step.input),
1508
+ ...step.output ? {
1509
+ output: {
1510
+ ...void 0 === step.output.summary ? {} : {
1511
+ summary: sanitizeReportText(step.output.summary)
1512
+ },
1513
+ ...void 0 === step.output.data ? {} : {
1514
+ data: sanitizeReportValue(step.output.data)
1515
+ }
1516
+ }
1517
+ } : {},
1518
+ ...step.error ? {
1519
+ error: sanitizeReportError(step.error)
1520
+ } : {},
1521
+ ...details.length > 0 ? {
1522
+ agentDetails: details
1523
+ } : {},
1524
+ ...agentDetailDiagnostic ? {
1525
+ agentDetailDiagnostic
1526
+ } : {}
1527
+ };
1528
+ };
1529
+ const buildAttempt = (attempt, context)=>({
1530
+ attemptId: attempt.runId,
1531
+ attemptIndex: attempt.attemptIndex,
1532
+ status: attempt.status,
1533
+ startedAt: attempt.startedAt,
1534
+ endedAt: attempt.endedAt,
1535
+ durationMs: attempt.durationMs,
1536
+ beforeEach: attempt.beforeEach.map((step)=>buildStep(step, attempt.runId, context)),
1537
+ steps: attempt.steps.map((step)=>buildStep(step, attempt.runId, context)),
1538
+ afterEach: attempt.afterEach.map((step)=>buildStep(step, attempt.runId, context)),
1539
+ ...attempt.teardownErrors?.length ? {
1540
+ teardownErrors: attempt.teardownErrors.map(sanitizeReportError)
1541
+ } : {},
1542
+ ...reportSourcesForScope(context, attempt.runId).length > 0 ? {
1543
+ scopeReportIds: reportSourcesForScope(context, attempt.runId).map((source)=>source.reportId)
1544
+ } : {}
1545
+ });
1546
+ const buildCase = (outcome, context)=>({
1547
+ caseId: outcome.caseId,
1548
+ name: outcome.name,
1549
+ caseIndex: outcome.caseIndex,
1550
+ status: outcome.status,
1551
+ ...outcome.notRunReason ? {
1552
+ notRunReason: outcome.notRunReason
1553
+ } : {},
1554
+ attempts: (outcome.attempts ?? (outcome.run ? [
1555
+ outcome.run
1556
+ ] : [])).map((attempt)=>buildAttempt(attempt, context))
1557
+ });
1558
+ const buildDocument = (documentId, document, cases, context)=>{
1559
+ const sourcePath = document?.sourcePath ?? cases[0]?.sourcePath ?? '<unknown>';
1560
+ const status = document?.status ?? (cases.some((item)=>'success' !== item.status) ? 'failed' : 'success');
1561
+ return {
1562
+ documentId,
1563
+ sourcePath,
1564
+ status,
1565
+ ...document ? {
1566
+ startedAt: document.startedAt,
1567
+ endedAt: document.endedAt,
1568
+ durationMs: document.durationMs
1569
+ } : {},
1570
+ beforeAll: (document?.beforeAll ?? []).map((step)=>buildStep(step, document.documentRunId, context)),
1571
+ cases: cases.map((outcome)=>buildCase(outcome, context)),
1572
+ afterAll: (document?.afterAll ?? []).map((step)=>buildStep(step, document.documentRunId, context)),
1573
+ ...document?.teardownErrors?.length ? {
1574
+ teardownErrors: document.teardownErrors.map(sanitizeReportError)
1575
+ } : {},
1576
+ ...document && reportSourcesForScope(context, document.documentRunId).length > 0 ? {
1577
+ scopeReportIds: reportSourcesForScope(context, document.documentRunId).map((source)=>source.reportId)
1578
+ } : {}
1579
+ };
1580
+ };
1581
+ const buildProject = (project, context)=>{
1582
+ const documentById = new Map(project.documents.map((document)=>[
1583
+ document.documentId,
1584
+ document
1585
+ ]));
1586
+ const casesByDocumentId = new Map();
1587
+ for (const outcome of project.cases){
1588
+ const current = casesByDocumentId.get(outcome.documentId) ?? [];
1589
+ current.push(outcome);
1590
+ casesByDocumentId.set(outcome.documentId, current);
1591
+ }
1592
+ const documentIds = new Set([
1593
+ ...project.documents.map((document)=>document.documentId),
1594
+ ...project.cases.map((outcome)=>outcome.documentId)
1595
+ ]);
1596
+ return {
1597
+ projectId: project.projectId,
1598
+ name: project.name,
1599
+ platform: project.platform,
1600
+ status: project.status,
1601
+ retry: project.retry,
1602
+ ...project.lifecycle ? {
1603
+ lifecycle: {
1604
+ status: project.lifecycle.status,
1605
+ startedAt: project.lifecycle.startedAt,
1606
+ endedAt: project.lifecycle.endedAt,
1607
+ durationMs: project.lifecycle.durationMs,
1608
+ ...project.lifecycle.setupError ? {
1609
+ setupError: sanitizeReportError(project.lifecycle.setupError)
1610
+ } : {},
1611
+ ...project.lifecycle.teardownErrors?.length ? {
1612
+ teardownErrors: project.lifecycle.teardownErrors.map(sanitizeReportError)
1613
+ } : {}
1614
+ }
1615
+ } : {},
1616
+ documents: [
1617
+ ...documentIds
1618
+ ].map((documentId)=>buildDocument(documentId, documentById.get(documentId), casesByDocumentId.get(documentId) ?? [], context)),
1619
+ collectionErrors: project.collectionErrors.map((collectionError)=>({
1620
+ sourcePath: collectionError.sourcePath,
1621
+ error: sanitizeReportError(collectionError.error)
1622
+ }))
1623
+ };
1624
+ };
1625
+ function collectTestRunReportSources(result) {
1626
+ const sources = [];
1627
+ for (const project of result.projects){
1628
+ for (const document of project.documents)for (const sourcePath of document.reportPaths ?? [])sources.push({
1629
+ scopeId: document.documentRunId,
1630
+ sourcePath
1631
+ });
1632
+ for (const outcome of project.cases)for (const attempt of outcome.attempts ?? (outcome.run ? [
1633
+ outcome.run
1634
+ ] : []))for (const sourcePath of attempt.reportPaths ?? [])sources.push({
1635
+ scopeId: attempt.runId,
1636
+ sourcePath
1637
+ });
1638
+ }
1639
+ return sources;
1640
+ }
1641
+ function buildTestRunReportDump(result, index) {
1642
+ const sourcesByScope = new Map();
1643
+ const detailsByScopeAndExecution = new Map();
1644
+ for (const source of index.sources){
1645
+ const scopeSources = sourcesByScope.get(source.scopeId) ?? [];
1646
+ scopeSources.push(source);
1647
+ sourcesByScope.set(source.scopeId, scopeSources);
1648
+ for (const executionId of source.executionIds)detailsByScopeAndExecution.set(scopedExecutionKey(source.scopeId, executionId), {
1649
+ reportId: source.reportId,
1650
+ executionId
1651
+ });
1652
+ }
1653
+ const context = {
1654
+ diagnostics: [],
1655
+ sourcesByScope,
1656
+ detailsByScopeAndExecution,
1657
+ tracedScopeByExecution: new Map(),
1658
+ warnedDiagnostics: new Set()
1659
+ };
1660
+ for (const source of index.sources)if (0 === source.executionIds.length) addDiagnostic(context, {
1661
+ level: 'warning',
1662
+ code: 'source-without-executions',
1663
+ message: `Agent report contains no executions: ${source.sourcePath}`,
1664
+ scopeId: source.scopeId,
1665
+ sourcePaths: [
1666
+ source.sourcePath
1667
+ ]
1668
+ });
1669
+ const projects = result.projects.map((project)=>buildProject(project, context));
1670
+ return {
1671
+ schemaVersion: 1,
1672
+ kind: 'test-runner',
1673
+ runId: result.runId,
1674
+ status: result.status,
1675
+ startedAt: result.startedAt,
1676
+ endedAt: result.endedAt,
1677
+ durationMs: result.durationMs,
1678
+ summary: {
1679
+ ...result.summary
1680
+ },
1681
+ metrics: index.metrics,
1682
+ projects,
1683
+ ...context.diagnostics.length > 0 ? {
1684
+ diagnostics: context.diagnostics
1685
+ } : {}
1686
+ };
1687
+ }
1688
+ export { CaseExecutionError, CaseRunner, DuplicateNodeError, FatalDeviceError, NodeDefinitionError, NodeExecutionError, NodeInputValidationError, NodeNotFoundError, NodeRegistry, NodeScopeTeardownError, ProjectSetupError, ProjectTeardownError, StepTimeoutError, WorkflowDocumentExecutionError, WorkflowError, WorkflowLifecycleError, WorkflowParseError, buildTestRunReportDump, collectTestRunReportSources, collectWorkflowDocument, createCaseId, createCaseRunner, createDocumentRuntime, createProjectRuntime, createWorkflowDocumentId, defineNode, isFatalDeviceError, normalizeNodeExecutionError, normalizeStep, normalizeSteps, resolveWorkflowVariables, runWorkflowDocument, sanitizeReportError, sanitizeReportText, sanitizeReportValue, z };
1236
1689
 
1237
1690
  //# sourceMappingURL=index.mjs.map