@arcadialdev/arcality 2.4.48 → 2.4.50

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.
@@ -2579,13 +2579,8 @@ ${history.join("\n")}` }
2579
2579
  }
2580
2580
  }
2581
2581
  /**
2582
- * MODO BRIDGE: Envía la percepción de la CLI hacia el Portal Web (SaaS)
2583
- * para que el servidor decida la acción usando su propia infraestructura e IP.
2584
- // askBridge eliminado — proxy mode ahora está integrado directamente en askIA.
2585
-
2586
- /**
2587
- * QA Skill: Summarizes the mission execution into a clean, human-friendly English YAML format.
2588
- */
2582
+ * QA Skill: Summarizes the mission execution into a clean, human-friendly English YAML format.
2583
+ */
2589
2584
  async summarizeMissionToYaml(prompt, history, startUrl) {
2590
2585
  if (!process.env.ANTHROPIC_API_KEY)
2591
2586
  return null;
@@ -3394,10 +3389,7 @@ ${patternContext}` : prompt;
3394
3389
  console.warn(`
3395
3390
  \u26A0\uFE0F [LOOP DETECTOR] Patr\xF3n repetitivo de ${loopType} detectado:`);
3396
3391
  console.warn(` \xDAltimas acciones: ${lastActions.join(" \u2192 ")}`);
3397
- console.warn(` El agente est\xE1 atrapado. Forzando terminaci\xF3n con sugerencia.`);
3398
- response.thought = `\u{1F6D1} ERROR: Me he quedado atrapado en un bucle repetitivo intentando interactuar con: ${Array.from(uniqueTargets).join(", ")}. No puedo continuar la misi\xF3n de forma aut\xF3noma.
3399
-
3400
- \u{1F4A1} REGLA DE QA: He detectado que mi acci\xF3n de ${loopType} no est\xE1 cambiando el estado de la p\xE1gina como esperaba. Esto podr\xEDa ser un bug de la aplicaci\xF3n o una limitaci\xF3n de mi percepci\xF3n actual.`;
3392
+ response.thought = `\u{1F6D1} ERROR: Bucle repetitivo en ${loopType} sobre: ${Array.from(uniqueTargets).join(", ")}.`;
3401
3393
  response.finish = true;
3402
3394
  response.actions = [];
3403
3395
  aiMarkedSuccess = false;
@@ -3407,6 +3399,30 @@ ${patternContext}` : prompt;
3407
3399
  console.log(`>>ARCALITY_STATUS>> \u{1F504} Loop candidato detectado pero el agente se recuper\xF3 en este turno. Continuando misi\xF3n.`);
3408
3400
  }
3409
3401
  }
3402
+ if (!response.finish && history.length >= 3) {
3403
+ const lastSixHistory = history.slice(-6);
3404
+ const consecutiveWaits = lastSixHistory.filter((h) => h.includes('wait en "')).length;
3405
+ if (consecutiveWaits >= 3) {
3406
+ const blankEvidencePath = path2.join(contextDir, `portal-blank-state-${Date.now()}.png`);
3407
+ await page.screenshot({ path: blankEvidencePath, fullPage: true }).catch(() => {
3408
+ });
3409
+ const blankUrl = page.url();
3410
+ console.error(`
3411
+ \u{1F6D1} [PORTAL RENDERING FAILURE] El agente ejecut\xF3 ${consecutiveWaits} esperas consecutivas sin progreso.`);
3412
+ console.error(` >> URL afectada: ${blankUrl}`);
3413
+ console.error(` >> El portal carg\xF3 el shell (navegaci\xF3n, header) pero los WIDGETS/COMPONENTES quedaron en blanco.`);
3414
+ console.error(` >> Evidencia guardada: ${blankEvidencePath}`);
3415
+ console.error(` >> Tipo: portal_rendering_failure | Esto es un bug del portal, NO del agente.`);
3416
+ response.thought = `\u{1F6D1} [BUG DEL PORTAL DETECTADO] La p\xE1gina ${blankUrl} carg\xF3 su estructura pero los componentes principales (widgets, tablas, listas) NO se renderizaron. El agente estuvo esperando ${consecutiveWaits} turnos sin mejora. Esto es un fallo de renderizado del portal.`;
3417
+ response.finish = true;
3418
+ response.actions = [];
3419
+ aiMarkedSuccess = false;
3420
+ hasCriticalError = true;
3421
+ failReason = "portal_rendering_failure";
3422
+ history.push(`Turno ${stepCount}: \u{1F6D1} [PORTAL_RENDER_FAILURE] La p\xE1gina ${blankUrl} carg\xF3 en blanco (${consecutiveWaits} esperas sin progreso). Los widgets no se renderizaron. Bug del portal detectado por Arcality QA. Evidencia: ${blankEvidencePath}`);
3423
+ saveMissionResults();
3424
+ }
3425
+ }
3410
3426
  if (response.actions && response.actions.length > 0) {
3411
3427
  for (const step of response.actions) {
3412
3428
  console.log(`
