@validate.qa/runner 1.0.24 → 1.0.26
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/cli.js +1331 -293
- package/dist/cli.mjs +1331 -293
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -686,6 +686,8 @@ var require_mobile_source_parser = __commonJS({
|
|
|
686
686
|
exports.buildLocatorBundle = buildLocatorBundle;
|
|
687
687
|
exports.preferredLocator = preferredLocator;
|
|
688
688
|
exports.parseMobileSource = parseMobileSource2;
|
|
689
|
+
exports.resolveLocatorAgainstScreenDetailed = resolveLocatorAgainstScreenDetailed;
|
|
690
|
+
exports.resolveLocatorAgainstScreen = resolveLocatorAgainstScreen;
|
|
689
691
|
var IOS_ACTIONABLE_ROLE_SUFFIXES = [
|
|
690
692
|
"Button",
|
|
691
693
|
"TextField",
|
|
@@ -1089,6 +1091,106 @@ var require_mobile_source_parser = __commonJS({
|
|
|
1089
1091
|
windowSize: null
|
|
1090
1092
|
};
|
|
1091
1093
|
}
|
|
1094
|
+
var XPATH_IDENTITY_TEXT_ATTRS = /* @__PURE__ */ new Set([
|
|
1095
|
+
"text",
|
|
1096
|
+
"content-desc",
|
|
1097
|
+
"label",
|
|
1098
|
+
"name",
|
|
1099
|
+
"value"
|
|
1100
|
+
]);
|
|
1101
|
+
function elementValuesForXpathAttr(el, attr) {
|
|
1102
|
+
if (attr === "resource-id")
|
|
1103
|
+
return [el.resourceId];
|
|
1104
|
+
if (attr === "class")
|
|
1105
|
+
return [el.role];
|
|
1106
|
+
if (XPATH_IDENTITY_TEXT_ATTRS.has(attr))
|
|
1107
|
+
return [el.text, el.accessibilityId, el.label];
|
|
1108
|
+
return [];
|
|
1109
|
+
}
|
|
1110
|
+
function elementCarriesIdentityText(el, value) {
|
|
1111
|
+
return el.text === value || el.accessibilityId === value || el.label === value;
|
|
1112
|
+
}
|
|
1113
|
+
function parseXpathClauses(xpath) {
|
|
1114
|
+
const clauses = [];
|
|
1115
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1116
|
+
const push = (attr, value, matchKind) => {
|
|
1117
|
+
const key = `${attr}\0${value}\0${matchKind}`;
|
|
1118
|
+
if (seen.has(key))
|
|
1119
|
+
return;
|
|
1120
|
+
seen.add(key);
|
|
1121
|
+
clauses.push({ attr, value, matchKind });
|
|
1122
|
+
};
|
|
1123
|
+
const fnRe = /\b(contains|starts-with)\s*\(\s*@([A-Za-z_][\w.:-]*)\s*,\s*("([^"]*)"|'([^']*)')\s*\)/gi;
|
|
1124
|
+
let m;
|
|
1125
|
+
while ((m = fnRe.exec(xpath)) !== null) {
|
|
1126
|
+
const kind = m[1].toLowerCase() === "contains" ? "contains" : "starts-with";
|
|
1127
|
+
const value = m[4] ?? m[5] ?? "";
|
|
1128
|
+
push(m[2], value, kind);
|
|
1129
|
+
}
|
|
1130
|
+
const eqRe = /@([A-Za-z_][\w.:-]*)\s*=\s*("([^"]*)"|'([^']*)')/g;
|
|
1131
|
+
while ((m = eqRe.exec(xpath)) !== null) {
|
|
1132
|
+
const value = m[3] ?? m[4] ?? "";
|
|
1133
|
+
push(m[1], value, "exact");
|
|
1134
|
+
}
|
|
1135
|
+
return clauses;
|
|
1136
|
+
}
|
|
1137
|
+
function elementMatchesClause(el, clause) {
|
|
1138
|
+
const values = elementValuesForXpathAttr(el, clause.attr);
|
|
1139
|
+
return values.some((v) => {
|
|
1140
|
+
if (v === void 0)
|
|
1141
|
+
return false;
|
|
1142
|
+
if (clause.matchKind === "contains")
|
|
1143
|
+
return v.includes(clause.value);
|
|
1144
|
+
if (clause.matchKind === "starts-with")
|
|
1145
|
+
return v.startsWith(clause.value);
|
|
1146
|
+
return v === clause.value;
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
function matchXpath(xpath, elements) {
|
|
1150
|
+
const clauses = parseXpathClauses(xpath);
|
|
1151
|
+
if (clauses.length === 0)
|
|
1152
|
+
return { elements: [], exact: false };
|
|
1153
|
+
const matched = elements.filter((el) => clauses.some((c) => elementMatchesClause(el, c)));
|
|
1154
|
+
const exact = clauses.every((c) => c.matchKind === "exact");
|
|
1155
|
+
return { elements: matched, exact };
|
|
1156
|
+
}
|
|
1157
|
+
function resolveLocatorAgainstScreenDetailed(candidate, screen) {
|
|
1158
|
+
const elements = screen.elements;
|
|
1159
|
+
const accId = candidate.accessibilityId?.trim();
|
|
1160
|
+
if (accId) {
|
|
1161
|
+
const matches = elements.filter((el) => el.accessibilityId === accId);
|
|
1162
|
+
if (matches.length > 0)
|
|
1163
|
+
return { elements: matches, strategy: "accessibilityId", exact: true };
|
|
1164
|
+
}
|
|
1165
|
+
const resId = candidate.resourceId?.trim();
|
|
1166
|
+
if (resId) {
|
|
1167
|
+
const matches = elements.filter((el) => el.resourceId === resId);
|
|
1168
|
+
if (matches.length > 0)
|
|
1169
|
+
return { elements: matches, strategy: "resourceId", exact: true };
|
|
1170
|
+
}
|
|
1171
|
+
const text = candidate.text?.trim();
|
|
1172
|
+
if (text) {
|
|
1173
|
+
const matches = elements.filter((el) => elementCarriesIdentityText(el, text));
|
|
1174
|
+
if (matches.length > 0)
|
|
1175
|
+
return { elements: matches, strategy: "text", exact: true };
|
|
1176
|
+
}
|
|
1177
|
+
const xpath = candidate.xpath?.trim();
|
|
1178
|
+
if (xpath) {
|
|
1179
|
+
const res = matchXpath(xpath, elements);
|
|
1180
|
+
if (res.elements.length > 0)
|
|
1181
|
+
return { elements: res.elements, strategy: "xpath", exact: res.exact };
|
|
1182
|
+
}
|
|
1183
|
+
const className = candidate.className?.trim();
|
|
1184
|
+
if (className) {
|
|
1185
|
+
const matches = elements.filter((el) => el.role === className);
|
|
1186
|
+
if (matches.length > 0)
|
|
1187
|
+
return { elements: matches, strategy: "className", exact: true };
|
|
1188
|
+
}
|
|
1189
|
+
return { elements: [], strategy: "none", exact: false };
|
|
1190
|
+
}
|
|
1191
|
+
function resolveLocatorAgainstScreen(candidate, screen) {
|
|
1192
|
+
return resolveLocatorAgainstScreenDetailed(candidate, screen).elements;
|
|
1193
|
+
}
|
|
1092
1194
|
}
|
|
1093
1195
|
});
|
|
1094
1196
|
|
|
@@ -62144,7 +62246,7 @@ Rules:
|
|
|
62144
62246
|
- Register ONCE per run. If signup says the account ALREADY exists, log in with that email + the \`${opts.passwordKey}\` password instead of registering again.
|
|
62145
62247
|
- Only call the verification tools AFTER submitting the signup form; pass the app as \`senderMatch\` (the inbox is shared).`;
|
|
62146
62248
|
}
|
|
62147
|
-
function buildSystemPrompt(mode, platform3, enableRecordJourney, maxIterations, appBrief, targetAppId, existingScreens) {
|
|
62249
|
+
function buildSystemPrompt(mode, platform3, enableRecordJourney, maxIterations, appBrief, targetAppId, existingScreens, incremental) {
|
|
62148
62250
|
const platformLabel = platform3 === "IOS" ? "iOS" : "Android";
|
|
62149
62251
|
const targetLine = targetAppId ? ` Target app package/bundle: ${targetAppId}.` : "";
|
|
62150
62252
|
const surveyBody = `You are a mobile QA exploration agent driving a real ${platformLabel} app on a connected device. Your goal: MAP every reachable screen so downstream agents know what to test. You are NOT testing \u2014 you are building a complete screen map.
|
|
@@ -62154,13 +62256,12 @@ Rules:
|
|
|
62154
62256
|
- Every element is addressed by a ref like e1, e2. **Refs are ONLY valid for the most recent mobile_snapshot.** Re-snapshot after every action that changes the screen, then use the NEW refs.
|
|
62155
62257
|
- mobile_tap/mobile_type/mobile_clear take a ref. The loop resolves the ref to coordinates for you \u2014 you never pass coordinates.
|
|
62156
62258
|
|
|
62157
|
-
## Strategy
|
|
62158
|
-
1
|
|
62159
|
-
2
|
|
62160
|
-
3
|
|
62161
|
-
|
|
62162
|
-
|
|
62163
|
-
6. When no new screens remain, call finish_exploration.
|
|
62259
|
+
## Strategy \u2014 three phases, in order
|
|
62260
|
+
**Phase 1 \u2014 Logged-out entry (be quick, ~15% of budget).** mobile_snapshot the launch screen, capture_screen it, and capture each distinct pre-login screen ONCE (landing, theme/language picker, sign-up, sign-in, forgot-password). Do NOT exhaustively try onboarding variants (every theme, every language) \u2014 one capture per screen type is enough. Then LOG IN using the provided credentials and verify you are actually signed in.
|
|
62261
|
+
**Phase 2 \u2014 Logged-in breadth first (~35% of budget).** Once signed in, find the primary navigation (bottom tab bar, drawer, or menu) and visit EVERY top-level destination ONCE, capturing each screen, BEFORE drilling into any of them. A survey that maps one tab deeply but never opens the other tabs has failed \u2014 breadth across all tabs/drawer entries is mandatory.
|
|
62262
|
+
**Phase 3 \u2014 Depth (remaining budget).** Return to each captured tab and explore its sub-screens: open ONE list row per list (rows share a template), open menus/sheets/dialogs, capture detail screens, and mobile_swipe up/down to reveal off-screen content. record_transition whenever you move between screens.
|
|
62263
|
+
|
|
62264
|
+
Rules that apply throughout: capture_screen every new screen (name + type \u2014 use type "onboarding"/"landing" for pre-login screens, "auth" for sign-in/sign-up); record_transition on every move; mobile_back to return; mobile_relaunch only for a clean restart between episodes. When no new screens remain, call finish_exploration.
|
|
62164
62265
|
|
|
62165
62266
|
## Boundaries (survey = map, do not mutate)
|
|
62166
62267
|
- Do NOT submit forms, save, delete, purchase, or send anything. You MAY open modals/menus to catalog them, then dismiss.
|
|
@@ -62190,7 +62291,7 @@ Max iterations: ${maxIterations}. You will be warned near the end.`;
|
|
|
62190
62291
|
## Application Brief
|
|
62191
62292
|
${appBrief}
|
|
62192
62293
|
Use this to prioritize which screens and flows to cover.` : "";
|
|
62193
|
-
const existingScreensBlock = mode === "survey" && existingScreens && existingScreens.length > 0 ? `
|
|
62294
|
+
const existingScreensBlock = mode === "survey" && incremental && existingScreens && existingScreens.length > 0 ? `
|
|
62194
62295
|
|
|
62195
62296
|
## ALREADY DISCOVERED SCREENS (skip these; find new)
|
|
62196
62297
|
These screens were mapped in a previous survey. Do NOT re-map them \u2014 use your budget to find NEW screens and flows not listed here. If you land on one of these, move on to something new.
|
|
@@ -62385,7 +62486,7 @@ ${existingScreens.slice(0, 100).map((s) => `- ${s.screenId}${s.name ? ` "${s.nam
|
|
|
62385
62486
|
const browserCreds = ctx.variableContext.allTestVariables ?? ctx.variableContext.publicTestVariables;
|
|
62386
62487
|
const { secrets: credentialSecrets } = (0, credential_tools_js_1.partitionTestVariables)(browserCreds);
|
|
62387
62488
|
const hasCredentials = Object.keys(credentialSecrets).length > 0;
|
|
62388
|
-
const systemPrompt = buildSystemPrompt(mode, platform3, enableRecordJourney, maxIterations, ctx.appBrief, targetAppId, existingScreens) + buildMobileCredentialPromptBlock(credentialSecrets) + (registerMode && inboxState ? buildMobileInboxPromptBlock({
|
|
62489
|
+
const systemPrompt = buildSystemPrompt(mode, platform3, enableRecordJourney, maxIterations, ctx.appBrief, targetAppId, existingScreens, ctx.incremental) + buildMobileCredentialPromptBlock(credentialSecrets) + (registerMode && inboxState ? buildMobileInboxPromptBlock({
|
|
62389
62490
|
email: inboxState.email,
|
|
62390
62491
|
passwordKey: inboxState.passwordKey ?? "TEST_USER_PASSWORD",
|
|
62391
62492
|
context: mode
|
|
@@ -65650,6 +65751,7 @@ Return ONLY one valid JSON object matching the schema below. Do NOT include <thi
|
|
|
65650
65751
|
7. Feature descriptions MUST reference actual element labels / accessibility-ids from the evidence
|
|
65651
65752
|
8. Do NOT create standalone features for generic error / empty screens (network-error, permission-denied). If a feature screen is broken or crashes, keep it in its intended feature and note the failure in the description.
|
|
65652
65753
|
9. COVER EVERY SCREEN: every explored screen except generic error / permission screens MUST appear in exactly one feature group's routes. Do not leave screens ungrouped \u2014 a screen the explorer reached is part of SOME feature. Attach an ambiguous screen to its most closely related feature and note the ambiguity in that feature's description. Sign-in / sign-up / forgot-password screens form an "Authentication" group even when they were only reached via links from other screens.
|
|
65754
|
+
10. LOGGED-OUT vs LOGGED-IN SEPARATION: screens shown BEFORE the user is signed in (splash, landing/welcome, theme or language pickers, walkthroughs, sign-up, sign-in, forgot-password, demo/preview screens) must NEVER share a feature group with the signed-in app. Put sign-in / sign-up / forgot-password in "Authentication" (rule 4) and the remaining pre-login screens in an "Onboarding" group. Features named after signed-in areas (feeds, dashboards, tabs, settings) must contain ONLY screens reached after authentication. A pre-login flow is a linear sequence, not a navigation destination \u2014 do not let it swallow the app's main features.
|
|
65653
65755
|
|
|
65654
65756
|
## Output JSON Schema
|
|
65655
65757
|
{
|
|
@@ -66033,7 +66135,8 @@ ${constraints.join("\n")}`);
|
|
|
66033
66135
|
const orderedScreens = targetAppScreens(graph, appId).filter((state2) => state2.screenType?.toLowerCase() !== "error").sort((a, b) => a.firstSeenIteration - b.firstSeenIteration);
|
|
66034
66136
|
const includedScreenIds = new Set(orderedScreens.map((state2) => state2.screenId));
|
|
66035
66137
|
for (const state2 of orderedScreens) {
|
|
66036
|
-
const
|
|
66138
|
+
const screenTypeLower = state2.screenType?.toLowerCase();
|
|
66139
|
+
const groupName = screenTypeLower === "auth" ? "Authentication" : screenTypeLower === "onboarding" || screenTypeLower === "landing" || screenTypeLower === "splash" ? "Onboarding" : screenDisplayName(state2);
|
|
66037
66140
|
const group = groups.get(groupName) ?? {
|
|
66038
66141
|
name: groupName,
|
|
66039
66142
|
description: `Native mobile screens related to ${groupName}.`,
|
|
@@ -66492,6 +66595,7 @@ var require_mobile_generator = __commonJS({
|
|
|
66492
66595
|
## Rules
|
|
66493
66596
|
- Re-snapshot before every assertion so the ref is fresh.
|
|
66494
66597
|
- Assert the OUTCOME of the flow (the new screen / new content), not the control you just tapped.
|
|
66598
|
+
- Assert only DURABLE elements \u2014 screen chrome that exists on every visit (tab labels, headers, nav bars, the entity you just created). NEVER assert one-time / data-dependent UI: empty-state CTAs ("Add Your First \u2026", "Get Started", "No items yet"), onboarding banners, or counters \u2014 they vanish as soon as the account has data, and the test then fails forever on a healthy app.
|
|
66495
66599
|
- Do NOT trigger irreversible side effects (real payments, sending messages to others) \u2014 note them and assert what you safely can.
|
|
66496
66600
|
- Stay inside this app.${targetLine} Do not open or use app stores, browsers, email apps, settings, or any other app. If an action leaves the target app, the runner will relaunch the target app and reject that action.
|
|
66497
66601
|
- Do ONLY the actions this scenario needs. Do NOT re-open a menu you already opened, re-select an option that is already selected, toggle a setting back and forth, or repeat a step that already succeeded \u2014 EVERY action you take is baked into the generated test verbatim, so each extra action becomes a permanent junk step.
|
|
@@ -67141,6 +67245,24 @@ ${statePacket}` },
|
|
|
67141
67245
|
return true;
|
|
67142
67246
|
return false;
|
|
67143
67247
|
}
|
|
67248
|
+
var BARE_CONTAINER_CLASS_RE = /(webview|framelayout|linearlayout|relativelayout|viewgroup|scrollview|recyclerview|listview|XCUIElementTypeWebView|XCUIElementTypeApplication|XCUIElementTypeWindow|XCUIElementTypeOther|XCUIElementTypeScrollView)$/i;
|
|
67249
|
+
function isBareContainerTap(action) {
|
|
67250
|
+
if (action.type !== "TAP")
|
|
67251
|
+
return false;
|
|
67252
|
+
const bundle = action.metadata.locatorBundle;
|
|
67253
|
+
if (!bundle)
|
|
67254
|
+
return false;
|
|
67255
|
+
const hasIdentity = Boolean(bundle.text?.trim() || bundle.contentDesc?.trim() || bundle.accessibilityId?.trim() || action.metadata.targetLabel?.trim());
|
|
67256
|
+
if (hasIdentity)
|
|
67257
|
+
return false;
|
|
67258
|
+
const resourceId = bundle.resourceId?.trim() ?? "";
|
|
67259
|
+
const localName = resourceId.includes("/") ? resourceId.slice(resourceId.indexOf("/") + 1) : resourceId;
|
|
67260
|
+
const containerishId = localName !== "" && (localName === "webview" || ALWAYS_PRESENT_CONTAINER_ID_NAMES.has(localName));
|
|
67261
|
+
const containerishClass = BARE_CONTAINER_CLASS_RE.test(bundle.className ?? "");
|
|
67262
|
+
if (containerishId)
|
|
67263
|
+
return true;
|
|
67264
|
+
return containerishClass && (resourceId === "" || containerishId);
|
|
67265
|
+
}
|
|
67144
67266
|
function appendHybridFloor(actions, recording, platform3) {
|
|
67145
67267
|
const anchor = pickLandingAnchor(recording.lastSnapshot);
|
|
67146
67268
|
if (!anchor)
|
|
@@ -67181,10 +67303,15 @@ ${statePacket}` },
|
|
|
67181
67303
|
}
|
|
67182
67304
|
function assembleTest(args) {
|
|
67183
67305
|
const { scenario, recording, ctx, platform: platform3, appDataCleared, log: log2 } = args;
|
|
67184
|
-
|
|
67306
|
+
let actions = collapseRetryCycles(recording.actions);
|
|
67185
67307
|
if (actions.length < recording.actions.length) {
|
|
67186
67308
|
log2(` collapsed ${recording.actions.length - actions.length} retry-cycle step(s) out of the recorded trace (${recording.actions.length} \u2192 ${actions.length}).`);
|
|
67187
67309
|
}
|
|
67310
|
+
const beforeContainerDrop = actions.length;
|
|
67311
|
+
actions = actions.filter((a) => !isBareContainerTap(a));
|
|
67312
|
+
if (actions.length < beforeContainerDrop) {
|
|
67313
|
+
log2(` dropped ${beforeContainerDrop - actions.length} bare-container tap step(s) (no identity \u2014 un-replayable ambient taps).`);
|
|
67314
|
+
}
|
|
67188
67315
|
const floorAppended = appendHybridFloor(actions, recording, platform3);
|
|
67189
67316
|
if (floorAppended) {
|
|
67190
67317
|
log2(" appended hybrid durable-outcome floor (landing-screen ASSERT_VISIBLE).");
|
|
@@ -67372,6 +67499,1157 @@ Mobile generate phase complete: ${tests.length}/${scenarios.length} test(s) gene
|
|
|
67372
67499
|
}
|
|
67373
67500
|
});
|
|
67374
67501
|
|
|
67502
|
+
// ../runner-core/dist/services/mobile/mobile-heal-postprocess.js
|
|
67503
|
+
var require_mobile_heal_postprocess = __commonJS({
|
|
67504
|
+
"../runner-core/dist/services/mobile/mobile-heal-postprocess.js"(exports) {
|
|
67505
|
+
"use strict";
|
|
67506
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67507
|
+
exports.redactMobileSecretsFromText = redactMobileSecretsFromText;
|
|
67508
|
+
exports.detectMobileStepSecretLeak = detectMobileStepSecretLeak;
|
|
67509
|
+
exports.computeMobileHealOutcome = computeMobileHealOutcome2;
|
|
67510
|
+
var REDACT_KEY_RE = /email|username|user|phone|password|secret|token|api[_-]?key|access[_-]?key|\bpass\b|credential|bearer|\bpat\b|session|cookie|jwt|otp|pin/i;
|
|
67511
|
+
var DETECT_KEY_RE = /password|secret|token|api[_]?key|\bpass\b|credential|bearer|\bpat\b/i;
|
|
67512
|
+
var MIN_REDACT_LEN = 4;
|
|
67513
|
+
var MIN_DETECT_LEN = 6;
|
|
67514
|
+
var TOKEN_SOURCES = [
|
|
67515
|
+
"eyJ[A-Za-z0-9_-]{6,}\\.[A-Za-z0-9_-]{6,}\\.[A-Za-z0-9_-]{4,}",
|
|
67516
|
+
// JWT (three base64url segments)
|
|
67517
|
+
"Bearer\\s+[A-Za-z0-9._~+/=-]{12,}",
|
|
67518
|
+
// Authorization: Bearer <token>
|
|
67519
|
+
"sk-[A-Za-z0-9]{16,}"
|
|
67520
|
+
// OpenAI-style secret key
|
|
67521
|
+
];
|
|
67522
|
+
var EMAIL_RE = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
67523
|
+
function escapeRegExp(value) {
|
|
67524
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
67525
|
+
}
|
|
67526
|
+
function collectSecretVars(testVariables, minLen, keyRe) {
|
|
67527
|
+
if (!testVariables)
|
|
67528
|
+
return [];
|
|
67529
|
+
const out = [];
|
|
67530
|
+
for (const [key, value] of Object.entries(testVariables)) {
|
|
67531
|
+
if (typeof value === "string" && value.length >= minLen && keyRe.test(key)) {
|
|
67532
|
+
out.push({ key, value });
|
|
67533
|
+
}
|
|
67534
|
+
}
|
|
67535
|
+
return out.sort((a, b) => b.value.length - a.value.length);
|
|
67536
|
+
}
|
|
67537
|
+
function redactMobileSecretsFromText(text, testVariables) {
|
|
67538
|
+
if (!text)
|
|
67539
|
+
return text;
|
|
67540
|
+
let out = text;
|
|
67541
|
+
for (const { key, value } of collectSecretVars(testVariables, MIN_REDACT_LEN, REDACT_KEY_RE)) {
|
|
67542
|
+
out = out.replace(new RegExp(escapeRegExp(value), "g"), `{{${key}}}`);
|
|
67543
|
+
}
|
|
67544
|
+
for (const source of TOKEN_SOURCES) {
|
|
67545
|
+
out = out.replace(new RegExp(source, "g"), "[REDACTED]");
|
|
67546
|
+
}
|
|
67547
|
+
out = out.replace(EMAIL_RE, "[EMAIL]");
|
|
67548
|
+
return out;
|
|
67549
|
+
}
|
|
67550
|
+
function detectMobileStepSecretLeak(steps, testVariables) {
|
|
67551
|
+
if (!Array.isArray(steps) || steps.length === 0)
|
|
67552
|
+
return null;
|
|
67553
|
+
const serialized = JSON.stringify(steps);
|
|
67554
|
+
if (typeof serialized !== "string")
|
|
67555
|
+
return null;
|
|
67556
|
+
for (const { key, value } of collectSecretVars(testVariables, MIN_DETECT_LEN, DETECT_KEY_RE)) {
|
|
67557
|
+
if (serialized.includes(value))
|
|
67558
|
+
return `literal value of ${key}`;
|
|
67559
|
+
}
|
|
67560
|
+
for (const source of TOKEN_SOURCES) {
|
|
67561
|
+
if (new RegExp(source).test(serialized))
|
|
67562
|
+
return "embedded token/bearer/JWT";
|
|
67563
|
+
}
|
|
67564
|
+
return null;
|
|
67565
|
+
}
|
|
67566
|
+
var NEEDS_REVIEW_VERDICTS = /* @__PURE__ */ new Set([
|
|
67567
|
+
"prereq_unmet",
|
|
67568
|
+
"state_stale",
|
|
67569
|
+
"test_invalid",
|
|
67570
|
+
"unhealable_dynamic"
|
|
67571
|
+
]);
|
|
67572
|
+
function computeMobileHealOutcome2(args) {
|
|
67573
|
+
const { heal } = args;
|
|
67574
|
+
const hasFix = Array.isArray(heal.healedSteps) && heal.healedSteps.length > 0;
|
|
67575
|
+
const secretLeak = heal.passed && hasFix ? detectMobileStepSecretLeak(heal.healedSteps, args.testVariables) : null;
|
|
67576
|
+
const isConfigIssue = heal.verdict === "config_issue";
|
|
67577
|
+
const isAppBug = heal.verdict === "app_bug";
|
|
67578
|
+
const extraTags = new Set((heal.extraTags ?? []).filter((t) => typeof t === "string" && t.length > 0));
|
|
67579
|
+
if (secretLeak)
|
|
67580
|
+
extraTags.add("@needs-review");
|
|
67581
|
+
if (!heal.passed && NEEDS_REVIEW_VERDICTS.has(heal.verdict))
|
|
67582
|
+
extraTags.add("@needs-review");
|
|
67583
|
+
let status;
|
|
67584
|
+
if (secretLeak)
|
|
67585
|
+
status = "FAILED";
|
|
67586
|
+
else if (heal.passed)
|
|
67587
|
+
status = "PASSED";
|
|
67588
|
+
else if (isConfigIssue)
|
|
67589
|
+
status = "ERROR";
|
|
67590
|
+
else
|
|
67591
|
+
status = "FAILED";
|
|
67592
|
+
let error2;
|
|
67593
|
+
if (status === "PASSED") {
|
|
67594
|
+
error2 = void 0;
|
|
67595
|
+
} else if (secretLeak) {
|
|
67596
|
+
error2 = `HEAL_SECRET_LEAK: healed steps contained a literal secret (${secretLeak}); patch dropped, tagged @needs-review`;
|
|
67597
|
+
} else if (isConfigIssue) {
|
|
67598
|
+
error2 = `CONFIG_ISSUE: ${heal.healReason ?? args.finalError ?? args.reproduceError ?? "environment/rate-limit blocker"}`;
|
|
67599
|
+
} else if (isAppBug) {
|
|
67600
|
+
error2 = `APP_BUG: ${heal.healReason ?? args.finalError ?? args.reproduceError ?? "application defect found during heal"}`;
|
|
67601
|
+
} else {
|
|
67602
|
+
error2 = args.finalError ?? heal.healReason ?? args.reproduceError ?? void 0;
|
|
67603
|
+
}
|
|
67604
|
+
return {
|
|
67605
|
+
status,
|
|
67606
|
+
error: error2,
|
|
67607
|
+
extraTags: extraTags.size > 0 ? [...extraTags] : void 0,
|
|
67608
|
+
removeTags: heal.removeTags,
|
|
67609
|
+
shouldPatch: heal.passed === true && hasFix && !secretLeak,
|
|
67610
|
+
secretLeak
|
|
67611
|
+
};
|
|
67612
|
+
}
|
|
67613
|
+
}
|
|
67614
|
+
});
|
|
67615
|
+
|
|
67616
|
+
// ../runner-core/dist/services/selector-registry-context.js
|
|
67617
|
+
var require_selector_registry_context = __commonJS({
|
|
67618
|
+
"../runner-core/dist/services/selector-registry-context.js"(exports) {
|
|
67619
|
+
"use strict";
|
|
67620
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67621
|
+
exports.normalizeSelectorRegistryEntries = normalizeSelectorRegistryEntries;
|
|
67622
|
+
exports.formatSelectorRegistryContextForPrompt = formatSelectorRegistryContextForPrompt;
|
|
67623
|
+
exports.collectRegistryCandidates = collectRegistryCandidates;
|
|
67624
|
+
exports.buildRegistryCandidateBlock = buildRegistryCandidateBlock;
|
|
67625
|
+
exports.planRegistryFallbackFix = planRegistryFallbackFix;
|
|
67626
|
+
exports.substituteSelectorInCode = substituteSelectorInCode;
|
|
67627
|
+
exports.parseMobileLocatorExpression = parseMobileLocatorExpression;
|
|
67628
|
+
exports.collectMobileRegistryCandidates = collectMobileRegistryCandidates;
|
|
67629
|
+
exports.mobileCandidateToTarget = mobileCandidateToTarget;
|
|
67630
|
+
function isRecord(value) {
|
|
67631
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
67632
|
+
}
|
|
67633
|
+
function asString(value, fallback = "") {
|
|
67634
|
+
return typeof value === "string" ? value : fallback;
|
|
67635
|
+
}
|
|
67636
|
+
function asNumber(value, fallback = 0) {
|
|
67637
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
67638
|
+
}
|
|
67639
|
+
function asStringArray(value) {
|
|
67640
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
67641
|
+
}
|
|
67642
|
+
function truncateForSelectorPrompt(value, maxLength = 180) {
|
|
67643
|
+
const normalized = (value ?? "").replace(/\s+/g, " ").trim();
|
|
67644
|
+
if (normalized.length <= maxLength)
|
|
67645
|
+
return normalized;
|
|
67646
|
+
return `${normalized.slice(0, Math.max(0, maxLength - 3))}...`;
|
|
67647
|
+
}
|
|
67648
|
+
function inlineCode(value, maxLength = 180) {
|
|
67649
|
+
return `\`${truncateForSelectorPrompt(value, maxLength).replace(/`/g, "'")}\``;
|
|
67650
|
+
}
|
|
67651
|
+
function normalizeRef(value) {
|
|
67652
|
+
if (!isRecord(value))
|
|
67653
|
+
return null;
|
|
67654
|
+
const expression = asString(value.expression).trim();
|
|
67655
|
+
if (!expression)
|
|
67656
|
+
return null;
|
|
67657
|
+
return {
|
|
67658
|
+
route: asString(value.route, "*"),
|
|
67659
|
+
usage: asString(value.usage, "locator"),
|
|
67660
|
+
source: asString(value.source, "generated"),
|
|
67661
|
+
expression,
|
|
67662
|
+
occurrenceIndex: asNumber(value.occurrenceIndex, 0)
|
|
67663
|
+
};
|
|
67664
|
+
}
|
|
67665
|
+
function normalizeSibling(value) {
|
|
67666
|
+
if (!isRecord(value))
|
|
67667
|
+
return null;
|
|
67668
|
+
const testCaseId = asString(value.testCaseId).trim();
|
|
67669
|
+
const expression = asString(value.expression).trim();
|
|
67670
|
+
if (!testCaseId || !expression)
|
|
67671
|
+
return null;
|
|
67672
|
+
return {
|
|
67673
|
+
testCaseId,
|
|
67674
|
+
name: asString(value.name, testCaseId),
|
|
67675
|
+
suite: typeof value.suite === "string" ? value.suite : null,
|
|
67676
|
+
lastPassedAt: typeof value.lastPassedAt === "string" ? value.lastPassedAt : null,
|
|
67677
|
+
expression,
|
|
67678
|
+
usage: asString(value.usage, "locator"),
|
|
67679
|
+
route: asString(value.route, "*"),
|
|
67680
|
+
source: asString(value.source, "generated")
|
|
67681
|
+
};
|
|
67682
|
+
}
|
|
67683
|
+
function normalizeEntry(value) {
|
|
67684
|
+
if (!isRecord(value))
|
|
67685
|
+
return null;
|
|
67686
|
+
const id = asString(value.id).trim();
|
|
67687
|
+
const expression = asString(value.expression).trim();
|
|
67688
|
+
if (!id || !expression)
|
|
67689
|
+
return null;
|
|
67690
|
+
return {
|
|
67691
|
+
id,
|
|
67692
|
+
key: asString(value.key, id),
|
|
67693
|
+
route: asString(value.route, "*"),
|
|
67694
|
+
scope: asString(value.scope, "page"),
|
|
67695
|
+
status: asString(value.status, "ACTIVE"),
|
|
67696
|
+
stability: asNumber(value.stability, 1),
|
|
67697
|
+
label: asString(value.label),
|
|
67698
|
+
locatorKind: asString(value.locatorKind),
|
|
67699
|
+
locatorRole: typeof value.locatorRole === "string" ? value.locatorRole : null,
|
|
67700
|
+
locatorName: typeof value.locatorName === "string" ? value.locatorName : null,
|
|
67701
|
+
locatorTestId: typeof value.locatorTestId === "string" ? value.locatorTestId : null,
|
|
67702
|
+
expression,
|
|
67703
|
+
fallbacks: asStringArray(value.fallbacks),
|
|
67704
|
+
currentTestRefs: Array.isArray(value.currentTestRefs) ? value.currentTestRefs.map(normalizeRef).filter((ref) => Boolean(ref)) : [],
|
|
67705
|
+
refCount: asNumber(value.refCount, 0),
|
|
67706
|
+
testCount: asNumber(value.testCount, 0),
|
|
67707
|
+
siblingFanoutCount: asNumber(value.siblingFanoutCount, 0),
|
|
67708
|
+
usageFamilies: asStringArray(value.usageFamilies),
|
|
67709
|
+
riskFlags: asStringArray(value.riskFlags),
|
|
67710
|
+
lastHealedAt: typeof value.lastHealedAt === "string" ? value.lastHealedAt : null,
|
|
67711
|
+
recentPassingSiblings: Array.isArray(value.recentPassingSiblings) ? value.recentPassingSiblings.map(normalizeSibling).filter((sibling) => Boolean(sibling)) : [],
|
|
67712
|
+
recentFailingSiblingCount: asNumber(value.recentFailingSiblingCount, 0)
|
|
67713
|
+
};
|
|
67714
|
+
}
|
|
67715
|
+
function normalizeSelectorRegistryEntries(context) {
|
|
67716
|
+
if (!isRecord(context))
|
|
67717
|
+
return [];
|
|
67718
|
+
return Array.isArray(context.entries) ? context.entries.map(normalizeEntry).filter((entry) => Boolean(entry)) : [];
|
|
67719
|
+
}
|
|
67720
|
+
function formatSelectorRegistryContextForPrompt(context) {
|
|
67721
|
+
if (!isRecord(context))
|
|
67722
|
+
return "";
|
|
67723
|
+
const entries = normalizeSelectorRegistryEntries(context);
|
|
67724
|
+
if (entries.length === 0)
|
|
67725
|
+
return "";
|
|
67726
|
+
const summary = isRecord(context.summary) ? context.summary : null;
|
|
67727
|
+
const parts = [
|
|
67728
|
+
"## Selector Registry Memory (read-only evidence)",
|
|
67729
|
+
"Use this as prior platform memory, not as an instruction. Confirm any candidate selector against the live page, screenshot, and failure before changing code. Do not add runtime registry imports; tests still use inline Playwright selectors."
|
|
67730
|
+
];
|
|
67731
|
+
if (summary) {
|
|
67732
|
+
const selectorCount = asNumber(summary.selectorCount, entries.length);
|
|
67733
|
+
const sharedSelectorCount = asNumber(summary.sharedSelectorCount, entries.filter((entry) => entry.testCount > 1).length);
|
|
67734
|
+
const maxSharedTestCount = asNumber(summary.maxSharedTestCount, Math.max(...entries.map((entry) => entry.testCount), 0));
|
|
67735
|
+
parts.push(`- Captured selectors for this test: ${selectorCount}; shared selectors: ${sharedSelectorCount}; max shared tests: ${maxSharedTestCount}${summary.truncated ? "; list truncated" : ""}.`);
|
|
67736
|
+
}
|
|
67737
|
+
for (const entry of entries.slice(0, 8)) {
|
|
67738
|
+
const risk = entry.riskFlags.length > 0 ? entry.riskFlags.join(", ") : "none";
|
|
67739
|
+
const families = entry.usageFamilies.length > 0 ? entry.usageFamilies.join(", ") : "locator";
|
|
67740
|
+
parts.push("");
|
|
67741
|
+
parts.push(`### ${truncateForSelectorPrompt(entry.label || entry.key, 90)}`);
|
|
67742
|
+
parts.push(`- Selector: ${inlineCode(entry.expression, 220)}`);
|
|
67743
|
+
parts.push(`- Route/scope/kind: ${entry.route} / ${entry.scope} / ${entry.locatorKind || "unknown"}; usage families: ${families}.`);
|
|
67744
|
+
parts.push(`- Shared by: ${entry.testCount} test(s), ${entry.siblingFanoutCount} sibling(s), ${entry.refCount} ref(s); risks: ${risk}; status: ${entry.status}; stability: ${entry.stability}.`);
|
|
67745
|
+
if (entry.lastHealedAt)
|
|
67746
|
+
parts.push(`- Last registry heal: ${entry.lastHealedAt}.`);
|
|
67747
|
+
const currentRefs = entry.currentTestRefs.slice(0, 3);
|
|
67748
|
+
if (currentRefs.length > 0) {
|
|
67749
|
+
parts.push("- Current test occurrences:");
|
|
67750
|
+
for (const ref of currentRefs) {
|
|
67751
|
+
parts.push(` - ${ref.usage} on ${ref.route} from ${ref.source}: ${inlineCode(ref.expression, 180)}`);
|
|
67752
|
+
}
|
|
67753
|
+
}
|
|
67754
|
+
const siblings = entry.recentPassingSiblings.slice(0, 3);
|
|
67755
|
+
if (siblings.length > 0) {
|
|
67756
|
+
parts.push("- Recent passing sibling tests using this registry entry:");
|
|
67757
|
+
for (const sibling of siblings) {
|
|
67758
|
+
const suite = sibling.suite ? ` (${truncateForSelectorPrompt(sibling.suite, 50)})` : "";
|
|
67759
|
+
const passed = sibling.lastPassedAt ? ` passed ${sibling.lastPassedAt}` : "";
|
|
67760
|
+
parts.push(` - ${truncateForSelectorPrompt(sibling.name, 80)}${suite}${passed}: ${inlineCode(sibling.expression, 180)}`);
|
|
67761
|
+
}
|
|
67762
|
+
}
|
|
67763
|
+
if (entry.recentFailingSiblingCount && entry.recentFailingSiblingCount > 0) {
|
|
67764
|
+
parts.push(`- Other recent failing siblings on this entry: ${entry.recentFailingSiblingCount}.`);
|
|
67765
|
+
}
|
|
67766
|
+
const fallbacks = (entry.fallbacks ?? []).slice(0, 3);
|
|
67767
|
+
if (fallbacks.length > 0) {
|
|
67768
|
+
parts.push(`- Registry fallbacks: ${fallbacks.map((fallback) => inlineCode(fallback, 120)).join(", ")}.`);
|
|
67769
|
+
}
|
|
67770
|
+
}
|
|
67771
|
+
return `${parts.join("\n")}
|
|
67772
|
+
`;
|
|
67773
|
+
}
|
|
67774
|
+
function selectorKey(expression) {
|
|
67775
|
+
return expression.trim().replace(/^page\s*\.\s*/, "").replace(/\s+/g, " ").replace(/"/g, "'").trim();
|
|
67776
|
+
}
|
|
67777
|
+
function collectRegistryCandidates(context) {
|
|
67778
|
+
const entries = normalizeSelectorRegistryEntries(context).slice(0, 8);
|
|
67779
|
+
const seen = /* @__PURE__ */ new Set();
|
|
67780
|
+
const ranked = [[], [], []];
|
|
67781
|
+
for (const entry of entries) {
|
|
67782
|
+
const entryLabel = entry.label || entry.key;
|
|
67783
|
+
for (const sibling of entry.recentPassingSiblings) {
|
|
67784
|
+
const key = selectorKey(sibling.expression);
|
|
67785
|
+
if (seen.has(key))
|
|
67786
|
+
continue;
|
|
67787
|
+
seen.add(key);
|
|
67788
|
+
ranked[0].push({ expression: sibling.expression, source: "passing-sibling", entryLabel, siblingName: sibling.name });
|
|
67789
|
+
}
|
|
67790
|
+
const entryKey = selectorKey(entry.expression);
|
|
67791
|
+
if (!seen.has(entryKey)) {
|
|
67792
|
+
seen.add(entryKey);
|
|
67793
|
+
ranked[1].push({ expression: entry.expression, source: "registry-entry", entryLabel });
|
|
67794
|
+
}
|
|
67795
|
+
for (const fallback of entry.fallbacks ?? []) {
|
|
67796
|
+
const key = selectorKey(fallback);
|
|
67797
|
+
if (seen.has(key))
|
|
67798
|
+
continue;
|
|
67799
|
+
seen.add(key);
|
|
67800
|
+
ranked[2].push({ expression: fallback, source: "fallback", entryLabel });
|
|
67801
|
+
}
|
|
67802
|
+
}
|
|
67803
|
+
return ranked.flat();
|
|
67804
|
+
}
|
|
67805
|
+
function buildRegistryCandidateBlock(context, excludeExpressions) {
|
|
67806
|
+
const exclude = new Set(excludeExpressions.map(selectorKey));
|
|
67807
|
+
const candidates = collectRegistryCandidates(context).filter((candidate) => !exclude.has(selectorKey(candidate.expression))).slice(0, 6);
|
|
67808
|
+
if (candidates.length === 0)
|
|
67809
|
+
return "";
|
|
67810
|
+
const lines = [
|
|
67811
|
+
"## Untried Selector Candidates (from registry memory)",
|
|
67812
|
+
"Ranked alternatives for elements this test uses, from the platform selector registry. Verify each against the screenshot and error before adopting \u2014 do not adopt blindly."
|
|
67813
|
+
];
|
|
67814
|
+
for (const candidate of candidates) {
|
|
67815
|
+
const provenance = candidate.source === "passing-sibling" ? `proven in passing sibling "${truncateForSelectorPrompt(candidate.siblingName, 80)}"` : candidate.source === "registry-entry" ? `registry entry for "${truncateForSelectorPrompt(candidate.entryLabel, 80)}"` : `registry fallback for "${truncateForSelectorPrompt(candidate.entryLabel, 80)}"`;
|
|
67816
|
+
lines.push(`- ${inlineCode(candidate.expression, 180)} \u2014 ${provenance}`);
|
|
67817
|
+
}
|
|
67818
|
+
return lines.join("\n");
|
|
67819
|
+
}
|
|
67820
|
+
function findExpressionInCode(code, expression) {
|
|
67821
|
+
const trimmed = expression.trim();
|
|
67822
|
+
if (trimmed && code.includes(trimmed))
|
|
67823
|
+
return trimmed;
|
|
67824
|
+
const withoutPage = trimmed.replace(/^page\s*\.\s*/, "");
|
|
67825
|
+
if (withoutPage !== trimmed && withoutPage && code.includes(withoutPage))
|
|
67826
|
+
return withoutPage;
|
|
67827
|
+
const withPage = `page.${withoutPage}`;
|
|
67828
|
+
if (withPage !== trimmed && code.includes(withPage))
|
|
67829
|
+
return withPage;
|
|
67830
|
+
return null;
|
|
67831
|
+
}
|
|
67832
|
+
function extractFailureFocus(error2) {
|
|
67833
|
+
const focus = error2.split(/\r?\n/).filter((line) => /^\s*>/.test(line) || /waiting for|locator resolved to/i.test(line) || /^\s*locator:/i.test(line));
|
|
67834
|
+
return focus.length > 0 ? focus.join("\n") : error2;
|
|
67835
|
+
}
|
|
67836
|
+
function planRegistryFallbackFix(args) {
|
|
67837
|
+
const { code, error: error2, context } = args;
|
|
67838
|
+
if (!error2 || !code)
|
|
67839
|
+
return null;
|
|
67840
|
+
const entries = normalizeSelectorRegistryEntries(context).slice(0, 8);
|
|
67841
|
+
if (entries.length === 0)
|
|
67842
|
+
return null;
|
|
67843
|
+
const errorKey = selectorKey(extractFailureFocus(error2));
|
|
67844
|
+
for (const entry of entries) {
|
|
67845
|
+
const failingExpressions = [entry.expression, ...entry.currentTestRefs.map((ref) => ref.expression)];
|
|
67846
|
+
const failingSeen = /* @__PURE__ */ new Set();
|
|
67847
|
+
for (const failing of failingExpressions) {
|
|
67848
|
+
const failingKey = selectorKey(failing);
|
|
67849
|
+
if (!failingKey || failingSeen.has(failingKey))
|
|
67850
|
+
continue;
|
|
67851
|
+
failingSeen.add(failingKey);
|
|
67852
|
+
if (!errorKey.includes(failingKey))
|
|
67853
|
+
continue;
|
|
67854
|
+
const matchedInCode = findExpressionInCode(code, failing);
|
|
67855
|
+
if (!matchedInCode)
|
|
67856
|
+
continue;
|
|
67857
|
+
const entryLabel = entry.label || entry.key;
|
|
67858
|
+
const candidateSeen = /* @__PURE__ */ new Set([failingKey]);
|
|
67859
|
+
const candidates = [];
|
|
67860
|
+
for (const fallback of entry.fallbacks ?? []) {
|
|
67861
|
+
const key = selectorKey(fallback);
|
|
67862
|
+
if (!key || candidateSeen.has(key) || code.includes(fallback.trim()))
|
|
67863
|
+
continue;
|
|
67864
|
+
candidateSeen.add(key);
|
|
67865
|
+
candidates.push({ expression: fallback, source: "fallback", entryLabel });
|
|
67866
|
+
}
|
|
67867
|
+
for (const sibling of entry.recentPassingSiblings) {
|
|
67868
|
+
const key = selectorKey(sibling.expression);
|
|
67869
|
+
if (!key || candidateSeen.has(key) || code.includes(sibling.expression.trim()))
|
|
67870
|
+
continue;
|
|
67871
|
+
candidateSeen.add(key);
|
|
67872
|
+
candidates.push({ expression: sibling.expression, source: "passing-sibling", entryLabel, siblingName: sibling.name });
|
|
67873
|
+
}
|
|
67874
|
+
if (candidates.length === 0)
|
|
67875
|
+
continue;
|
|
67876
|
+
return { matchedInCode, entryLabel, candidates };
|
|
67877
|
+
}
|
|
67878
|
+
}
|
|
67879
|
+
return null;
|
|
67880
|
+
}
|
|
67881
|
+
function substituteSelectorInCode(code, matchedInCode, replacement) {
|
|
67882
|
+
const target = matchedInCode.trim();
|
|
67883
|
+
let normalized = replacement.trim();
|
|
67884
|
+
const targetHasPage = /^page\s*\.\s*/.test(target);
|
|
67885
|
+
const replacementHasPage = /^page\s*\.\s*/.test(normalized);
|
|
67886
|
+
if (targetHasPage && !replacementHasPage)
|
|
67887
|
+
normalized = `page.${normalized}`;
|
|
67888
|
+
if (!targetHasPage && replacementHasPage)
|
|
67889
|
+
normalized = normalized.replace(/^page\s*\.\s*/, "");
|
|
67890
|
+
return code.split(target).join(normalized);
|
|
67891
|
+
}
|
|
67892
|
+
var MOBILE_LOCATOR_RE = /^mobile\.(accessibilityId|resourceId|text|contentDesc|xpath|className|locator)\(\s*'((?:\\.|[^'])*)'\s*\)$/;
|
|
67893
|
+
function unescapeMobileLocatorValue(value) {
|
|
67894
|
+
return value.replace(/\\'/g, "'").replace(/\\\\/g, "\\");
|
|
67895
|
+
}
|
|
67896
|
+
function parseMobileLocatorExpression(expression) {
|
|
67897
|
+
const match = MOBILE_LOCATOR_RE.exec(expression.trim());
|
|
67898
|
+
if (!match)
|
|
67899
|
+
return null;
|
|
67900
|
+
return { kind: match[1], value: unescapeMobileLocatorValue(match[2]).trim() };
|
|
67901
|
+
}
|
|
67902
|
+
function mobileIdentityKey(parts) {
|
|
67903
|
+
return `${parts.kind}\0${parts.value}`;
|
|
67904
|
+
}
|
|
67905
|
+
function collectMobileFallbackExpressions(entry, primary) {
|
|
67906
|
+
const seen = /* @__PURE__ */ new Set([mobileIdentityKey(primary)]);
|
|
67907
|
+
const fallbacks = [];
|
|
67908
|
+
const consider = (expression) => {
|
|
67909
|
+
const parsed = parseMobileLocatorExpression(expression);
|
|
67910
|
+
if (!parsed)
|
|
67911
|
+
return;
|
|
67912
|
+
const key = mobileIdentityKey(parsed);
|
|
67913
|
+
if (seen.has(key))
|
|
67914
|
+
return;
|
|
67915
|
+
seen.add(key);
|
|
67916
|
+
fallbacks.push(expression.trim());
|
|
67917
|
+
};
|
|
67918
|
+
for (const fallback of entry.fallbacks ?? [])
|
|
67919
|
+
consider(fallback);
|
|
67920
|
+
for (const sibling of entry.recentPassingSiblings)
|
|
67921
|
+
consider(sibling.expression);
|
|
67922
|
+
return fallbacks;
|
|
67923
|
+
}
|
|
67924
|
+
function collectMobileRegistryCandidates(context) {
|
|
67925
|
+
const entries = normalizeSelectorRegistryEntries(context).slice(0, 8);
|
|
67926
|
+
const seen = /* @__PURE__ */ new Set();
|
|
67927
|
+
const candidates = [];
|
|
67928
|
+
for (const entry of entries) {
|
|
67929
|
+
const primary = parseMobileLocatorExpression(entry.expression);
|
|
67930
|
+
if (!primary)
|
|
67931
|
+
continue;
|
|
67932
|
+
const identityKey = mobileIdentityKey(primary);
|
|
67933
|
+
if (seen.has(identityKey))
|
|
67934
|
+
continue;
|
|
67935
|
+
seen.add(identityKey);
|
|
67936
|
+
candidates.push({
|
|
67937
|
+
kind: primary.kind,
|
|
67938
|
+
value: primary.value,
|
|
67939
|
+
fallbacks: collectMobileFallbackExpressions(entry, primary)
|
|
67940
|
+
});
|
|
67941
|
+
}
|
|
67942
|
+
return candidates;
|
|
67943
|
+
}
|
|
67944
|
+
function mobileCandidateToTarget(candidate) {
|
|
67945
|
+
const { kind, value } = candidate;
|
|
67946
|
+
switch (kind) {
|
|
67947
|
+
case "resourceId":
|
|
67948
|
+
return { locatorBundle: { resourceId: value } };
|
|
67949
|
+
case "accessibilityId":
|
|
67950
|
+
return { locatorBundle: { accessibilityId: value } };
|
|
67951
|
+
case "text":
|
|
67952
|
+
return { locatorBundle: { text: value } };
|
|
67953
|
+
case "contentDesc":
|
|
67954
|
+
return { locatorBundle: { contentDesc: value } };
|
|
67955
|
+
case "xpath":
|
|
67956
|
+
return { locatorBundle: { xpath: value } };
|
|
67957
|
+
case "className":
|
|
67958
|
+
return { locatorBundle: { className: value } };
|
|
67959
|
+
default:
|
|
67960
|
+
return {};
|
|
67961
|
+
}
|
|
67962
|
+
}
|
|
67963
|
+
}
|
|
67964
|
+
});
|
|
67965
|
+
|
|
67966
|
+
// ../runner-core/dist/services/mobile/mobile-heal-loop.js
|
|
67967
|
+
var require_mobile_heal_loop = __commonJS({
|
|
67968
|
+
"../runner-core/dist/services/mobile/mobile-heal-loop.js"(exports) {
|
|
67969
|
+
"use strict";
|
|
67970
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67971
|
+
exports.MOBILE_LIVE_HEAL_SYSTEM_PROMPT = exports.MOBILE_SCRIPT_HEAL_SYSTEM_PROMPT = void 0;
|
|
67972
|
+
exports.executeMobileScriptDrivenHeal = executeMobileScriptDrivenHeal;
|
|
67973
|
+
exports.executeMobileTestWithHealing = executeMobileTestWithHealing2;
|
|
67974
|
+
exports.executeMobileLiveHeal = executeMobileLiveHeal2;
|
|
67975
|
+
var ai_provider_js_1 = require_ai_provider();
|
|
67976
|
+
var ai_queue_js_1 = require_ai_queue();
|
|
67977
|
+
var ai_retry_js_1 = require_ai_retry();
|
|
67978
|
+
var mobile_source_parser_js_1 = require_mobile_source_parser();
|
|
67979
|
+
var mobile_heal_postprocess_js_1 = require_mobile_heal_postprocess();
|
|
67980
|
+
var mobile_observation_js_1 = require_mobile_observation();
|
|
67981
|
+
var selector_registry_context_js_1 = require_selector_registry_context();
|
|
67982
|
+
exports.MOBILE_SCRIPT_HEAL_SYSTEM_PROMPT = `You are a QA engineer fixing a failing Appium (mobile UI automation) test. You receive: the test STEPS as JSON, the failure ERROR + step-level results, and the PAGE-SOURCE accessibility tree captured at the moment of failure (this tree is your 'screenshot'), plus optional known-good selector candidates from a registry.
|
|
67983
|
+
## You MUST try to fix the steps
|
|
67984
|
+
Reason over steps + error + tree + registry and return working healed steps. Do NOT return needs_device unless you have genuinely exhausted that reasoning (and NEVER before your final attempt).
|
|
67985
|
+
## Analyze
|
|
67986
|
+
1. ERROR: which step failed, on what locator/assertion? "element not found"/"no such element" almost always means a WRONG LOCATOR on a screen that DOES exist \u2014 pick a stronger IDENTITY locator that is actually present in the captured tree: a resource-id, an accessibility-id/content-desc, or an EXACT @text= predicate (never a loose contains()). Do NOT declare a feature absent from one failed locator.
|
|
67987
|
+
2. STEP RESULTS: which steps passed before the failure.
|
|
67988
|
+
3. TREE: does the current screen match what the failed step expects?
|
|
67989
|
+
3b. STALE EMPTY-STATE ASSERT: a failing assert on one-time / data-dependent UI (empty-state CTAs like "Add Your First \u2026", "No items yet", onboarding banners) is NOT a locator problem \u2014 the element is gone because the account now has data. REPLACE the assertion with a durable landing-screen anchor (tab label, header, nav bar) that proves the same outcome (verdict fix).
|
|
67990
|
+
4. ENTRY-SCREEN DRIFT ("unexpected screen"/"screen drift"): the app started on a DIFFERENT screen than recorded; the fix is usually a MISSING NAVIGATION step (e.g. tap "Get Started" before the recorded first step). Author it from the tree if you can (verdict fix); if a single static tree is insufficient, return needs_device.
|
|
67991
|
+
## Response \u2014 STRICT JSON, exactly one verdict:
|
|
67992
|
+
{"verdict":"fix","steps":[<FULL healed MobileTestStep array, all steps, your changes applied, order/metadata preserved>],"reason":"what changed and why","confidence":0.0-1.0}
|
|
67993
|
+
{"verdict":"app_bug","reason":"app crashed/blank/5xx (NOT rate-limit)"}
|
|
67994
|
+
{"verdict":"config_issue","reason":"429/rate limit/lockout/quota"}
|
|
67995
|
+
{"verdict":"needs_device","reason":"cannot fix from a static tree; need live re-observation"}
|
|
67996
|
+
{"verdict":"prereq_unmet","reason":"required entity/state absent for the account"}
|
|
67997
|
+
{"verdict":"state_stale","reason":"leftover data blocks a baseline assertion"}
|
|
67998
|
+
{"verdict":"test_invalid","reason":"scenario cannot be made to pass"}
|
|
67999
|
+
For a fix, return the COMPLETE steps array (not a diff).`;
|
|
68000
|
+
var DEFAULT_SCRIPT_MAX_ATTEMPTS = 6;
|
|
68001
|
+
var RECOVERABLE_MAX = 3;
|
|
68002
|
+
var BONUS_ATTEMPTS_CEIL = 4;
|
|
68003
|
+
var DEFAULT_BONUS_ATTEMPTS = 2;
|
|
68004
|
+
var MAX_LOG_CHARS = 4096;
|
|
68005
|
+
var OBSERVATION_MAX_ELEMENTS = 120;
|
|
68006
|
+
var REGISTRY_PREFLIGHT_MAX_CANDIDATES = 2;
|
|
68007
|
+
var MOBILE_HEAL_VERDICTS = [
|
|
68008
|
+
"fix",
|
|
68009
|
+
"app_bug",
|
|
68010
|
+
"config_issue",
|
|
68011
|
+
"needs_device",
|
|
68012
|
+
"prereq_unmet",
|
|
68013
|
+
"state_stale",
|
|
68014
|
+
"test_invalid",
|
|
68015
|
+
"unhealable_dynamic"
|
|
68016
|
+
];
|
|
68017
|
+
var TERMINAL_VERDICTS = /* @__PURE__ */ new Set([
|
|
68018
|
+
"app_bug",
|
|
68019
|
+
"config_issue",
|
|
68020
|
+
"prereq_unmet",
|
|
68021
|
+
"state_stale",
|
|
68022
|
+
"test_invalid",
|
|
68023
|
+
"unhealable_dynamic"
|
|
68024
|
+
]);
|
|
68025
|
+
function isRecord(value) {
|
|
68026
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
68027
|
+
}
|
|
68028
|
+
function envInt2(key) {
|
|
68029
|
+
const raw = process.env[key];
|
|
68030
|
+
if (raw === void 0)
|
|
68031
|
+
return void 0;
|
|
68032
|
+
const parsed = Number.parseInt(raw, 10);
|
|
68033
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
68034
|
+
}
|
|
68035
|
+
function tailLimit(text, max) {
|
|
68036
|
+
return text.length <= max ? text : text.slice(text.length - max);
|
|
68037
|
+
}
|
|
68038
|
+
function isMobileHealVerdict(value) {
|
|
68039
|
+
return MOBILE_HEAL_VERDICTS.includes(value);
|
|
68040
|
+
}
|
|
68041
|
+
function isLocatorNotFound(error2) {
|
|
68042
|
+
return /not found|no such element/i.test(error2 ?? "");
|
|
68043
|
+
}
|
|
68044
|
+
function isDrift(error2) {
|
|
68045
|
+
return /unexpected screen|screen drift/i.test(error2 ?? "");
|
|
68046
|
+
}
|
|
68047
|
+
function stripCodeFences(text) {
|
|
68048
|
+
const trimmed = text.trim();
|
|
68049
|
+
const fenced = /^```(?:json)?\s*([\s\S]*?)\s*```$/m.exec(trimmed);
|
|
68050
|
+
return fenced ? fenced[1].trim() : trimmed;
|
|
68051
|
+
}
|
|
68052
|
+
function extractBracesSubstring(text) {
|
|
68053
|
+
const first = text.indexOf("{");
|
|
68054
|
+
const last = text.lastIndexOf("}");
|
|
68055
|
+
if (first === -1 || last === -1 || last <= first)
|
|
68056
|
+
return null;
|
|
68057
|
+
return text.slice(first, last + 1);
|
|
68058
|
+
}
|
|
68059
|
+
function safeJsonParse(text) {
|
|
68060
|
+
try {
|
|
68061
|
+
return JSON.parse(text);
|
|
68062
|
+
} catch {
|
|
68063
|
+
return void 0;
|
|
68064
|
+
}
|
|
68065
|
+
}
|
|
68066
|
+
function coerceSteps(value) {
|
|
68067
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
68068
|
+
return void 0;
|
|
68069
|
+
const allValid = value.every((step) => isRecord(step) && typeof step.action === "string" && typeof step.order === "number");
|
|
68070
|
+
return allValid ? value : void 0;
|
|
68071
|
+
}
|
|
68072
|
+
function parseHealVerdict(content) {
|
|
68073
|
+
const cleaned = stripCodeFences(content);
|
|
68074
|
+
let obj = safeJsonParse(cleaned);
|
|
68075
|
+
if (!isRecord(obj)) {
|
|
68076
|
+
const sub = extractBracesSubstring(cleaned);
|
|
68077
|
+
obj = sub ? safeJsonParse(sub) : void 0;
|
|
68078
|
+
}
|
|
68079
|
+
if (!isRecord(obj))
|
|
68080
|
+
return null;
|
|
68081
|
+
const rawVerdict = obj.verdict;
|
|
68082
|
+
if (typeof rawVerdict !== "string" || !isMobileHealVerdict(rawVerdict))
|
|
68083
|
+
return null;
|
|
68084
|
+
return {
|
|
68085
|
+
verdict: rawVerdict,
|
|
68086
|
+
steps: coerceSteps(obj.steps),
|
|
68087
|
+
reason: typeof obj.reason === "string" ? obj.reason : void 0,
|
|
68088
|
+
confidence: typeof obj.confidence === "number" ? obj.confidence : void 0
|
|
68089
|
+
};
|
|
68090
|
+
}
|
|
68091
|
+
function partsToCandidate(parts) {
|
|
68092
|
+
switch (parts.kind) {
|
|
68093
|
+
case "accessibilityId":
|
|
68094
|
+
return { accessibilityId: parts.value };
|
|
68095
|
+
case "resourceId":
|
|
68096
|
+
return { resourceId: parts.value };
|
|
68097
|
+
case "text":
|
|
68098
|
+
case "contentDesc":
|
|
68099
|
+
return { text: parts.value };
|
|
68100
|
+
case "xpath":
|
|
68101
|
+
return { xpath: parts.value };
|
|
68102
|
+
case "className":
|
|
68103
|
+
return { className: parts.value };
|
|
68104
|
+
default:
|
|
68105
|
+
return {};
|
|
68106
|
+
}
|
|
68107
|
+
}
|
|
68108
|
+
function hasIdentitySignal(candidate) {
|
|
68109
|
+
return Boolean(candidate.accessibilityId || candidate.resourceId || candidate.text || candidate.xpath);
|
|
68110
|
+
}
|
|
68111
|
+
function stepToLocatorCandidate(step) {
|
|
68112
|
+
const primary = step.target?.primary;
|
|
68113
|
+
if (primary) {
|
|
68114
|
+
const parsed = (0, selector_registry_context_js_1.parseMobileLocatorExpression)(primary);
|
|
68115
|
+
if (parsed) {
|
|
68116
|
+
const candidate = partsToCandidate(parsed);
|
|
68117
|
+
if (hasIdentitySignal(candidate))
|
|
68118
|
+
return candidate;
|
|
68119
|
+
}
|
|
68120
|
+
}
|
|
68121
|
+
const bundle = step.target?.locatorBundle;
|
|
68122
|
+
if (bundle) {
|
|
68123
|
+
const candidate = {};
|
|
68124
|
+
if (bundle.accessibilityId)
|
|
68125
|
+
candidate.accessibilityId = bundle.accessibilityId;
|
|
68126
|
+
if (bundle.resourceId)
|
|
68127
|
+
candidate.resourceId = bundle.resourceId;
|
|
68128
|
+
if (bundle.text)
|
|
68129
|
+
candidate.text = bundle.text;
|
|
68130
|
+
else if (bundle.contentDesc)
|
|
68131
|
+
candidate.text = bundle.contentDesc;
|
|
68132
|
+
if (bundle.xpath)
|
|
68133
|
+
candidate.xpath = bundle.xpath;
|
|
68134
|
+
if (hasIdentitySignal(candidate))
|
|
68135
|
+
return candidate;
|
|
68136
|
+
}
|
|
68137
|
+
return null;
|
|
68138
|
+
}
|
|
68139
|
+
function stepIdentityExpressions(step) {
|
|
68140
|
+
const out = [];
|
|
68141
|
+
const primary = step.target?.primary;
|
|
68142
|
+
if (primary)
|
|
68143
|
+
out.push(primary);
|
|
68144
|
+
const bundle = step.target?.locatorBundle;
|
|
68145
|
+
if (bundle) {
|
|
68146
|
+
if (bundle.resourceId)
|
|
68147
|
+
out.push(`mobile.resourceId('${bundle.resourceId}')`);
|
|
68148
|
+
if (bundle.accessibilityId)
|
|
68149
|
+
out.push(`mobile.accessibilityId('${bundle.accessibilityId}')`);
|
|
68150
|
+
if (bundle.text)
|
|
68151
|
+
out.push(`mobile.text('${bundle.text}')`);
|
|
68152
|
+
if (bundle.contentDesc)
|
|
68153
|
+
out.push(`mobile.contentDesc('${bundle.contentDesc}')`);
|
|
68154
|
+
if (bundle.xpath)
|
|
68155
|
+
out.push(`mobile.xpath('${bundle.xpath}')`);
|
|
68156
|
+
}
|
|
68157
|
+
return out;
|
|
68158
|
+
}
|
|
68159
|
+
function stepTargetChanged(base2, healed) {
|
|
68160
|
+
return JSON.stringify(base2?.target) !== JSON.stringify(healed.target);
|
|
68161
|
+
}
|
|
68162
|
+
function findMissingChangedLocators(baseSteps, healedSteps, screen) {
|
|
68163
|
+
const missing = [];
|
|
68164
|
+
healedSteps.forEach((healed, index) => {
|
|
68165
|
+
if (!stepTargetChanged(baseSteps[index], healed))
|
|
68166
|
+
return;
|
|
68167
|
+
const candidate = stepToLocatorCandidate(healed);
|
|
68168
|
+
if (!candidate)
|
|
68169
|
+
return;
|
|
68170
|
+
if ((0, mobile_source_parser_js_1.resolveLocatorAgainstScreen)(candidate, screen).length === 0) {
|
|
68171
|
+
missing.push({
|
|
68172
|
+
label: healed.target?.primary ?? JSON.stringify(candidate),
|
|
68173
|
+
expressions: stepIdentityExpressions(healed)
|
|
68174
|
+
});
|
|
68175
|
+
}
|
|
68176
|
+
});
|
|
68177
|
+
return missing;
|
|
68178
|
+
}
|
|
68179
|
+
function changedStepExpressions(baseSteps, healedSteps) {
|
|
68180
|
+
const out = [];
|
|
68181
|
+
healedSteps.forEach((healed, index) => {
|
|
68182
|
+
if (stepTargetChanged(baseSteps[index], healed))
|
|
68183
|
+
out.push(...stepIdentityExpressions(healed));
|
|
68184
|
+
});
|
|
68185
|
+
return out;
|
|
68186
|
+
}
|
|
68187
|
+
function pushUnique(target, additions) {
|
|
68188
|
+
for (const value of additions) {
|
|
68189
|
+
if (value && !target.includes(value))
|
|
68190
|
+
target.push(value);
|
|
68191
|
+
}
|
|
68192
|
+
}
|
|
68193
|
+
function buildUserContent(args) {
|
|
68194
|
+
const parts = [];
|
|
68195
|
+
const safeError = (0, mobile_heal_postprocess_js_1.redactMobileSecretsFromText)(args.activeError ?? void 0, args.testVariables);
|
|
68196
|
+
const safeLogs = (0, mobile_heal_postprocess_js_1.redactMobileSecretsFromText)(args.trimmedLogs, args.testVariables);
|
|
68197
|
+
parts.push("## Failing test steps (JSON)");
|
|
68198
|
+
parts.push("```json\n" + JSON.stringify(args.baseSteps, null, 2) + "\n```");
|
|
68199
|
+
parts.push("## Steps (numbered)");
|
|
68200
|
+
parts.push(args.baseSteps.map((step, index) => {
|
|
68201
|
+
const locator = step.target?.primary ? ` -> ${step.target.primary}` : "";
|
|
68202
|
+
return `${index + 1}. [${step.action}] ${step.description ?? ""}${locator}`;
|
|
68203
|
+
}).join("\n"));
|
|
68204
|
+
parts.push("## Failure");
|
|
68205
|
+
parts.push(`Error: ${safeError ?? "(none reported)"}`);
|
|
68206
|
+
if (safeLogs)
|
|
68207
|
+
parts.push("Logs (tail):\n" + safeLogs);
|
|
68208
|
+
if (args.activeFailingSource) {
|
|
68209
|
+
const safeSource = (0, mobile_heal_postprocess_js_1.redactMobileSecretsFromText)(args.activeFailingSource, args.testVariables) ?? args.activeFailingSource;
|
|
68210
|
+
const screen = (0, mobile_source_parser_js_1.parseMobileSource)(safeSource, args.platform);
|
|
68211
|
+
parts.push("## Captured screen (accessibility tree at moment of failure)");
|
|
68212
|
+
parts.push((0, mobile_observation_js_1.renderMobileObservation)(screen, { maxElements: OBSERVATION_MAX_ELEMENTS }));
|
|
68213
|
+
}
|
|
68214
|
+
if (args.attempt === 1) {
|
|
68215
|
+
const registryBlock = (0, selector_registry_context_js_1.formatSelectorRegistryContextForPrompt)(args.registryContext);
|
|
68216
|
+
if (registryBlock)
|
|
68217
|
+
parts.push(registryBlock);
|
|
68218
|
+
} else {
|
|
68219
|
+
const candidateBlock = (0, selector_registry_context_js_1.buildRegistryCandidateBlock)(args.registryContext, [...args.triedLocators]);
|
|
68220
|
+
if (candidateBlock)
|
|
68221
|
+
parts.push(candidateBlock);
|
|
68222
|
+
if (args.triedLocators.length > 0) {
|
|
68223
|
+
parts.push("## Locators already tried (do NOT repeat):\n" + args.triedLocators.map((locator) => `- ${locator}`).join("\n"));
|
|
68224
|
+
}
|
|
68225
|
+
const safeLastError = (0, mobile_heal_postprocess_js_1.redactMobileSecretsFromText)(args.lastError, args.testVariables);
|
|
68226
|
+
if (safeLastError)
|
|
68227
|
+
parts.push(`## Previous fix failed with:
|
|
68228
|
+
${safeLastError}`);
|
|
68229
|
+
}
|
|
68230
|
+
if (args.directive)
|
|
68231
|
+
parts.push(`## Directive
|
|
68232
|
+
${args.directive}`);
|
|
68233
|
+
return parts.join("\n\n");
|
|
68234
|
+
}
|
|
68235
|
+
function findFailingStepIndex(steps, error2) {
|
|
68236
|
+
const withTarget = steps.map((step, index) => ({ step, index })).filter((entry) => Boolean(entry.step.target?.primary));
|
|
68237
|
+
if (withTarget.length === 0)
|
|
68238
|
+
return -1;
|
|
68239
|
+
if (error2) {
|
|
68240
|
+
for (let k = withTarget.length - 1; k >= 0; k -= 1) {
|
|
68241
|
+
const primary = withTarget[k].step.target?.primary;
|
|
68242
|
+
if (primary && error2.includes(primary))
|
|
68243
|
+
return withTarget[k].index;
|
|
68244
|
+
}
|
|
68245
|
+
}
|
|
68246
|
+
return withTarget[withTarget.length - 1].index;
|
|
68247
|
+
}
|
|
68248
|
+
function substituteStepTarget(steps, index, candidate, bundlePartial) {
|
|
68249
|
+
const existing = steps[index].target;
|
|
68250
|
+
const newBundle = {
|
|
68251
|
+
xpath: existing?.locatorBundle?.xpath ?? "",
|
|
68252
|
+
className: existing?.locatorBundle?.className ?? "",
|
|
68253
|
+
...existing?.locatorBundle,
|
|
68254
|
+
...bundlePartial
|
|
68255
|
+
};
|
|
68256
|
+
const escaped = candidate.value.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
68257
|
+
const newTarget = {
|
|
68258
|
+
primary: `mobile.${candidate.kind}('${escaped}')`,
|
|
68259
|
+
fallbacks: existing?.fallbacks ?? [],
|
|
68260
|
+
screenName: existing?.screenName ?? "",
|
|
68261
|
+
locatorBundle: newBundle,
|
|
68262
|
+
platformLocators: existing?.platformLocators
|
|
68263
|
+
};
|
|
68264
|
+
return steps.map((step, i) => i === index ? { ...step, target: newTarget } : step);
|
|
68265
|
+
}
|
|
68266
|
+
async function tryRegistryPreflight(steps, target, ctx, options) {
|
|
68267
|
+
const runNativeTest = options.runNativeTest;
|
|
68268
|
+
if (!runNativeTest || !options.selectorRegistryContext || !ctx.error)
|
|
68269
|
+
return null;
|
|
68270
|
+
const candidates = (0, selector_registry_context_js_1.collectMobileRegistryCandidates)(options.selectorRegistryContext);
|
|
68271
|
+
const failingIndex = findFailingStepIndex(steps, ctx.error);
|
|
68272
|
+
if (failingIndex < 0)
|
|
68273
|
+
return null;
|
|
68274
|
+
let tried = 0;
|
|
68275
|
+
for (const candidate of candidates) {
|
|
68276
|
+
if (tried >= REGISTRY_PREFLIGHT_MAX_CANDIDATES)
|
|
68277
|
+
break;
|
|
68278
|
+
const mapped = (0, selector_registry_context_js_1.mobileCandidateToTarget)(candidate);
|
|
68279
|
+
if (!mapped.locatorBundle || Object.keys(mapped.locatorBundle).length === 0)
|
|
68280
|
+
continue;
|
|
68281
|
+
tried += 1;
|
|
68282
|
+
const healedSteps = substituteStepTarget(steps, failingIndex, candidate, mapped.locatorBundle);
|
|
68283
|
+
const verify = await runNativeTest({ steps: healedSteps, target, testVariables: ctx.testVariables });
|
|
68284
|
+
if (verify.passed) {
|
|
68285
|
+
return {
|
|
68286
|
+
passed: true,
|
|
68287
|
+
verdict: "fix",
|
|
68288
|
+
healedSteps,
|
|
68289
|
+
healReason: "registry-fallback",
|
|
68290
|
+
stepResults: verify.stepResults,
|
|
68291
|
+
logs: verify.logs
|
|
68292
|
+
};
|
|
68293
|
+
}
|
|
68294
|
+
}
|
|
68295
|
+
return null;
|
|
68296
|
+
}
|
|
68297
|
+
async function executeMobileScriptDrivenHeal(steps, target, ctx, options) {
|
|
68298
|
+
const aiClient = options.aiClient ?? (options.model ? (0, ai_provider_js_1.getMobileClientForModel)(options.model) : (0, ai_provider_js_1.getMobileAIClient)());
|
|
68299
|
+
const model = options.model ? (0, ai_provider_js_1.resolveModelForTask)(options.model, "strong") : (0, ai_provider_js_1.getModel)("strong");
|
|
68300
|
+
const base2 = options.maxScriptAttempts ?? envInt2("MOBILE_HEAL_SCRIPT_MAX_ATTEMPTS") ?? DEFAULT_SCRIPT_MAX_ATTEMPTS;
|
|
68301
|
+
const bonusMax = Math.min(options.bonusAttempts ?? DEFAULT_BONUS_ATTEMPTS, BONUS_ATTEMPTS_CEIL);
|
|
68302
|
+
const registryPresent = options.selectorRegistryContext != null;
|
|
68303
|
+
const platform3 = target.platform;
|
|
68304
|
+
const trimmedLogs = tailLimit(ctx.logs ?? "", MAX_LOG_CHARS);
|
|
68305
|
+
let attemptCap = base2;
|
|
68306
|
+
let recoverableUsed = 0;
|
|
68307
|
+
let bonusUsed = 0;
|
|
68308
|
+
let attempt = 0;
|
|
68309
|
+
let baseSteps = steps;
|
|
68310
|
+
let activeError = ctx.error;
|
|
68311
|
+
let activeFailingSource = ctx.failingSource;
|
|
68312
|
+
let lastError;
|
|
68313
|
+
let lastHealedSteps;
|
|
68314
|
+
let lastHealReason;
|
|
68315
|
+
let lastConfidence;
|
|
68316
|
+
let lastVerdict;
|
|
68317
|
+
let pendingDirective = null;
|
|
68318
|
+
const triedLocators = [];
|
|
68319
|
+
let sameErrorCount = 0;
|
|
68320
|
+
let lastErrorSignature = null;
|
|
68321
|
+
const markRecoverableTurn = () => {
|
|
68322
|
+
if (recoverableUsed < RECOVERABLE_MAX) {
|
|
68323
|
+
attemptCap += 1;
|
|
68324
|
+
recoverableUsed += 1;
|
|
68325
|
+
}
|
|
68326
|
+
};
|
|
68327
|
+
const noteError = (error2) => {
|
|
68328
|
+
const signature = (error2 ?? "").slice(0, 150);
|
|
68329
|
+
if (signature && signature === lastErrorSignature) {
|
|
68330
|
+
sameErrorCount += 1;
|
|
68331
|
+
} else {
|
|
68332
|
+
sameErrorCount = error2 ? 1 : 0;
|
|
68333
|
+
lastErrorSignature = signature;
|
|
68334
|
+
}
|
|
68335
|
+
};
|
|
68336
|
+
for (; ; ) {
|
|
68337
|
+
if (attempt >= attemptCap) {
|
|
68338
|
+
const untriedRegistry = registryPresent && (0, selector_registry_context_js_1.buildRegistryCandidateBlock)(options.selectorRegistryContext, triedLocators) !== "";
|
|
68339
|
+
const canBonus = bonusUsed < bonusMax && lastHealedSteps !== void 0 && sameErrorCount < 2 && untriedRegistry;
|
|
68340
|
+
if (canBonus) {
|
|
68341
|
+
attemptCap += 1;
|
|
68342
|
+
bonusUsed += 1;
|
|
68343
|
+
} else {
|
|
68344
|
+
break;
|
|
68345
|
+
}
|
|
68346
|
+
}
|
|
68347
|
+
attempt += 1;
|
|
68348
|
+
const userContent = buildUserContent({
|
|
68349
|
+
attempt,
|
|
68350
|
+
baseSteps,
|
|
68351
|
+
activeError,
|
|
68352
|
+
trimmedLogs,
|
|
68353
|
+
activeFailingSource,
|
|
68354
|
+
platform: platform3,
|
|
68355
|
+
registryContext: options.selectorRegistryContext ?? null,
|
|
68356
|
+
triedLocators,
|
|
68357
|
+
lastError,
|
|
68358
|
+
directive: pendingDirective,
|
|
68359
|
+
testVariables: ctx.testVariables
|
|
68360
|
+
});
|
|
68361
|
+
pendingDirective = null;
|
|
68362
|
+
const messages = [
|
|
68363
|
+
{ role: "system", content: exports.MOBILE_SCRIPT_HEAL_SYSTEM_PROMPT },
|
|
68364
|
+
{ role: "user", content: userContent }
|
|
68365
|
+
];
|
|
68366
|
+
let content;
|
|
68367
|
+
try {
|
|
68368
|
+
const response = await (0, ai_retry_js_1.resilientAICall)((signal, arm) => (0, ai_queue_js_1.queuedAICall)(() => {
|
|
68369
|
+
arm();
|
|
68370
|
+
return aiClient.chat.completions.create({ model, messages, max_tokens: 8e3, temperature: 0.1 }, { signal });
|
|
68371
|
+
}), { label: `mobile-heal-attempt-${attempt}`, deferTimeoutUntilArmed: true });
|
|
68372
|
+
content = response?.choices?.[0]?.message?.content ?? "";
|
|
68373
|
+
} catch {
|
|
68374
|
+
markRecoverableTurn();
|
|
68375
|
+
pendingDirective = "The previous attempt did not reach the model. Re-analyze and return one valid JSON verdict.";
|
|
68376
|
+
continue;
|
|
68377
|
+
}
|
|
68378
|
+
const parsed = parseHealVerdict(content);
|
|
68379
|
+
if (!parsed) {
|
|
68380
|
+
markRecoverableTurn();
|
|
68381
|
+
pendingDirective = "Your last response was not valid JSON matching the verdict schema. Return exactly one JSON verdict object.";
|
|
68382
|
+
continue;
|
|
68383
|
+
}
|
|
68384
|
+
if (TERMINAL_VERDICTS.has(parsed.verdict)) {
|
|
68385
|
+
return { passed: false, verdict: parsed.verdict, healReason: parsed.reason, attemptsUsed: attempt };
|
|
68386
|
+
}
|
|
68387
|
+
if (parsed.verdict === "needs_device") {
|
|
68388
|
+
const isFinalAttempt = attempt >= attemptCap && recoverableUsed >= RECOVERABLE_MAX;
|
|
68389
|
+
if (!isFinalAttempt) {
|
|
68390
|
+
markRecoverableTurn();
|
|
68391
|
+
pendingDirective = "You returned needs_device but MUST try a step/locator fix first \u2014 this is not your final attempt. Re-analyze the captured tree and return a concrete fix.";
|
|
68392
|
+
continue;
|
|
68393
|
+
}
|
|
68394
|
+
return {
|
|
68395
|
+
passed: false,
|
|
68396
|
+
verdict: "needs_device",
|
|
68397
|
+
healedSteps: lastHealedSteps,
|
|
68398
|
+
healReason: parsed.reason,
|
|
68399
|
+
attemptsUsed: attempt,
|
|
68400
|
+
verifiedFallbackAvailable: lastHealedSteps !== void 0
|
|
68401
|
+
};
|
|
68402
|
+
}
|
|
68403
|
+
const healedSteps = parsed.steps;
|
|
68404
|
+
if (!healedSteps) {
|
|
68405
|
+
markRecoverableTurn();
|
|
68406
|
+
pendingDirective = 'You returned verdict "fix" but no usable steps array. Return the COMPLETE healed MobileTestStep array.';
|
|
68407
|
+
continue;
|
|
68408
|
+
}
|
|
68409
|
+
if (activeFailingSource && isLocatorNotFound(activeError) && !isDrift(activeError)) {
|
|
68410
|
+
const screen = (0, mobile_source_parser_js_1.parseMobileSource)(activeFailingSource, platform3);
|
|
68411
|
+
const missing = findMissingChangedLocators(baseSteps, healedSteps, screen);
|
|
68412
|
+
if (missing.length > 0) {
|
|
68413
|
+
for (const entry of missing)
|
|
68414
|
+
pushUnique(triedLocators, entry.expressions);
|
|
68415
|
+
markRecoverableTurn();
|
|
68416
|
+
lastVerdict = "fix";
|
|
68417
|
+
pendingDirective = `Your proposed locator ${missing[0].label} does NOT exist in the captured screen tree. Pick an identity locator (resource-id, accessibility-id, or exact @text=) that is PRESENT in the tree.`;
|
|
68418
|
+
continue;
|
|
68419
|
+
}
|
|
68420
|
+
}
|
|
68421
|
+
if (!options.runNativeTest) {
|
|
68422
|
+
lastHealedSteps = healedSteps;
|
|
68423
|
+
lastHealReason = parsed.reason;
|
|
68424
|
+
lastConfidence = parsed.confidence;
|
|
68425
|
+
lastVerdict = "fix";
|
|
68426
|
+
pushUnique(triedLocators, changedStepExpressions(baseSteps, healedSteps));
|
|
68427
|
+
baseSteps = healedSteps;
|
|
68428
|
+
pendingDirective = "The proposed fix could not be device-verified here. If it is not clearly correct, revise it.";
|
|
68429
|
+
continue;
|
|
68430
|
+
}
|
|
68431
|
+
const verify = await options.runNativeTest({ steps: healedSteps, target, testVariables: ctx.testVariables });
|
|
68432
|
+
if (verify.passed) {
|
|
68433
|
+
return {
|
|
68434
|
+
passed: true,
|
|
68435
|
+
verdict: "fix",
|
|
68436
|
+
healedSteps,
|
|
68437
|
+
healReason: parsed.reason,
|
|
68438
|
+
confidence: parsed.confidence,
|
|
68439
|
+
attemptsUsed: attempt
|
|
68440
|
+
};
|
|
68441
|
+
}
|
|
68442
|
+
lastError = verify.error ?? lastError;
|
|
68443
|
+
lastHealedSteps = healedSteps;
|
|
68444
|
+
lastHealReason = parsed.reason;
|
|
68445
|
+
lastConfidence = parsed.confidence;
|
|
68446
|
+
lastVerdict = "fix";
|
|
68447
|
+
noteError(verify.error);
|
|
68448
|
+
pushUnique(triedLocators, changedStepExpressions(baseSteps, healedSteps));
|
|
68449
|
+
if (verify.failingSource)
|
|
68450
|
+
activeFailingSource = verify.failingSource;
|
|
68451
|
+
activeError = verify.error ?? activeError;
|
|
68452
|
+
baseSteps = healedSteps;
|
|
68453
|
+
}
|
|
68454
|
+
return {
|
|
68455
|
+
passed: false,
|
|
68456
|
+
verdict: lastVerdict ?? "fix",
|
|
68457
|
+
healedSteps: lastHealedSteps,
|
|
68458
|
+
healReason: lastHealReason,
|
|
68459
|
+
confidence: lastConfidence,
|
|
68460
|
+
attemptsUsed: attempt,
|
|
68461
|
+
lastError,
|
|
68462
|
+
verifiedFallbackAvailable: lastHealedSteps !== void 0 ? false : void 0
|
|
68463
|
+
};
|
|
68464
|
+
}
|
|
68465
|
+
async function executeMobileTestWithHealing2(steps, target, ctx, options) {
|
|
68466
|
+
const preflight = await tryRegistryPreflight(steps, target, ctx, options);
|
|
68467
|
+
if (preflight)
|
|
68468
|
+
return preflight;
|
|
68469
|
+
const script = await executeMobileScriptDrivenHeal(steps, target, ctx, options);
|
|
68470
|
+
const shouldEscalate = script.verdict === "needs_device" || !script.passed;
|
|
68471
|
+
if (shouldEscalate && options.runLiveHeal) {
|
|
68472
|
+
return options.runLiveHeal({
|
|
68473
|
+
steps: script.healedSteps ?? steps,
|
|
68474
|
+
target,
|
|
68475
|
+
testVariables: ctx.testVariables,
|
|
68476
|
+
options
|
|
68477
|
+
});
|
|
68478
|
+
}
|
|
68479
|
+
return {
|
|
68480
|
+
passed: script.passed,
|
|
68481
|
+
healedSteps: script.healedSteps,
|
|
68482
|
+
healedAppiumCode: script.healedAppiumCode,
|
|
68483
|
+
healReason: script.healReason,
|
|
68484
|
+
verdict: script.verdict,
|
|
68485
|
+
confidence: script.confidence,
|
|
68486
|
+
extraTags: script.extraTags,
|
|
68487
|
+
removeTags: script.removeTags
|
|
68488
|
+
};
|
|
68489
|
+
}
|
|
68490
|
+
var DEFAULT_PHASE2_MAX_PASSES = 6;
|
|
68491
|
+
exports.MOBILE_LIVE_HEAL_SYSTEM_PROMPT = `You are a QA engineer fixing a failing Appium (mobile UI automation) test with LIVE device access (Phase 2). You receive: the failing test STEPS as JSON, the PRIOR failure error, and the LIVE current screen accessibility tree observed on-device RIGHT NOW. Unlike a frozen failure snapshot, this LIVE tree is the REAL screen the app is on this instant.
|
|
68492
|
+
## Key insight \u2014 ENTRY-SCREEN DRIFT
|
|
68493
|
+
The recorded flow may have expected a DIFFERENT starting screen than the one shown. When the LIVE screen is an earlier/other screen (e.g. an onboarding or "Get Started" screen), the fix is almost always a MISSING NAVIGATION step: AUTHOR the leading step(s) (e.g. a tap on "Get Started") that reach the recorded first screen, then keep the recorded steps. This is exactly what a static failing-source cannot reveal but a LIVE screen can.
|
|
68494
|
+
## Analyze
|
|
68495
|
+
1. Compare the recorded first step's expected screen to the LIVE tree.
|
|
68496
|
+
2. If they differ, PREPEND the missing navigation step(s), authored from IDENTITY locators (resource-id, accessibility-id, or EXACT @text=) that are PRESENT in the LIVE tree \u2014 never a loose contains().
|
|
68497
|
+
3. If a locator is simply wrong, swap it for a stronger identity locator present in the LIVE tree.
|
|
68498
|
+
3b. If the failing step ASSERTS one-time / data-dependent UI (an empty-state CTA like "Add Your First \u2026") that is absent from the LIVE tree while the screen is otherwise correct, the assert is STALE \u2014 replace it with a durable element of the same screen (tab label, header, nav bar) and keep the rest.
|
|
68499
|
+
4. If you cannot yet SEE the screen you need, use "observe" to advance ONE step, then you will be re-shown the new live screen.
|
|
68500
|
+
## Response \u2014 STRICT JSON, exactly one verdict:
|
|
68501
|
+
{"verdict":"fix","steps":[<FULL healed MobileTestStep array, all steps incl. any prepended navigation, order/metadata coherent>],"reason":"what changed and why","confidence":0.0-1.0}
|
|
68502
|
+
{"verdict":"observe","action":{"type":"tap","target":"mobile.text('Get Started')"}}
|
|
68503
|
+
{"verdict":"observe","action":{"type":"back"}}
|
|
68504
|
+
{"verdict":"observe","action":{"type":"relaunch"}}
|
|
68505
|
+
{"verdict":"observe","action":{"type":"reset"}} \u2190 clears app data + cold-relaunches: use when the app is in the WRONG STATE for the recorded flow (e.g. signed in when the test expects the cleared first-launch screens, stale onboarding, poisoned local state)
|
|
68506
|
+
{"verdict":"app_bug","reason":"app crashed/blank/5xx (NOT rate-limit)"}
|
|
68507
|
+
{"verdict":"config_issue","reason":"429/rate limit/lockout/quota"}
|
|
68508
|
+
{"verdict":"needs_device","reason":"cannot resolve even with live access"}
|
|
68509
|
+
{"verdict":"prereq_unmet","reason":"required entity/state absent for the account"}
|
|
68510
|
+
{"verdict":"state_stale","reason":"leftover data blocks a baseline assertion"}
|
|
68511
|
+
{"verdict":"test_invalid","reason":"scenario cannot be made to pass"}
|
|
68512
|
+
{"verdict":"unhealable_dynamic","reason":"assertion targets non-durable dynamic content"}
|
|
68513
|
+
For a fix, return the COMPLETE steps array (not a diff). Use "observe" only to reveal a screen you cannot yet see; prefer "fix" as soon as the LIVE tree is enough. "observe" with type "tap" REQUIRES a target locator expression; "back"/"relaunch" take no target.`;
|
|
68514
|
+
function parseLiveObserveAction(content) {
|
|
68515
|
+
const cleaned = stripCodeFences(content);
|
|
68516
|
+
let obj = safeJsonParse(cleaned);
|
|
68517
|
+
if (!isRecord(obj)) {
|
|
68518
|
+
const sub = extractBracesSubstring(cleaned);
|
|
68519
|
+
obj = sub ? safeJsonParse(sub) : void 0;
|
|
68520
|
+
}
|
|
68521
|
+
if (!isRecord(obj) || obj.verdict !== "observe")
|
|
68522
|
+
return null;
|
|
68523
|
+
const action = obj.action;
|
|
68524
|
+
if (!isRecord(action))
|
|
68525
|
+
return null;
|
|
68526
|
+
const type = action.type;
|
|
68527
|
+
if (type !== "tap" && type !== "back" && type !== "relaunch" && type !== "reset")
|
|
68528
|
+
return null;
|
|
68529
|
+
const target = typeof action.target === "string" ? action.target : void 0;
|
|
68530
|
+
return { type, target };
|
|
68531
|
+
}
|
|
68532
|
+
async function applyLiveObserveAction(driver, action, screen) {
|
|
68533
|
+
if (action.type === "back") {
|
|
68534
|
+
await driver.back();
|
|
68535
|
+
return;
|
|
68536
|
+
}
|
|
68537
|
+
if (action.type === "relaunch") {
|
|
68538
|
+
await driver.relaunch();
|
|
68539
|
+
return;
|
|
68540
|
+
}
|
|
68541
|
+
if (action.type === "reset") {
|
|
68542
|
+
const cleared = await driver.resetAppState();
|
|
68543
|
+
if (!cleared)
|
|
68544
|
+
await driver.relaunch();
|
|
68545
|
+
return;
|
|
68546
|
+
}
|
|
68547
|
+
if (!action.target)
|
|
68548
|
+
return;
|
|
68549
|
+
const parts = (0, selector_registry_context_js_1.parseMobileLocatorExpression)(action.target);
|
|
68550
|
+
if (!parts)
|
|
68551
|
+
return;
|
|
68552
|
+
const candidate = partsToCandidate(parts);
|
|
68553
|
+
if (!hasIdentitySignal(candidate))
|
|
68554
|
+
return;
|
|
68555
|
+
const first = (0, mobile_source_parser_js_1.resolveLocatorAgainstScreen)(candidate, screen)[0];
|
|
68556
|
+
if (first)
|
|
68557
|
+
await driver.tap(first.bounds);
|
|
68558
|
+
}
|
|
68559
|
+
function buildLiveUserContent(args) {
|
|
68560
|
+
const parts = [];
|
|
68561
|
+
parts.push("## Failing test steps (JSON)");
|
|
68562
|
+
parts.push("```json\n" + JSON.stringify(args.steps, null, 2) + "\n```");
|
|
68563
|
+
parts.push("## Prior failure");
|
|
68564
|
+
parts.push(`Error: ${args.priorError ?? "(none reported)"}`);
|
|
68565
|
+
parts.push("## LIVE current screen (accessibility tree observed on-device NOW)");
|
|
68566
|
+
parts.push(args.observation);
|
|
68567
|
+
return parts.join("\n\n");
|
|
68568
|
+
}
|
|
68569
|
+
async function executeMobileLiveHeal2(args) {
|
|
68570
|
+
const { target, testVariables, options } = args;
|
|
68571
|
+
const liveDriver = options.liveDriver;
|
|
68572
|
+
if (!liveDriver) {
|
|
68573
|
+
return { passed: false, verdict: "needs_device", healReason: "no live driver available" };
|
|
68574
|
+
}
|
|
68575
|
+
const runNativeTest = options.runNativeTest;
|
|
68576
|
+
if (!runNativeTest) {
|
|
68577
|
+
return { passed: false, verdict: "needs_device", healReason: "no native verify seam available" };
|
|
68578
|
+
}
|
|
68579
|
+
const aiClient = options.aiClient ?? (options.model ? (0, ai_provider_js_1.getMobileClientForModel)(options.model) : (0, ai_provider_js_1.getMobileAIClient)());
|
|
68580
|
+
const model = options.model ? (0, ai_provider_js_1.resolveModelForTask)(options.model, "agent") : (0, ai_provider_js_1.getModel)("agent");
|
|
68581
|
+
const maxPasses = envInt2("MOBILE_HEAL_PHASE2_MAX_PASSES") ?? DEFAULT_PHASE2_MAX_PASSES;
|
|
68582
|
+
let baseSteps = args.steps;
|
|
68583
|
+
let priorError = args.priorError ?? null;
|
|
68584
|
+
let bestSteps;
|
|
68585
|
+
let bestStepResults;
|
|
68586
|
+
for (let pass = 1; pass <= maxPasses; pass += 1) {
|
|
68587
|
+
const snap = await liveDriver.snapshot();
|
|
68588
|
+
const screen = (0, mobile_source_parser_js_1.parseMobileSource)(snap.xml, target.platform);
|
|
68589
|
+
const safeScreen = (0, mobile_source_parser_js_1.parseMobileSource)((0, mobile_heal_postprocess_js_1.redactMobileSecretsFromText)(snap.xml, testVariables) ?? snap.xml, target.platform);
|
|
68590
|
+
const observation = (0, mobile_observation_js_1.renderMobileObservation)(safeScreen, { maxElements: OBSERVATION_MAX_ELEMENTS });
|
|
68591
|
+
const messages = [
|
|
68592
|
+
{ role: "system", content: exports.MOBILE_LIVE_HEAL_SYSTEM_PROMPT },
|
|
68593
|
+
{
|
|
68594
|
+
role: "user",
|
|
68595
|
+
content: buildLiveUserContent({
|
|
68596
|
+
steps: baseSteps,
|
|
68597
|
+
priorError: (0, mobile_heal_postprocess_js_1.redactMobileSecretsFromText)(priorError ?? void 0, testVariables) ?? null,
|
|
68598
|
+
observation
|
|
68599
|
+
})
|
|
68600
|
+
}
|
|
68601
|
+
];
|
|
68602
|
+
let content;
|
|
68603
|
+
try {
|
|
68604
|
+
const response = await (0, ai_retry_js_1.resilientAICall)((signal, arm) => (0, ai_queue_js_1.queuedAICall)(() => {
|
|
68605
|
+
arm();
|
|
68606
|
+
return aiClient.chat.completions.create({ model, messages, max_tokens: 8e3, temperature: 0.1 }, { signal });
|
|
68607
|
+
}), { label: `mobile-live-heal-pass-${pass}`, deferTimeoutUntilArmed: true });
|
|
68608
|
+
content = response?.choices?.[0]?.message?.content ?? "";
|
|
68609
|
+
} catch {
|
|
68610
|
+
continue;
|
|
68611
|
+
}
|
|
68612
|
+
const observe = parseLiveObserveAction(content);
|
|
68613
|
+
if (observe) {
|
|
68614
|
+
await applyLiveObserveAction(liveDriver, observe, screen);
|
|
68615
|
+
continue;
|
|
68616
|
+
}
|
|
68617
|
+
const parsed = parseHealVerdict(content);
|
|
68618
|
+
if (!parsed)
|
|
68619
|
+
continue;
|
|
68620
|
+
if (TERMINAL_VERDICTS.has(parsed.verdict)) {
|
|
68621
|
+
return { passed: false, verdict: parsed.verdict, healReason: parsed.reason, healedSteps: bestSteps };
|
|
68622
|
+
}
|
|
68623
|
+
if (parsed.verdict !== "fix" || !parsed.steps)
|
|
68624
|
+
continue;
|
|
68625
|
+
const healedSteps = parsed.steps;
|
|
68626
|
+
const verify = await runNativeTest({ steps: healedSteps, target, testVariables });
|
|
68627
|
+
if (verify.passed) {
|
|
68628
|
+
return {
|
|
68629
|
+
passed: true,
|
|
68630
|
+
verdict: "fix",
|
|
68631
|
+
healedSteps,
|
|
68632
|
+
healReason: parsed.reason,
|
|
68633
|
+
confidence: parsed.confidence,
|
|
68634
|
+
stepResults: verify.stepResults
|
|
68635
|
+
};
|
|
68636
|
+
}
|
|
68637
|
+
baseSteps = healedSteps;
|
|
68638
|
+
bestSteps = healedSteps;
|
|
68639
|
+
bestStepResults = verify.stepResults;
|
|
68640
|
+
priorError = verify.error ?? priorError;
|
|
68641
|
+
}
|
|
68642
|
+
return {
|
|
68643
|
+
passed: false,
|
|
68644
|
+
verdict: "needs_device",
|
|
68645
|
+
healedSteps: bestSteps,
|
|
68646
|
+
healReason: "live heal exhausted",
|
|
68647
|
+
stepResults: bestStepResults
|
|
68648
|
+
};
|
|
68649
|
+
}
|
|
68650
|
+
}
|
|
68651
|
+
});
|
|
68652
|
+
|
|
67375
68653
|
// ../runner-core/dist/services/browser-config.js
|
|
67376
68654
|
var require_browser_config = __commonJS({
|
|
67377
68655
|
"../runner-core/dist/services/browser-config.js"(exports) {
|
|
@@ -293120,282 +294398,6 @@ var require_preflight_syntax = __commonJS({
|
|
|
293120
294398
|
}
|
|
293121
294399
|
});
|
|
293122
294400
|
|
|
293123
|
-
// ../runner-core/dist/services/selector-registry-context.js
|
|
293124
|
-
var require_selector_registry_context = __commonJS({
|
|
293125
|
-
"../runner-core/dist/services/selector-registry-context.js"(exports) {
|
|
293126
|
-
"use strict";
|
|
293127
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
293128
|
-
exports.normalizeSelectorRegistryEntries = normalizeSelectorRegistryEntries;
|
|
293129
|
-
exports.formatSelectorRegistryContextForPrompt = formatSelectorRegistryContextForPrompt;
|
|
293130
|
-
exports.collectRegistryCandidates = collectRegistryCandidates;
|
|
293131
|
-
exports.buildRegistryCandidateBlock = buildRegistryCandidateBlock;
|
|
293132
|
-
exports.planRegistryFallbackFix = planRegistryFallbackFix;
|
|
293133
|
-
exports.substituteSelectorInCode = substituteSelectorInCode;
|
|
293134
|
-
function isRecord(value) {
|
|
293135
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
293136
|
-
}
|
|
293137
|
-
function asString(value, fallback = "") {
|
|
293138
|
-
return typeof value === "string" ? value : fallback;
|
|
293139
|
-
}
|
|
293140
|
-
function asNumber(value, fallback = 0) {
|
|
293141
|
-
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
293142
|
-
}
|
|
293143
|
-
function asStringArray(value) {
|
|
293144
|
-
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
293145
|
-
}
|
|
293146
|
-
function truncateForSelectorPrompt(value, maxLength = 180) {
|
|
293147
|
-
const normalized = (value ?? "").replace(/\s+/g, " ").trim();
|
|
293148
|
-
if (normalized.length <= maxLength)
|
|
293149
|
-
return normalized;
|
|
293150
|
-
return `${normalized.slice(0, Math.max(0, maxLength - 3))}...`;
|
|
293151
|
-
}
|
|
293152
|
-
function inlineCode(value, maxLength = 180) {
|
|
293153
|
-
return `\`${truncateForSelectorPrompt(value, maxLength).replace(/`/g, "'")}\``;
|
|
293154
|
-
}
|
|
293155
|
-
function normalizeRef(value) {
|
|
293156
|
-
if (!isRecord(value))
|
|
293157
|
-
return null;
|
|
293158
|
-
const expression = asString(value.expression).trim();
|
|
293159
|
-
if (!expression)
|
|
293160
|
-
return null;
|
|
293161
|
-
return {
|
|
293162
|
-
route: asString(value.route, "*"),
|
|
293163
|
-
usage: asString(value.usage, "locator"),
|
|
293164
|
-
source: asString(value.source, "generated"),
|
|
293165
|
-
expression,
|
|
293166
|
-
occurrenceIndex: asNumber(value.occurrenceIndex, 0)
|
|
293167
|
-
};
|
|
293168
|
-
}
|
|
293169
|
-
function normalizeSibling(value) {
|
|
293170
|
-
if (!isRecord(value))
|
|
293171
|
-
return null;
|
|
293172
|
-
const testCaseId = asString(value.testCaseId).trim();
|
|
293173
|
-
const expression = asString(value.expression).trim();
|
|
293174
|
-
if (!testCaseId || !expression)
|
|
293175
|
-
return null;
|
|
293176
|
-
return {
|
|
293177
|
-
testCaseId,
|
|
293178
|
-
name: asString(value.name, testCaseId),
|
|
293179
|
-
suite: typeof value.suite === "string" ? value.suite : null,
|
|
293180
|
-
lastPassedAt: typeof value.lastPassedAt === "string" ? value.lastPassedAt : null,
|
|
293181
|
-
expression,
|
|
293182
|
-
usage: asString(value.usage, "locator"),
|
|
293183
|
-
route: asString(value.route, "*"),
|
|
293184
|
-
source: asString(value.source, "generated")
|
|
293185
|
-
};
|
|
293186
|
-
}
|
|
293187
|
-
function normalizeEntry(value) {
|
|
293188
|
-
if (!isRecord(value))
|
|
293189
|
-
return null;
|
|
293190
|
-
const id = asString(value.id).trim();
|
|
293191
|
-
const expression = asString(value.expression).trim();
|
|
293192
|
-
if (!id || !expression)
|
|
293193
|
-
return null;
|
|
293194
|
-
return {
|
|
293195
|
-
id,
|
|
293196
|
-
key: asString(value.key, id),
|
|
293197
|
-
route: asString(value.route, "*"),
|
|
293198
|
-
scope: asString(value.scope, "page"),
|
|
293199
|
-
status: asString(value.status, "ACTIVE"),
|
|
293200
|
-
stability: asNumber(value.stability, 1),
|
|
293201
|
-
label: asString(value.label),
|
|
293202
|
-
locatorKind: asString(value.locatorKind),
|
|
293203
|
-
locatorRole: typeof value.locatorRole === "string" ? value.locatorRole : null,
|
|
293204
|
-
locatorName: typeof value.locatorName === "string" ? value.locatorName : null,
|
|
293205
|
-
locatorTestId: typeof value.locatorTestId === "string" ? value.locatorTestId : null,
|
|
293206
|
-
expression,
|
|
293207
|
-
fallbacks: asStringArray(value.fallbacks),
|
|
293208
|
-
currentTestRefs: Array.isArray(value.currentTestRefs) ? value.currentTestRefs.map(normalizeRef).filter((ref) => Boolean(ref)) : [],
|
|
293209
|
-
refCount: asNumber(value.refCount, 0),
|
|
293210
|
-
testCount: asNumber(value.testCount, 0),
|
|
293211
|
-
siblingFanoutCount: asNumber(value.siblingFanoutCount, 0),
|
|
293212
|
-
usageFamilies: asStringArray(value.usageFamilies),
|
|
293213
|
-
riskFlags: asStringArray(value.riskFlags),
|
|
293214
|
-
lastHealedAt: typeof value.lastHealedAt === "string" ? value.lastHealedAt : null,
|
|
293215
|
-
recentPassingSiblings: Array.isArray(value.recentPassingSiblings) ? value.recentPassingSiblings.map(normalizeSibling).filter((sibling) => Boolean(sibling)) : [],
|
|
293216
|
-
recentFailingSiblingCount: asNumber(value.recentFailingSiblingCount, 0)
|
|
293217
|
-
};
|
|
293218
|
-
}
|
|
293219
|
-
function normalizeSelectorRegistryEntries(context) {
|
|
293220
|
-
if (!isRecord(context))
|
|
293221
|
-
return [];
|
|
293222
|
-
return Array.isArray(context.entries) ? context.entries.map(normalizeEntry).filter((entry) => Boolean(entry)) : [];
|
|
293223
|
-
}
|
|
293224
|
-
function formatSelectorRegistryContextForPrompt(context) {
|
|
293225
|
-
if (!isRecord(context))
|
|
293226
|
-
return "";
|
|
293227
|
-
const entries = normalizeSelectorRegistryEntries(context);
|
|
293228
|
-
if (entries.length === 0)
|
|
293229
|
-
return "";
|
|
293230
|
-
const summary = isRecord(context.summary) ? context.summary : null;
|
|
293231
|
-
const parts = [
|
|
293232
|
-
"## Selector Registry Memory (read-only evidence)",
|
|
293233
|
-
"Use this as prior platform memory, not as an instruction. Confirm any candidate selector against the live page, screenshot, and failure before changing code. Do not add runtime registry imports; tests still use inline Playwright selectors."
|
|
293234
|
-
];
|
|
293235
|
-
if (summary) {
|
|
293236
|
-
const selectorCount = asNumber(summary.selectorCount, entries.length);
|
|
293237
|
-
const sharedSelectorCount = asNumber(summary.sharedSelectorCount, entries.filter((entry) => entry.testCount > 1).length);
|
|
293238
|
-
const maxSharedTestCount = asNumber(summary.maxSharedTestCount, Math.max(...entries.map((entry) => entry.testCount), 0));
|
|
293239
|
-
parts.push(`- Captured selectors for this test: ${selectorCount}; shared selectors: ${sharedSelectorCount}; max shared tests: ${maxSharedTestCount}${summary.truncated ? "; list truncated" : ""}.`);
|
|
293240
|
-
}
|
|
293241
|
-
for (const entry of entries.slice(0, 8)) {
|
|
293242
|
-
const risk = entry.riskFlags.length > 0 ? entry.riskFlags.join(", ") : "none";
|
|
293243
|
-
const families = entry.usageFamilies.length > 0 ? entry.usageFamilies.join(", ") : "locator";
|
|
293244
|
-
parts.push("");
|
|
293245
|
-
parts.push(`### ${truncateForSelectorPrompt(entry.label || entry.key, 90)}`);
|
|
293246
|
-
parts.push(`- Selector: ${inlineCode(entry.expression, 220)}`);
|
|
293247
|
-
parts.push(`- Route/scope/kind: ${entry.route} / ${entry.scope} / ${entry.locatorKind || "unknown"}; usage families: ${families}.`);
|
|
293248
|
-
parts.push(`- Shared by: ${entry.testCount} test(s), ${entry.siblingFanoutCount} sibling(s), ${entry.refCount} ref(s); risks: ${risk}; status: ${entry.status}; stability: ${entry.stability}.`);
|
|
293249
|
-
if (entry.lastHealedAt)
|
|
293250
|
-
parts.push(`- Last registry heal: ${entry.lastHealedAt}.`);
|
|
293251
|
-
const currentRefs = entry.currentTestRefs.slice(0, 3);
|
|
293252
|
-
if (currentRefs.length > 0) {
|
|
293253
|
-
parts.push("- Current test occurrences:");
|
|
293254
|
-
for (const ref of currentRefs) {
|
|
293255
|
-
parts.push(` - ${ref.usage} on ${ref.route} from ${ref.source}: ${inlineCode(ref.expression, 180)}`);
|
|
293256
|
-
}
|
|
293257
|
-
}
|
|
293258
|
-
const siblings = entry.recentPassingSiblings.slice(0, 3);
|
|
293259
|
-
if (siblings.length > 0) {
|
|
293260
|
-
parts.push("- Recent passing sibling tests using this registry entry:");
|
|
293261
|
-
for (const sibling of siblings) {
|
|
293262
|
-
const suite = sibling.suite ? ` (${truncateForSelectorPrompt(sibling.suite, 50)})` : "";
|
|
293263
|
-
const passed = sibling.lastPassedAt ? ` passed ${sibling.lastPassedAt}` : "";
|
|
293264
|
-
parts.push(` - ${truncateForSelectorPrompt(sibling.name, 80)}${suite}${passed}: ${inlineCode(sibling.expression, 180)}`);
|
|
293265
|
-
}
|
|
293266
|
-
}
|
|
293267
|
-
if (entry.recentFailingSiblingCount && entry.recentFailingSiblingCount > 0) {
|
|
293268
|
-
parts.push(`- Other recent failing siblings on this entry: ${entry.recentFailingSiblingCount}.`);
|
|
293269
|
-
}
|
|
293270
|
-
const fallbacks = (entry.fallbacks ?? []).slice(0, 3);
|
|
293271
|
-
if (fallbacks.length > 0) {
|
|
293272
|
-
parts.push(`- Registry fallbacks: ${fallbacks.map((fallback) => inlineCode(fallback, 120)).join(", ")}.`);
|
|
293273
|
-
}
|
|
293274
|
-
}
|
|
293275
|
-
return `${parts.join("\n")}
|
|
293276
|
-
`;
|
|
293277
|
-
}
|
|
293278
|
-
function selectorKey(expression) {
|
|
293279
|
-
return expression.trim().replace(/^page\s*\.\s*/, "").replace(/\s+/g, " ").replace(/"/g, "'").trim();
|
|
293280
|
-
}
|
|
293281
|
-
function collectRegistryCandidates(context) {
|
|
293282
|
-
const entries = normalizeSelectorRegistryEntries(context).slice(0, 8);
|
|
293283
|
-
const seen = /* @__PURE__ */ new Set();
|
|
293284
|
-
const ranked = [[], [], []];
|
|
293285
|
-
for (const entry of entries) {
|
|
293286
|
-
const entryLabel = entry.label || entry.key;
|
|
293287
|
-
for (const sibling of entry.recentPassingSiblings) {
|
|
293288
|
-
const key = selectorKey(sibling.expression);
|
|
293289
|
-
if (seen.has(key))
|
|
293290
|
-
continue;
|
|
293291
|
-
seen.add(key);
|
|
293292
|
-
ranked[0].push({ expression: sibling.expression, source: "passing-sibling", entryLabel, siblingName: sibling.name });
|
|
293293
|
-
}
|
|
293294
|
-
const entryKey = selectorKey(entry.expression);
|
|
293295
|
-
if (!seen.has(entryKey)) {
|
|
293296
|
-
seen.add(entryKey);
|
|
293297
|
-
ranked[1].push({ expression: entry.expression, source: "registry-entry", entryLabel });
|
|
293298
|
-
}
|
|
293299
|
-
for (const fallback of entry.fallbacks ?? []) {
|
|
293300
|
-
const key = selectorKey(fallback);
|
|
293301
|
-
if (seen.has(key))
|
|
293302
|
-
continue;
|
|
293303
|
-
seen.add(key);
|
|
293304
|
-
ranked[2].push({ expression: fallback, source: "fallback", entryLabel });
|
|
293305
|
-
}
|
|
293306
|
-
}
|
|
293307
|
-
return ranked.flat();
|
|
293308
|
-
}
|
|
293309
|
-
function buildRegistryCandidateBlock(context, excludeExpressions) {
|
|
293310
|
-
const exclude = new Set(excludeExpressions.map(selectorKey));
|
|
293311
|
-
const candidates = collectRegistryCandidates(context).filter((candidate) => !exclude.has(selectorKey(candidate.expression))).slice(0, 6);
|
|
293312
|
-
if (candidates.length === 0)
|
|
293313
|
-
return "";
|
|
293314
|
-
const lines = [
|
|
293315
|
-
"## Untried Selector Candidates (from registry memory)",
|
|
293316
|
-
"Ranked alternatives for elements this test uses, from the platform selector registry. Verify each against the screenshot and error before adopting \u2014 do not adopt blindly."
|
|
293317
|
-
];
|
|
293318
|
-
for (const candidate of candidates) {
|
|
293319
|
-
const provenance = candidate.source === "passing-sibling" ? `proven in passing sibling "${truncateForSelectorPrompt(candidate.siblingName, 80)}"` : candidate.source === "registry-entry" ? `registry entry for "${truncateForSelectorPrompt(candidate.entryLabel, 80)}"` : `registry fallback for "${truncateForSelectorPrompt(candidate.entryLabel, 80)}"`;
|
|
293320
|
-
lines.push(`- ${inlineCode(candidate.expression, 180)} \u2014 ${provenance}`);
|
|
293321
|
-
}
|
|
293322
|
-
return lines.join("\n");
|
|
293323
|
-
}
|
|
293324
|
-
function findExpressionInCode(code, expression) {
|
|
293325
|
-
const trimmed = expression.trim();
|
|
293326
|
-
if (trimmed && code.includes(trimmed))
|
|
293327
|
-
return trimmed;
|
|
293328
|
-
const withoutPage = trimmed.replace(/^page\s*\.\s*/, "");
|
|
293329
|
-
if (withoutPage !== trimmed && withoutPage && code.includes(withoutPage))
|
|
293330
|
-
return withoutPage;
|
|
293331
|
-
const withPage = `page.${withoutPage}`;
|
|
293332
|
-
if (withPage !== trimmed && code.includes(withPage))
|
|
293333
|
-
return withPage;
|
|
293334
|
-
return null;
|
|
293335
|
-
}
|
|
293336
|
-
function extractFailureFocus(error2) {
|
|
293337
|
-
const focus = error2.split(/\r?\n/).filter((line) => /^\s*>/.test(line) || /waiting for|locator resolved to/i.test(line) || /^\s*locator:/i.test(line));
|
|
293338
|
-
return focus.length > 0 ? focus.join("\n") : error2;
|
|
293339
|
-
}
|
|
293340
|
-
function planRegistryFallbackFix(args) {
|
|
293341
|
-
const { code, error: error2, context } = args;
|
|
293342
|
-
if (!error2 || !code)
|
|
293343
|
-
return null;
|
|
293344
|
-
const entries = normalizeSelectorRegistryEntries(context).slice(0, 8);
|
|
293345
|
-
if (entries.length === 0)
|
|
293346
|
-
return null;
|
|
293347
|
-
const errorKey = selectorKey(extractFailureFocus(error2));
|
|
293348
|
-
for (const entry of entries) {
|
|
293349
|
-
const failingExpressions = [entry.expression, ...entry.currentTestRefs.map((ref) => ref.expression)];
|
|
293350
|
-
const failingSeen = /* @__PURE__ */ new Set();
|
|
293351
|
-
for (const failing of failingExpressions) {
|
|
293352
|
-
const failingKey = selectorKey(failing);
|
|
293353
|
-
if (!failingKey || failingSeen.has(failingKey))
|
|
293354
|
-
continue;
|
|
293355
|
-
failingSeen.add(failingKey);
|
|
293356
|
-
if (!errorKey.includes(failingKey))
|
|
293357
|
-
continue;
|
|
293358
|
-
const matchedInCode = findExpressionInCode(code, failing);
|
|
293359
|
-
if (!matchedInCode)
|
|
293360
|
-
continue;
|
|
293361
|
-
const entryLabel = entry.label || entry.key;
|
|
293362
|
-
const candidateSeen = /* @__PURE__ */ new Set([failingKey]);
|
|
293363
|
-
const candidates = [];
|
|
293364
|
-
for (const fallback of entry.fallbacks ?? []) {
|
|
293365
|
-
const key = selectorKey(fallback);
|
|
293366
|
-
if (!key || candidateSeen.has(key) || code.includes(fallback.trim()))
|
|
293367
|
-
continue;
|
|
293368
|
-
candidateSeen.add(key);
|
|
293369
|
-
candidates.push({ expression: fallback, source: "fallback", entryLabel });
|
|
293370
|
-
}
|
|
293371
|
-
for (const sibling of entry.recentPassingSiblings) {
|
|
293372
|
-
const key = selectorKey(sibling.expression);
|
|
293373
|
-
if (!key || candidateSeen.has(key) || code.includes(sibling.expression.trim()))
|
|
293374
|
-
continue;
|
|
293375
|
-
candidateSeen.add(key);
|
|
293376
|
-
candidates.push({ expression: sibling.expression, source: "passing-sibling", entryLabel, siblingName: sibling.name });
|
|
293377
|
-
}
|
|
293378
|
-
if (candidates.length === 0)
|
|
293379
|
-
continue;
|
|
293380
|
-
return { matchedInCode, entryLabel, candidates };
|
|
293381
|
-
}
|
|
293382
|
-
}
|
|
293383
|
-
return null;
|
|
293384
|
-
}
|
|
293385
|
-
function substituteSelectorInCode(code, matchedInCode, replacement) {
|
|
293386
|
-
const target = matchedInCode.trim();
|
|
293387
|
-
let normalized = replacement.trim();
|
|
293388
|
-
const targetHasPage = /^page\s*\.\s*/.test(target);
|
|
293389
|
-
const replacementHasPage = /^page\s*\.\s*/.test(normalized);
|
|
293390
|
-
if (targetHasPage && !replacementHasPage)
|
|
293391
|
-
normalized = `page.${normalized}`;
|
|
293392
|
-
if (!targetHasPage && replacementHasPage)
|
|
293393
|
-
normalized = normalized.replace(/^page\s*\.\s*/, "");
|
|
293394
|
-
return code.split(target).join(normalized);
|
|
293395
|
-
}
|
|
293396
|
-
}
|
|
293397
|
-
});
|
|
293398
|
-
|
|
293399
294401
|
// ../runner-core/dist/services/heal-selector-ledger.js
|
|
293400
294402
|
var require_heal_selector_ledger = __commonJS({
|
|
293401
294403
|
"../runner-core/dist/services/heal-selector-ledger.js"(exports) {
|
|
@@ -313801,7 +314803,7 @@ var require_mobile_discovery_agent = __commonJS({
|
|
|
313801
314803
|
log2(exploreAppDataCleared ? "App data cleared \u2014 exploring from a deterministic cold (logged-out) state." : "App data reset unavailable (platform/device policy) \u2014 exploring the app in its current state.");
|
|
313802
314804
|
const state2 = new mobile_exploration_state_js_1.MobileExplorationState();
|
|
313803
314805
|
const maxIterations = getMobileExploreBudget(mode, ctx.incremental);
|
|
313804
|
-
const existingScreens = compactExistingScreens(ctx.existingSiteMap);
|
|
314806
|
+
const existingScreens = isSurvey && ctx.incremental ? compactExistingScreens(ctx.existingSiteMap) : void 0;
|
|
313805
314807
|
const explore = await runExplore({
|
|
313806
314808
|
ctx,
|
|
313807
314809
|
driver,
|
|
@@ -328149,8 +329151,9 @@ var require_dist2 = __commonJS({
|
|
|
328149
329151
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
328150
329152
|
};
|
|
328151
329153
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
328152
|
-
exports.
|
|
328153
|
-
exports.
|
|
329154
|
+
exports.buildImportSystemRules = exports.buildImportKickoff = exports.buildImportContractMd = exports.MAX_ARCHIVE_BYTES = exports.isUnsafeEntryName = exports.extractZipSafely = exports.downloadArchiveCapped = exports.detectArchiveKind = exports.acquireRepoForImport = exports.runFrameworkImportOnRunner = exports.getAgenticEngine = exports.resolveRefFromSnapshot = exports.replayAuthRecipeIntoBrowser = exports.runRegisterCaptureRun = exports.runLoginCaptureRun = exports.AUTH_MARKER_VERSION = exports.buildHealAuthStamp = exports.extractAuthRegion = exports.upsertAuthBlock = exports.buildAuthRecipe = exports.commandToReplayStep = exports.buildReplayPlan = exports.absoluteRoute = exports.renderReplaySettleArrow = exports.renderReplayClickArrow = exports.renderAuthFn = exports.canonicalizeRoute = exports.executeGrokPerBatchHeal = exports.executeGrokPerTestHeal = exports.headerVal = exports.classifyAuthType = exports.isTextExcerptable = exports.isStaticAssetByExt = exports.isApiCall = exports.buildApiCallSummary = exports.computeMobileHealOutcome = exports.detectMobileStepSecretLeak = exports.redactMobileSecretsFromText = exports.MOBILE_LIVE_HEAL_SYSTEM_PROMPT = exports.MOBILE_SCRIPT_HEAL_SYSTEM_PROMPT = exports.executeMobileLiveHeal = exports.executeMobileTestWithHealing = exports.executeMobileScriptDrivenHeal = exports.runMobileGeneratePhase = exports.runMobileAIPlanner = exports.buildMobileSiteMap = exports.formatMobileEvidenceForPlanner = exports.MOBILE_SCENARIO_SYSTEM_PROMPT = exports.MOBILE_SURVEY_SYSTEM_PROMPT = exports.runMobileExplorePhase = void 0;
|
|
329155
|
+
exports.UnsupportedRendererError = exports.buildCanvasModeAuthoringAddendum = exports.buildUnsupportedRendererMessage = exports.modelSupportsVision = exports.decideCanvasStrategy = exports.decideAppRenderType = exports.detectCanvasApp = exports.detectRateLimitBlock = exports.isSafeCanonicalRedirect = exports.resolveBaseUrlPreflight = exports.checkBaseUrlRedirect = exports.stripJsonFences = exports.scrubCredentials = exports.withAIRetry = exports.snapshotMatchingChildren = exports.findNewChromiumChildPid = exports.killProcessTree = exports.gracefulCloseWithTreeKill = exports.liveBrowserRegistry = exports.REPO_SWITCH_REMOVED_FRACTION = exports.MAX_MANIFEST_FILES = exports.toDiffSummary = exports.isLikelyTestFile = exports.sanitizeRepoRelPath = exports.sha256Hex = exports.hashFiles = exports.enumerateTestFiles = exports.buildNextManifest = exports.detectRepoSwitch = exports.classifyImportDiff = exports.parseImportManifest = exports.REPO_ANALYSIS_SCHEMA_VERSION = exports.validateSourceEndpoints = exports.validateAuthoredTest = exports.validateRepoMapFile = exports.validateRepoMemoryFile = exports.buildTestingStandardsSection = exports.buildRepoAuthorSystemRules = exports.buildRepoAuthorKickoff = exports.buildRepoAuthorContractMd = exports.buildRepoMapSystemRules = exports.buildRepoMapKickoff = exports.buildRepoMapContractMd = exports.buildRepoMemorySystemRules = exports.buildRepoMemoryKickoff = exports.buildRepoMemoryContractMd = exports.runRepoAnalysisOnRunner = exports.IMPORT_SCHEMA_VERSION = exports.validateImportResultFile = exports.validateImportedTest = void 0;
|
|
329156
|
+
exports.UNSUPPORTED_RENDERER_PREFIX = void 0;
|
|
328154
329157
|
__exportStar(require_ai_provider(), exports);
|
|
328155
329158
|
__exportStar(require_mobile_types(), exports);
|
|
328156
329159
|
__exportStar(require_mobile_source_parser(), exports);
|
|
@@ -328179,6 +329182,32 @@ var require_dist2 = __commonJS({
|
|
|
328179
329182
|
Object.defineProperty(exports, "runMobileGeneratePhase", { enumerable: true, get: function() {
|
|
328180
329183
|
return mobile_generator_js_1.runMobileGeneratePhase;
|
|
328181
329184
|
} });
|
|
329185
|
+
var mobile_heal_loop_js_1 = require_mobile_heal_loop();
|
|
329186
|
+
Object.defineProperty(exports, "executeMobileScriptDrivenHeal", { enumerable: true, get: function() {
|
|
329187
|
+
return mobile_heal_loop_js_1.executeMobileScriptDrivenHeal;
|
|
329188
|
+
} });
|
|
329189
|
+
Object.defineProperty(exports, "executeMobileTestWithHealing", { enumerable: true, get: function() {
|
|
329190
|
+
return mobile_heal_loop_js_1.executeMobileTestWithHealing;
|
|
329191
|
+
} });
|
|
329192
|
+
Object.defineProperty(exports, "executeMobileLiveHeal", { enumerable: true, get: function() {
|
|
329193
|
+
return mobile_heal_loop_js_1.executeMobileLiveHeal;
|
|
329194
|
+
} });
|
|
329195
|
+
Object.defineProperty(exports, "MOBILE_SCRIPT_HEAL_SYSTEM_PROMPT", { enumerable: true, get: function() {
|
|
329196
|
+
return mobile_heal_loop_js_1.MOBILE_SCRIPT_HEAL_SYSTEM_PROMPT;
|
|
329197
|
+
} });
|
|
329198
|
+
Object.defineProperty(exports, "MOBILE_LIVE_HEAL_SYSTEM_PROMPT", { enumerable: true, get: function() {
|
|
329199
|
+
return mobile_heal_loop_js_1.MOBILE_LIVE_HEAL_SYSTEM_PROMPT;
|
|
329200
|
+
} });
|
|
329201
|
+
var mobile_heal_postprocess_js_1 = require_mobile_heal_postprocess();
|
|
329202
|
+
Object.defineProperty(exports, "redactMobileSecretsFromText", { enumerable: true, get: function() {
|
|
329203
|
+
return mobile_heal_postprocess_js_1.redactMobileSecretsFromText;
|
|
329204
|
+
} });
|
|
329205
|
+
Object.defineProperty(exports, "detectMobileStepSecretLeak", { enumerable: true, get: function() {
|
|
329206
|
+
return mobile_heal_postprocess_js_1.detectMobileStepSecretLeak;
|
|
329207
|
+
} });
|
|
329208
|
+
Object.defineProperty(exports, "computeMobileHealOutcome", { enumerable: true, get: function() {
|
|
329209
|
+
return mobile_heal_postprocess_js_1.computeMobileHealOutcome;
|
|
329210
|
+
} });
|
|
328182
329211
|
__exportStar(require_browser_config(), exports);
|
|
328183
329212
|
__exportStar(require_mcp(), exports);
|
|
328184
329213
|
var api_call_redaction_js_1 = require_api_call_redaction();
|
|
@@ -328488,7 +329517,7 @@ var require_package4 = __commonJS({
|
|
|
328488
329517
|
"package.json"(exports, module) {
|
|
328489
329518
|
module.exports = {
|
|
328490
329519
|
name: "@validate.qa/runner",
|
|
328491
|
-
version: "1.0.
|
|
329520
|
+
version: "1.0.26",
|
|
328492
329521
|
description: "validate local test runner - execute Playwright tests on your machine, connected to validate.qa cloud.",
|
|
328493
329522
|
bin: {
|
|
328494
329523
|
"validate-runner": "dist/cli.js"
|
|
@@ -331212,9 +332241,18 @@ async function executeMobileTest(options) {
|
|
|
331212
332241
|
let entryDrift = false;
|
|
331213
332242
|
const runPlatform = options.target.platform;
|
|
331214
332243
|
const isCrossPlatform = options.target.authoringPlatform != null && options.target.authoringPlatform !== runPlatform;
|
|
331215
|
-
const
|
|
332244
|
+
const CONTAINER_ONLY_ID_RE = /(?:^|[:/])id\/(webview|content|decor|decor_content_parent|action_bar_root|statusBarBackground|navigationBarBackground)$|^(?:main-content|root|app|app-root|__next|react-root|application)$/i;
|
|
332245
|
+
const isContainerOnlyEntryTarget = (target) => {
|
|
332246
|
+
const primary = target?.primary?.trim() ?? "";
|
|
332247
|
+
if (primary === "") return false;
|
|
332248
|
+
const m = primary.match(/^mobile\.(?:resourceId|accessibilityId)\('([^']+)'\)$/);
|
|
332249
|
+
const value = m ? m[1] : primary;
|
|
332250
|
+
return CONTAINER_ONLY_ID_RE.test(value);
|
|
332251
|
+
};
|
|
332252
|
+
const identityBearingSteps = runSteps.filter(
|
|
331216
332253
|
(s) => s.action !== "launchApp" && stepAppliesToPlatform(s, runPlatform) && buildIdentityLocatorStrategies(s.target, runPlatform).length > 0
|
|
331217
332254
|
);
|
|
332255
|
+
const entryStep = identityBearingSteps.find((s) => !isContainerOnlyEntryTarget(s.target)) ?? identityBearingSteps[0];
|
|
331218
332256
|
if (entryStep) {
|
|
331219
332257
|
try {
|
|
331220
332258
|
const entryTimeout = recordedFromClearedState ? Math.max(DEFAULT_STEP_TIMEOUT_MS, COLD_BOOT_ENTRY_TIMEOUT_MS) : DEFAULT_STEP_TIMEOUT_MS;
|