@validate.qa/runner 1.0.52 → 1.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/cli.js +1175 -131
  2. package/dist/cli.mjs +1175 -131
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -7702,6 +7702,7 @@ var require_credential_tools = __commonJS({
7702
7702
  exports2.buildCredentialPromptBlock = buildCredentialPromptBlock;
7703
7703
  exports2.isLikelyCredentialKey = isLikelyCredentialKey;
7704
7704
  exports2.partitionTestVariables = partitionTestVariables;
7705
+ exports2.hasUsableLoginIdentity = hasUsableLoginIdentity;
7705
7706
  exports2.renderPublicVariablesBlock = renderPublicVariablesBlock;
7706
7707
  exports2.handleFillCredential = handleFillCredential;
7707
7708
  exports2.handleFillCredentialForm = handleFillCredentialForm;
@@ -7849,6 +7850,25 @@ CREDENTIAL ROTATION (rare \u2014 read this carefully):
7849
7850
  }
7850
7851
  return { secrets, publics };
7851
7852
  }
7853
+ var IDENTITY_KEY_PATTERN = /^(TEST_|E2E_|QA_)?(USER_?EMAIL|USER_?NAME|USERNAME|LOGIN_?ID|LOGIN_?EMAIL|ACCOUNT_?EMAIL)$/i;
7854
+ var BOOLEAN_LIKE_VALUE = /^(true|false|1|0|yes|no|on|off|enabled|disabled)$/i;
7855
+ var EMAIL_SHAPED_VALUE = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;
7856
+ function hasUsableLoginIdentity(vars, opts) {
7857
+ if (!vars)
7858
+ return false;
7859
+ return Object.entries(vars).some(([k, rawValue]) => {
7860
+ const v = (rawValue ?? "").trim();
7861
+ if (!v)
7862
+ return false;
7863
+ if (!IDENTITY_KEY_PATTERN.test(k.trim()))
7864
+ return false;
7865
+ if (BOOLEAN_LIKE_VALUE.test(v))
7866
+ return false;
7867
+ if (/EMAIL/i.test(k) && !EMAIL_SHAPED_VALUE.test(v))
7868
+ return false;
7869
+ return !opts?.isPlaceholderIdentityValue?.(v);
7870
+ });
7871
+ }
7852
7872
  function renderPublicVariablesBlock(publics) {
7853
7873
  const entries = Object.entries(publics);
7854
7874
  if (entries.length === 0)
@@ -72451,6 +72471,7 @@ var require_verification_inbox = __commonJS({
72451
72471
  Object.defineProperty(exports2, "__esModule", { value: true });
72452
72472
  exports2.VerificationInboxReader = void 0;
72453
72473
  exports2.isVerificationInboxConfigured = isVerificationInboxConfigured;
72474
+ exports2.describeVerificationInboxConfigGap = describeVerificationInboxConfigGap;
72454
72475
  exports2.loadVerificationInboxConfig = loadVerificationInboxConfig;
72455
72476
  exports2.shouldUseUidWatermark = shouldUseUidWatermark;
72456
72477
  exports2.recipientMatchesAddress = recipientMatchesAddress;
@@ -72472,6 +72493,21 @@ var require_verification_inbox = __commonJS({
72472
72493
  function isVerificationInboxConfigured(env = process.env) {
72473
72494
  return !!(readEnv(env, "VERIFICATION_INBOX_HOST") && readEnv(env, "VERIFICATION_INBOX_USER") && readEnv(env, "VERIFICATION_INBOX_PASSWORD") && readEnv(env, "VERIFICATION_INBOX_ADDRESS"));
72474
72495
  }
72496
+ var REQUIRED_INBOX_ENV_KEYS = [
72497
+ "VERIFICATION_INBOX_HOST",
72498
+ "VERIFICATION_INBOX_USER",
72499
+ "VERIFICATION_INBOX_PASSWORD",
72500
+ "VERIFICATION_INBOX_ADDRESS"
72501
+ ];
72502
+ function describeVerificationInboxConfigGap(env = process.env) {
72503
+ const missing = REQUIRED_INBOX_ENV_KEYS.filter((key) => !readEnv(env, key));
72504
+ if (missing.length === 0)
72505
+ return null;
72506
+ if (missing.length === REQUIRED_INBOX_ENV_KEYS.length) {
72507
+ return "verification inbox not configured (no VERIFICATION_INBOX_* env)";
72508
+ }
72509
+ return `verification inbox PARTIALLY configured \u2014 missing: ${missing.join(", ")}`;
72510
+ }
72475
72511
  function loadVerificationInboxConfig(env = process.env) {
72476
72512
  if (!isVerificationInboxConfigured(env))
72477
72513
  return null;
@@ -73080,14 +73116,16 @@ var require_inbox_tools = __commonJS({
73080
73116
  "../runner-core/dist/services/inbox-tools.js"(exports2) {
73081
73117
  "use strict";
73082
73118
  Object.defineProperty(exports2, "__esModule", { value: true });
73083
- exports2.INBOX_TOOL_NAMES = exports2.INBOX_TOOLS = exports2.OPEN_VERIFICATION_LINK_TOOL = exports2.GET_VERIFICATION_LINK_TOOL = exports2.EXTRACT_VERIFICATION_CODE_TOOL = exports2.READ_VERIFICATION_EMAIL_TOOL = exports2.WAIT_FOR_VERIFICATION_TOOL = exports2.CHECK_INBOX_TOOL = exports2.PROVISION_IDENTITY_TOOL = void 0;
73119
+ exports2.EMAIL_VERIFICATION_UNAVAILABLE_OVERRIDE_BLOCK = exports2.INBOX_TOOL_NAMES = exports2.INBOX_TOOLS = exports2.OPEN_VERIFICATION_LINK_TOOL = exports2.GET_VERIFICATION_LINK_TOOL = exports2.EXTRACT_VERIFICATION_CODE_TOOL = exports2.READ_VERIFICATION_EMAIL_TOOL = exports2.WAIT_FOR_VERIFICATION_TOOL = exports2.CHECK_INBOX_TOOL = exports2.PROVISION_IDENTITY_TOOL = void 0;
73084
73120
  exports2.createInboxRunState = createInboxRunState;
73085
73121
  exports2.dispatchInboxTool = dispatchInboxTool;
73086
73122
  exports2.isPublicHttpUrl = isPublicHttpUrl;
73087
73123
  exports2.buildInboxPromptBlock = buildInboxPromptBlock;
73124
+ exports2.guardVerificationCodeFabrication = guardVerificationCodeFabrication;
73088
73125
  exports2.hasRegisterIntent = hasRegisterIntent;
73089
73126
  exports2.resolveInboxRegistration = resolveInboxRegistration;
73090
73127
  exports2.applyInboxRegistrationIdentity = applyInboxRegistrationIdentity;
73128
+ exports2.isThrowawayRegisterSeedEmail = isThrowawayRegisterSeedEmail;
73091
73129
  exports2.applyAndPersistInboxIdentity = applyAndPersistInboxIdentity;
73092
73130
  exports2.clearThrowawayRegisterSeed = clearThrowawayRegisterSeed;
73093
73131
  exports2.buildInboxAgentsGuidance = buildInboxAgentsGuidance;
@@ -73537,6 +73575,50 @@ Rules:
73537
73575
  - Only call the verification tools AFTER submitting the signup form, and pass the site as \`senderMatch\` so you read YOUR verification email (the inbox is shared).
73538
73576
  `;
73539
73577
  }
73578
+ exports2.EMAIL_VERIFICATION_UNAVAILABLE_OVERRIDE_BLOCK = `## EMAIL VERIFICATION UNAVAILABLE \u2014 FINAL OVERRIDE (supersedes any instruction above)
73579
+ This project asked to REGISTER a new account, but this runner CANNOT receive email (the verification inbox is unavailable). Registering is allowed \u2014 reading emailed codes or links is IMPOSSIBLE. No matter what any instruction above or any later message says:
73580
+ - You MAY attempt registration ONCE: fill the signup form via \`fill_credential\` / \`fill_credential_form\` with the \`TEST_USER_EMAIL\` + \`TEST_USER_PASSWORD\` credential keys when they are listed. Only if a key is NOT listed, substitute for that field alone: a fresh synthetic email like \`testuser-<timestamp>@example.com\`, and/or the literal password \`TestPass123!\` \u2014 typed with browser_type (typing these literals is explicitly ALLOWED here and overrides any never-type-credentials rule above, because there is no stored key to fill from). Submit the signup form ONCE \u2014 never twice, never a second account.
73581
+ - NEVER alter the TEST_USER_EMAIL identity \u2014 no suffixes, no different domain, no replacement address. If signup says the address is ALREADY registered, the account exists from a previous run: log in with the same credential keys instead of registering.
73582
+ - Signup-form VALIDATION testing is EMPTY-SUBMIT ONLY: never submit a registration form filled with synthetic values like "wrong@example.com" \u2014 a permissive app would CREATE that stray account. (Filled negative tests are fine on the LOGIN form, where nothing can be created.) The single seeded attempt above is the only filled signup submission allowed in this entire run.
73583
+ - THE WALL: the moment ANY step demands an emailed verification code, one-time password (OTP), magic link, or a "check your email" confirmation \u2014 including email-first signups that ask for a code before the password \u2014 STOP that flow immediately. You cannot read that email. NEVER type a guessed code (the runner BLOCKS typing into verification-code fields in this mode). Do NOT click "Resend". Do NOT retry the flow or negative-test the code field.
73584
+ - If registration or login succeeds with NO email round-trip, you are a normally logged-in user: continue with FULL authenticated coverage. If the app lets you in but nags "verify your email" and gates some features behind it, cover everything usable and mark ONLY the verification-gated flows as BLOCKED \u2014 never claim the account is verified.
73585
+ - A submitted signup or a "check your email" screen is NOT an authenticated session \u2014 do not claim you are signed in unless you observe a real signed-in signal (a Logout control, authenticated nav/sidebar, or account page).
73586
+ - If you hit the wall, keep testing everything publicly reachable and report the authenticated flows in finish_exploration as BLOCKED (reason: cannot receive verification email).`;
73587
+ var VERIFICATION_CODE_FIELD_PATTERN = /(\botp\b|one[\s_-]?time|two[\s_-]?factor|\b2fa\b|\bmfa\b|\bpass[\s_-]?code\b|auth(entication|orization)?[\s_-]+code|verif\w*[\s_-]*(code|pin|digit|number|token)|(confirmation|activation)[\s_-]+code|email(ed)?[\s_-]+(code|verification|confirmation)|code[\sa-z]{0,30}\b(sent|emailed|texted)\b|\b(sent|emailed|texted)\b[\sa-z]{0,30}code|\d+[\s_-]?digit[\s_-]*(code|pin)|\bdigit[\s_-]*\d\b|enter[\s_-]+(the[\s_-]+)?code\b|^\s*verification\s*$)/i;
73588
+ var GENERIC_CODE_OR_PIN = /\b(code|pin)\b/i;
73589
+ var BENIGN_QUALIFIED_CODE = /\b(promo(tional)?|coupon|discount|referr?al|invite|invitation|gift([\s_-]+card)?|voucher|redeem|redemption|zip|postal|area|country|dial(ing)?|currency|swift|iban|sort|routing|tax|vat|security|cvv|cvc|company|employee|org|organization|team|store|branch|dealer|partner|product|item|serial|model|colou?r|embed|source)[\s_-]+code\b|(create|choose|set|new)[\s_-]+(a[\s_-]+)?pin\b/i;
73590
+ function guardVerificationCodeFabrication(toolName, toolArgs) {
73591
+ const isRawTool = toolName === "browser_type" || toolName === "browser_fill_form";
73592
+ const isCredentialTool = toolName === "fill_credential" || toolName === "fill_credential_form";
73593
+ if (!isRawTool && !isCredentialTool)
73594
+ return { blocked: false };
73595
+ const descriptors = [];
73596
+ if (toolName === "browser_type" || toolName === "fill_credential") {
73597
+ descriptors.push(String(toolArgs.element ?? ""));
73598
+ } else {
73599
+ const fields = Array.isArray(toolArgs.fields) ? toolArgs.fields : [];
73600
+ for (const f of fields) {
73601
+ if (!f || typeof f !== "object")
73602
+ continue;
73603
+ const entry = f;
73604
+ descriptors.push([entry.name, entry.element, entry.field, entry.label, entry.placeholder, entry.ariaLabel, entry.description].filter((part) => typeof part === "string").join(" "));
73605
+ }
73606
+ }
73607
+ for (const descriptor of descriptors) {
73608
+ if (!descriptor)
73609
+ continue;
73610
+ const otpSpecific = VERIFICATION_CODE_FIELD_PATTERN.test(descriptor);
73611
+ const genericCodeField = GENERIC_CODE_OR_PIN.test(descriptor) && !BENIGN_QUALIFIED_CODE.test(descriptor);
73612
+ if (otpSpecific || genericCodeField) {
73613
+ return {
73614
+ blocked: true,
73615
+ matchedField: descriptor.slice(0, 120),
73616
+ message: "BLOCKED: this looks like an email verification / one-time code field, but this runner CANNOT receive email \u2014 any code you type would be fabricated. Stop this flow now (do not click Resend, do not retry), continue with publicly reachable coverage, and report this flow as BLOCKED (cannot receive verification email) in finish_exploration."
73617
+ };
73618
+ }
73619
+ }
73620
+ return { blocked: false };
73621
+ }
73540
73622
  function hasRegisterIntent(variableContext) {
73541
73623
  const v = variableContext.allTestVariables?.DISCOVERY_SHOULD_REGISTER ?? variableContext.publicTestVariables?.DISCOVERY_SHOULD_REGISTER ?? "";
73542
73624
  return String(v).trim().toLowerCase() === "true";
@@ -73574,7 +73656,11 @@ Rules:
73574
73656
  vars[passwordKey] = derived;
73575
73657
  }
73576
73658
  }
73577
- var THROWAWAY_REGISTER_EMAIL = /^testuser\+\d+@validate\.qa$/i;
73659
+ var THROWAWAY_REGISTER_EMAIL = /^testuser\+(\d{10,16}|[0-9a-f]{10})@validate\.qa$/i;
73660
+ function isThrowawayRegisterSeedEmail(value) {
73661
+ const v = (value ?? "").trim();
73662
+ return !!v && THROWAWAY_REGISTER_EMAIL.test(v);
73663
+ }
73578
73664
  async function applyAndPersistInboxIdentity(opts) {
73579
73665
  const { variableContext, registration, persist, log: log2 } = opts;
73580
73666
  const vars = variableContext.allTestVariables ??= {};
@@ -318090,6 +318176,8 @@ var require_exploration_state = __commonJS({
318090
318176
  existing.protected = true;
318091
318177
  if (entry.label && !existing.label)
318092
318178
  existing.label = entry.label;
318179
+ if (entry.provenance && !existing.provenance)
318180
+ existing.provenance = entry.provenance;
318093
318181
  protectedCount++;
318094
318182
  }
318095
318183
  continue;
@@ -318099,10 +318187,10 @@ var require_exploration_state = __commonJS({
318099
318187
  continue;
318100
318188
  let evictKey = null;
318101
318189
  let evictIter = -1;
318102
- for (const [key, item] of state2.frontier) {
318103
- if (item.source === "link-seen" && !item.protected && item.discoveredAtIteration >= evictIter) {
318190
+ for (const [key, item2] of state2.frontier) {
318191
+ if (item2.source === "link-seen" && !item2.protected && item2.discoveredAtIteration >= evictIter) {
318104
318192
  evictKey = key;
318105
- evictIter = item.discoveredAtIteration;
318193
+ evictIter = item2.discoveredAtIteration;
318106
318194
  }
318107
318195
  }
318108
318196
  if (evictKey === null)
@@ -318111,14 +318199,17 @@ var require_exploration_state = __commonJS({
318111
318199
  linkSeenCount--;
318112
318200
  }
318113
318201
  const canProtect = entry.protected && protectedCount < exports2.PROTECTED_FRONTIER_CAP;
318114
- state2.frontier.set(entry.route, {
318202
+ const item = {
318115
318203
  route: entry.route,
318116
318204
  source: "link-seen",
318117
318205
  discoveredAtIteration: state2.iteration,
318118
318206
  label: entry.label,
318119
318207
  protected: canProtect,
318120
318208
  familyKey: entry.familyKey
318121
- });
318209
+ };
318210
+ if (entry.provenance)
318211
+ item.provenance = entry.provenance;
318212
+ state2.frontier.set(entry.route, item);
318122
318213
  linkSeenCount++;
318123
318214
  if (canProtect)
318124
318215
  protectedCount++;
@@ -318825,9 +318916,11 @@ var require_survey_link_frontier = __commonJS({
318825
318916
  exports2.isSurveyLinkFrontierEnabled = isSurveyLinkFrontierEnabled;
318826
318917
  exports2.extractSnapshotLinks = extractSnapshotLinks;
318827
318918
  exports2.deriveLinkScope = deriveLinkScope;
318919
+ exports2.sameAppOrigin = sameAppOrigin;
318828
318920
  exports2.computeFamilyKey = computeFamilyKey;
318829
318921
  exports2.basePathDepthOf = basePathDepthOf;
318830
318922
  exports2.ingestSnapshotLinks = ingestSnapshotLinks;
318923
+ exports2.ingestSeenLinks = ingestSeenLinks;
318831
318924
  exports2.visitedSatisfies = visitedSatisfies;
318832
318925
  exports2.markLinkNavigationAttempt = markLinkNavigationAttempt;
318833
318926
  exports2.getFinishBlockingFrontier = getFinishBlockingFrontier;
@@ -318886,6 +318979,20 @@ var require_survey_link_frontier = __commonJS({
318886
318979
  }
318887
318980
  }
318888
318981
  var NON_HTTP_SCHEME_RE = /^(mailto|tel|sms|javascript|data|blob|ftp|file|about|chrome|intent):/i;
318982
+ function sameAppOrigin(a, b) {
318983
+ if (!a || !b)
318984
+ return false;
318985
+ if (a === b)
318986
+ return true;
318987
+ try {
318988
+ const ua = new URL(a);
318989
+ const ub = new URL(b);
318990
+ const host = (u) => u.host.replace(/^www\./i, "");
318991
+ return ua.protocol === ub.protocol && host(ua) === host(ub);
318992
+ } catch {
318993
+ return false;
318994
+ }
318995
+ }
318889
318996
  var GENERATOR_QUERY_KEYS = /* @__PURE__ */ new Set([
318890
318997
  "page",
318891
318998
  "p",
@@ -318954,9 +319061,15 @@ var require_survey_link_frontier = __commonJS({
318954
319061
  return (0, exploration_parser_js_1.normalizeRouteForFocusScope)(route2).split("/").filter(Boolean).length;
318955
319062
  }
318956
319063
  function ingestSnapshotLinks(state2, params) {
318957
- const { rawSnapshot, scope, isEntryOrHub, isErrorContext, pageUrl, log: log2 } = params;
319064
+ const { rawSnapshot, ...rest } = params;
319065
+ ingestSeenLinks(state2, { ...rest, links: extractSnapshotLinks(rawSnapshot), provenance: "snapshot" });
319066
+ }
319067
+ var SESSION_KILLER_PATH_RE = /(^|\/)(log[-_]?out|sign[-_]?out|sign[-_]?off|sessions?\/(destroy|delete))([/?#.]|$)/i;
319068
+ function ingestSeenLinks(state2, params) {
319069
+ const { links, scope, isEntryOrHub, isErrorContext, pageUrl, log: log2, provenance = "snapshot" } = params;
318958
319070
  if (isErrorContext)
318959
319071
  return;
319072
+ const originsMatch = (a, b) => provenance === "dom" ? sameAppOrigin(a, b) : a === b;
318960
319073
  let pageBase = null;
318961
319074
  if (pageUrl) {
318962
319075
  try {
@@ -318965,11 +319078,11 @@ var require_survey_link_frontier = __commonJS({
318965
319078
  pageBase = null;
318966
319079
  }
318967
319080
  }
318968
- if (pageBase && scope.origin && pageBase.origin !== scope.origin) {
319081
+ if (pageBase && scope.origin && !originsMatch(pageBase.origin, scope.origin)) {
318969
319082
  log2?.(` [link-frontier] skipped off-origin page ${pageBase.origin}`);
318970
319083
  return;
318971
319084
  }
318972
- const seen = extractSnapshotLinks(rawSnapshot);
319085
+ const seen = links;
318973
319086
  if (seen.length === 0)
318974
319087
  return;
318975
319088
  const suppressed = [];
@@ -319015,14 +319128,14 @@ var require_survey_link_frontier = __commonJS({
319015
319128
  suppressed.push(`${raw} (unparseable)`);
319016
319129
  continue;
319017
319130
  }
319018
- if (scope.origin && abs.origin !== scope.origin) {
319131
+ if (scope.origin && !originsMatch(abs.origin, scope.origin)) {
319019
319132
  suppressed.push(`${raw} (external)`);
319020
319133
  continue;
319021
319134
  }
319022
319135
  if (abs.hash && !abs.hash.startsWith("#/"))
319023
319136
  abs.hash = "";
319024
319137
  const route2 = (0, exploration_parser_js_1.canonicalizeRoute)(abs.pathname + abs.search + abs.hash);
319025
- candidates.push({ route: route2, label: link.label });
319138
+ candidates.push({ route: route2, label: link.label, hidden: link.hidden, inNav: link.inNav, inFooter: link.inFooter });
319026
319139
  }
319027
319140
  candidates.sort((a, b) => {
319028
319141
  const aVariant = a.route === (0, exploration_parser_js_1.normalizeRouteForFocusScope)(a.route) ? 0 : 1;
@@ -319036,6 +319149,10 @@ var require_survey_link_frontier = __commonJS({
319036
319149
  if (stripped)
319037
319150
  suppressed.push(`${candidate.route} (generator-stripped -> ${route2})`);
319038
319151
  const scopePath = (0, exploration_parser_js_1.normalizeRouteForFocusScope)(route2);
319152
+ if (provenance === "dom" && SESSION_KILLER_PATH_RE.test(scopePath)) {
319153
+ suppressed.push(`${route2} (session-killer)`);
319154
+ continue;
319155
+ }
319039
319156
  if (scope.basePath !== "/" && !(0, exploration_parser_js_1.routeIsWithinFocusAreas)(route2, [scope.basePath])) {
319040
319157
  suppressed.push(`${route2} (out-of-scope)`);
319041
319158
  continue;
@@ -319044,9 +319161,10 @@ var require_survey_link_frontier = __commonJS({
319044
319161
  suppressed.push(`${route2} (root)`);
319045
319162
  continue;
319046
319163
  }
319164
+ const doorLike = provenance === "dom" && candidate.inNav === true && candidate.hidden === true;
319047
319165
  const existing = state2.frontier.get(route2);
319048
319166
  if (existing) {
319049
- const upgradeCandidate = isEntryOrHub && existing.source === "link-seen" && !existing.protected;
319167
+ const upgradeCandidate = (isEntryOrHub || doorLike) && existing.source === "link-seen" && !existing.protected;
319050
319168
  if (!upgradeCandidate)
319051
319169
  continue;
319052
319170
  }
@@ -319068,9 +319186,17 @@ var require_survey_link_frontier = __commonJS({
319068
319186
  familiesInBatch.add(familyKey);
319069
319187
  seenScopedPaths.add(scopePath);
319070
319188
  const relPath = scope.basePath === "/" ? scopePath : scopePath.slice(scope.basePath.length) || "/";
319071
- const isFooterLegal = FOOTER_LEGAL_PATH_RE.test(relPath);
319072
- const isProtected = isEntryOrHub && !isTemplate && !isFooterLegal;
319073
- entries.push({ route: route2, label, protected: isProtected, familyKey });
319189
+ const isFooterLegal = FOOTER_LEGAL_PATH_RE.test(relPath) || provenance === "dom" && candidate.inFooter === true;
319190
+ const isProtected = (isEntryOrHub || doorLike) && !isTemplate && !isFooterLegal;
319191
+ entries.push({
319192
+ route: route2,
319193
+ label,
319194
+ protected: isProtected,
319195
+ familyKey,
319196
+ // Snapshot entries stay provenance-free — the legacy state shape must be
319197
+ // byte-identical when the DOM-harvest flag is off (flag-off invariance).
319198
+ provenance: provenance === "dom" ? candidate.hidden ? "dom-hidden" : "dom" : void 0
319199
+ });
319074
319200
  }
319075
319201
  if (suppressed.length > 0 && log2) {
319076
319202
  log2(` [link-frontier] suppressed ${suppressed.length}: ${suppressed.slice(0, 8).join(", ")}${suppressed.length > 8 ? ` \u2026+${suppressed.length - 8}` : ""}`);
@@ -319082,7 +319208,10 @@ var require_survey_link_frontier = __commonJS({
319082
319208
  (0, exploration_state_js_1.reduceEvent)(state2, { type: "LINKS_DISCOVERED", entries });
319083
319209
  const admitted = countLinkSeen(state2) - before;
319084
319210
  if (admitted > 0 && log2) {
319085
- log2(` [link-frontier] +${admitted} link-seen route(s) (${countLinkSeen(state2)}/${exploration_state_js_1.LINK_SEEN_FRONTIER_CAP}): ${entries.slice(0, 6).map((e) => e.route).join(", ")}${entries.length > 6 ? " \u2026" : ""}`);
319211
+ const tag = provenance === "dom" ? " [dom-harvest]" : "";
319212
+ const hiddenCount = entries.filter((e) => e.provenance === "dom-hidden").length;
319213
+ const hiddenNote = hiddenCount > 0 ? ` (${hiddenCount} hidden-menu door(s))` : "";
319214
+ log2(` [link-frontier]${tag} +${admitted} link-seen route(s)${hiddenNote} (${countLinkSeen(state2)}/${exploration_state_js_1.LINK_SEEN_FRONTIER_CAP}): ${entries.slice(0, 6).map((e) => e.route).join(", ")}${entries.length > 6 ? " \u2026" : ""}`);
319086
319215
  }
319087
319216
  const deniedProtected = entries.filter((e) => e.protected && state2.frontier.get(e.route) && !state2.frontier.get(e.route)?.protected);
319088
319217
  if (deniedProtected.length > 0 && log2) {
@@ -319209,10 +319338,10 @@ var require_exploration_prompt_builder = __commonJS({
319209
319338
  sections.push(`Mode: ${config.mode} | Budget remaining: ${config.maxIterations - state2.iteration} iterations`);
319210
319339
  const budgetPct = state2.iteration / config.maxIterations;
319211
319340
  const budgetBlocking = config.linkFrontierEnabled ? (0, survey_link_frontier_js_1.getFinishBlockingFrontier)(state2) : [];
319212
- if (budgetPct >= 0.95) {
319341
+ if (!config.adaptiveBudget && budgetPct >= 0.95) {
319213
319342
  sections.push("");
319214
319343
  sections.push(budgetBlocking.length > 0 ? `**CRITICAL: FINAL ITERATIONS. Unvisited discovered routes remain: ${(0, survey_link_frontier_js_1.describeBlockingRoutes)(budgetBlocking, 3)}. Visit ONLY these (capture_page each), then call finish_exploration. Nothing else.**` : "**CRITICAL: FINAL ITERATIONS. Call finish_exploration NOW with a summary of what you found. Do NOT start any new exploration.**");
319215
- } else if (budgetPct >= 0.9) {
319344
+ } else if (!config.adaptiveBudget && budgetPct >= 0.9) {
319216
319345
  sections.push("");
319217
319346
  sections.push(budgetBlocking.length > 0 ? `**CRITICAL: You have used 90%+ of your iteration budget. Unvisited discovered routes remain: ${(0, survey_link_frontier_js_1.describeBlockingRoutes)(budgetBlocking, 4)}. Visit ONLY these (capture_page each), then call finish_exploration.**` : "**CRITICAL: You have used 90%+ of your iteration budget. Wrap up immediately and call finish_exploration.**");
319218
319347
  }
@@ -319598,9 +319727,9 @@ var require_exploration_prompt_builder = __commonJS({
319598
319727
  sections.push("## Control Brief");
319599
319728
  sections.push(`Current route: ${state2.currentRoute} | Iteration ${state2.iteration}/${config.maxIterations} | Budget remaining: ${config.maxIterations - state2.iteration}`);
319600
319729
  const budgetPct = state2.iteration / config.maxIterations;
319601
- if (budgetPct >= 0.95) {
319730
+ if (!config.adaptiveBudget && budgetPct >= 0.95) {
319602
319731
  sections.push("**CRITICAL: FINAL ITERATIONS. Call finish_exploration NOW.**");
319603
- } else if (budgetPct >= 0.9) {
319732
+ } else if (!config.adaptiveBudget && budgetPct >= 0.9) {
319604
319733
  sections.push("**CRITICAL: 90%+ budget used. Wrap up and call finish_exploration.**");
319605
319734
  }
319606
319735
  if (state2.routeState.size > 0) {
@@ -321568,6 +321697,332 @@ var require_evidence_harvester = __commonJS({
321568
321697
  }
321569
321698
  });
321570
321699
 
321700
+ // ../runner-core/dist/services/survey-door-harvester.js
321701
+ var require_survey_door_harvester = __commonJS({
321702
+ "../runner-core/dist/services/survey-door-harvester.js"(exports2) {
321703
+ "use strict";
321704
+ Object.defineProperty(exports2, "__esModule", { value: true });
321705
+ exports2.PAGE_URL_PROBE_FN = exports2.MENU_EXPAND_COLLECT_FN = exports2.DOM_LINK_COLLECT_FN = void 0;
321706
+ exports2.isDomHarvestEnabled = isDomHarvestEnabled;
321707
+ exports2.isMenuExpandEnabled = isMenuExpandEnabled;
321708
+ exports2.parseEvaluateResult = parseEvaluateResult;
321709
+ exports2.sortDoorsFirst = sortDoorsFirst;
321710
+ exports2.harvestDomLinks = harvestDomLinks;
321711
+ exports2.toSeenLinks = toSeenLinks;
321712
+ function isDomHarvestEnabled() {
321713
+ const v = process.env.DISCOVERY_SURVEY_DOM_HARVEST;
321714
+ return v === "true" || v === "1";
321715
+ }
321716
+ function isMenuExpandEnabled() {
321717
+ const v = process.env.DISCOVERY_SURVEY_MENU_EXPAND;
321718
+ return (v === "true" || v === "1") && isDomHarvestEnabled();
321719
+ }
321720
+ var MAX_DOM_LINKS = 150;
321721
+ var MAX_EXPAND_TRIGGERS = 4;
321722
+ var EVALUATE_TIMEOUT_MS = 1e4;
321723
+ exports2.DOM_LINK_COLLECT_FN = `() => {
321724
+ const doors = [];
321725
+ const rest = [];
321726
+ const seen = new Set();
321727
+ const styleHidden = (el) => {
321728
+ try {
321729
+ const s = window.getComputedStyle(el);
321730
+ return s.display === 'none' || s.visibility === 'hidden';
321731
+ } catch { return false; }
321732
+ };
321733
+ const anchors = document.querySelectorAll('a[href], area[href]');
321734
+ for (const a of anchors) {
321735
+ const raw = a.getAttribute('href') || '';
321736
+ if (!raw || raw === '#') continue;
321737
+ if (/^(javascript|mailto|tel|sms|data|blob|about):/i.test(raw)) continue;
321738
+ if (a.hasAttribute('download')) continue;
321739
+ let resolved = '';
321740
+ try { resolved = a.href || ''; } catch {}
321741
+ if (typeof resolved !== 'string') resolved = String(resolved.baseVal || '');
321742
+ const key = raw + '|' + resolved;
321743
+ if (seen.has(key)) continue;
321744
+ seen.add(key);
321745
+ const label = (a.getAttribute('aria-label') || a.textContent || '')
321746
+ .replace(/\\s+/g, ' ').trim().slice(0, 80);
321747
+ let hidden = false;
321748
+ let node = a;
321749
+ while (node && node !== document.documentElement) {
321750
+ if (styleHidden(node)) { hidden = true; break; }
321751
+ node = node.parentElement;
321752
+ }
321753
+ // Footer context WINS over nav: <footer><nav> link farms are boilerplate,
321754
+ // not doors (sol implementation-review P1).
321755
+ const inFooter = !!a.closest('footer,[role="contentinfo"]');
321756
+ const inNav = !inFooter && !!a.closest('nav,[role="navigation"],[role="menubar"],[role="menu"],header,[role="banner"]');
321757
+ const entry = { href: raw.slice(0, 500), resolved: resolved.slice(0, 500), label, hidden, inNav, inFooter };
321758
+ if (inNav || hidden) doors.push(entry); else rest.push(entry);
321759
+ if (doors.length >= ${MAX_DOM_LINKS}) break;
321760
+ }
321761
+ const links = doors.concat(rest).slice(0, ${MAX_DOM_LINKS});
321762
+ return { pageUrl: location.href, links };
321763
+ }`;
321764
+ exports2.MENU_EXPAND_COLLECT_FN = `async () => {
321765
+ const startUrl = location.href;
321766
+ // Baseline pass records KEYS ONLY (no output budget consumed) \u2014 a page with
321767
+ // 150+ static anchors must not crowd freshly-mounted menu links out of the
321768
+ // result. Only post-click NEW anchors are returned.
321769
+ const seen = new Set();
321770
+ const out = [];
321771
+ const keyOf = (a) => {
321772
+ const raw = a.getAttribute('href') || '';
321773
+ if (!raw || raw === '#') return null;
321774
+ if (/^(javascript|mailto|tel|sms|data|blob|about):/i.test(raw)) return null;
321775
+ if (a.hasAttribute('download')) return null;
321776
+ let resolved = '';
321777
+ try { resolved = a.href || ''; } catch {}
321778
+ if (typeof resolved !== 'string') resolved = String(resolved.baseVal || '');
321779
+ return { raw, resolved, key: raw + '|' + resolved };
321780
+ };
321781
+ for (const a of document.querySelectorAll('a[href], area[href]')) {
321782
+ const k = keyOf(a);
321783
+ if (k) seen.add(k.key);
321784
+ }
321785
+ const collectNew = () => {
321786
+ for (const a of document.querySelectorAll('a[href], area[href]')) {
321787
+ if (out.length >= ${MAX_DOM_LINKS}) return;
321788
+ const k = keyOf(a);
321789
+ if (!k || seen.has(k.key)) continue;
321790
+ seen.add(k.key);
321791
+ const label = (a.getAttribute('aria-label') || a.textContent || '')
321792
+ .replace(/\\s+/g, ' ').trim().slice(0, 80);
321793
+ // hidden:true \u2014 mounted-on-demand links are absent from a resting
321794
+ // accessibility snapshot, which is exactly what "hidden door" means.
321795
+ out.push({ href: k.raw.slice(0, 500), resolved: k.resolved.slice(0, 500), label, hidden: true, inNav: true, inFooter: false });
321796
+ }
321797
+ };
321798
+ const chrome = 'nav,[role="navigation"],[role="menubar"],header,[role="banner"]';
321799
+ const destructive = /(delete|remove|archive|reset|disconnect|deactivate|destroy|purge|log\\s*out|sign\\s*out)/i;
321800
+ const styleVisible = (el) => {
321801
+ let node = el;
321802
+ while (node && node !== document.documentElement) {
321803
+ try {
321804
+ const s = window.getComputedStyle(node);
321805
+ if (s.display === 'none' || s.visibility === 'hidden') return false;
321806
+ } catch { return false; }
321807
+ node = node.parentElement;
321808
+ }
321809
+ return true;
321810
+ };
321811
+ const candidates = [];
321812
+ for (const el of document.querySelectorAll('button[aria-haspopup], button[aria-expanded="false"], [role="button"][aria-haspopup], [role="button"][aria-expanded="false"]')) {
321813
+ if (candidates.length >= ${MAX_EXPAND_TRIGGERS}) break;
321814
+ if (el.tagName === 'A' || el.closest('a[href]')) continue;
321815
+ const haspopup = el.getAttribute('aria-haspopup');
321816
+ const expanded = el.getAttribute('aria-expanded');
321817
+ if (haspopup === 'false') continue; // explicit no-popup
321818
+ if (expanded === 'true') continue; // already open \u2014 not ours to toggle
321819
+ if (el.form || el.closest('form')) continue; // form-associated (incl. form="" attr)
321820
+ const type = (el.getAttribute('type') || '').toLowerCase();
321821
+ if (type === 'submit' || type === 'reset') continue;
321822
+ if (!el.closest(chrome)) continue;
321823
+ if (el.hasAttribute('disabled') || el.getAttribute('aria-disabled') === 'true') continue;
321824
+ if (!styleVisible(el)) continue; // hidden triggers keep bogus geometry
321825
+ const name = (el.getAttribute('aria-label') || el.textContent || '').replace(/\\s+/g, ' ').trim();
321826
+ if (destructive.test(name)) continue;
321827
+ const rect = el.getBoundingClientRect();
321828
+ if (rect.width === 0 && rect.height === 0) continue;
321829
+ candidates.push(el);
321830
+ }
321831
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
321832
+ let expanded = 0;
321833
+ for (const el of candidates) {
321834
+ let opened = false;
321835
+ try {
321836
+ try { el.click(); opened = true; } catch { continue; }
321837
+ expanded++;
321838
+ await sleep(350);
321839
+ if (location.href !== startUrl) {
321840
+ return { pageUrl: location.href, links: out, expandedTriggers: expanded, navigated: true, originalUrl: startUrl };
321841
+ }
321842
+ collectNew();
321843
+ } finally {
321844
+ // Restore the exact trigger we opened: aria-expanded still "true" needs a
321845
+ // closing click; an attribute-less toggle gets clicked back once too.
321846
+ if (opened) {
321847
+ try {
321848
+ const nowExpanded = el.getAttribute('aria-expanded');
321849
+ if (nowExpanded !== 'false') el.click();
321850
+ } catch {}
321851
+ }
321852
+ }
321853
+ await sleep(100);
321854
+ if (location.href !== startUrl) {
321855
+ return { pageUrl: location.href, links: out, expandedTriggers: expanded, navigated: true, originalUrl: startUrl };
321856
+ }
321857
+ }
321858
+ return { pageUrl: location.href, links: out, expandedTriggers: expanded, navigated: false, originalUrl: startUrl };
321859
+ }`;
321860
+ exports2.PAGE_URL_PROBE_FN = `() => location.href`;
321861
+ function parseEvaluateResult(mcpResult) {
321862
+ if (!mcpResult || typeof mcpResult !== "object")
321863
+ return null;
321864
+ if (mcpResult.isError === true)
321865
+ return null;
321866
+ const content = mcpResult.content;
321867
+ if (!Array.isArray(content))
321868
+ return null;
321869
+ for (const item of content) {
321870
+ if (!item || typeof item !== "object")
321871
+ continue;
321872
+ const { type, text } = item;
321873
+ if (type !== "text" || typeof text !== "string" || !text.trim())
321874
+ continue;
321875
+ let payload = null;
321876
+ const section = /(?:^|\n)### Result\s*\n([\s\S]*?)(?=\n### |$)/.exec(text);
321877
+ if (section) {
321878
+ payload = section[1];
321879
+ } else if (!text.trimStart().startsWith("###")) {
321880
+ payload = text;
321881
+ }
321882
+ if (!payload)
321883
+ continue;
321884
+ const cleaned = payload.replace(/^\s*```(json)?\s*\n?/, "").replace(/\n?```\s*$/, "").trim();
321885
+ if (!cleaned)
321886
+ continue;
321887
+ try {
321888
+ return JSON.parse(cleaned);
321889
+ } catch {
321890
+ continue;
321891
+ }
321892
+ }
321893
+ return null;
321894
+ }
321895
+ function normalizeLinks(value) {
321896
+ if (!value || typeof value !== "object")
321897
+ return [];
321898
+ const links = value.links;
321899
+ if (!Array.isArray(links))
321900
+ return [];
321901
+ const out = [];
321902
+ for (const raw of links) {
321903
+ if (!raw || typeof raw !== "object")
321904
+ continue;
321905
+ const l = raw;
321906
+ if (typeof l.href !== "string" || !l.href)
321907
+ continue;
321908
+ out.push({
321909
+ href: l.href,
321910
+ resolved: typeof l.resolved === "string" ? l.resolved : "",
321911
+ label: typeof l.label === "string" && l.label ? l.label : void 0,
321912
+ hidden: l.hidden === true,
321913
+ inNav: l.inNav === true,
321914
+ inFooter: l.inFooter === true
321915
+ });
321916
+ }
321917
+ return out;
321918
+ }
321919
+ function sortDoorsFirst(links) {
321920
+ const tier = (l) => {
321921
+ if (l.inNav && l.hidden)
321922
+ return 0;
321923
+ if (l.inNav)
321924
+ return 1;
321925
+ if (!l.inFooter)
321926
+ return 2;
321927
+ return 3;
321928
+ };
321929
+ return [...links].sort((a, b) => tier(a) - tier(b));
321930
+ }
321931
+ async function callWithTimeout(client, fn, timeoutMs) {
321932
+ let timer;
321933
+ const timeout = new Promise((_, reject) => {
321934
+ timer = setTimeout(() => reject(new Error(`browser_evaluate timed out after ${timeoutMs}ms`)), timeoutMs);
321935
+ });
321936
+ try {
321937
+ return await Promise.race([
321938
+ client.callTool({ name: "browser_evaluate", arguments: { function: fn } }, void 0, { timeout: timeoutMs }),
321939
+ timeout
321940
+ ]);
321941
+ } finally {
321942
+ if (timer)
321943
+ clearTimeout(timer);
321944
+ }
321945
+ }
321946
+ async function harvestDomLinks(client, options = {}) {
321947
+ const { expandMenus = false, log: log2 } = options;
321948
+ const empty = { pageUrl: null, links: [], expandedTriggers: 0, navigated: false, originalUrl: null };
321949
+ let staticResult = empty;
321950
+ try {
321951
+ const parsed = parseEvaluateResult(await callWithTimeout(client, exports2.DOM_LINK_COLLECT_FN, EVALUATE_TIMEOUT_MS));
321952
+ const links = normalizeLinks(parsed);
321953
+ const pageUrl = parsed && typeof parsed === "object" && typeof parsed.pageUrl === "string" ? parsed.pageUrl : null;
321954
+ staticResult = { pageUrl, links, expandedTriggers: 0, navigated: false, originalUrl: pageUrl };
321955
+ } catch (err) {
321956
+ log2?.(` [door-harvest] dom read skipped \u2014 ${err instanceof Error ? err.message : String(err)}`);
321957
+ return empty;
321958
+ }
321959
+ if (!expandMenus) {
321960
+ return { ...staticResult, links: sortDoorsFirst(staticResult.links) };
321961
+ }
321962
+ if (!staticResult.pageUrl) {
321963
+ log2?.(" [door-harvest] skipping menu expansion \u2014 no verifiable page URL from the static pass");
321964
+ return { ...staticResult, links: sortDoorsFirst(staticResult.links) };
321965
+ }
321966
+ let extra = [];
321967
+ let expandedTriggers = 0;
321968
+ let expansionFailed = false;
321969
+ try {
321970
+ const parsed = parseEvaluateResult(await callWithTimeout(client, exports2.MENU_EXPAND_COLLECT_FN, EVALUATE_TIMEOUT_MS + 4e3));
321971
+ if (parsed === null) {
321972
+ expansionFailed = true;
321973
+ } else {
321974
+ extra = normalizeLinks(parsed);
321975
+ const obj = typeof parsed === "object" ? parsed : {};
321976
+ expandedTriggers = typeof obj.expandedTriggers === "number" ? obj.expandedTriggers : 0;
321977
+ }
321978
+ } catch (err) {
321979
+ expansionFailed = true;
321980
+ log2?.(` [door-harvest] menu expansion skipped \u2014 ${err instanceof Error ? err.message : String(err)}`);
321981
+ }
321982
+ let navigated = false;
321983
+ try {
321984
+ const probe = parseEvaluateResult(await callWithTimeout(client, exports2.PAGE_URL_PROBE_FN, 5e3));
321985
+ if (typeof probe === "string" && probe) {
321986
+ navigated = probe !== staticResult.pageUrl;
321987
+ } else {
321988
+ navigated = expansionFailed;
321989
+ }
321990
+ } catch {
321991
+ navigated = expansionFailed;
321992
+ }
321993
+ const known = new Set(staticResult.links.map((l) => l.href));
321994
+ const merged = [...staticResult.links];
321995
+ for (const link of extra) {
321996
+ if (!known.has(link.href)) {
321997
+ known.add(link.href);
321998
+ merged.push(link);
321999
+ }
322000
+ }
322001
+ if (expandedTriggers > 0) {
322002
+ log2?.(` [door-harvest] expanded ${expandedTriggers} menu trigger(s), +${merged.length - staticResult.links.length} link(s)${navigated ? " \u2014 PAGE NAVIGATED, caller must restore" : ""}`);
322003
+ } else if (navigated) {
322004
+ log2?.(" [door-harvest] page moved during expansion attempt \u2014 caller must restore");
322005
+ }
322006
+ return {
322007
+ pageUrl: staticResult.pageUrl,
322008
+ links: sortDoorsFirst(merged),
322009
+ expandedTriggers,
322010
+ navigated,
322011
+ originalUrl: staticResult.pageUrl
322012
+ };
322013
+ }
322014
+ function toSeenLinks(links) {
322015
+ return links.map((l) => ({
322016
+ url: l.resolved || l.href,
322017
+ label: l.label,
322018
+ hidden: l.hidden,
322019
+ inNav: l.inNav,
322020
+ inFooter: l.inFooter
322021
+ }));
322022
+ }
322023
+ }
322024
+ });
322025
+
321571
322026
  // ../runner-core/dist/services/survey-scope.js
321572
322027
  var require_survey_scope = __commonJS({
321573
322028
  "../runner-core/dist/services/survey-scope.js"(exports2) {
@@ -321575,7 +322030,9 @@ var require_survey_scope = __commonJS({
321575
322030
  Object.defineProperty(exports2, "__esModule", { value: true });
321576
322031
  exports2.deriveSurveyPathScope = deriveSurveyPathScope;
321577
322032
  exports2.isAuthFlowRoute = isAuthFlowRoute;
322033
+ exports2.hasAuthFlowSegment = hasAuthFlowSegment;
321578
322034
  exports2.buildSurveyScopeBoundary = buildSurveyScopeBoundary;
322035
+ exports2.routeWithinSurveyBasePath = routeWithinSurveyBasePath;
321579
322036
  exports2.filterFeatureGroupsToPathScope = filterFeatureGroupsToPathScope;
321580
322037
  var exploration_parser_js_1 = require_exploration_parser();
321581
322038
  function deriveSurveyPathScope(baseUrl) {
@@ -321603,22 +322060,35 @@ var require_survey_scope = __commonJS({
321603
322060
  "callback",
321604
322061
  "login",
321605
322062
  "log-in",
322063
+ "log_in",
321606
322064
  "signin",
321607
322065
  "sign-in",
322066
+ "sign_in",
321608
322067
  "signup",
321609
322068
  "sign-up",
322069
+ "sign_up",
321610
322070
  "register",
321611
322071
  "logout",
321612
322072
  "log-out",
322073
+ "log_out",
321613
322074
  "signout",
321614
322075
  "sign-out",
322076
+ "sign_out",
321615
322077
  "sso",
321616
322078
  "saml",
321617
322079
  "oidc"
321618
322080
  ]);
322081
+ var AUTH_FLOW_PARENT_SEGMENTS = /* @__PURE__ */ new Set(["api", "auth", "users", "user", "account", "accounts", "identity", "id"]);
321619
322082
  function isAuthFlowRoute(route2) {
321620
- const normalized = (0, exploration_parser_js_1.normalizeRouteForFocusScope)(route2).toLowerCase();
321621
- return normalized.split(/[/#]/).some((segment) => AUTH_FLOW_SEGMENTS.has(segment));
322083
+ const segments = (0, exploration_parser_js_1.normalizeRouteForFocusScope)(route2).toLowerCase().split(/[/#]/).filter(Boolean);
322084
+ if (segments.length === 0)
322085
+ return false;
322086
+ if (AUTH_FLOW_SEGMENTS.has(segments[0]))
322087
+ return true;
322088
+ return segments.length > 1 && AUTH_FLOW_PARENT_SEGMENTS.has(segments[0]) && AUTH_FLOW_SEGMENTS.has(segments[1]);
322089
+ }
322090
+ function hasAuthFlowSegment(route2) {
322091
+ return (0, exploration_parser_js_1.normalizeRouteForFocusScope)(route2).toLowerCase().split(/[/#]/).filter(Boolean).some((segment) => AUTH_FLOW_SEGMENTS.has(segment));
321622
322092
  }
321623
322093
  function routePathForScope(route2, origin) {
321624
322094
  const trimmed = (route2 ?? "").trim();
@@ -321642,7 +322112,7 @@ var require_survey_scope = __commonJS({
321642
322112
  return trimmed;
321643
322113
  }
321644
322114
  }
321645
- if (trimmed.startsWith("/") && trimmed.includes("..")) {
322115
+ if (trimmed.startsWith("/") && (trimmed.includes("..") || /%2e/i.test(trimmed))) {
321646
322116
  try {
321647
322117
  const resolved = new URL(trimmed, "https://scope.invalid");
321648
322118
  return `${resolved.pathname}${resolved.search}${resolved.hash}`;
@@ -321662,20 +322132,21 @@ var require_survey_scope = __commonJS({
321662
322132
  }
321663
322133
  return lines.join("\n");
321664
322134
  }
322135
+ function routeWithinSurveyBasePath(route2, scope) {
322136
+ const path = routePathForScope(route2, scope.origin);
322137
+ if (path === null)
322138
+ return false;
322139
+ if ((0, exploration_parser_js_1.routeIsWithinFocusAreas)(path, [scope.basePath]))
322140
+ return true;
322141
+ const norm = (0, exploration_parser_js_1.normalizeRouteForFocusScope)(path);
322142
+ return norm === `${scope.basePath}#` || norm.startsWith(`${scope.basePath}#/`);
322143
+ }
321665
322144
  function filterFeatureGroupsToPathScope(featureGroups, baseUrl) {
321666
322145
  const scope = deriveSurveyPathScope(baseUrl);
321667
322146
  if (!scope) {
321668
- return { kept: featureGroups, droppedGroups: [], trimmedRoutes: [], trimmedPages: [], basePath: null };
322147
+ return { kept: featureGroups, droppedGroups: [], trimmedRoutes: [], trimmedPages: [], basePath: null, failedOpen: false };
321669
322148
  }
321670
- const withinBase = (route2) => {
321671
- const path = routePathForScope(route2, scope.origin);
321672
- if (path === null)
321673
- return false;
321674
- if ((0, exploration_parser_js_1.routeIsWithinFocusAreas)(path, [scope.basePath]))
321675
- return true;
321676
- const norm = (0, exploration_parser_js_1.normalizeRouteForFocusScope)(path);
321677
- return norm === `${scope.basePath}#` || norm.startsWith(`${scope.basePath}#/`);
321678
- };
322149
+ const withinBase = (route2) => routeWithinSurveyBasePath(route2, scope);
321679
322150
  const allowedAuthFlow = (route2) => {
321680
322151
  const path = routePathForScope(route2, scope.origin);
321681
322152
  return path !== null && isAuthFlowRoute(path);
@@ -321725,7 +322196,23 @@ var require_survey_scope = __commonJS({
321725
322196
  trimmedPages.push({ name: group.name, routes: removedPages });
321726
322197
  }
321727
322198
  }
321728
- return { kept, droppedGroups, trimmedRoutes, trimmedPages, basePath: scope.basePath };
322199
+ if (kept.length === 0 && droppedGroups.length > 0) {
322200
+ const redirectSignature = featureGroups.some((group) => (Array.isArray(group.routes) ? group.routes : []).some((route2) => {
322201
+ const path = routePathForScope(route2, scope.origin);
322202
+ return path !== null && !isAuthFlowRoute(path);
322203
+ }));
322204
+ if (redirectSignature) {
322205
+ return {
322206
+ kept: featureGroups,
322207
+ droppedGroups: [],
322208
+ trimmedRoutes: [],
322209
+ trimmedPages: [],
322210
+ basePath: scope.basePath,
322211
+ failedOpen: true
322212
+ };
322213
+ }
322214
+ }
322215
+ return { kept, droppedGroups, trimmedRoutes, trimmedPages, basePath: scope.basePath, failedOpen: false };
321729
322216
  }
321730
322217
  }
321731
322218
  });
@@ -321746,8 +322233,10 @@ var require_discover_explorer = __commonJS({
321746
322233
  exports2.shouldSurfaceSurveyModalTrigger = shouldSurfaceSurveyModalTrigger;
321747
322234
  exports2.normalizeAssistantToolCallArgs = normalizeAssistantToolCallArgs;
321748
322235
  exports2.getMaxIterations = getMaxIterations;
322236
+ exports2.computeBudgetDecision = computeBudgetDecision;
321749
322237
  exports2.updatePendingRouteScreenshot = updatePendingRouteScreenshot;
321750
322238
  exports2.consumePendingRouteScreenshot = consumePendingRouteScreenshot;
322239
+ exports2.buildSystemPrompt = buildSystemPrompt;
321751
322240
  exports2.runExplorePhase = runExplorePhase;
321752
322241
  var crypto_1 = require("crypto");
321753
322242
  var ai_provider_js_1 = require_ai_provider();
@@ -321771,6 +322260,7 @@ var require_discover_explorer = __commonJS({
321771
322260
  var evidence_harvester_js_1 = require_evidence_harvester();
321772
322261
  var exploration_parser_js_1 = require_exploration_parser();
321773
322262
  var survey_link_frontier_js_1 = require_survey_link_frontier();
322263
+ var survey_door_harvester_js_1 = require_survey_door_harvester();
321774
322264
  var survey_scope_js_1 = require_survey_scope();
321775
322265
  var snapshot_context_compactor_js_2 = require_snapshot_context_compactor();
321776
322266
  Object.defineProperty(exports2, "formatMCPToolResult", { enumerable: true, get: function() {
@@ -321924,6 +322414,46 @@ var require_discover_explorer = __commonJS({
321924
322414
  }
321925
322415
  return readPositiveIntEnv2(env, "DISCOVERY_EXPLORE_MAX_ITERATIONS_DEFAULT", DEFAULT_MAX_EXPLORE_ITERATIONS_DEFAULT);
321926
322416
  }
322417
+ var DEFAULT_ADAPTIVE_BUDGET_HARD_CAP = 200;
322418
+ var ADAPTIVE_BUDGET_FINALIZE_RESERVE = 5;
322419
+ var ADAPTIVE_BUDGET_ITERS_PER_ROUTE = 4;
322420
+ var ADAPTIVE_BUDGET_MIN_LEASE = 10;
322421
+ var ADAPTIVE_BUDGET_MAX_LEASE = 30;
322422
+ var ADAPTIVE_BUDGET_DISCOVERY_LEASE = 20;
322423
+ var ADAPTIVE_BUDGET_RESCUE_WINDOW = 10;
322424
+ var ADAPTIVE_BUDGET_MIN_GAP = 10;
322425
+ var ADAPTIVE_BUDGET_DECISION_PCT = 0.9;
322426
+ var ADAPTIVE_BUDGET_PROGRESS_WINDOW = 15;
322427
+ function computeBudgetDecision(input) {
322428
+ const { iteration, currentCap, hardCap, remainingRoutes, capturing, freshDiscovery, discoveryLeaseUsed, rescueUsed, allowExtension } = input;
322429
+ if (remainingRoutes <= 0)
322430
+ return { action: "finish", reason: "drained" };
322431
+ if (iteration >= hardCap)
322432
+ return { action: "finish", reason: "hard-cap" };
322433
+ const tail = Math.max(0, currentCap - iteration);
322434
+ const needed = ADAPTIVE_BUDGET_FINALIZE_RESERVE + ADAPTIVE_BUDGET_ITERS_PER_ROUTE * remainingRoutes;
322435
+ if (allowExtension && capturing) {
322436
+ if (currentCap >= hardCap)
322437
+ return { action: "none" };
322438
+ const shortfall = needed - tail;
322439
+ if (shortfall <= 0)
322440
+ return { action: "none" };
322441
+ const clamped = Math.min(Math.max(shortfall, ADAPTIVE_BUDGET_MIN_LEASE), ADAPTIVE_BUDGET_MAX_LEASE);
322442
+ const delta = Math.min(hardCap - currentCap, clamped);
322443
+ return { action: "extend", delta, newCap: currentCap + delta, lease: "capture" };
322444
+ }
322445
+ if (allowExtension && freshDiscovery && !discoveryLeaseUsed) {
322446
+ if (currentCap >= hardCap)
322447
+ return { action: "none" };
322448
+ if (tail >= needed)
322449
+ return { action: "none" };
322450
+ const delta = Math.min(hardCap - currentCap, ADAPTIVE_BUDGET_DISCOVERY_LEASE);
322451
+ return { action: "extend", delta, newCap: currentCap + delta, lease: "discovery" };
322452
+ }
322453
+ if (!rescueUsed)
322454
+ return { action: "rescue" };
322455
+ return { action: "finish", reason: "stalled" };
322456
+ }
321927
322457
  function updatePendingRouteScreenshot(pending, { imageData, detectedRoute, fallbackRoute }) {
321928
322458
  if (imageData) {
321929
322459
  return {
@@ -322120,8 +322650,9 @@ NEVER assert: user-specific text (names, emails), counts/numbers, timestamps, ma
322120
322650
  };
322121
322651
  function buildSystemPrompt(baseUrl, variableContext, existingSiteMap, existingTestNames, options) {
322122
322652
  const browserCredentials = variableContext.allTestVariables ?? variableContext.publicTestVariables;
322123
- const { secrets: explorerSecretVars, publics: explorerPublicVars } = (0, credential_tools_js_1.partitionTestVariables)(browserCredentials);
322653
+ const { secrets: explorerSecretVars, publics: explorerPublicVarsRaw } = (0, credential_tools_js_1.partitionTestVariables)(browserCredentials);
322124
322654
  const hasCredentials = Object.keys(explorerSecretVars).length > 0;
322655
+ const { DISCOVERY_SHOULD_REGISTER: _omitRegisterFlag, ...explorerPublicVars } = explorerPublicVarsRaw;
322125
322656
  const explorerPublicLines = (0, credential_tools_js_1.renderPublicVariablesBlock)(explorerPublicVars);
322126
322657
  const credentialBlock = `${explorerPublicLines ? `
322127
322658
  ## Test Variables (public)
@@ -322131,6 +322662,7 @@ ${explorerPublicLines}
322131
322662
  const inboxBlock = options?.inboxPrompt ? `
322132
322663
  ${options.inboxPrompt}` : "";
322133
322664
  const isRegisterMode = !!options?.inboxPrompt;
322665
+ const emailVerificationUnavailable = !isRegisterMode && !!options?.emailVerificationUnavailable;
322134
322666
  const focusAreas = options?.focusAreas;
322135
322667
  let alreadyDiscoveredPages = "";
322136
322668
  if (existingSiteMap && existingSiteMap.pages.length > 0) {
@@ -322152,21 +322684,27 @@ ${options.inboxPrompt}` : "";
322152
322684
  const isIncremental = !!(options?.incremental && mode === "survey");
322153
322685
  const MAX_EXPLORE_ITERATIONS = getMaxIterations(mode, options?.incremental);
322154
322686
  const isSurvey = mode === "survey";
322687
+ const adaptiveBudgetOn = isSurvey && !isIncremental && (process.env.DISCOVERY_ADAPTIVE_BUDGET === "1" || (0, shared_1.parseBoolFlag)(process.env.DISCOVERY_ADAPTIVE_BUDGET)) && (0, survey_link_frontier_js_1.isSurveyLinkFrontierEnabled)();
322688
+ const surveyPathScope = isSurvey ? (0, survey_scope_js_1.deriveSurveyPathScope)(baseUrl) : null;
322155
322689
  if (isSurvey) {
322156
- return `You are a QA exploration agent. Your goal: MAP an entire web application by visiting every reachable page and cataloging its structure. You are NOT testing - you are building a complete site map so downstream agents know what to test.
322690
+ return `You are a QA exploration agent. Your goal: ${surveyPathScope ? `MAP one flow of a web application in ISOLATION \u2014 the flow under \`${surveyPathScope.basePath}\` \u2014 visiting every reachable page INSIDE that scope and cataloging its structure` : "MAP an entire web application by visiting every reachable page and cataloging its structure"}. You are NOT testing - you are building a ${surveyPathScope ? "site map of this flow" : "complete site map"} so downstream agents know what to test.
322157
322691
 
322158
322692
  ## Strategy
322159
322693
  1. ${isRegisterMode ? `Navigate to the base URL. BEFORE registering, explore the unauthenticated experience first:
322160
322694
  - Find all reachable public auth pages from the logged-out experience: Login, Register/Sign Up, Forgot Password - check menus, drawers, and modal auth switches too
322161
322695
  - For each: browser_snapshot \u2192 capture_page \u2192 record_transition
322162
322696
  - Do NOT submit the password-reset form - only catalog it (survey rule: map, do not mutate)
322163
- - After capturing the public auth pages, REGISTER a new account by following the Account Registration section below, then continue mapping the authenticated app` : hasCredentials ? `Navigate to the base URL. BEFORE logging in, explore the unauthenticated experience first:
322697
+ - After capturing the public auth pages, REGISTER a new account by following the Account Registration section below, then continue mapping the authenticated app` : emailVerificationUnavailable ? `Navigate to the base URL. NOTE: this project asked to REGISTER a new account, but this runner CANNOT receive email (verification inbox unavailable). Registration may still work if the app does not require email verification:
322698
+ - FIRST explore the unauthenticated experience: find all reachable public auth pages (Login, Register/Sign Up, Forgot Password - check menus, drawers, and modal auth switches too) and capture each: browser_snapshot \u2192 capture_page \u2192 record_transition. Do NOT submit the password-reset form
322699
+ - THEN attempt registration ONCE: fill the signup form via \`fill_credential_form\` with the \`TEST_USER_EMAIL\` + \`TEST_USER_PASSWORD\` credential keys (only if no TEST_USER_EMAIL key is listed, use a fresh \`testuser-<timestamp>@example.com\`), submit it ONCE, and never alter the email or create a second account. If signup says the address is already registered, log in with the same keys instead
322700
+ - If you end up signed in WITHOUT an email round-trip, continue mapping the authenticated app normally
322701
+ - THE WALL: if any step demands an emailed code/link ("check your email", OTP, magic link), STOP that flow immediately \u2014 never type a guessed code, never click Resend \u2014 keep mapping the public app, and state in finish_exploration that authenticated coverage is BLOCKED (cannot receive verification email)` : hasCredentials ? `Navigate to the base URL. BEFORE logging in, explore the unauthenticated experience first:
322164
322702
  - Find all reachable public auth pages from the logged-out experience: Login, Register/Sign Up, Forgot Password - check menus, drawers, and modal auth switches too
322165
322703
  - For each: browser_snapshot \u2192 capture_page \u2192 record_transition
322166
322704
  - Do NOT submit registration or password-reset forms - only catalog the page structure (survey rule: map, do not mutate)
322167
322705
  - After capturing all reachable public auth pages, use the credentials below to log in and continue mapping the authenticated app` : "Navigate to the base URL"}
322168
322706
  2. Take a \`browser_snapshot\` on the landing page. **IMPORTANT: NEVER pass a filename parameter to browser_snapshot - always call it with no arguments so the snapshot is returned inline.**
322169
- 3. **BUILD YOUR CHECKLIST**: Before clicking anything, list the navigation links visible in the snapshot - sidebar, header, footer, user menus, hamburger menus. If the snapshot output says some navigation chrome was omitted, immediately call \`capture_page\` on the current page and use its structured nav list to complete the checklist before proceeding. This is your exploration checklist. Visit each one in order
322707
+ 3. **BUILD YOUR CHECKLIST**: Before clicking anything, list the navigation links visible in the snapshot - sidebar, header, footer, user menus, hamburger menus. If the snapshot output says some navigation chrome was omitted, immediately call \`capture_page\` on the current page and use its structured nav list to complete the checklist before proceeding. This is your exploration checklist. Visit each one in order${surveyPathScope ? ` \u2014 but ONLY the links inside the entry scope \`${surveyPathScope.basePath}\`. Links leading outside it (global header/footer, a parent hub, sibling sections) are OUT of scope: leave them off the checklist, do not visit them` : ""}
322170
322708
  - **ALWAYS navigate by CLICKING links in the page**, not by typing URLs into browser_navigate. Clicking captures the exact locator that downstream test generators need. Direct URL navigation loses this information.
322171
322709
  4. Visit each navigation target systematically. On each page:
322172
322710
  - \`browser_snapshot\` to see the page
@@ -322177,8 +322715,8 @@ ${options.inboxPrompt}` : "";
322177
322715
  5. **Tabs and sub-sections**: If a page has tabs, click EACH tab and call \`capture_page\` for each tab state. Use a route suffix like \`/settings?tab=profile\`, \`/settings?tab=billing\`
322178
322716
  6. **Hidden navigation**: Look for dropdown menus, user/avatar menus (click the avatar), hamburger menus, "More..." links, breadcrumbs. Click to OPEN these to discover navigation targets
322179
322717
  7. **List pages**: If a page shows a list of items with links (e.g. /users/1, /users/2), click ONE item to discover the detail page template. Do NOT visit every item - they are the same page pattern
322180
- 8. **Error page**: Navigate to a path that does not exist (e.g. \`/this-page-does-not-exist-404\`) to capture the app's error page
322181
- 9. After visiting ALL reachable pages, call \`finish_exploration\`
322718
+ 8. **Error page**: do NOT probe made-up routes to capture the app's error page \u2014 nothing downstream uses a probed 404. Only catalog an error page if the app itself routes you to one (broken link, failed action, redirect)
322719
+ 9. After visiting ALL reachable ${surveyPathScope ? "in-scope " : ""}pages, call \`finish_exploration\`
322182
322720
  You do NOT have a \`record_journey\` tool - your job is mapping, not testing. Downstream agents will create tests from your site map.
322183
322721
 
322184
322722
  ## What to catalog (capture_page)
@@ -322203,7 +322741,7 @@ ${(0, survey_scope_js_1.buildSurveyScopeBoundary)(baseUrl)}
322203
322741
  - **OAuth/SSO**: If login redirects to an external provider (Google, GitHub), do not follow it. Note that the app uses OAuth and explore unauthenticated pages only
322204
322742
  - **Auth failure**: If login${isRegisterMode ? " or account registration" : ""} fails after 2 attempts, capture the auth page and explore unauthenticated pages. Note the failure in your \`finish_exploration\` summary
322205
322743
  - **Parameterized routes**: /users/1 and /users/2 are the same page template. Visit ONE instance, not all of them
322206
- - Max iterations: ${MAX_EXPLORE_ITERATIONS}. You will be warned at 90%. Use your full budget to discover every page thoroughly
322744
+ - ${adaptiveBudgetOn ? `Initial iteration budget: ${MAX_EXPLORE_ITERATIONS}. If the map is still incomplete as you approach it, the harness may GRANT you more iterations (up to a hard cap) - an explicit "GRANTED: ..." message supersedes this number. Use your budget to discover every page thoroughly` : `Max iterations: ${MAX_EXPLORE_ITERATIONS}. You will be warned at 90%. Use your full budget to discover every page thoroughly`}
322207
322745
 
322208
322746
  ${appBrief ? `## Application Brief
322209
322747
  The user provided this description of their application:
@@ -322225,7 +322763,7 @@ If the user mentioned a specific page that changed (e.g. "Settings was redesigne
322225
322763
  - Check for Login, Register/Sign Up, Forgot Password - including behind menus, drawers, and modal auth switches
322226
322764
  - For each NEW auth page: browser_snapshot \u2192 capture_page \u2192 record_transition
322227
322765
  - Do NOT submit the password-reset form (survey rule: map, do not mutate)
322228
- - After capturing any new public auth pages, REGISTER a new account (see the Account Registration section) and continue` : hasCredentials ? `Navigate to the base URL. BEFORE logging in, explore the unauthenticated experience for any NEW public auth pages not in the known routes above:
322766
+ - After capturing any new public auth pages, REGISTER a new account (see the Account Registration section) and continue` : emailVerificationUnavailable ? `Navigate to the base URL. NOTE: registration was requested for this project but this runner CANNOT receive email (verification inbox unavailable). Attempt registration ONCE with the \`TEST_USER_EMAIL\` + \`TEST_USER_PASSWORD\` credential keys via \`fill_credential_form\` (if signup says the address is already registered, log in with the same keys). If you get signed in without an email round-trip, map NEW authenticated pages normally. If any step demands an emailed code/link, STOP that flow \u2014 never type a guessed code \u2014 map only NEW public pages and note in finish_exploration that authenticated coverage is BLOCKED (cannot receive verification email)` : hasCredentials ? `Navigate to the base URL. BEFORE logging in, explore the unauthenticated experience for any NEW public auth pages not in the known routes above:
322229
322767
  - Check for Login, Register/Sign Up, Forgot Password - including behind menus, drawers, and modal auth switches
322230
322768
  - For each NEW auth page: browser_snapshot \u2192 capture_page \u2192 record_transition
322231
322769
  - Do NOT submit registration or password-reset forms (survey rule: map, do not mutate)
@@ -322243,7 +322781,9 @@ ${surfaceIntelligence ? "## Prior Recordings\n" + surfaceIntelligence + "\n" : "
322243
322781
 
322244
322782
  ## App Details
322245
322783
  - Base URL: ${baseUrl}
322246
- ${credentialBlock}${redactedBlock}${inboxBlock}`;
322784
+ ${credentialBlock}${redactedBlock}${inboxBlock}${emailVerificationUnavailable ? `
322785
+
322786
+ ${inbox_tools_js_1.EMAIL_VERIFICATION_UNAVAILABLE_OVERRIDE_BLOCK}` : ""}`;
322247
322787
  }
322248
322788
  return `You are an expert QA exploration agent. Your job is to USE a web application like a real user - interact with every feature you find, observe what happens, and catalog the results.
322249
322789
 
@@ -322270,7 +322810,7 @@ Every feature you discover should be USED, not just cataloged. The test generato
322270
322810
 
322271
322811
  ## Strategy
322272
322812
  1. Navigate to the BASE URL (the landing/home page). ALWAYS start here - never deep-link directly to sub-pages like /auth/login or /dashboard.
322273
- 2. From the landing page, find and use the app's own navigation to reach features.${isRegisterMode ? " First create your account by following the Account Registration section below, then continue." : hasCredentials ? " Find the login/sign-in link and log in using the credentials below." : ""}
322813
+ 2. From the landing page, find and use the app's own navigation to reach features.${isRegisterMode ? " First create your account by following the Account Registration section below, then continue." : emailVerificationUnavailable ? " NOTE: registration was requested for this project but this runner CANNOT receive email (verification inbox unavailable). First attempt registration ONCE with the `TEST_USER_EMAIL` + `TEST_USER_PASSWORD` credential keys via `fill_credential_form` (never alter the email; if it is already registered, log in with the same keys). If you are signed in without an email round-trip, continue as a normal logged-in user. If any step demands an emailed code/link, STOP that flow \u2014 never type a guessed code \u2014 explore what is publicly reachable and state in finish_exploration that authenticated coverage is BLOCKED (cannot receive verification email)." : hasCredentials ? " Find the login/sign-in link and log in using the credentials below." : ""}
322274
322814
  3. On each page: take a \`browser_snapshot\`, identify what features/actions are available
322275
322815
  4. **USE the features on the page:**
322276
322816
  - Forms: fill every field with realistic data, submit, observe the result (success page, validation errors, redirect, toast messages)
@@ -322288,7 +322828,11 @@ Every feature you discover should be USED, not just cataloged. The test generato
322288
322828
  - Do NOT split validation, invalid input, and recovery into separate tests - combine them into ONE comprehensive test
322289
322829
  c) For multi-section pages (profile with tabs, settings with categories): test each DISTINCT section as a separate happy path test
322290
322830
  Focus on meaningful coverage: every form should have at least a happy path and a validation test. Multi-section pages (tabs, categories) should test each distinct section.
322291
- **Auth pages (login/register) - SPECIAL ORDER: test NEGATIVE before positive:**
322831
+ ${emailVerificationUnavailable ? ` **Auth pages (login/register) - registration requested but this runner CANNOT receive email:**
322832
+ - Step 1: Test negative flows FIRST while not logged in: on the LOGIN form, submit empty fields and invalid credentials (synthetic values like "wrong@example.com" / "badpassword" via \`browser_type\` \u2014 nothing can be created there); on the REGISTRATION form, empty-submit validation ONLY (a filled synthetic signup could CREATE a stray account on a permissive app). Call \`record_journey\` ONCE for the combined validation flow
322833
+ - Step 2: Attempt the happy path ONCE via REGISTRATION: \`fill_credential_form\` with the \`TEST_USER_EMAIL\` + \`TEST_USER_PASSWORD\` credential keys, submit the signup form ONCE. Never alter the email or create a second account; if signup says the address is already registered, log in with the same keys instead
322834
+ - Step 3: If you are signed in with NO email round-trip, call \`record_journey\` for the happy path and continue exploring as a logged-in user
322835
+ - THE WALL: if any step demands an emailed code/link (verification code, OTP, magic link, "check your email"), STOP immediately \u2014 never type a guessed code, never click Resend \u2014 record only the validation journey and note in \`finish_exploration\` that the authenticated happy path is BLOCKED (cannot receive verification email)` : ` **Auth pages (login/register) - SPECIAL ORDER: test NEGATIVE before positive:**
322292
322836
  - You arrive at the login/register page NOT logged in - use this state to test errors FIRST
322293
322837
  - Step 1: Submit with empty fields \u2192 observe validation errors
322294
322838
  - Step 2: Submit with invalid credentials (wrong password, bad email) \u2192 observe error messages
@@ -322296,7 +322840,7 @@ Every feature you discover should be USED, not just cataloged. The test generato
322296
322840
  - Step 4: NOW do the happy path - log in with valid credentials \u2192 observe redirect to dashboard
322297
322841
  - Step 5: Call \`record_journey\` for the happy path
322298
322842
  - This order avoids needing to log out between tests. After the happy path, you are logged in and ready to explore other features
322299
- - **Login filling**: ALWAYS use \`fill_credential_form\` for the happy-path login \u2014 never \`browser_fill_form\` or \`browser_type\` with the actual email/password (those calls will be blocked). Example: \`fill_credential_form({ fields: [{ field: "Email", credentialKey: "TEST_USER_EMAIL" }, { field: "Password", credentialKey: "TEST_USER_PASSWORD" }] })\`. For sequential fills, use \`fill_credential\` per field. Pure validation flows (empty submit, deliberately wrong password) can use \`browser_type\` with synthetic invalid values like "wrong@example.com" / "badpassword" \u2014 those are not real credentials and won't be blocked.
322843
+ - **Login filling**: ALWAYS use \`fill_credential_form\` for the happy-path login \u2014 never \`browser_fill_form\` or \`browser_type\` with the actual email/password (those calls will be blocked). Example: \`fill_credential_form({ fields: [{ field: "Email", credentialKey: "TEST_USER_EMAIL" }, { field: "Password", credentialKey: "TEST_USER_PASSWORD" }] })\`. For sequential fills, use \`fill_credential\` per field. Pure validation flows (empty submit, deliberately wrong password) can use \`browser_type\` with synthetic invalid values like "wrong@example.com" / "badpassword" \u2014 those are not real credentials and won't be blocked.`}
322300
322844
  **Logging out (when needed for other reasons):**
322301
322845
  - To find the logout button: look in the user/avatar menu (click the profile icon or avatar in the header), check sidebar bottom, check settings page
322302
322846
  - Do NOT try navigating to /logout or /auth/logout directly - these URLs rarely exist. Always find and click the actual logout button in the UI
@@ -322347,25 +322891,38 @@ Every feature you discover should be USED, not just cataloged. The test generato
322347
322891
 
322348
322892
  GOOD (specific, with routes, stable assertions):
322349
322893
  \`\`\`
322350
- record_journey({
322894
+ ${emailVerificationUnavailable ? `record_journey({
322895
+ name: "Contact Form - Validation",
322896
+ route: "/contact",
322897
+ routes: ["/", "/contact"],
322898
+ steps: ["Navigate to /", "Click 'Contact' link", "Submit the empty form", "Observe validation errors"],
322899
+ expectedOutcome: "URL matches /contact. Validation error 'Email is required' is visible.",
322900
+ assertions: [{ type: "url", value: "/contact" }, { type: "error-text", value: "Email is required" }]
322901
+ })` : `record_journey({
322351
322902
  name: "Login - Happy Path",
322352
322903
  route: "/auth/login",
322353
322904
  routes: ["/", "/auth/login", "/dashboard"],
322354
322905
  steps: ["Navigate to /", "Click 'Sign In' link", "Fill email and password with test credentials", "Click 'Log In' button", "Observe redirect to /dashboard"],
322355
322906
  expectedOutcome: "URL matches /dashboard. Sidebar link 'Overview' is visible.",
322356
322907
  assertions: [{ type: "url", value: "/dashboard" }, { type: "nav-link", locator: "getByRole('link', { name: 'Overview' })" }]
322357
- })
322908
+ })`}
322358
322909
  \`\`\`
322359
322910
 
322360
322911
  BAD (vague, missing routes, marketing assertions):
322361
322912
  \`\`\`
322362
- record_journey({
322913
+ ${emailVerificationUnavailable ? `record_journey({
322914
+ name: "Contact test",
322915
+ route: "/contact",
322916
+ routes: ["/contact"],
322917
+ steps: ["Try the contact form"],
322918
+ expectedOutcome: "User sees 'The Best Platform Ever' heading"
322919
+ })` : `record_journey({
322363
322920
  name: "Login test",
322364
322921
  route: "/auth/login",
322365
322922
  routes: ["/auth/login"],
322366
322923
  steps: ["Login to the app"],
322367
322924
  expectedOutcome: "User sees dashboard with 'Welcome to the Best Platform Ever' heading"
322368
- })
322925
+ })`}
322369
322926
  \`\`\`
322370
322927
 
322371
322928
  ## Bug Detection - CRITICAL
@@ -322410,7 +322967,7 @@ Exception: if you need to navigate THROUGH other pages to reach a focus area (e.
322410
322967
  2. Take a \`browser_snapshot\` to understand what's on the page
322411
322968
  3. **HAPPY PATH**: Fill ALL form fields with valid/realistic data, click the primary action button (Submit, Generate, Save, Create, etc.), and observe the result. For AI/async operations, wait for the result using \`browser_wait_for\` before taking a snapshot. Call \`record_journey\` to document this flow
322412
322969
  4. **VALIDATION/ERROR**: Go back to the page. Try submitting with empty required fields. Try invalid data (wrong email format, short password, etc.). Observe ALL validation messages. Fix errors and resubmit successfully. Call \`record_journey\` for the combined validation+recovery flow
322413
- - **Exception for auth pages (login/register)**: Do validation/errors FIRST (step 4 before step 3) while you are not logged in, then happy path last. See the auth-specific instructions above
322970
+ - **Exception for auth pages (login/register)**: ${emailVerificationUnavailable ? "validation FIRST, then ONE registration attempt with the TEST_USER_EMAIL + TEST_USER_PASSWORD credential keys \u2014 if an emailed code/link is demanded, STOP (never guess a code) and note the happy path as BLOCKED (cannot receive verification email). See the auth-specific instructions above" : "Do validation/errors FIRST (step 4 before step 3) while you are not logged in, then happy path last. See the auth-specific instructions above"}
322414
322971
  5. **ADDITIONAL INTERACTIONS**: Click buttons, open dropdowns, test tabs/sections, try search if available. If there are distinct sub-sections (e.g. tabs, accordion panels), test each one
322415
322972
  6. After each interaction, call \`capture_page\` with detailed observations
322416
322973
  7. **ONLY after completing steps 1-6 for ALL focus areas**, call \`finish_exploration\`
@@ -322512,7 +323069,9 @@ ${surfaceIntelligence}
322512
323069
 
322513
323070
  ## App Details
322514
323071
  - Base URL: ${baseUrl}
322515
- ${credentialBlock}${redactedBlock}${inboxBlock}`;
323072
+ ${credentialBlock}${redactedBlock}${inboxBlock}${emailVerificationUnavailable ? `
323073
+
323074
+ ${inbox_tools_js_1.EMAIL_VERIFICATION_UNAVAILABLE_OVERRIDE_BLOCK}` : ""}`;
322516
323075
  }
322517
323076
  async function runExplorePhase(mcpClient, baseUrl, variableContext, existingSiteMap, projectId, existingTestNames, options, config) {
322518
323077
  const logs2 = [];
@@ -322556,6 +323115,7 @@ ${credentialBlock}${redactedBlock}${inboxBlock}`;
322556
323115
  const perceptionEnricherEnabled = ((0, shared_1.parseBoolFlag)(process.env.DISCOVERY_PERCEPTION_ENRICHER) || process.env.DISCOVERY_PERCEPTION_ENRICHER === "1") && typeof options?.getPerceptionPage === "function";
322557
323116
  const linkFrontierEnabled = (0, survey_link_frontier_js_1.isSurveyLinkFrontierEnabled)() && options?.mode === "survey";
322558
323117
  const linkScope = (0, survey_link_frontier_js_1.deriveLinkScope)(baseUrl);
323118
+ const surveyNavScope = options?.mode === "survey" ? (0, survey_scope_js_1.deriveSurveyPathScope)(baseUrl) : null;
322559
323119
  let finishRedirects = 0;
322560
323120
  let lastLandedPageUrl = null;
322561
323121
  const state2 = (0, exploration_state_js_1.createExplorationState)();
@@ -322584,6 +323144,50 @@ ${credentialBlock}${redactedBlock}${inboxBlock}`;
322584
323144
  logs2.push(` [link-frontier] ingestion skipped - ${err instanceof Error ? err.message : String(err)}`);
322585
323145
  }
322586
323146
  }
323147
+ const domHarvestEnabled = linkFrontierEnabled && (0, survey_door_harvester_js_1.isDomHarvestEnabled)();
323148
+ const menuExpandEnabled = domHarvestEnabled && (0, survey_door_harvester_js_1.isMenuExpandEnabled)();
323149
+ const menuExpandAttemptedRoutes = /* @__PURE__ */ new Set();
323150
+ async function harvestDomLinksIntoFrontier() {
323151
+ if (!domHarvestEnabled)
323152
+ return;
323153
+ const currentScoped = (0, exploration_parser_js_1.normalizeRouteForFocusScope)(state2.currentRoute);
323154
+ const currentRs = state2.routeState.get(state2.currentRoute);
323155
+ try {
323156
+ const expandHere = menuExpandEnabled && !menuExpandAttemptedRoutes.has(currentScoped);
323157
+ if (expandHere)
323158
+ menuExpandAttemptedRoutes.add(currentScoped);
323159
+ const harvest = await (0, survey_door_harvester_js_1.harvestDomLinks)(mcpClient, {
323160
+ expandMenus: expandHere,
323161
+ log: (m) => logs2.push(m)
323162
+ });
323163
+ if (harvest.pageUrl)
323164
+ lastLandedPageUrl = harvest.pageUrl;
323165
+ if (harvest.links.length > 0) {
323166
+ (0, survey_link_frontier_js_1.ingestSeenLinks)(state2, {
323167
+ links: (0, survey_door_harvester_js_1.toSeenLinks)(harvest.links),
323168
+ scope: linkScope,
323169
+ isEntryOrHub: currentScoped === linkScope.basePath || state2.iteration <= 2,
323170
+ isErrorContext: currentRs?.pageType === "ERROR",
323171
+ pageUrl: harvest.pageUrl ?? lastLandedPageUrl,
323172
+ provenance: "dom",
323173
+ log: (m) => logs2.push(m)
323174
+ });
323175
+ }
323176
+ if (harvest.navigated && harvest.originalUrl) {
323177
+ logs2.push(` [door-harvest] page moved during menu expansion \u2014 restoring ${harvest.originalUrl}`);
323178
+ try {
323179
+ const navResult = await mcpClient.callTool({ name: "browser_navigate", arguments: { url: harvest.originalUrl } });
323180
+ if (navResult && typeof navResult === "object" && navResult.isError === true) {
323181
+ logs2.push(" [door-harvest] restore navigate returned an error \u2014 model may be on a different page");
323182
+ }
323183
+ } catch (navErr) {
323184
+ logs2.push(` [door-harvest] restore failed - ${navErr instanceof Error ? navErr.message : String(navErr)}`);
323185
+ }
323186
+ }
323187
+ } catch (err) {
323188
+ logs2.push(` [door-harvest] skipped - ${err instanceof Error ? err.message : String(err)}`);
323189
+ }
323190
+ }
322587
323191
  const recentExchanges = [];
322588
323192
  const transientDirectives = [];
322589
323193
  const MAX_RECENT_EXCHANGES = 28;
@@ -322612,7 +323216,8 @@ ${credentialBlock}${redactedBlock}${inboxBlock}`;
322612
323216
  let inboxState = null;
322613
323217
  let inboxReader = null;
322614
323218
  const inboxConfig = (0, verification_inbox_js_1.loadVerificationInboxConfig)();
322615
- if (inboxConfig && (0, inbox_tools_js_1.hasRegisterIntent)(variableContext)) {
323219
+ const registerIntent = (0, inbox_tools_js_1.hasRegisterIntent)(variableContext);
323220
+ if (inboxConfig && registerIntent) {
322616
323221
  inboxState = (0, inbox_tools_js_1.createInboxRunState)(inboxConfig, {
322617
323222
  tagSeed: baseUrl,
322618
323223
  projectScope: projectId,
@@ -322630,8 +323235,19 @@ ${credentialBlock}${redactedBlock}${inboxBlock}`;
322630
323235
  log: (line) => logs2.push(line)
322631
323236
  });
322632
323237
  logs2.push(`Verification inbox ENABLED for registration \u2014 email ${inboxState.email}`);
322633
- } else if ((0, inbox_tools_js_1.clearThrowawayRegisterSeed)(variableContext)) {
322634
- logs2.push("Register intent set but verification inbox not configured here \u2014 dropped the throwaway TEST_USER_EMAIL seed so the agent registers a fresh account.");
323238
+ } else {
323239
+ if (registerIntent && !inboxConfig) {
323240
+ const gap = (0, verification_inbox_js_1.describeVerificationInboxConfigGap)() ?? "verification inbox unavailable";
323241
+ logs2.push(`Register intent set but the ${gap} on this runner \u2014 keeping the seeded register identity for a one-shot registration attempt.`);
323242
+ } else if ((0, inbox_tools_js_1.clearThrowawayRegisterSeed)(variableContext)) {
323243
+ logs2.push("Stale throwaway TEST_USER_EMAIL seed found (register intent not set) \u2014 dropped it so the agent does not log in with a never-registered account.");
323244
+ }
323245
+ }
323246
+ const emailVerificationUnavailable = registerIntent && !inboxConfig && !(0, credential_tools_js_1.hasUsableLoginIdentity)(variableContext.allTestVariables ?? variableContext.publicTestVariables, {
323247
+ isPlaceholderIdentityValue: inbox_tools_js_1.isThrowawayRegisterSeedEmail
323248
+ });
323249
+ if (emailVerificationUnavailable) {
323250
+ logs2.push("Email verification unavailable \u2014 the agent will ATTEMPT registration once; any flow requiring an emailed code/link will be reported BLOCKED.");
322635
323251
  }
322636
323252
  const inboxPromptBlock = inboxState ? (0, inbox_tools_js_1.buildInboxPromptBlock)({
322637
323253
  email: inboxState.email,
@@ -322669,7 +323285,8 @@ ${credentialBlock}${redactedBlock}${inboxBlock}`;
322669
323285
  let systemPrompt = config?.systemPrompt ?? buildSystemPrompt(baseUrl, variableContext, existingSiteMap, existingTestNames, {
322670
323286
  ...options,
322671
323287
  canRotateCredentials: !!options?.onCredentialUpdate,
322672
- inboxPrompt: inboxPromptBlock
323288
+ inboxPrompt: inboxPromptBlock,
323289
+ emailVerificationUnavailable
322673
323290
  });
322674
323291
  if (config?.systemPrompt && inboxPromptBlock) {
322675
323292
  systemPrompt += `
@@ -322680,7 +323297,14 @@ ${inboxPromptBlock}`;
322680
323297
  const hasLoginCredentials = Object.keys(browserSecretsForHint).length > 0;
322681
323298
  const aiClient = options?.modelOverride ? (0, ai_provider_js_1.getRunnerClientForModel)(options.modelOverride) : (0, ai_provider_js_1.getRunnerAIClient)();
322682
323299
  const isDeepMode = options?.mode === "deep";
322683
- const maxIterations = config?.maxIterationsOverride && config.maxIterationsOverride > 0 ? config.maxIterationsOverride : getMaxIterations(options?.mode ?? "full", options?.incremental);
323300
+ const baseMaxIterations = config?.maxIterationsOverride && config.maxIterationsOverride > 0 ? config.maxIterationsOverride : getMaxIterations(options?.mode ?? "full", options?.incremental);
323301
+ const adaptiveBudgetEnabled = process.env.DISCOVERY_ADAPTIVE_BUDGET === "1" || (0, shared_1.parseBoolFlag)(process.env.DISCOVERY_ADAPTIVE_BUDGET);
323302
+ const adaptiveActive = adaptiveBudgetEnabled && isSurveyMode && linkFrontierEnabled && !options?.incremental && !(config?.maxIterationsOverride && config.maxIterationsOverride > 0);
323303
+ const adaptiveHardCap = adaptiveActive ? Math.max(baseMaxIterations, readPositiveIntEnv2(process.env, "DISCOVERY_ADAPTIVE_BUDGET_HARD_CAP", DEFAULT_ADAPTIVE_BUDGET_HARD_CAP)) : baseMaxIterations;
323304
+ let maxIterations = baseMaxIterations;
323305
+ if (adaptiveActive) {
323306
+ logs2.push(`Adaptive budget: ON (floor ${baseMaxIterations}, hard cap ${adaptiveHardCap})`);
323307
+ }
322684
323308
  const configKeepTail = isDeepMode ? Math.ceil(ctxConfig.keepTail * 1.5) : ctxConfig.keepTail;
322685
323309
  logs2.push(`Context: ${ctxConfig.tier} tier (${Math.round(ctxConfig.contextWindow / 1e3)}k window, emergency at ${Math.round(ctxConfig.emergencyTokenThreshold / 1e3)}k, prune every ${ctxConfig.pruneEveryN || "never"}, keepTail=${configKeepTail})`);
322686
323310
  logs2.push(`Discovery mode: ${useV3 ? "V3 (per-turn rebuild)" : "V2.5 (full transcript + control brief)"}${v3Env ? ` [override: V3=${v3Env}]` : " [auto]"}`);
@@ -322689,7 +323313,8 @@ ${inboxPromptBlock}`;
322689
323313
  const inboxPasswordKey = inboxState?.passwordKey ?? "TEST_USER_PASSWORD";
322690
323314
  const registerHint = ` follow the **Account Registration** steps in the system prompt to create and email-verify a new account (call provision_identity for the email, fill the signup form with that email + the \`${inboxPasswordKey}\` credential, submit, then complete the email verification)`;
322691
323315
  const surveyBreadthHint = linkFrontierEnabled ? " Visit and capture EVERY top-level link on your checklist BEFORE drilling into any section's sub-pages. The state packet's Frontier list tracks discovered-but-unvisited routes - drain it." : "";
322692
- const userMessage = config?.userMessage ?? (isSurveyMode ? registerMode ? `Navigate to ${baseUrl}. BEFORE registering, explore all reachable public auth pages from the logged-out experience (login, register, forgot-password - check menus and drawers too). Capture each with capture_page and record_transition. Do NOT submit the password-reset form. Then create your account:${registerHint}. After your account is verified and you are logged in, take a browser_snapshot and list the navigation links visible in the snapshot before clicking anything - this is your checklist.${surveyBreadthHint} Then visit each page systematically, catalog it with capture_page, and record transitions. After capture_page records a page, reuse the captured state facts; only take a fresh browser_snapshot after navigation, loading, or a visible UI state change. Open tabs, and visit one detail page per list. Map the entire application thoroughly.` : `Navigate to ${baseUrl}.${hasLoginCredentials ? ` BEFORE logging in, explore all reachable public auth pages from the logged-out experience (login, register, forgot-password - check menus and drawers too). Capture each with capture_page and record_transition. Do NOT submit registration or password-reset forms. After mapping public auth pages, log in.${loginHint}` : ""} After${hasLoginCredentials ? " logging in" : " landing"}, take a browser_snapshot and list the navigation links visible in the snapshot before clicking anything - this is your checklist.${surveyBreadthHint} Then visit each page systematically, catalog it with capture_page, and record transitions. After capture_page records a page, reuse the captured state facts; only take a fresh browser_snapshot after navigation, loading, or a visible UI state change. Open tabs, and visit one detail page per list. Map the entire application thoroughly.` : isDeepMode ? `Start by navigating to ${baseUrl}${registerMode ? ` and create your account:${registerHint}.` : hasLoginCredentials ? ` and log in.${loginHint}` : "."} Then go to the focus areas listed in the system prompt. For EACH focus area, you must: (1) test the happy path with valid data and call record_journey, (2) test validation/errors with invalid/empty data and call record_journey, (3) interact with all buttons/dropdowns/tabs on the page. You have ${maxIterations} iterations - use them all. Do NOT call finish_exploration until you have completed BOTH happy path AND validation testing for every focus area.` : `Start by navigating to ${baseUrl}${registerMode ? ` and create your account:${registerHint}.` : hasLoginCredentials ? ` and log in.${loginHint}` : "."} Then explore the application feature by feature. On each page, take a browser_snapshot and call capture_page. When you find forms or interactive features, actually USE them - fill in fields, click buttons, submit forms, and observe what happens. Capture every resulting page. Remember: visiting a page is not enough - interact with it like a real user would.`);
323316
+ const emailWallNote = ' NOTE: this project asked to REGISTER a new account, but this runner CANNOT receive email (verification inbox unavailable). Attempt registration ONCE with the `TEST_USER_EMAIL` + `TEST_USER_PASSWORD` credential keys via `fill_credential_form` (never alter the email or create a second account; if signup says the address is already registered, log in with the same keys instead). If you are signed in without an email round-trip, continue as a normal logged-in user. The moment any step demands an emailed code/link (verification code, OTP, magic link, "check your email"), STOP that flow - never type a guessed code, never click Resend - continue with publicly reachable pages and state in your finish_exploration summary that authenticated coverage is BLOCKED (cannot receive verification email).';
323317
+ const userMessage = config?.userMessage ?? (isSurveyMode ? registerMode ? `Navigate to ${baseUrl}. BEFORE registering, explore all reachable public auth pages from the logged-out experience (login, register, forgot-password - check menus and drawers too). Capture each with capture_page and record_transition. Do NOT submit the password-reset form. Then create your account:${registerHint}. After your account is verified and you are logged in, take a browser_snapshot and list the navigation links visible in the snapshot before clicking anything - this is your checklist.${surveyBreadthHint} Then visit each page systematically, catalog it with capture_page, and record transitions. After capture_page records a page, reuse the captured state facts; only take a fresh browser_snapshot after navigation, loading, or a visible UI state change. Open tabs, and visit one detail page per list. Map the entire application thoroughly.` : emailVerificationUnavailable ? `Navigate to ${baseUrl}.${emailWallNote} BEFORE the registration attempt, explore all reachable public auth pages from the logged-out experience and capture each with capture_page and record_transition (do NOT submit the password-reset form). After the registration attempt resolves (signed in, or blocked at the email wall), take a browser_snapshot and list the navigation links visible in the snapshot before clicking anything - this is your checklist.${surveyBreadthHint} Then visit each reachable page systematically, catalog it with capture_page, and record transitions. After capture_page records a page, reuse the captured state facts; only take a fresh browser_snapshot after navigation, loading, or a visible UI state change. Open tabs, and visit one detail page per list. Map the entire reachable application thoroughly.` : `Navigate to ${baseUrl}.${hasLoginCredentials ? ` BEFORE logging in, explore all reachable public auth pages from the logged-out experience (login, register, forgot-password - check menus and drawers too). Capture each with capture_page and record_transition. Do NOT submit registration or password-reset forms. After mapping public auth pages, log in.${loginHint}` : ""} After${hasLoginCredentials ? " logging in" : " landing"}, take a browser_snapshot and list the navigation links visible in the snapshot before clicking anything - this is your checklist.${surveyBreadthHint} Then visit each page systematically, catalog it with capture_page, and record transitions. After capture_page records a page, reuse the captured state facts; only take a fresh browser_snapshot after navigation, loading, or a visible UI state change. Open tabs, and visit one detail page per list. Map the entire application thoroughly.` : isDeepMode ? emailVerificationUnavailable ? `Start by navigating to ${baseUrl}.${emailWallNote} Make the ONE registration attempt first. Then go to the focus areas listed in the system prompt. If you are signed in, cover EACH focus area fully: (1) happy path with valid data \u2192 record_journey, (2) validation/errors with invalid/empty data \u2192 record_journey, (3) interact with all buttons/dropdowns/tabs. If you were blocked at the email wall, cover what is reachable WITHOUT an account: validation/errors with synthetic invalid/empty data \u2192 record_journey, public interactions, and note account-gated flows as BLOCKED in finish_exploration instead of attempting them. You have ${maxIterations} iterations. Do NOT call finish_exploration until you have covered every reachable focus area.` : `Start by navigating to ${baseUrl}${registerMode ? ` and create your account:${registerHint}.` : hasLoginCredentials ? ` and log in.${loginHint}` : "."} Then go to the focus areas listed in the system prompt. For EACH focus area, you must: (1) test the happy path with valid data and call record_journey, (2) test validation/errors with invalid/empty data and call record_journey, (3) interact with all buttons/dropdowns/tabs on the page. You have ${maxIterations} iterations - use them all. Do NOT call finish_exploration until you have completed BOTH happy path AND validation testing for every focus area.` : `Start by navigating to ${baseUrl}${registerMode ? ` and create your account:${registerHint}.` : emailVerificationUnavailable ? `.${emailWallNote}` : hasLoginCredentials ? ` and log in.${loginHint}` : "."} Then explore the application feature by feature. On each page, take a browser_snapshot and call capture_page. When you find forms or interactive features, actually USE them - fill in fields, click buttons, submit forms, and observe what happens. Capture every resulting page. Remember: visiting a page is not enough - interact with it like a real user would.`);
322693
323318
  let messages = [
322694
323319
  { role: "system", content: systemPrompt },
322695
323320
  { role: "user", content: userMessage }
@@ -322698,6 +323323,7 @@ ${inboxPromptBlock}`;
322698
323323
  let lastVisitedSize = 0;
322699
323324
  let lastSurveyProgressMark = 0;
322700
323325
  let staleIterations = 0;
323326
+ let staleKnownKeysMark = 0;
322701
323327
  let lastCaptureIteration = 0;
322702
323328
  let lastJourneyProgress = 0;
322703
323329
  let lastDeepProgressMark = 0;
@@ -322710,9 +323336,151 @@ ${inboxPromptBlock}`;
322710
323336
  const BRIEF_INTERVAL = 5;
322711
323337
  const stuckDetectorEnabled = process.env.DISCOVERY_STUCK_DETECTOR === "1" || (0, shared_1.parseBoolFlag)(process.env.DISCOVERY_STUCK_DETECTOR);
322712
323338
  const stuckDetector = stuckDetectorEnabled ? new stuck_detector_js_1.StuckDetector({ repetitionReachesRecovery: !isDeepMode }) : null;
322713
- while (iteration < maxIterations && !explorationComplete) {
323339
+ let adaptiveDecisionArmedAt = Math.ceil(maxIterations * ADAPTIVE_BUDGET_DECISION_PCT);
323340
+ let adaptiveRescueUsed = false;
323341
+ let adaptiveComplete = false;
323342
+ let adaptivePendingDiscoveryRoutes = [];
323343
+ let adaptiveLastNewRouteIteration = Number.NEGATIVE_INFINITY;
323344
+ let adaptivePrevVisitedSize = 0;
323345
+ let captureRevision = 0;
323346
+ let captureCreditedThrough = 0;
323347
+ const adaptiveKnownKeys = /* @__PURE__ */ new Set();
323348
+ let discoveryRevision = 0;
323349
+ let discoveryCreditedThrough = 0;
323350
+ let adaptiveLastDiscoveryIteration = Number.NEGATIVE_INFINITY;
323351
+ let adaptiveDiscoveryLeaseUsed = false;
323352
+ const adaptiveDebtRoutes = () => {
323353
+ const isAttemptedLinkEntry = (r) => {
323354
+ const item = state2.frontier.get(r);
323355
+ return item?.source === "link-seen" && item.attempted === true;
323356
+ };
323357
+ const ranked = (0, exploration_state_js_1.getRankedFrontier)(state2, { preferShallow: true }).filter((r) => r !== "/" && !isAttemptedLinkEntry(r));
323358
+ const rankedSet = new Set(ranked);
323359
+ const navigatedUncaptured = [];
323360
+ for (const r of state2.frontier.keys()) {
323361
+ if (r !== "/" && !rankedSet.has(r) && !isAttemptedLinkEntry(r))
323362
+ navigatedUncaptured.push(r);
323363
+ }
323364
+ return ranked.concat(navigatedUncaptured);
323365
+ };
323366
+ const describeRankedRoutes = (routes, max) => routes.slice(0, max).map((r) => {
323367
+ const label = state2.frontier.get(r)?.label;
323368
+ return label ? `${label} (${r})` : r;
323369
+ }).join(", ");
323370
+ const refreshAdaptiveDiscovery = () => {
323371
+ if (state2.visitedRoutes.size > adaptivePrevVisitedSize) {
323372
+ adaptivePrevVisitedSize = state2.visitedRoutes.size;
323373
+ adaptiveLastNewRouteIteration = iteration;
323374
+ captureRevision++;
323375
+ }
323376
+ const debt = adaptiveDebtRoutes();
323377
+ let grew = false;
323378
+ for (const route2 of debt) {
323379
+ const key = state2.frontier.get(route2)?.familyKey ?? (0, exploration_parser_js_1.normalizeRouteForFocusScope)(route2);
323380
+ if (!adaptiveKnownKeys.has(key)) {
323381
+ adaptiveKnownKeys.add(key);
323382
+ adaptivePendingDiscoveryRoutes.push(route2);
323383
+ grew = true;
323384
+ }
323385
+ }
323386
+ if (grew) {
323387
+ discoveryRevision++;
323388
+ adaptiveLastDiscoveryIteration = iteration;
323389
+ }
323390
+ if (!adaptiveComplete && adaptiveDecisionArmedAt === Number.POSITIVE_INFINITY && debt.length > 0) {
323391
+ adaptiveDecisionArmedAt = iteration;
323392
+ }
323393
+ };
323394
+ const runBudgetController = (opts = {}) => {
323395
+ const allowExtension = opts.allowExtension ?? true;
323396
+ const remainingList = adaptiveDebtRoutes();
323397
+ const capturing = captureRevision > captureCreditedThrough && iteration - adaptiveLastNewRouteIteration <= ADAPTIVE_BUDGET_PROGRESS_WINDOW;
323398
+ const freshDiscovery = discoveryRevision > discoveryCreditedThrough && iteration - adaptiveLastDiscoveryIteration <= ADAPTIVE_BUDGET_PROGRESS_WINDOW;
323399
+ const decision = computeBudgetDecision({
323400
+ iteration,
323401
+ currentCap: maxIterations,
323402
+ hardCap: adaptiveHardCap,
323403
+ remainingRoutes: remainingList.length,
323404
+ capturing,
323405
+ freshDiscovery,
323406
+ discoveryLeaseUsed: adaptiveDiscoveryLeaseUsed,
323407
+ rescueUsed: adaptiveRescueUsed,
323408
+ allowExtension
323409
+ });
323410
+ if (decision.action === "extend") {
323411
+ maxIterations = decision.newCap;
323412
+ adaptiveRescueUsed = false;
323413
+ discoveryCreditedThrough = discoveryRevision;
323414
+ adaptiveDecisionArmedAt = Math.min(maxIterations, Math.max(iteration + ADAPTIVE_BUDGET_MIN_GAP, Math.ceil(maxIterations * ADAPTIVE_BUDGET_DECISION_PCT)));
323415
+ const remainingSet = new Set(remainingList);
323416
+ const freshFirst = [.../* @__PURE__ */ new Set([
323417
+ ...adaptivePendingDiscoveryRoutes.filter((r) => remainingSet.has(r)),
323418
+ ...remainingList
323419
+ ])];
323420
+ adaptivePendingDiscoveryRoutes = [];
323421
+ if (decision.lease === "discovery") {
323422
+ adaptiveDiscoveryLeaseUsed = true;
323423
+ logs2.push(` [adaptive-budget] discovery lease +${decision.delta} \u2192 ${maxIterations}; ${remainingList.length} newly-found route(s)`);
323424
+ return {
323425
+ directive: `GRANTED: ${decision.delta} more iterations to capture routes you discovered late in the crawl. Reach these through the app's own links/menus, then capture_page + record_transition each: ${describeRankedRoutes(freshFirst, 6)}. If one can't be reached after a deliberate attempt, note it in your summary and move on.`,
323426
+ keepGoing: true
323427
+ };
323428
+ }
323429
+ captureCreditedThrough = captureRevision;
323430
+ logs2.push(` [adaptive-budget] capture lease +${decision.delta} \u2192 ${maxIterations}; ${remainingList.length} route(s) still un-captured`);
323431
+ return {
323432
+ directive: `GRANTED: ${decision.delta} additional iterations (your budget is now ${maxIterations}). Coverage is incomplete. Reach these still-unmapped routes through the app's own links and menus, then capture_page + record_transition each: ${describeRankedRoutes(freshFirst, 6)}. Already-captured pages may be traversed, but do not re-catalog them. If a target redirects, errors, or cannot be located after a deliberate attempt, note it in your summary and move to the next.`,
323433
+ keepGoing: true
323434
+ };
323435
+ }
323436
+ if (decision.action === "rescue") {
323437
+ adaptiveRescueUsed = true;
323438
+ const runwayTarget = Math.min(adaptiveHardCap, iteration + ADAPTIVE_BUDGET_RESCUE_WINDOW);
323439
+ if (runwayTarget > maxIterations)
323440
+ maxIterations = runwayTarget;
323441
+ adaptiveDecisionArmedAt = Math.min(maxIterations, iteration + ADAPTIVE_BUDGET_RESCUE_WINDOW);
323442
+ logs2.push(` [adaptive-budget] stall rescue \u2192 steering to ${remainingList.length} un-captured route(s) (cap ${maxIterations})`);
323443
+ return {
323444
+ directive: `You are revisiting pages without capturing anything new. ${remainingList.length} discovered route(s) are still unmapped: ${describeRankedRoutes(remainingList, 4)}. Navigate to each through the app's links/menus and capture_page it now. If one is genuinely unreachable, note it and move on \u2014 do not keep re-loading pages you have already seen.`,
323445
+ keepGoing: true
323446
+ };
323447
+ }
323448
+ if (decision.action === "finish") {
323449
+ if (decision.reason === "drained") {
323450
+ adaptiveDecisionArmedAt = Number.POSITIVE_INFINITY;
323451
+ logs2.push(" [adaptive-budget] frontier drained \u2014 quiescent (will re-arm on new discovery)");
323452
+ } else {
323453
+ adaptiveComplete = true;
323454
+ adaptiveDecisionArmedAt = Number.POSITIVE_INFINITY;
323455
+ logs2.push(` [adaptive-budget] finishing (${decision.reason}); ${remainingList.length} route(s) left un-captured`);
323456
+ }
323457
+ return { directive: null, keepGoing: false };
323458
+ }
323459
+ adaptiveDecisionArmedAt = Math.min(iteration + 5, maxIterations);
323460
+ return { directive: null, keepGoing: true };
323461
+ };
323462
+ const tryAdaptiveBoundaryExtend = () => {
323463
+ if (!adaptiveActive || adaptiveComplete)
323464
+ return false;
323465
+ refreshAdaptiveDiscovery();
323466
+ const { directive, keepGoing } = runBudgetController();
323467
+ if (keepGoing && maxIterations > iteration) {
323468
+ if (directive) {
323469
+ if (useV3) {
323470
+ transientDirectives.push(directive);
323471
+ } else {
323472
+ messages.push({ role: "user", content: directive });
323473
+ }
323474
+ }
323475
+ return true;
323476
+ }
323477
+ return false;
323478
+ };
323479
+ while (!explorationComplete && (iteration < maxIterations || tryAdaptiveBoundaryExtend())) {
322714
323480
  iteration++;
322715
323481
  (0, exploration_state_js_1.reduceEvent)(state2, { type: "ITERATION_STARTED", iteration });
323482
+ if (adaptiveActive)
323483
+ refreshAdaptiveDiscovery();
322716
323484
  const iterStartedAt = Date.now();
322717
323485
  logs2.push(`
322718
323486
  -- Explore iteration ${iteration}/${maxIterations} --`);
@@ -322756,7 +323524,7 @@ ${inboxPromptBlock}`;
322756
323524
  logs2.push(` Deep mode escalation: forced action after ${deepStaleChecks * 5} stale iterations`);
322757
323525
  } else if (deepStaleChecks >= 3 && !deepStaleNudgeSent) {
322758
323526
  deepStaleNudgeSent = true;
322759
- const nudgeMsg = `You haven't recorded any new journeys or captured new interactions in a while. If you've finished testing all focus areas (both happy path AND validation), call finish_exploration. Otherwise, continue - try submitting forms with invalid/empty data to test validation, or interact with elements you haven't tried yet.`;
323527
+ const nudgeMsg = emailVerificationUnavailable ? `You haven't recorded any new journeys or captured new interactions in a while. If you've finished testing everything reachable in your focus areas, call finish_exploration. Otherwise, continue - try submitting forms with invalid/empty synthetic data to test validation, or interact with elements you haven't tried yet. Do NOT re-attempt registration or login flows that were blocked at the email-verification wall - note them as BLOCKED instead.` : `You haven't recorded any new journeys or captured new interactions in a while. If you've finished testing all focus areas (both happy path AND validation), call finish_exploration. Otherwise, continue - try submitting forms with invalid/empty data to test validation, or interact with elements you haven't tried yet.`;
322760
323528
  if (useV3) {
322761
323529
  transientDirectives.push(nudgeMsg);
322762
323530
  } else {
@@ -322790,14 +323558,39 @@ ${inboxPromptBlock}`;
322790
323558
  }
322791
323559
  logs2.push(` Snapshot-loop nudge: ${itersSinceCapture} iterations without capture_page`);
322792
323560
  }
322793
- if (currentSurveyProgressMark === lastSurveyProgressMark) {
323561
+ if (adaptiveActive && !adaptiveComplete && adaptiveKnownKeys.size > staleKnownKeysMark) {
323562
+ staleKnownKeysMark = adaptiveKnownKeys.size;
323563
+ if (currentSurveyProgressMark === lastSurveyProgressMark && staleIterations > 0) {
323564
+ logs2.push(` Stall check: frontier grew to ${adaptiveKnownKeys.size} identities \u2014 counting as progress`);
323565
+ }
323566
+ staleIterations = 0;
323567
+ } else if (currentSurveyProgressMark === lastSurveyProgressMark) {
322794
323568
  staleIterations++;
322795
323569
  if (staleIterations >= 4) {
322796
- logs2.push(` Survey hard stop: no survey progress in ${staleIterations * 5} iterations, forcing completion`);
322797
- explorationComplete = true;
322798
- summary = `Exploration force-stopped after ${iteration} iterations - no survey progress in ${staleIterations * 5} iterations. Visited ${currentVisitedSize} pages.`;
322799
- break;
322800
- } else if (staleIterations >= 2) {
323570
+ if (adaptiveActive && !adaptiveComplete) {
323571
+ const { directive, keepGoing } = runBudgetController({ allowExtension: false });
323572
+ if (keepGoing) {
323573
+ staleIterations = 2;
323574
+ if (directive) {
323575
+ if (useV3) {
323576
+ transientDirectives.push(directive);
323577
+ } else {
323578
+ messages.push({ role: "user", content: directive });
323579
+ }
323580
+ }
323581
+ } else {
323582
+ logs2.push(` Survey hard stop (adaptive terminal): no survey progress in ${staleIterations * 5} iterations`);
323583
+ explorationComplete = true;
323584
+ summary = `Exploration force-stopped after ${iteration} iterations - no survey progress in ${staleIterations * 5} iterations. Visited ${currentVisitedSize} pages.`;
323585
+ break;
323586
+ }
323587
+ } else {
323588
+ logs2.push(` Survey hard stop: no survey progress in ${staleIterations * 5} iterations, forcing completion`);
323589
+ explorationComplete = true;
323590
+ summary = `Exploration force-stopped after ${iteration} iterations - no survey progress in ${staleIterations * 5} iterations. Visited ${currentVisitedSize} pages.`;
323591
+ break;
323592
+ }
323593
+ } else if (staleIterations >= 2 && !adaptiveActive) {
322801
323594
  const loopMsg = "You appear to be revisiting the same pages without discovering new routes, transitions, or useful auth/navigation progress. Call finish_exploration NOW with a summary of what you found.";
322802
323595
  if (useV3) {
322803
323596
  transientDirectives.push(loopMsg);
@@ -322844,7 +323637,23 @@ ${inboxPromptBlock}`;
322844
323637
  lastJourneyProgress = currentJourneyProgress;
322845
323638
  }
322846
323639
  }
322847
- if (iteration >= Math.floor(maxIterations * 0.9)) {
323640
+ if (adaptiveActive && !adaptiveComplete && iteration >= adaptiveDecisionArmedAt) {
323641
+ const { directive, keepGoing } = runBudgetController();
323642
+ if (directive) {
323643
+ if (useV3) {
323644
+ transientDirectives.push(directive);
323645
+ } else {
323646
+ messages.push({ role: "user", content: directive });
323647
+ }
323648
+ }
323649
+ if (!keepGoing && adaptiveComplete) {
323650
+ explorationComplete = true;
323651
+ summary = summary || `Exploration finished after ${iteration} iterations (adaptive budget: coverage incomplete).`;
323652
+ logs2.push(` [adaptive-budget] terminal at iteration ${iteration}`);
323653
+ break;
323654
+ }
323655
+ }
323656
+ if (!adaptiveActive && iteration >= Math.floor(maxIterations * 0.9)) {
322848
323657
  const budgetTestCount = useV2 ? state2.recordedJourneys.length : localJourneys.length;
322849
323658
  const budgetBlocking = linkFrontierEnabled ? (0, survey_link_frontier_js_1.getFinishBlockingFrontier)(state2) : [];
322850
323659
  const budgetMsg = isDeepMode ? budgetTestCount === 0 ? "CRITICAL: You have used 90% of your iteration budget and have NOT recorded any journeys yet. You MUST call record_journey NOW for every flow you have tested (happy paths, validation, edge cases). After calling record_journey for all completed flows, call finish_exploration. Do NOT call finish_exploration without first calling record_journey." : `CRITICAL: You have used 90% of your iteration budget. You have recorded ${budgetTestCount} journey(s) so far. If you have completed any additional flows that you haven't called record_journey for, do so NOW. Then call finish_exploration with a summary.` : budgetBlocking.length > 0 ? `CRITICAL: You have used 90% of your iteration budget. These discovered routes were never visited: ${(0, survey_link_frontier_js_1.describeBlockingRoutes)(budgetBlocking, 4)}. Visit ONLY these (capture_page each), then call finish_exploration. Do not explore anything else.` : "CRITICAL: You have used 90% of your iteration budget. Wrap up your current interaction and call finish_exploration with a summary of what you found. If you are mid-flow, complete it quickly then finish.";
@@ -322936,7 +323745,7 @@ ${recent}`);
322936
323745
  if (remainingFocusAreas.length > 0)
322937
323746
  progressLines.push(`### Focus Areas NOT YET Visited: ${remainingFocusAreas.join(", ")} - explore these next!`);
322938
323747
  progressLines.push("");
322939
- progressLines.push("IMPORTANT: For each focus area, you must test BOTH the happy path (valid data) AND validation/error handling (invalid/empty data). If you have only done the happy path, go back and test validation now.");
323748
+ progressLines.push(emailVerificationUnavailable ? "IMPORTANT: For each focus area, test everything reachable in your current auth state: validation/error handling with invalid/empty data, plus the happy path if you are signed in. If a flow was blocked at the email-verification wall, note it as BLOCKED \u2014 do not re-attempt it and never type a guessed code." : "IMPORTANT: For each focus area, you must test BOTH the happy path (valid data) AND validation/error handling (invalid/empty data). If you have only done the happy path, go back and test validation now.");
322940
323749
  }
322941
323750
  progressLines.push("");
322942
323751
  progressLines.push("## NEXT ACTIONS");
@@ -322947,7 +323756,7 @@ ${recent}`);
322947
323756
  });
322948
323757
  if (untestedAreas.length > 0) {
322949
323758
  progressLines.push(`These focus areas still need testing: ${untestedAreas.join(", ")}`);
322950
- progressLines.push("For each: (1) happy path with valid data \u2192 record_journey, (2) validation with invalid/empty data \u2192 record_journey");
323759
+ progressLines.push(emailVerificationUnavailable ? "For each: cover what your current auth state reaches \u2014 validation with invalid/empty data \u2192 record_journey, plus happy path if signed in; note email-wall-blocked flows as BLOCKED instead of re-attempting them" : "For each: (1) happy path with valid data \u2192 record_journey, (2) validation with invalid/empty data \u2192 record_journey");
322951
323760
  } else {
322952
323761
  progressLines.push("All focus areas have tests. Look for additional edge cases or call finish_exploration.");
322953
323762
  }
@@ -323000,7 +323809,8 @@ ${currentSummary}`;
323000
323809
  const brief = (0, exploration_prompt_builder_js_2.buildControlBrief)(state2, {
323001
323810
  mode: options?.mode ?? "full",
323002
323811
  maxIterations,
323003
- focusAreas: options?.focusAreas
323812
+ focusAreas: options?.focusAreas,
323813
+ adaptiveBudget: adaptiveActive
323004
323814
  });
323005
323815
  messages.push({ role: "user", content: brief });
323006
323816
  lastBriefRoute = currentStateRoute;
@@ -323019,7 +323829,8 @@ ${currentSummary}`;
323019
323829
  recentExchanges,
323020
323830
  incremental: options?.incremental,
323021
323831
  userNotes: options?.userNotes,
323022
- linkFrontierEnabled
323832
+ linkFrontierEnabled,
323833
+ adaptiveBudget: adaptiveActive
323023
323834
  });
323024
323835
  transientDirectives.length = 0;
323025
323836
  }
@@ -323228,6 +324039,9 @@ ${currentSummary}`;
323228
324039
  sessionState: normalized.sessionState
323229
324040
  });
323230
324041
  ingestLinksFromText(snapshotText.snapshotText);
324042
+ if (domHarvestEnabled) {
324043
+ await harvestDomLinksIntoFrontier();
324044
+ }
323231
324045
  const isSurvey = options?.mode === "survey";
323232
324046
  const subNavItems = [];
323233
324047
  for (const el of normalized.elements) {
@@ -323736,6 +324550,30 @@ finish_exploration bounced (${finishRedirects}/${survey_link_frontier_js_1.MAX_F
323736
324550
  logs2.push(` finish accepted with ${blocking.length} uncovered discovered route(s): ${(0, survey_link_frontier_js_1.describeBlockingRoutes)(blocking, 10)}`);
323737
324551
  }
323738
324552
  }
324553
+ if (adaptiveActive && !adaptiveComplete) {
324554
+ refreshAdaptiveDiscovery();
324555
+ const remainingList = adaptiveDebtRoutes();
324556
+ if (remainingList.length > 0 && iteration < adaptiveHardCap) {
324557
+ let reason = null;
324558
+ if (iteration >= adaptiveDecisionArmedAt) {
324559
+ const { directive, keepGoing } = runBudgetController();
324560
+ if (keepGoing) {
324561
+ reason = directive ?? `Not done yet \u2014 ${remainingList.length} discovered route(s) were never captured: ${describeRankedRoutes(remainingList, 6)}. Visit and capture_page each (via the app's links), then call finish_exploration.`;
324562
+ }
324563
+ } else {
324564
+ reason = `Not done yet \u2014 ${remainingList.length} discovered route(s) were never captured: ${describeRankedRoutes(remainingList, 6)}. Visit and capture_page each (via the app's links), then call finish_exploration.`;
324565
+ }
324566
+ if (reason) {
324567
+ toolResults.push({
324568
+ role: "tool",
324569
+ tool_call_id: toolCall.id,
324570
+ content: JSON.stringify({ acknowledged: false, keepExploring: true, reason })
324571
+ });
324572
+ logs2.push(` [adaptive-budget] finish bounced: ${remainingList.length} route(s) still un-captured`);
324573
+ continue;
324574
+ }
324575
+ }
324576
+ }
323739
324577
  explorationComplete = true;
323740
324578
  summary = String(toolArgs.summary || "");
323741
324579
  (0, exploration_state_js_1.reduceEvent)(state2, { type: "EXPLORATION_FINISHED", summary });
@@ -323793,6 +324631,18 @@ Exploration complete: ${summary}`);
323793
324631
  continue;
323794
324632
  }
323795
324633
  if (toolName === "fill_credential" || toolName === "fill_credential_form") {
324634
+ if (emailVerificationUnavailable) {
324635
+ const codeGuard = (0, inbox_tools_js_1.guardVerificationCodeFabrication)(toolName, toolArgs);
324636
+ if (codeGuard.blocked) {
324637
+ logs2.push(` BLOCKED ${toolName}: verification-code field in email-verification-unavailable mode (field="${codeGuard.matchedField}")`);
324638
+ toolResults.push({
324639
+ role: "tool",
324640
+ tool_call_id: toolCall.id,
324641
+ content: codeGuard.message ?? "BLOCKED: cannot receive verification email"
324642
+ });
324643
+ continue;
324644
+ }
324645
+ }
323796
324646
  const fullVarMap = variableContext.allTestVariables ?? variableContext.publicTestVariables;
323797
324647
  const { secrets: dispatchSecrets } = (0, credential_tools_js_1.partitionTestVariables)(fullVarMap);
323798
324648
  try {
@@ -323875,6 +324725,18 @@ Exploration complete: ${summary}`);
323875
324725
  continue;
323876
324726
  }
323877
324727
  }
324728
+ if (emailVerificationUnavailable) {
324729
+ const codeGuard = (0, inbox_tools_js_1.guardVerificationCodeFabrication)(toolName, toolArgs);
324730
+ if (codeGuard.blocked) {
324731
+ logs2.push(` BLOCKED ${toolName}: verification-code field in email-verification-unavailable mode (field="${codeGuard.matchedField}")`);
324732
+ toolResults.push({
324733
+ role: "tool",
324734
+ tool_call_id: toolCall.id,
324735
+ content: codeGuard.message ?? "BLOCKED: cannot receive verification email"
324736
+ });
324737
+ continue;
324738
+ }
324739
+ }
323878
324740
  if (inboxState?.provisioned && toolCallLooksLikeSignupSubmit(toolName, toolArgs)) {
323879
324741
  accountAlreadyExistsRecoveryExpiresAt = iteration + 2;
323880
324742
  }
@@ -324118,6 +324980,11 @@ Exploration complete: ${summary}`);
324118
324980
  logs2.push(` \u26A0 Out of scope: ${detectedRoute} (focus: ${navFocusAreas.join(", ")})`);
324119
324981
  toolResults.__outOfScopeRedirect = `You navigated to ${detectedRoute} which is OUTSIDE your focus areas (${navFocusAreas.join(", ")}). This is a different feature. You may observe the URL for assertion purposes (e.g. "verify redirect to ${detectedRoute}"), but do NOT interact with this page - do not fill forms, click buttons, or call capture_page here. Navigate back to your focus areas or call finish_exploration if you are done.`;
324120
324982
  }
324983
+ } else if (surveyNavScope) {
324984
+ if (!(0, survey_scope_js_1.routeWithinSurveyBasePath)(detectedRoute, surveyNavScope) && !(0, survey_scope_js_1.hasAuthFlowSegment)(detectedRoute)) {
324985
+ logs2.push(` \u26A0 Out of survey scope: ${detectedRoute} (entry scope: ${surveyNavScope.basePath})`);
324986
+ toolResults.__outOfScopeRedirect = `You navigated to ${detectedRoute}, which is OUTSIDE this survey's entry scope (\`${surveyNavScope.basePath}\`). This is a SCOPED survey \u2014 that page is not part of the audited flow: do NOT catalog it (no capture_page), do not follow its links, and do not create a featureGroup for it. Navigate back to a page under \`${surveyNavScope.basePath}\` and continue mapping the in-scope flow. If you have already covered the in-scope pages, call finish_exploration.`;
324987
+ }
324121
324988
  }
324122
324989
  }
324123
324990
  }
@@ -324413,6 +325280,7 @@ Fatal error: ${msg}`);
324413
325280
  const status = fatalErr?.status;
324414
325281
  const lower = msg.toLowerCase();
324415
325282
  const truncatedReason = status === 429 || lower.includes("rate limit") || lower.includes("too many requests") || lower.includes("quota") ? "rate_limit" : status === 408 || lower.includes("timeout") || lower.includes("timed out") || lower.includes("etimedout") ? "timeout" : "ai_error";
325283
+ const truncatedTransient = (0, ai_retry_js_1.isTransientRateError)(fatalErr);
324416
325284
  if (useV2) {
324417
325285
  try {
324418
325286
  (0, exploration_state_js_1.flushUnflushedCommands)(state2, variableContext.allTestVariables ?? variableContext.publicTestVariables);
@@ -324457,7 +325325,8 @@ Fatal error: ${msg}`);
324457
325325
  collectedTransitions: state2.collectedTransitions,
324458
325326
  iterationTimeline: iterationTimeline.length > 0 ? iterationTimeline : void 0,
324459
325327
  truncated: true,
324460
- truncatedReason
325328
+ truncatedReason,
325329
+ truncatedTransient
324461
325330
  };
324462
325331
  }
324463
325332
  return {
@@ -324477,7 +325346,8 @@ Fatal error: ${msg}`);
324477
325346
  collectedTransitions,
324478
325347
  iterationTimeline: iterationTimeline.length > 0 ? iterationTimeline : void 0,
324479
325348
  truncated: true,
324480
- truncatedReason
325349
+ truncatedReason,
325350
+ truncatedTransient
324481
325351
  };
324482
325352
  } finally {
324483
325353
  if (inboxReader) {
@@ -324506,9 +325376,12 @@ var require_discover_feature_explorer = __commonJS({
324506
325376
  "../runner-core/dist/services/discover-feature-explorer.js"(exports2) {
324507
325377
  "use strict";
324508
325378
  Object.defineProperty(exports2, "__esModule", { value: true });
325379
+ exports2.buildFeatureExplorePrompt = buildFeatureExplorePrompt;
325380
+ exports2.buildIncrementalExplorePrompt = buildIncrementalExplorePrompt;
324509
325381
  exports2.runFeatureExplorePhase = runFeatureExplorePhase;
324510
325382
  var discover_explorer_js_1 = require_discover_explorer();
324511
325383
  var exploration_parser_js_1 = require_exploration_parser();
325384
+ var credential_tools_js_1 = require_credential_tools();
324512
325385
  var verification_inbox_js_1 = require_verification_inbox();
324513
325386
  var inbox_tools_js_1 = require_inbox_tools();
324514
325387
  function buildFeatureExplorerConfig(focusAreas, incremental, otherRoutes) {
@@ -324573,7 +325446,8 @@ var require_discover_feature_explorer = __commonJS({
324573
325446
  const browserCredentials = variableContext.allTestVariables ?? variableContext.publicTestVariables;
324574
325447
  const hasCredentials = Object.keys(browserCredentials).length > 0;
324575
325448
  const registerMode = !!((0, verification_inbox_js_1.loadVerificationInboxConfig)() && (0, inbox_tools_js_1.hasRegisterIntent)(variableContext));
324576
- const credentialLines = Object.entries(browserCredentials).map(([k, v]) => `- **${k}**: \`${v}\``).join("\n");
325449
+ const emailVerificationUnavailable = !registerMode && (0, inbox_tools_js_1.hasRegisterIntent)(variableContext) && !(0, credential_tools_js_1.hasUsableLoginIdentity)(browserCredentials, { isPlaceholderIdentityValue: inbox_tools_js_1.isThrowawayRegisterSeedEmail });
325450
+ const credentialLines = Object.entries(browserCredentials).filter(([k]) => k !== "DISCOVERY_SHOULD_REGISTER").map(([k, v]) => `- **${k}**: \`${v}\``).join("\n");
324577
325451
  const otherFeaturesBlock = featureOpts.otherFeatures && featureOpts.otherFeatures.length > 0 ? `
324578
325452
  ## Other Features (DO NOT TEST)
324579
325453
  These are separate features. Do NOT navigate to their pages, do NOT interact with them, do NOT call record_journey for them:
@@ -324684,6 +325558,22 @@ ${transitionBlock}
324684
325558
  ${(() => {
324685
325559
  const isAuthFeature = featureOpts.focusAreas.some((fa) => /\/(auth|login|sign-?in|register|signup)\b/i.test(fa));
324686
325560
  if (isAuthFeature && hasCredentials) {
325561
+ if (emailVerificationUnavailable) {
325562
+ return `## Login/Registration IS Your Test Assignment (email verification UNAVAILABLE)
325563
+ Your assigned pages ARE the login/registration pages. This project registers its own account, but this runner CANNOT receive email \u2014 registration may still work if the app does not require email verification.
325564
+
325565
+ Follow this order:
325566
+ 1. Navigate to your first assigned auth page (e.g., the login page)
325567
+ 2. Take a \`browser_snapshot\` to see what's there
325568
+ 3. **Test VALIDATION FIRST** while you are NOT logged in - on the LOGIN form: empty fields, invalid email, wrong password (synthetic values like "wrong@example.com" / "badpassword"); on the REGISTRATION form: empty-submit validation ONLY (a filled synthetic signup could create a stray account)
325569
+ 4. Call \`record_journey\` for the validation flow
325570
+ 5. **THEN attempt the happy path ONCE via REGISTRATION**: fill the signup form with \`fill_credential_form\` using the \`TEST_USER_EMAIL\` + \`TEST_USER_PASSWORD\` credential keys and submit it ONCE. Never alter the email, never create a second account. If signup says the address is ALREADY registered (a previous run created it), log in with the same credential keys instead
325571
+ 6. **THE WALL**: if any step demands an emailed code/link (verification code, OTP, magic link, "check your email"), STOP immediately - never type a guessed code, never click Resend - and treat the happy path as BLOCKED
325572
+ 7. If you are signed in with NO email round-trip, call \`record_journey\` for the happy path
325573
+ 8. Call \`capture_page\` on each auth page AFTER interacting (this saves the successful commands for test generation)
325574
+
325575
+ When done, call \`finish_exploration\` - if you hit the wall, note that the authenticated happy path is BLOCKED (cannot receive verification email).`;
325576
+ }
324687
325577
  return `## Login/Registration IS Your Test Assignment
324688
325578
  Your assigned pages ARE the login/registration pages. Do NOT log in as a pass-through - the auth pages are what you are testing.
324689
325579
 
@@ -324738,7 +325628,7 @@ ${otherFeaturesBlock}
324738
325628
  4. Take \`browser_snapshot\` of the result page
324739
325629
  - If the page shows a loading skeleton or spinner after navigation, wait for the real content to appear before calling \`capture_page\` or \`record_journey\`
324740
325630
  5. Call \`record_journey\` with:
324741
- - All routes visited in \`routes\` array (e.g., ["/auth/login", "/dashboard"])
325631
+ - All routes visited in \`routes\` array (e.g., ${emailVerificationUnavailable ? '["/", "/contact"]' : '["/auth/login", "/dashboard"]'})
324742
325632
  - Specific steps describing what you did
324743
325633
  - expectedOutcome with the EXACT result you observed
324744
325634
  - assertions with STABLE structural elements from the result page
@@ -324750,11 +325640,15 @@ ${otherFeaturesBlock}
324750
325640
  4. Fix the errors and resubmit successfully \u2192 observe recovery
324751
325641
  5. Call \`record_journey\` ONCE for this entire combined flow
324752
325642
 
324753
- **Auth pages (login/register) - test NEGATIVE before positive:**
325643
+ ${emailVerificationUnavailable ? `**Auth pages (login/register) - this runner CANNOT receive email:**
325644
+ - Test negative flows FIRST: on the LOGIN form empty fields \u2192 invalid synthetic values; on the REGISTRATION form empty-submit only (never submit a filled synthetic signup) \u2192 call record_journey for the validation flow
325645
+ - THEN attempt the happy path ONCE via registration with the \`TEST_USER_EMAIL\` + \`TEST_USER_PASSWORD\` credential keys (\`fill_credential_form\`); if the address is already registered, log in with the same keys
325646
+ - If any step demands an emailed code/link, STOP - never type a guessed code - and note in finish_exploration that the authenticated happy path is BLOCKED (cannot receive verification email)
325647
+ - If you are signed in without an email round-trip, call record_journey for the happy path` : `**Auth pages (login/register) - test NEGATIVE before positive:**
324754
325648
  - You arrive at the page NOT logged in - test errors FIRST while in this state
324755
325649
  - Empty fields \u2192 invalid data \u2192 call record_journey
324756
325650
  - THEN do the happy path - valid credentials \u2192 call record_journey
324757
- - This order avoids needing to log out between journeys
325651
+ - This order avoids needing to log out between journeys`}
324758
325652
 
324759
325653
  ### For CRUD Features - Combine into a Single Journey:
324760
325654
  If the feature has Create/View/Edit/Delete operations across pages:
@@ -324779,7 +325673,7 @@ When you have thoroughly explored all the feature pages and tested the key flows
324779
325673
  - Pages you visited and what you found there
324780
325674
 
324781
325675
  ## Test Data Rules
324782
- ${registerMode ? `- **Account credentials**: do NOT invent an email or password \u2014 register and log in with the email returned by \`provision_identity\` and the \`TEST_USER_PASSWORD\` credential (filled via \`fill_credential\`). See the Account Registration section.` : `- **LOGIN** credential fields: use \`process.env.TEST_USER_EMAIL!\` and \`process.env.TEST_USER_PASSWORD!\`
325676
+ ${registerMode ? `- **Account credentials**: do NOT invent an email or password \u2014 register and log in with the email returned by \`provision_identity\` and the \`TEST_USER_PASSWORD\` credential (filled via \`fill_credential\`). See the Account Registration section.` : emailVerificationUnavailable ? `- **Account credentials**: this project registers its own account but this runner CANNOT receive email. Register/log in ONLY with the \`TEST_USER_EMAIL\` + \`TEST_USER_PASSWORD\` credential keys (\`fill_credential\` / \`fill_credential_form\`) \u2014 never invent a different email, never create a second account. If a step demands an emailed verification code or link, STOP that flow (never guess a code) and mark it BLOCKED.` : `- **LOGIN** credential fields: use \`process.env.TEST_USER_EMAIL!\` and \`process.env.TEST_USER_PASSWORD!\`
324783
325677
  - **REGISTRATION/SIGNUP** email fields: MUST be unique every run \u2192 \`testuser-\${Date.now()}@example.com\`
324784
325678
  - Passwords for registration: \`TestPass123!\` (meets typical strength rules)`}
324785
325679
  - **Other form fields**: use realistic static values (Jane Smith, 555-0100, https://example.com)
@@ -324801,7 +325695,17 @@ When calling \`record_journey\`:
324801
325695
 
324802
325696
  **Example record_journey with good assertions:**
324803
325697
  \`\`\`
324804
- record_journey({
325698
+ ${emailVerificationUnavailable ? `record_journey({
325699
+ name: "Login Form - Validation",
325700
+ route: "/auth/login",
325701
+ routes: ["/", "/auth/login"],
325702
+ steps: ["Navigate to /", "Click 'Sign In'", "Submit the empty form", "Observe validation errors"],
325703
+ expectedOutcome: "URL matches /auth/login. Validation error 'Email is required' is visible.",
325704
+ assertions: [
325705
+ { type: "url", value: "/auth/login" },
325706
+ { type: "error-text", value: "Email is required" }
325707
+ ]
325708
+ })` : `record_journey({
324805
325709
  name: "Login - Happy Path",
324806
325710
  route: "/auth/login",
324807
325711
  routes: ["/", "/auth/login", "/dashboard"],
@@ -324812,7 +325716,7 @@ record_journey({
324812
325716
  { type: "nav-link", locator: "getByRole('link', { name: 'Dashboard' })" },
324813
325717
  { type: "heading", locator: "getByRole('heading', { name: 'Dashboard' })" }
324814
325718
  ]
324815
- })
325719
+ })`}
324816
325720
  \`\`\`
324817
325721
  BAD assertions (do NOT use): \`{ type: "heading", locator: "getByRole('heading', { name: 'Welcome back, John!' })" }\` - user-specific text
324818
325722
 
@@ -324848,13 +325752,16 @@ Do NOT re-propose a test with the same name or identical steps as any item above
324848
325752
  ${hasCredentials ? `
324849
325753
  ## Credentials (browser interaction ONLY - NEVER include in record_journey steps)
324850
325754
  ${credentialLines}
325755
+ ` : ""}${emailVerificationUnavailable ? `
325756
+ ${inbox_tools_js_1.EMAIL_VERIFICATION_UNAVAILABLE_OVERRIDE_BLOCK}
324851
325757
  ` : ""}`;
324852
325758
  }
324853
325759
  function buildIncrementalExplorePrompt(baseUrl, variableContext, existingSiteMap, existingTestNames, featureOpts) {
324854
325760
  const browserCredentials = variableContext.allTestVariables ?? variableContext.publicTestVariables;
324855
325761
  const hasCredentials = Object.keys(browserCredentials).length > 0;
324856
325762
  const registerMode = !!((0, verification_inbox_js_1.loadVerificationInboxConfig)() && (0, inbox_tools_js_1.hasRegisterIntent)(variableContext));
324857
- const credentialLines = Object.entries(browserCredentials).map(([k, v]) => `- **${k}**: \`${v}\``).join("\n");
325763
+ const emailVerificationUnavailable = !registerMode && (0, inbox_tools_js_1.hasRegisterIntent)(variableContext) && !(0, credential_tools_js_1.hasUsableLoginIdentity)(browserCredentials, { isPlaceholderIdentityValue: inbox_tools_js_1.isThrowawayRegisterSeedEmail });
325764
+ const credentialLines = Object.entries(browserCredentials).filter(([k]) => k !== "DISCOVERY_SHOULD_REGISTER").map(([k, v]) => `- **${k}**: \`${v}\``).join("\n");
324858
325765
  const existingTestsBlock = featureOpts.existingTestDetails && featureOpts.existingTestDetails.length > 0 ? featureOpts.existingTestDetails.map((t, i) => {
324859
325766
  const stepsStr = t.steps.length > 0 ? `
324860
325767
  Steps: ${t.steps.join(" \u2192 ")}` : "";
@@ -324926,7 +325833,7 @@ ${featureOpts.appBrief}
324926
325833
  ${featureOpts.focusAreas.map((fa) => `- ${fa}`).join("\n")}
324927
325834
  ${pageElementsBlock}${otherFeaturesBlock}
324928
325835
  ## Process
324929
- 1. ${registerMode ? "Create your account by following the Account Registration section below, then navigate to the feature pages" : isAuthFeature && hasCredentials ? "Navigate to the auth pages - test validation/error scenarios NOT already covered" : hasCredentials ? "Log in using credentials below, then navigate to the feature pages" : "Navigate to the feature pages"}
325836
+ 1. ${registerMode ? "Create your account by following the Account Registration section below, then navigate to the feature pages" : emailVerificationUnavailable ? "This runner CANNOT receive email. Attempt registration ONCE with the `TEST_USER_EMAIL` + `TEST_USER_PASSWORD` credential keys via `fill_credential_form` (if the address is already registered, log in with the same keys), then navigate to the feature pages. If any step demands an emailed code/link, STOP that flow \u2014 never type a guessed code \u2014 cover only unauthenticated gaps and note blocked authenticated scenarios in finish_exploration" : isAuthFeature && hasCredentials ? "Navigate to the auth pages - test validation/error scenarios NOT already covered" : hasCredentials ? "Log in using credentials below, then navigate to the feature pages" : "Navigate to the feature pages"}
324930
325837
  2. Take \`browser_snapshot\` on each page
324931
325838
  3. Compare what you see with the existing tests - what flows are NOT tested?
324932
325839
  4. For each gap you find, interact with the page to verify the flow works, then call \`record_journey\`
@@ -324950,11 +325857,14 @@ ${featureOpts.priorInsight}
324950
325857
  ${hasCredentials ? `
324951
325858
  ## Credentials (browser interaction ONLY)
324952
325859
  ${credentialLines}
325860
+ ` : ""}${emailVerificationUnavailable ? `
325861
+ ${inbox_tools_js_1.EMAIL_VERIFICATION_UNAVAILABLE_OVERRIDE_BLOCK}
324953
325862
  ` : ""}`;
324954
325863
  }
324955
325864
  async function runFeatureExplorePhase(mcpClient, baseUrl, variableContext, existingSiteMap, projectId, existingTestNames, featureOpts) {
324956
325865
  const inboxConfig = (0, verification_inbox_js_1.loadVerificationInboxConfig)();
324957
- const registerMode = !!(inboxConfig && (0, inbox_tools_js_1.hasRegisterIntent)(variableContext));
325866
+ const registerIntent = (0, inbox_tools_js_1.hasRegisterIntent)(variableContext);
325867
+ const registerMode = !!(inboxConfig && registerIntent);
324958
325868
  let inboxPasswordKey = "TEST_USER_PASSWORD";
324959
325869
  if (registerMode && inboxConfig) {
324960
325870
  const inboxIdentity = (0, inbox_tools_js_1.createInboxRunState)(inboxConfig, { tagSeed: baseUrl, projectScope: projectId });
@@ -324965,6 +325875,9 @@ ${credentialLines}
324965
325875
  passwordKey: inboxPasswordKey
324966
325876
  });
324967
325877
  }
325878
+ const emailVerificationUnavailable = registerIntent && !inboxConfig && !(0, credential_tools_js_1.hasUsableLoginIdentity)(variableContext.allTestVariables ?? variableContext.publicTestVariables, {
325879
+ isPlaceholderIdentityValue: inbox_tools_js_1.isThrowawayRegisterSeedEmail
325880
+ });
324968
325881
  const isIncremental = featureOpts.incremental && existingTestNames.length > 0;
324969
325882
  const systemPrompt = isIncremental ? buildIncrementalExplorePrompt(baseUrl, variableContext, existingSiteMap, existingTestNames, featureOpts) : buildFeatureExplorePrompt(baseUrl, variableContext, existingSiteMap, existingTestNames, featureOpts);
324970
325883
  const hasCredentials = Object.keys(variableContext.allTestVariables ?? variableContext.publicTestVariables).length > 0;
@@ -324975,6 +325888,8 @@ ${credentialLines}
324975
325888
  const focusHint = featureOpts.userNotes ? ` The user asked you to focus on: "${featureOpts.userNotes}".` : "";
324976
325889
  if (registerMode) {
324977
325890
  userMessage = `Navigate to ${baseUrl} and create your account:${registerHint}. Then review the ${existingTestNames.length} existing tests and navigate to: ${featureOpts.focusAreas.join(", ")}. Look for gaps - scenarios, pages, or error cases not yet covered.${focusHint} If all meaningful scenarios are covered, call finish_exploration with "No additional tests needed."`;
325891
+ } else if (emailVerificationUnavailable) {
325892
+ userMessage = `Navigate to ${baseUrl}. NOTE: this project registers its own account but this runner CANNOT receive email. Attempt registration ONCE with the TEST_USER_EMAIL + TEST_USER_PASSWORD credential keys via fill_credential_form (if the address is already registered, log in with the same keys; never alter the email or invent another). If any step demands an emailed code/link, STOP that flow \u2014 never type a guessed code. Review the ${existingTestNames.length} existing tests, then look for gaps reachable in your auth state on: ${featureOpts.focusAreas.join(", ")}.${focusHint} Note any email-wall-blocked scenarios as BLOCKED in finish_exploration.`;
324978
325893
  } else if (isAuthFeature) {
324979
325894
  userMessage = `Navigate to ${baseUrl}. Review the ${existingTestNames.length} existing tests listed above, then navigate to the auth pages: ${featureOpts.focusAreas.join(", ")}. Look for untested scenarios - error cases, edge cases, flows not yet covered.${focusHint} If all meaningful scenarios are covered, call finish_exploration with "No additional tests needed."`;
324980
325895
  } else if (hasCredentials) {
@@ -324986,6 +325901,8 @@ ${credentialLines}
324986
325901
  let navigationInstruction;
324987
325902
  if (registerMode) {
324988
325903
  navigationInstruction = `Navigate to ${baseUrl} and create your account:${registerHint}. Then go to your assigned feature pages: ${featureOpts.focusAreas.join(", ")}.`;
325904
+ } else if (emailVerificationUnavailable) {
325905
+ navigationInstruction = `Navigate to ${baseUrl}. NOTE: this project registers its own account but this runner CANNOT receive email. Attempt registration ONCE with the TEST_USER_EMAIL + TEST_USER_PASSWORD credential keys via fill_credential_form (if the address is already registered, log in with the same keys; never alter the email or create a second account). If you are signed in without an email round-trip, test your assigned feature pages fully: ${featureOpts.focusAreas.join(", ")}. If any step demands an emailed code/link, STOP that flow \u2014 never type a guessed code \u2014 test what is reachable without authentication instead and note blocked authenticated flows in finish_exploration.`;
324989
325906
  } else if (isAuthFeature) {
324990
325907
  navigationInstruction = `Navigate to ${baseUrl}. Your test assignment is the authentication pages: ${featureOpts.focusAreas.join(", ")}. Navigate to the login/register page and test it - start with validation (empty/wrong fields) while NOT logged in, then test the happy path.`;
324991
325908
  } else if (hasCredentials) {
@@ -325218,8 +326135,14 @@ var require_auth_capture_run = __commonJS({
325218
326135
  exports2.filterLoginCaptureCredentials = filterLoginCaptureCredentials;
325219
326136
  exports2.buildLoginCaptureCredentials = buildLoginCaptureCredentials;
325220
326137
  exports2.getLoginCaptureMaxIterations = getLoginCaptureMaxIterations;
326138
+ exports2.getCaptureRateLimitMaxRetries = getCaptureRateLimitMaxRetries;
326139
+ exports2.getCaptureRateLimitMaxDelayMs = getCaptureRateLimitMaxDelayMs;
326140
+ exports2.getAuthCaptureTimeoutMs = getAuthCaptureTimeoutMs;
326141
+ exports2.getAuthCaptureRunRetryMaxAttempts = getAuthCaptureRunRetryMaxAttempts;
326142
+ exports2.classifyCaptureMiss = classifyCaptureMiss;
325221
326143
  exports2.harvestAuthProofLive = harvestAuthProofLive;
325222
326144
  exports2.findCredentialLiteralLeaks = findCredentialLiteralLeaks;
326145
+ exports2.runLoginCaptureRunWithOutcome = runLoginCaptureRunWithOutcome;
325223
326146
  exports2.runLoginCaptureRun = runLoginCaptureRun;
325224
326147
  exports2.getRegisterCaptureMaxIterations = getRegisterCaptureMaxIterations;
325225
326148
  exports2.runRegisterCaptureRun = runRegisterCaptureRun;
@@ -325232,6 +326155,7 @@ var require_auth_capture_run = __commonJS({
325232
326155
  var playwright_native_js_1 = require_playwright_native();
325233
326156
  var scrub_credentials_js_1 = require_scrub_credentials();
325234
326157
  var credential_tools_js_1 = require_credential_tools();
326158
+ var ai_retry_js_1 = require_ai_retry();
325235
326159
  var LOGIN_CAPTURE_CONTROL_VARIABLES = /* @__PURE__ */ new Set([
325236
326160
  "BASE_URL",
325237
326161
  "DISCOVERY_SHOULD_REGISTER",
@@ -325265,6 +326189,36 @@ var require_auth_capture_run = __commonJS({
325265
326189
  }
325266
326190
  var CAPTURE_RATE_LIMIT_MAX_RETRIES = 2;
325267
326191
  var CAPTURE_RATE_LIMIT_MAX_DELAY_MS = 8e3;
326192
+ function readNonNegativeIntEnv(env, name, fallback) {
326193
+ const raw = env[name]?.trim();
326194
+ if (raw === void 0 || raw === "" || !/^\d+$/.test(raw))
326195
+ return fallback;
326196
+ const parsed = Number(raw);
326197
+ return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : fallback;
326198
+ }
326199
+ function getCaptureRateLimitMaxRetries(env = process.env) {
326200
+ return readNonNegativeIntEnv(env, "AUTH_CAPTURE_RATE_LIMIT_MAX_RETRIES", CAPTURE_RATE_LIMIT_MAX_RETRIES);
326201
+ }
326202
+ function getCaptureRateLimitMaxDelayMs(env = process.env) {
326203
+ return readPositiveIntEnv2(env, "AUTH_CAPTURE_RATE_LIMIT_MAX_DELAY_MS", CAPTURE_RATE_LIMIT_MAX_DELAY_MS);
326204
+ }
326205
+ var DEFAULT_AUTH_CAPTURE_TIMEOUT_MS = 4 * 60 * 1e3;
326206
+ function getAuthCaptureTimeoutMs(env = process.env) {
326207
+ return readPositiveIntEnv2(env, "AUTH_CAPTURE_TIMEOUT_MS", DEFAULT_AUTH_CAPTURE_TIMEOUT_MS);
326208
+ }
326209
+ var DEFAULT_AUTH_CAPTURE_RUN_RETRY_MAX_ATTEMPTS = 2;
326210
+ function getAuthCaptureRunRetryMaxAttempts(env = process.env) {
326211
+ return readPositiveIntEnv2(env, "AUTH_CAPTURE_RUN_RETRY_MAX_ATTEMPTS", DEFAULT_AUTH_CAPTURE_RUN_RETRY_MAX_ATTEMPTS);
326212
+ }
326213
+ function classifyCaptureMiss(explore, fallback) {
326214
+ if (!explore.truncated)
326215
+ return fallback;
326216
+ if (explore.truncatedTransient)
326217
+ return "rate_limited";
326218
+ if (explore.truncatedReason === "timeout")
326219
+ return "timeout";
326220
+ return "error";
326221
+ }
325268
326222
  function buildLoginCaptureSystemPrompt(baseUrl, availableKeys, maxIterations = getLoginCaptureMaxIterations()) {
325269
326223
  const keyLines = availableKeys.map((k) => `- \`${k}\``).join("\n");
325270
326224
  return `You are a login specialist. Your SINGLE objective: navigate to the app, log in with the provided test credentials, and confirm you are authenticated. Then stop.
@@ -325288,6 +326242,7 @@ ${keyLines || "- (none provided)"}
325288
326242
  ## Hard rules
325289
326243
  - Do NOT submit registration, password-reset, or any other forms. Login only.
325290
326244
  - Do NOT fill validation / negative values. Happy-path login only.
326245
+ - If login demands an emailed verification code, one-time password (OTP), or magic link, STOP \u2014 you have no inbox access and NEVER type a guessed code (any code you type is fabricated). Call \`capture_page\` on the verification wall noting it as the blocker, then \`finish_exploration\`.
325291
326246
  - Use RELATIVE routes in capture_page (e.g. \`/login\`, \`/dashboard\`), never absolute URLs.
325292
326247
  - If login fails after 2 attempts, call \`capture_page\` noting the failure and call \`finish_exploration\`.
325293
326248
  - You have a hard limit of ${maxIterations} iterations. Finish well before then.`;
@@ -325458,17 +326413,17 @@ ${keyLines || "- (none provided)"}
325458
326413
  }
325459
326414
  return false;
325460
326415
  }
325461
- async function runLoginCaptureRun(args) {
326416
+ async function runLoginCaptureRunWithOutcome(args) {
325462
326417
  const { loginBrowser, baseUrl, projectId, model, onAudit, logs: logs2 } = args;
325463
326418
  const credentials = filterLoginCaptureCredentials(args.credentials);
325464
326419
  if ((0, agentic_cli_constants_js_1.getAgenticEngine)(model) !== "native") {
325465
326420
  logs2(` auth-capture skipped: engine for ${model} is not native (V1 is native-engine-only)`);
325466
- return null;
326421
+ return { recipe: null, outcome: "skipped" };
325467
326422
  }
325468
326423
  const { secrets } = (0, credential_tools_js_1.partitionTestVariables)(credentials);
325469
326424
  if (Object.keys(secrets).length === 0) {
325470
326425
  logs2(" auth-capture skipped: no secret credentials available to log in with");
325471
- return null;
326426
+ return { recipe: null, outcome: "skipped" };
325472
326427
  }
325473
326428
  const auditRemap = onAudit ? (info) => {
325474
326429
  try {
@@ -325489,7 +326444,7 @@ ${keyLines || "- (none provided)"}
325489
326444
  const mcpClient = handle.mcpClient;
325490
326445
  if (!mcpClient) {
325491
326446
  logs2(" auth-capture aborted: instrumented context has no MCP client");
325492
- return null;
326447
+ return { recipe: null, outcome: "skipped" };
325493
326448
  }
325494
326449
  const availableKeys = Object.keys(credentials);
325495
326450
  const maxIterations = getLoginCaptureMaxIterations();
@@ -325499,8 +326454,8 @@ ${keyLines || "- (none provided)"}
325499
326454
  enableRecordJourney: false,
325500
326455
  // login-only — no feature journeys to record
325501
326456
  maxIterationsOverride: maxIterations,
325502
- rateLimitMaxRetries: CAPTURE_RATE_LIMIT_MAX_RETRIES,
325503
- rateLimitMaxDelayMs: CAPTURE_RATE_LIMIT_MAX_DELAY_MS
326457
+ rateLimitMaxRetries: getCaptureRateLimitMaxRetries(),
326458
+ rateLimitMaxDelayMs: getCaptureRateLimitMaxDelayMs()
325504
326459
  };
325505
326460
  const exploreResult = await (0, discover_explorer_js_1.runExplorePhase)(mcpClient, baseUrl, {
325506
326461
  publicTestVariables: credentials,
@@ -325515,6 +326470,7 @@ ${keyLines || "- (none provided)"}
325515
326470
  onProgress: void 0
325516
326471
  }, loginConfig);
325517
326472
  logs2(` auth-capture explore: ${exploreResult.pagesDiscovered} pages, ${exploreResult.collectedPages.length} captured`);
326473
+ const exploreMiss = (fallback) => classifyCaptureMiss(exploreResult, fallback);
325518
326474
  const loginObservedOrigins = exploreResult.observedOrigins ?? [];
325519
326475
  try {
325520
326476
  args.onObservedOrigins?.(loginObservedOrigins);
@@ -325530,7 +326486,7 @@ ${keyLines || "- (none provided)"}
325530
326486
  const login = (0, discover_generator_js_1.getLoginCommands)(loginSiteMap.pages, credentials);
325531
326487
  if (!login) {
325532
326488
  logs2(" \u26A0 auth unverified (login run produced no derivable login sequence) \u2014 falling back to model-authored login");
325533
- return null;
326489
+ return { recipe: null, outcome: exploreMiss("no_login") };
325534
326490
  }
325535
326491
  const scrubbedLogin = {
325536
326492
  ...login,
@@ -325540,19 +326496,19 @@ ${keyLines || "- (none provided)"}
325540
326496
  const authProof = harvestAuthProofLive(loginSiteMap, scrubbedLogin.redirectRoute, scrubbedLogin.route, credentials, logs2);
325541
326497
  if (!authProof) {
325542
326498
  logs2(" \u26A0 auth unverified (no durable signed-in proof on the authenticated page) \u2014 falling back to model-authored login");
325543
- return null;
326499
+ return { recipe: null, outcome: exploreMiss("verify_failed") };
325544
326500
  }
325545
326501
  const candidate = { ...(0, auth_recipe_js_1.buildAuthRecipe)(scrubbedLogin, authProof, (/* @__PURE__ */ new Date()).toISOString()), appOrigin: loginRedirectAppOrigin };
325546
326502
  const rendered = (0, auth_recipe_js_1.renderAuthFn)(candidate);
325547
326503
  const leaks = findCredentialLiteralLeaks(rendered, credentials);
325548
326504
  if (leaks.length > 0) {
325549
326505
  logs2(` \u26A0 auth recipe rejected: rendered __vqaLogin contains literal credential value(s) for ${leaks.join(", ")} \u2014 falling back to model-authored login`);
325550
- return null;
326506
+ return { recipe: null, outcome: "credential_leak" };
325551
326507
  }
325552
326508
  const planLeaks = findCredentialLiteralLeaks(JSON.stringify(candidate.replayPlan ?? []), credentials);
325553
326509
  if (planLeaks.length > 0) {
325554
326510
  logs2(` \u26A0 auth recipe rejected: structured replayPlan contains literal credential value(s) for ${planLeaks.join(", ")} \u2014 falling back to model-authored login`);
325555
- return null;
326511
+ return { recipe: null, outcome: "credential_leak" };
325556
326512
  }
325557
326513
  try {
325558
326514
  await handle.close();
@@ -325562,14 +326518,14 @@ ${keyLines || "- (none provided)"}
325562
326518
  const ok = await verifyAuthRecipe(candidate, baseUrl, credentials, logs2);
325563
326519
  if (!ok) {
325564
326520
  logs2(" \u26A0 auth unverified (live-verify replay failed \u2014 fleet-config drift) \u2014 falling back to model-authored login");
325565
- return null;
326521
+ return { recipe: null, outcome: exploreMiss("verify_failed") };
325566
326522
  }
325567
326523
  const proofDesc = authProof.kind === "role" ? `role:${authProof.role}${authProof.name ? `(${authProof.name})` : ""}` : authProof.kind === "testid" ? `testid:${authProof.testId}` : `url:${authProof.route}`;
325568
326524
  logs2(` \u2713 auth recipe verified (hash ${candidate.recipeHash}, proof ${proofDesc}, ${(candidate.replayPlan ?? []).length} replay steps) \u2014 stamping into @needs-auth tests`);
325569
- return candidate;
326525
+ return { recipe: candidate, outcome: "captured" };
325570
326526
  } catch (err) {
325571
326527
  logs2(` \u26A0 auth-capture run failed: ${err instanceof Error ? err.message : String(err)} \u2014 falling back to model-authored login`);
325572
- return null;
326528
+ return { recipe: null, outcome: (0, ai_retry_js_1.isTransientRateError)(err) ? "rate_limited" : "error" };
325573
326529
  } finally {
325574
326530
  if (handle) {
325575
326531
  try {
@@ -325579,6 +326535,9 @@ ${keyLines || "- (none provided)"}
325579
326535
  }
325580
326536
  }
325581
326537
  }
326538
+ async function runLoginCaptureRun(args) {
326539
+ return (await runLoginCaptureRunWithOutcome(args)).recipe;
326540
+ }
325582
326541
  var DEFAULT_MAX_REGISTER_CAPTURE_ITERATIONS = 18;
325583
326542
  function getRegisterCaptureMaxIterations(env = process.env) {
325584
326543
  return readPositiveIntEnv2(env, "AUTH_CAPTURE_REGISTER_MAX_ITERATIONS", DEFAULT_MAX_REGISTER_CAPTURE_ITERATIONS);
@@ -325650,8 +326609,8 @@ ${keyLines || "- (none provided)"}
325650
326609
  userMessage: buildRegisterCaptureUserMessage(baseUrl),
325651
326610
  enableRecordJourney: false,
325652
326611
  maxIterationsOverride: maxIterations,
325653
- rateLimitMaxRetries: CAPTURE_RATE_LIMIT_MAX_RETRIES,
325654
- rateLimitMaxDelayMs: CAPTURE_RATE_LIMIT_MAX_DELAY_MS,
326612
+ rateLimitMaxRetries: getCaptureRateLimitMaxRetries(),
326613
+ rateLimitMaxDelayMs: getCaptureRateLimitMaxDelayMs(),
325655
326614
  // Register + poll the PROJECT-SCOPED address so it matches the one the
325656
326615
  // standalone authored tests log in with (see #922).
325657
326616
  inboxTagOverride: args.inboxTag
@@ -332383,6 +333342,8 @@ var require_discover_agent = __commonJS({
332383
333342
  Object.defineProperty(exports2, "__esModule", { value: true });
332384
333343
  exports2.runMobileDiscoveryOnRunner = exports2.buildInMemorySiteMap = void 0;
332385
333344
  exports2.runCanvasPreflight = runCanvasPreflight;
333345
+ exports2.runCaptureAttemptLoop = runCaptureAttemptLoop;
333346
+ exports2.isCaptureRunRetryEnabled = isCaptureRunRetryEnabled;
332386
333347
  exports2.getFatalExploreError = getFatalExploreError;
332387
333348
  exports2.runSiteDiscoveryOnRunner = runSiteDiscoveryOnRunner2;
332388
333349
  exports2.runFeatureDiscoveryOnRunner = runFeatureDiscoveryOnRunner2;
@@ -332631,8 +333592,56 @@ Respond with ONLY valid JSON:
332631
333592
  }
332632
333593
  return merged;
332633
333594
  }
332634
- var AUTH_CAPTURE_TIMEOUT_MS = 4 * 60 * 1e3;
332635
- function maybeStartLoginCaptureRun(ctx, callbackOptions, onAICall, pushLog, onObservedOrigins) {
333595
+ function computeCaptureRetryBackoffMs(attempt) {
333596
+ const capped = Math.min(3e3 * Math.pow(2, attempt - 1), 15e3);
333597
+ const jitter = 0.5 + Math.random() * 0.5;
333598
+ return Math.round(capped * jitter);
333599
+ }
333600
+ async function runCaptureAttemptLoop(args) {
333601
+ const { runCapture, maxAttempts, deadline, minRetryBudgetMs, now, sleep, backoffMs, log: log2, onAttempt } = args;
333602
+ let attemptsMade = 0;
333603
+ let lastOutcome = "error";
333604
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
333605
+ if (now() >= deadline) {
333606
+ lastOutcome = "timeout";
333607
+ break;
333608
+ }
333609
+ attemptsMade = attempt;
333610
+ onAttempt?.(attempt);
333611
+ const { recipe, outcome } = await runCapture(attempt);
333612
+ lastOutcome = outcome;
333613
+ if (recipe)
333614
+ return { recipe, outcome, attempts: attemptsMade };
333615
+ if (attempt >= maxAttempts || outcome !== "rate_limited")
333616
+ break;
333617
+ const remaining = deadline - now();
333618
+ if (remaining < minRetryBudgetMs) {
333619
+ log2(`auth-prologue: transient rate-limit miss, but only ${Math.round(remaining / 1e3)}s of the capture wall remain \u2014 not retrying`);
333620
+ break;
333621
+ }
333622
+ const backoff = Math.min(backoffMs(attempt), remaining - minRetryBudgetMs);
333623
+ if (backoff > 0) {
333624
+ log2(`auth-prologue: login-capture hit a transient rate limit (attempt ${attempt}/${maxAttempts}) \u2014 retrying in ${Math.round(backoff / 1e3)}s`);
333625
+ await sleep(backoff);
333626
+ }
333627
+ if (deadline - now() < minRetryBudgetMs) {
333628
+ log2("auth-prologue: capture wall nearly exhausted after backoff \u2014 not retrying");
333629
+ break;
333630
+ }
333631
+ }
333632
+ return { recipe: null, outcome: lastOutcome, attempts: attemptsMade };
333633
+ }
333634
+ function logAuthGenerationStats(logs2, tests, authRecipe) {
333635
+ const needsAuth = tests.filter((t) => t.tags.includes("@needs-auth"));
333636
+ if (needsAuth.length === 0)
333637
+ return;
333638
+ const recipeStamped = needsAuth.filter((t) => /VALIDATE_QA_AUTH/.test(t.playwrightCode ?? "")).length;
333639
+ logs2.push(`[auth-capture] needsAuthTests=${needsAuth.length} recipeStamped=${recipeStamped} inlineLogin=${needsAuth.length - recipeStamped} recipeAvailable=${authRecipe ? "yes" : "no"}`);
333640
+ }
333641
+ function isCaptureRunRetryEnabled(env = process.env) {
333642
+ return (0, shared_1.parseBoolFlag)(env.AUTH_CAPTURE_RUN_RETRY, true);
333643
+ }
333644
+ function maybeStartLoginCaptureRun(ctx, callbackOptions, onAICall, pushLog, onObservedOrigins, onOutcome) {
332636
333645
  if (!(0, shared_1.parseBoolFlag)(process.env.AUTH_RECIPE_STAMP) && ctx.mode !== "capture")
332637
333646
  return null;
332638
333647
  if (ctx.authRecipe) {
@@ -332657,25 +333666,44 @@ Respond with ONLY valid JSON:
332657
333666
  return null;
332658
333667
  }
332659
333668
  const credentials = (0, auth_capture_run_js_1.buildLoginCaptureCredentials)(ctx.variableContext);
333669
+ const runStart = Date.now();
333670
+ const timeoutMs = (0, auth_capture_run_js_1.getAuthCaptureTimeoutMs)();
333671
+ const deadline = runStart + timeoutMs;
333672
+ const retryEnabled = isCaptureRunRetryEnabled();
333673
+ const maxAttempts = retryEnabled ? (0, auth_capture_run_js_1.getAuthCaptureRunRetryMaxAttempts)() : 1;
333674
+ const MIN_RETRY_BUDGET_MS = 45e3;
333675
+ let attemptsMade = 0;
332660
333676
  const run2 = (async () => {
332661
333677
  let lease = null;
332662
333678
  try {
332663
333679
  lease = await acquire();
332664
- const recipe = await (0, auth_capture_run_js_1.runLoginCaptureRun)({
332665
- loginBrowser: lease.browser,
332666
- baseUrl: ctx.baseUrl,
332667
- credentials,
332668
- projectId: ctx.projectId,
332669
- model,
332670
- existingSiteMap: ctx.existingSiteMap,
332671
- onAudit: onAICall,
332672
- onObservedOrigins,
332673
- logs: pushLog
333680
+ const leased = lease;
333681
+ return await runCaptureAttemptLoop({
333682
+ maxAttempts,
333683
+ deadline,
333684
+ minRetryBudgetMs: MIN_RETRY_BUDGET_MS,
333685
+ now: Date.now,
333686
+ sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
333687
+ backoffMs: computeCaptureRetryBackoffMs,
333688
+ log: pushLog,
333689
+ onAttempt: (n) => {
333690
+ attemptsMade = n;
333691
+ },
333692
+ runCapture: () => (0, auth_capture_run_js_1.runLoginCaptureRunWithOutcome)({
333693
+ loginBrowser: leased.browser,
333694
+ baseUrl: ctx.baseUrl,
333695
+ credentials,
333696
+ projectId: ctx.projectId,
333697
+ model,
333698
+ existingSiteMap: ctx.existingSiteMap,
333699
+ onAudit: onAICall,
333700
+ onObservedOrigins,
333701
+ logs: pushLog
333702
+ })
332674
333703
  });
332675
- return recipe;
332676
333704
  } catch (err) {
332677
333705
  pushLog(`auth-prologue: login-capture run threw (non-fatal): ${err instanceof Error ? err.message : String(err)}`);
332678
- return null;
333706
+ return { recipe: null, outcome: "error", attempts: attemptsMade };
332679
333707
  } finally {
332680
333708
  if (lease) {
332681
333709
  try {
@@ -332688,16 +333716,19 @@ Respond with ONLY valid JSON:
332688
333716
  let timer;
332689
333717
  const timeout = new Promise((resolve2) => {
332690
333718
  timer = setTimeout(() => {
332691
- pushLog(`auth-prologue: login-capture run exceeded ${AUTH_CAPTURE_TIMEOUT_MS / 1e3}s \u2014 proceeding without a recipe`);
332692
- resolve2(null);
332693
- }, AUTH_CAPTURE_TIMEOUT_MS);
333719
+ pushLog(`auth-prologue: login-capture run exceeded ${Math.round(timeoutMs / 1e3)}s \u2014 proceeding without a recipe`);
333720
+ resolve2({ recipe: null, outcome: "timeout", attempts: attemptsMade });
333721
+ }, Math.max(0, deadline - Date.now()));
332694
333722
  timer.unref?.();
332695
333723
  });
332696
- const timed = Promise.race([run2, timeout]).finally(() => {
333724
+ return Promise.race([run2, timeout]).finally(() => {
332697
333725
  if (timer)
332698
333726
  clearTimeout(timer);
332699
- });
332700
- return timed.catch(() => null);
333727
+ }).then((res) => {
333728
+ pushLog(`[auth-capture] outcome=${res.outcome} attempts=${res.attempts} durationMs=${Date.now() - runStart} mode=${ctx.mode ?? "discovery"}`);
333729
+ onOutcome?.(res.outcome);
333730
+ return res.recipe;
333731
+ }).catch(() => null);
332701
333732
  }
332702
333733
  function getFatalExploreError(exploreResult) {
332703
333734
  const prefix = "Fatal error:";
@@ -332712,12 +333743,15 @@ Respond with ONLY valid JSON:
332712
333743
  logs2.push(`Base URL: ${ctx.baseUrl}`);
332713
333744
  onLog?.("starting", logs2.join("\n"));
332714
333745
  const loginObservedOrigins = [];
333746
+ let captureOutcome;
332715
333747
  const loginRun = maybeStartLoginCaptureRun(ctx, callbackOptions, onAICall, (line) => {
332716
333748
  logs2.push(line);
332717
333749
  onLog?.("progress", logs2.join("\n"));
332718
333750
  }, (origins) => {
332719
333751
  for (const origin of origins)
332720
333752
  loginObservedOrigins.push(origin);
333753
+ }, (outcome) => {
333754
+ captureOutcome = outcome;
332721
333755
  });
332722
333756
  const authRecipe = loginRun ? await loginRun : null;
332723
333757
  const duration = (Date.now() - startTime) / 1e3;
@@ -332742,7 +333776,7 @@ Respond with ONLY valid JSON:
332742
333776
  },
332743
333777
  duration,
332744
333778
  mode: "capture",
332745
- ...authRecipe ? {} : { error: "Login capture did not produce a verified recipe" }
333779
+ ...authRecipe ? {} : { error: `Login capture did not produce a verified recipe${captureOutcome ? ` (${captureOutcome})` : ""}` }
332746
333780
  };
332747
333781
  }
332748
333782
  const mode = ctx.mode;
@@ -332922,14 +333956,18 @@ Explore complete: ${exploreResult.pagesDiscovered} pages, ${exploreResult.elemen
332922
333956
  const updatedSiteMap = (0, sitemap_builder_js_1.buildInMemorySiteMap)(ctx.projectId, ctx.baseUrl, exploreResult.collectedPages, exploreResult.collectedTransitions, ctx.existingSiteMap);
332923
333957
  if (updatedSiteMap.pages.length === 0) {
332924
333958
  logs2.push("No site map data available - skipping plan and generate phases");
332925
- if (loginRunP)
332926
- await loginRunP;
333959
+ const earlyAuthRecipe = loginRunP ? await loginRunP : null;
332927
333960
  const duration2 = (Date.now() - startTime) / 1e3;
332928
333961
  const fatalExploreError = getFatalExploreError(exploreResult);
332929
333962
  return {
332930
333963
  collectedPages: exploreResult.collectedPages,
332931
333964
  collectedTransitions: exploreResult.collectedTransitions,
332932
333965
  tests: [],
333966
+ // Persist only a FRESHLY-captured recipe — never re-persist a reused cached one
333967
+ // (ctx.authRecipe set) or a late warm run could overwrite/re-verify a newer recipe.
333968
+ authRecipe: ctx.authRecipe ? void 0 : earlyAuthRecipe,
333969
+ observedOrigins: mergeObservedOrigins(exploreResult.observedOrigins, loginObservedOrigins),
333970
+ resolvedAppOrigin: earlyAuthRecipe?.appOrigin ?? void 0,
332933
333971
  healthObservations: healthObserver?.getSummary(),
332934
333972
  logs: logs2.join("\n"),
332935
333973
  screenshots,
@@ -333017,12 +334055,6 @@ Plan: ${planResult.scenarios.length} scenarios, ${planResult.featureGroups.lengt
333017
334055
  logs2.push(surveyHealth.totalIssues > 0 ? `
333018
334056
  Health: ${surveyHealth.totalIssues} issue(s) - ${surveyHealth.consoleErrors.length} console errors, ${surveyHealth.failedRequests.length} failed requests` : "\nHealth observer: no issues detected");
333019
334057
  }
333020
- const duration2 = (Date.now() - startTime) / 1e3;
333021
- const featureCount = featureGroups?.length || finalPlan.testSuites.length;
333022
- const summary2 = `Survey complete: ${exploreResult.pagesDiscovered} pages, ${exploreResult.elementsFound} elements, ${featureCount} features identified in ${duration2.toFixed(1)}s`;
333023
- logs2.push(`
333024
- === Survey Complete (${duration2.toFixed(1)}s) ===`);
333025
- logs2.push(summary2);
333026
334058
  let mergedWarning = planResult.warning;
333027
334059
  if (exploreResult.truncated) {
333028
334060
  const reasonLabel = exploreResult.truncatedReason === "rate_limit" ? "AI rate-limit" : exploreResult.truncatedReason === "timeout" ? "AI timeout" : "AI error";
@@ -333043,6 +334075,12 @@ Health: ${surveyHealth.totalIssues} issue(s) - ${surveyHealth.consoleErrors.leng
333043
334075
  if (surveyAuthRecipe) {
333044
334076
  logs2.push(`Auth-prologue: captured + verified login recipe ${surveyAuthRecipe.recipeHash} during survey \u2014 persisting for reuse on later runs`);
333045
334077
  }
334078
+ const duration2 = (Date.now() - startTime) / 1e3;
334079
+ const featureCount = featureGroups?.length || finalPlan.testSuites.length;
334080
+ const summary2 = `Survey complete: ${exploreResult.pagesDiscovered} pages, ${exploreResult.elementsFound} elements, ${featureCount} features identified in ${duration2.toFixed(1)}s`;
334081
+ logs2.push(`
334082
+ === Survey Complete (${duration2.toFixed(1)}s) ===`);
334083
+ logs2.push(summary2);
333046
334084
  const plannerFailedError = planResult.plannerFailed ? `Survey planning failed (${planResult.plannerFailureKind ?? "unknown"}): ${planResult.fallbackReason ?? "planner did not produce a usable plan"}. Explore evidence was saved; re-run the survey to retry planning.` : void 0;
333047
334085
  return {
333048
334086
  observedOrigins: mergeObservedOrigins(exploreResult.observedOrigins, loginObservedOrigins),
@@ -333105,6 +334143,7 @@ Generation complete: ${generateResult.tests.length} tests generated (${generateE
333105
334143
  const tags = t.tags.join(", ");
333106
334144
  logs2.push(` ${i + 1}. ${t.name} [${tags}]${t.verified ? " \u2713live" : ""}`);
333107
334145
  });
334146
+ logAuthGenerationStats(logs2, generateResult.tests, authRecipe);
333108
334147
  onLog?.("generate", logs2.join("\n"));
333109
334148
  const postGenClose = await handle.close();
333110
334149
  handle = null;
@@ -333474,8 +334513,7 @@ Feature explore complete: ${exploreResult.pagesDiscovered} pages, ${exploreResul
333474
334513
  }
333475
334514
  if (!isPlanReuseResume && updatedSiteMap.pages.length === 0) {
333476
334515
  logs2.push("No site map data - skipping plan and generate phases");
333477
- if (loginRunP)
333478
- await loginRunP;
334516
+ const earlyAuthRecipe = loginRunP ? await loginRunP : null;
333479
334517
  const earlyClose = await handle.close();
333480
334518
  handle = null;
333481
334519
  discoveryApiCalls = earlyClose.apiCalls;
@@ -333486,6 +334524,11 @@ Feature explore complete: ${exploreResult.pagesDiscovered} pages, ${exploreResul
333486
334524
  collectedPages: exploreResult.collectedPages,
333487
334525
  collectedTransitions: exploreResult.collectedTransitions,
333488
334526
  tests: [],
334527
+ // Persist only a FRESHLY-captured recipe — never re-persist a reused cached one
334528
+ // (ctx.authRecipe set) or a late warm run could overwrite/re-verify a newer recipe.
334529
+ authRecipe: ctx.authRecipe ? void 0 : earlyAuthRecipe,
334530
+ observedOrigins: mergeObservedOrigins(exploreResult.observedOrigins, loginObservedOrigins),
334531
+ resolvedAppOrigin: earlyAuthRecipe?.appOrigin ?? void 0,
333489
334532
  logs: logs2.join("\n"),
333490
334533
  screenshots,
333491
334534
  apiCalls: discoveryApiCalls.length > 0 ? discoveryApiCalls : void 0,
@@ -333626,6 +334669,7 @@ Generation complete: ${generateResult.tests.length} tests (${generateElapsed}s e
333626
334669
  const tags = t.tags.join(", ");
333627
334670
  logs2.push(` ${i + 1}. ${t.name} [${tags}]${t.verified ? " \u2713live" : ""}`);
333628
334671
  });
334672
+ logAuthGenerationStats(logs2, generateResult.tests, authRecipe);
333629
334673
  onLog?.("generate", logs2.join("\n"));
333630
334674
  const postGenClose = await handle.close();
333631
334675
  handle = null;
@@ -348090,7 +349134,7 @@ var require_package4 = __commonJS({
348090
349134
  "package.json"(exports2, module2) {
348091
349135
  module2.exports = {
348092
349136
  name: "@validate.qa/runner",
348093
- version: "1.0.52",
349137
+ version: "1.0.53",
348094
349138
  description: "validate local test runner - execute Playwright tests on your machine, connected to validate.qa cloud.",
348095
349139
  bin: {
348096
349140
  "validate-runner": "dist/cli.js"