@@ -3421,11 +3437,11 @@ ${patternContext}` : prompt;
3421
3437
  const elementRole = await loc.getAttribute("role").catch(() => "") || "";
3422
3438
  const ariaExpanded = await loc.getAttribute("aria-expanded").catch(() => "") || "";
3423
3439
  const isInsideForm = await loc.evaluate((el) => !!el.closest("form")).catch(() => false);
3424
- const isLoginPage = page.url().includes("/login") || page.url().includes("/auth") || page.url().includes("oauth") || await page.locator('input[type="password"]').count().then((c) => c > 0).catch(() => false);
3440
+ const isLoginPage = page.url().includes("/login") || page.url().includes("/auth") || page.url().includes("oauth");
3425
3441
  const isAnchorLink = desc.startsWith("[a]") || step.type === "a";
3426
3442
  const isMenuItem = isAnchorLink || elementRole === "menuitem" || elementRole === "option" || desc.startsWith("[li]") || step.type === "li";
3427
3443
  const isMenuTrigger = desc.includes("more_vert") || desc.includes("more_horiz") || elementRole === "menu" || ariaExpanded !== "";
3428
- const isSubmitAction = !isMenuItem && (elementType === "submit" || isInsideForm && step.type === "button" || isLoginPage);
3444
+ const isSubmitAction = !isMenuItem && (elementType === "submit" || isInsideForm && step.type === "button" && !isLoginPage);
3429
3445
  if (isSubmitAction) {
3430
3446
  const rawBodyText = await page.innerText("body").catch(() => "");
3431
3447
  const textLower = rawBodyText.toLowerCase();
@@ -3509,7 +3525,7 @@ ${patternContext}` : prompt;
3509
3525
  console.log(" \u23F3 Abriendo men\xFA, esperando 1.5s para renderizado...");
3510
3526
  await page.waitForTimeout(1500);
3511
3527
  }
3512
- if (!isMenuTrigger && (elementRole === "combobox" || elementRole === "listbox" || ariaExpanded === "true")) {
3528
+ if (!isMenuTrigger && (elementRole === "combobox" || elementRole === "listbox")) {
3513
3529
  console.log(" \u23F3 Dropdown/combobox detectado por ARIA role, esperando 800ms para opciones...");
3514
3530
  await page.waitForTimeout(800);
3515
3531
  }
@@ -3641,7 +3657,43 @@ ${patternContext}` : prompt;
3641
3657
  }
3642
3658
  await page.waitForTimeout(500);
3643
3659
  } else if (step.action === "wait") {
3644
- await page.waitForTimeout(3e3);
3660
+ const waitMs = Math.min(parseInt(step.value || "3000", 10) || 3e3, 5e3);
3661
+ await page.waitForTimeout(waitMs);
3662
+ if (stepCount > 5) {
3663
+ try {
3664
+ const dockManager = await page.locator("igc-dockmanager").count().catch(() => 0);
3665
+ if (dockManager > 0) {
3666
+ const panels = await page.locator("igc-dockmanager [slot]").all();
3667
+ let emptyPanelCount = 0;
3668
+ for (const panel of panels.slice(0, 6)) {
3669
+ const txt = (await panel.innerText().catch(() => "")).trim();
3670
+ const isVisible = await panel.isVisible().catch(() => false);
3671
+ if (isVisible && txt.length < 10)
3672
+ emptyPanelCount++;
3673
+ }
3674
+ const panelCount = Math.min(panels.length, 6);
3675
+ if (panelCount >= 2 && emptyPanelCount >= panelCount * 0.6) {
3676
+ const blankUrl = page.url();
3677
+ const blankEvidencePath = path2.join(contextDir, `portal-blank-dashboard-${Date.now()}.png`);
3678
+ await page.screenshot({ path: blankEvidencePath, fullPage: true }).catch(() => {
3679
+ });
3680
+ console.error(`
3681
+ \u{1F6D1} [BLANK_DASHBOARD] El portal carg\xF3 el shell pero los widgets est\xE1n vac\xEDos.`);
3682
+ console.error(` >> URL: ${blankUrl}`);
3683
+ console.error(` >> ${emptyPanelCount} de ${panelCount} paneles est\xE1n en blanco.`);
3684
+ console.error(` >> Tipo: portal_rendering_failure | Bug del portal confirmado.`);
3685
+ console.error(` >> Evidencia: ${blankEvidencePath}`);
3686
+ hasCriticalError = true;
3687
+ failReason = "portal_rendering_failure";
3688
+ isFinished = true;
3689
+ history.push(`Turno ${stepCount}: \u{1F6D1} [BLANK_DASHBOARD] El portal carg\xF3 la p\xE1gina ${blankUrl} pero los widgets/tablas NO se renderizaron (${emptyPanelCount}/${panelCount} paneles vac\xEDos). Esto es un BUG DEL PORTAL detectado autom\xE1ticamente por Arcality QA. El agente NO puede continuar. Evidencia guardada: ${blankEvidencePath}`);
3690
+ saveMissionResults();
3691
+ break;
3692
+ }
3693
+ }
3694
+ } catch {
3695
+ }
3696
+ }
3645
3697
  }
3646
3698
  const descForHistory = (step.description || step.selector || "").substring(0, 80);
3647
3699
  const valStr = step.value ? ` con valor "${step.value}"` : "";