mcp-lab-agent 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1506,15 +1506,99 @@ function runTestsOnce(cmd, args, cwd, env = process.env) {
1506
1506
  });
1507
1507
  });
1508
1508
  }
1509
+ async function handleMultipleAutoTests(testRequests, maxRetries) {
1510
+ console.log(`\u{1F4CB} Testes a executar:`);
1511
+ testRequests.forEach((req, i) => console.log(` ${i + 1}. ${req}`));
1512
+ console.log("");
1513
+ const results = [];
1514
+ const startTime = Date.now();
1515
+ const promises = testRequests.map(async (testRequest, index) => {
1516
+ const testNum = index + 1;
1517
+ const prefix = `[Teste ${testNum}/${testRequests.length}]`;
1518
+ console.log(`${prefix} \u{1F680} Iniciando: "${testRequest}"
1519
+ `);
1520
+ try {
1521
+ const { spawn: spawn3 } = await import("child_process");
1522
+ const args = ["auto", testRequest, "--max-retries", maxRetries.toString()];
1523
+ return new Promise((resolve) => {
1524
+ const child = spawn3("mcp-lab-agent", args, {
1525
+ cwd: process.cwd(),
1526
+ stdio: "pipe",
1527
+ shell: process.platform === "win32"
1528
+ });
1529
+ let output = "";
1530
+ if (child.stdout) child.stdout.on("data", (d) => {
1531
+ const text = d.toString();
1532
+ output += text;
1533
+ process.stdout.write(text.split("\n").map((line) => line ? `${prefix} ${line}` : "").join("\n"));
1534
+ });
1535
+ if (child.stderr) child.stderr.on("data", (d) => {
1536
+ output += d.toString();
1537
+ });
1538
+ child.on("close", (code) => {
1539
+ const success = code === 0;
1540
+ const duration = Math.round((Date.now() - startTime) / 1e3);
1541
+ resolve({
1542
+ testRequest,
1543
+ success,
1544
+ exitCode: code,
1545
+ output,
1546
+ duration
1547
+ });
1548
+ });
1549
+ });
1550
+ } catch (err) {
1551
+ return {
1552
+ testRequest,
1553
+ success: false,
1554
+ exitCode: 1,
1555
+ error: err.message,
1556
+ duration: 0
1557
+ };
1558
+ }
1559
+ });
1560
+ const allResults = await Promise.all(promises);
1561
+ const totalDuration = Math.round((Date.now() - startTime) / 1e3);
1562
+ const passed = allResults.filter((r) => r.success).length;
1563
+ const failed = allResults.length - passed;
1564
+ console.log("\n" + "=".repeat(60));
1565
+ console.log("\u{1F4CA} RESUMO DOS TESTES");
1566
+ console.log("=".repeat(60) + "\n");
1567
+ allResults.forEach((result, i) => {
1568
+ const icon = result.success ? "\u2705" : "\u274C";
1569
+ const status = result.success ? "PASSOU" : "FALHOU";
1570
+ console.log(`${icon} ${i + 1}. ${result.testRequest} - ${status}`);
1571
+ });
1572
+ console.log("");
1573
+ console.log(`Total: ${allResults.length} testes`);
1574
+ console.log(`\u2705 Passou: ${passed}`);
1575
+ console.log(`\u274C Falhou: ${failed}`);
1576
+ console.log(`\u23F1\uFE0F Tempo total: ${totalDuration}s`);
1577
+ console.log("");
1578
+ if (failed > 0) {
1579
+ process.exit(1);
1580
+ }
1581
+ }
1509
1582
  async function handleAutoCommand() {
1510
1583
  const request = process.argv.slice(3).join(" ");
1511
1584
  if (!request) {
1512
1585
  console.error("\u274C Uso: mcp-lab-agent auto <descri\xE7\xE3o do teste> [--max-retries N]");
1586
+ console.error(" Exemplos:");
1587
+ console.error(' mcp-lab-agent auto "login"');
1588
+ console.error(' mcp-lab-agent auto "login, cadastro, buscar" --max-retries 3');
1513
1589
  process.exit(1);
1514
1590
  }
1515
1591
  const maxRetriesIdx = process.argv.indexOf("--max-retries");
1516
1592
  const maxRetries = maxRetriesIdx !== -1 && process.argv[maxRetriesIdx + 1] ? parseInt(process.argv[maxRetriesIdx + 1], 10) : 3;
1517
1593
  const cleanRequest = request.replace(/--max-retries\s+\d+/g, "").trim();
1594
+ const testRequests = cleanRequest.split(",").map((r) => r.trim()).filter(Boolean);
1595
+ if (testRequests.length > 1) {
1596
+ console.log(`
1597
+ \u{1F916} Modo aut\xF4nomo iniciado: ${testRequests.length} testes em paralelo
1598
+ `);
1599
+ await handleMultipleAutoTests(testRequests, maxRetries);
1600
+ return;
1601
+ }
1518
1602
  console.log(`
1519
1603
  \u{1F916} Modo aut\xF4nomo iniciado: "${cleanRequest}"
1520
1604
  `);