@riddledc/riddle-proof 0.7.139 → 0.7.141

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -6998,6 +6998,7 @@ var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
6998
6998
  "wait",
6999
6999
  "wait_for_selector",
7000
7000
  "wait_for_text",
7001
+ "window_eval",
7001
7002
  "window_call",
7002
7003
  "window_call_until"
7003
7004
  ];
@@ -7417,6 +7418,21 @@ function profileSetupWindowCallReceipts(results) {
7417
7418
  return receipt;
7418
7419
  });
7419
7420
  }
7421
+ function profileSetupWindowEvalReceipts(results) {
7422
+ return results.filter((result) => profileSetupResultAction(result) === "window_eval").map((result) => {
7423
+ const receipt = {
7424
+ ordinal: result.ordinal ?? null,
7425
+ ok: result.ok !== false,
7426
+ script_length: result.script_length ?? null,
7427
+ return_captured: result.return_captured ?? null,
7428
+ return_stored_to: result.return_stored_to ?? null,
7429
+ reason: result.reason ?? result.error ?? result.store_reason ?? null
7430
+ };
7431
+ if (result.returned !== void 0) receipt.returned = result.returned;
7432
+ if (result.expected_return !== void 0) receipt.expected_return = result.expected_return;
7433
+ return receipt;
7434
+ });
7435
+ }
7420
7436
  function sampleProfileSetupSummaryItems(items, limit) {
7421
7437
  if (items.length <= limit) return items;
7422
7438
  const firstCount = Math.floor(limit / 2);
@@ -7431,12 +7447,18 @@ function profileScreenshotLabels(viewports) {
7431
7447
  }
7432
7448
  return labels;
7433
7449
  }
7434
- function profileSetupSummary(viewports, actionCount, expectedActionCountByViewport) {
7450
+ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewport, finalScreenshotFullPage) {
7451
+ const normalizedFinalScreenshotFullPage = finalScreenshotFullPage === void 0 ? void 0 : finalScreenshotFullPage !== false;
7452
+ const finalScreenshotCount = viewports.filter((viewport) => typeof viewport.screenshot_label === "string" && viewport.screenshot_label.trim()).length;
7435
7453
  return toJsonValue({
7436
7454
  viewport_count: viewports.length,
7437
7455
  action_count: actionCount ?? null,
7456
+ final_screenshot_count: finalScreenshotCount,
7457
+ final_screenshot_full_page: normalizedFinalScreenshotFullPage ?? null,
7458
+ final_screenshot_mode: normalizedFinalScreenshotFullPage === void 0 ? null : normalizedFinalScreenshotFullPage ? "full_page" : "viewport",
7438
7459
  viewports: viewports.map((viewport) => {
7439
7460
  const expectedActionCount = expectedActionCountByViewport?.get(viewport.name) ?? actionCount;
7461
+ const viewportFinalScreenshotFullPage = typeof viewport.screenshot_full_page === "boolean" ? viewport.screenshot_full_page : normalizedFinalScreenshotFullPage;
7440
7462
  const results = viewport.setup_action_results || [];
7441
7463
  const failed = results.filter((result) => result.ok === false && result.optional !== true);
7442
7464
  const optionalFailed = results.filter((result) => result.ok === false && result.optional === true);
@@ -7449,6 +7471,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
7449
7471
  const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
7450
7472
  const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
7451
7473
  const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
7474
+ const windowEvalReceipts = profileSetupWindowEvalReceipts(results);
7475
+ const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
7476
+ const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
7477
+ const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
7452
7478
  const clickedItems = results.filter((result) => profileSetupResultAction(result) === "click" && result.ok !== false).map((result) => {
7453
7479
  const clickCount = typeof result.click_count === "number" && Number.isFinite(result.click_count) && result.click_count > 1 ? result.click_count : void 0;
7454
7480
  return {
@@ -7476,6 +7502,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
7476
7502
  action_counts: profileSetupActionCounts(results),
7477
7503
  frame_action_count: results.filter((result) => result.frame_selector).length,
7478
7504
  frame_urls: profileSetupFrameUrls(viewport),
7505
+ final_screenshot: viewport.screenshot_label ?? null,
7506
+ final_screenshot_full_page: viewportFinalScreenshotFullPage ?? null,
7479
7507
  setup_screenshots: profileSetupScreenshotLabels(results),
7480
7508
  clicked_total: clickedItems.length,
7481
7509
  clicked_truncated: clickedItems.length > clicked.length,
@@ -7490,6 +7518,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
7490
7518
  window_call_captured_total: windowCallCapturedTotal,
7491
7519
  window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
7492
7520
  window_call: sampledWindowCallReceipts,
7521
+ window_eval_total: windowEvalReceipts.length,
7522
+ window_eval_stored_total: windowEvalStoredTotal,
7523
+ window_eval_captured_total: windowEvalCapturedTotal,
7524
+ window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
7525
+ window_eval: sampledWindowEvalReceipts,
7493
7526
  clicked,
7494
7527
  text_samples,
7495
7528
  failed: failed.map((result) => ({
@@ -7542,7 +7575,7 @@ function isSupportedCheckType(value) {
7542
7575
  }
7543
7576
  function normalizeSetupActionType(value, index) {
7544
7577
  const normalizedInput = String(value || "").trim().replace(/-/g, "_");
7545
- const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput === "reset_console" || normalizedInput === "clear_browser_console" || normalizedInput === "reset_browser_console" ? "clear_console" : normalizedInput === "pointer_drag" || normalizedInput === "mouse_drag" || normalizedInput === "drag_to" ? "drag" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "capture_screenshot" || normalizedInput === "save_screenshot" || normalizedInput === "setup_screenshot" ? "screenshot" : normalizedInput === "accept_dialog" || normalizedInput === "accept_dialogs" || normalizedInput === "confirm_dialog" || normalizedInput === "set_dialog_response" ? "dialog_response" : normalizedInput === "dismiss_dialog" || normalizedInput === "dismiss_dialogs" || normalizedInput === "cancel_dialog" ? "dialog_response" : normalizedInput === "window_call_until" || normalizedInput === "call_until" || normalizedInput === "window_call_repeat_until" || normalizedInput === "repeat_window_call_until" ? "window_call_until" : normalizedInput;
7578
+ const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput === "reset_console" || normalizedInput === "clear_browser_console" || normalizedInput === "reset_browser_console" ? "clear_console" : normalizedInput === "pointer_drag" || normalizedInput === "mouse_drag" || normalizedInput === "drag_to" ? "drag" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "capture_screenshot" || normalizedInput === "save_screenshot" || normalizedInput === "setup_screenshot" ? "screenshot" : normalizedInput === "accept_dialog" || normalizedInput === "accept_dialogs" || normalizedInput === "confirm_dialog" || normalizedInput === "set_dialog_response" ? "dialog_response" : normalizedInput === "dismiss_dialog" || normalizedInput === "dismiss_dialogs" || normalizedInput === "cancel_dialog" ? "dialog_response" : normalizedInput === "window_call_until" || normalizedInput === "call_until" || normalizedInput === "window_call_repeat_until" || normalizedInput === "repeat_window_call_until" ? "window_call_until" : normalizedInput === "window_evaluate" || normalizedInput === "browser_eval" || normalizedInput === "browser_evaluate" || normalizedInput === "evaluate_script" || normalizedInput === "profile_script" ? "window_eval" : normalizedInput;
7546
7579
  if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
7547
7580
  return normalized;
7548
7581
  }
@@ -7560,7 +7593,7 @@ function normalizeSetupActionArgs(input, index) {
7560
7593
  const argsInput = valueFromOwn(input, "args", "arguments", "args_json", "argsJson");
7561
7594
  if (argsInput === void 0) return void 0;
7562
7595
  if (!Array.isArray(argsInput)) {
7563
- throw new Error(`target.setup_actions[${index}] window_call args must be an array.`);
7596
+ throw new Error(`target.setup_actions[${index}] window_call/window_eval args must be an array.`);
7564
7597
  }
7565
7598
  return argsInput.map(toJsonValue);
7566
7599
  }
@@ -7704,7 +7737,11 @@ function normalizeSetupAction(input, index) {
7704
7737
  if ((type === "window_call" || type === "window_call_until" || type === "assert_window_value" || type === "assert_window_number") && !path7) {
7705
7738
  throw new Error(`target.setup_actions[${index}] ${type} requires path.`);
7706
7739
  }
7707
- const args = type === "window_call" || type === "window_call_until" ? normalizeSetupActionArgs(input, index) : void 0;
7740
+ const script = stringFromOwn(input, "script", "code", "source", "body");
7741
+ if (type === "window_eval" && !script) {
7742
+ throw new Error(`target.setup_actions[${index}] window_eval requires script.`);
7743
+ }
7744
+ const args = type === "window_call" || type === "window_call_until" || type === "window_eval" ? normalizeSetupActionArgs(input, index) : void 0;
7708
7745
  const hasExpectedValue = hasOwn(input, "expected_value") || hasOwn(input, "expectedValue") || hasOwn(input, "expected") || hasOwn(input, "expect_value") || hasOwn(input, "expectValue") || hasOwn(input, "expect");
7709
7746
  if (type === "assert_window_value" && !hasExpectedValue) {
7710
7747
  throw new Error(`target.setup_actions[${index}] ${type} requires expected_value.`);
@@ -7775,6 +7812,7 @@ function normalizeSetupAction(input, index) {
7775
7812
  value,
7776
7813
  value_json: hasJsonValue ? toJsonValue(input.value_json ?? input.valueJson ?? input.json) : void 0,
7777
7814
  label: stringFromOwn(input, "label", "name", "screenshot_label", "screenshotLabel"),
7815
+ script,
7778
7816
  path: path7,
7779
7817
  args,
7780
7818
  expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
@@ -9720,7 +9758,7 @@ function assessSetupActionsFromEvidence(profile, evidence) {
9720
9758
  ok: (viewport.setup_action_results || []).length >= (expectedActionCountByViewport.get(viewport.name) ?? actionCount) && (viewport.setup_action_results || []).every((result) => result.ok !== false || result.optional === true),
9721
9759
  result_count: (viewport.setup_action_results || []).length
9722
9760
  })),
9723
- setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountByViewport),
9761
+ setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountByViewport, profile.target.screenshot_full_page),
9724
9762
  failed
9725
9763
  },
9726
9764
  message: failed.length ? `Setup actions failed in ${failed.length} viewport action(s).` : void 0
@@ -10710,6 +10748,23 @@ function profileSetupWindowCallReceipts(results) {
10710
10748
  return receipt;
10711
10749
  });
10712
10750
  }
10751
+ function profileSetupWindowEvalReceipts(results) {
10752
+ return (results || [])
10753
+ .filter((result) => result && profileSetupResultAction(result) === "window_eval")
10754
+ .map((result) => {
10755
+ const receipt = {
10756
+ ordinal: result.ordinal ?? null,
10757
+ ok: result.ok !== false,
10758
+ script_length: result.script_length ?? null,
10759
+ return_captured: result.return_captured ?? null,
10760
+ return_stored_to: result.return_stored_to ?? null,
10761
+ reason: result.reason || result.error || result.store_reason || null,
10762
+ };
10763
+ if (result.returned !== undefined) receipt.returned = result.returned;
10764
+ if (result.expected_return !== undefined) receipt.expected_return = result.expected_return;
10765
+ return receipt;
10766
+ });
10767
+ }
10713
10768
  function sampleProfileSetupSummaryItems(items, limit) {
10714
10769
  if ((items || []).length <= limit) return items || [];
10715
10770
  const firstCount = Math.floor(limit / 2);
@@ -10724,14 +10779,28 @@ function profileScreenshotLabels(viewports) {
10724
10779
  }
10725
10780
  return labels;
10726
10781
  }
10727
- function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport) {
10782
+ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport, finalScreenshotFullPage) {
10783
+ const normalizedFinalScreenshotFullPage = finalScreenshotFullPage === undefined
10784
+ ? undefined
10785
+ : finalScreenshotFullPage !== false;
10786
+ const finalScreenshotCount = (viewports || []).filter((viewport) => viewport && typeof viewport.screenshot_label === "string" && viewport.screenshot_label.trim()).length;
10728
10787
  return {
10729
10788
  viewport_count: (viewports || []).length,
10730
10789
  action_count: actionCount ?? null,
10790
+ final_screenshot_count: finalScreenshotCount,
10791
+ final_screenshot_full_page: normalizedFinalScreenshotFullPage ?? null,
10792
+ final_screenshot_mode: normalizedFinalScreenshotFullPage === undefined
10793
+ ? null
10794
+ : normalizedFinalScreenshotFullPage
10795
+ ? "full_page"
10796
+ : "viewport",
10731
10797
  viewports: (viewports || []).map((viewport) => {
10732
10798
  const expectedActionCount = expectedActionCountsByViewport && expectedActionCountsByViewport[viewport.name] !== undefined
10733
10799
  ? expectedActionCountsByViewport[viewport.name]
10734
10800
  : actionCount;
10801
+ const viewportFinalScreenshotFullPage = typeof viewport.screenshot_full_page === "boolean"
10802
+ ? viewport.screenshot_full_page
10803
+ : normalizedFinalScreenshotFullPage;
10735
10804
  const results = viewport.setup_action_results || [];
10736
10805
  const failed = results.filter((result) => result && result.ok === false && result.optional !== true);
10737
10806
  const optionalFailed = results.filter((result) => result && result.ok === false && result.optional === true);
@@ -10748,6 +10817,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
10748
10817
  const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
10749
10818
  const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
10750
10819
  const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
10820
+ const windowEvalReceipts = profileSetupWindowEvalReceipts(results);
10821
+ const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
10822
+ const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
10823
+ const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
10751
10824
  const clickedItems = results
10752
10825
  .filter((result) => result && profileSetupResultAction(result) === "click" && result.ok !== false)
10753
10826
  .map((result) => {
@@ -10785,6 +10858,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
10785
10858
  action_counts: profileSetupActionCounts(results),
10786
10859
  frame_action_count: results.filter((result) => result && result.frame_selector).length,
10787
10860
  frame_urls: profileSetupFrameUrls(viewport),
10861
+ final_screenshot: viewport.screenshot_label || null,
10862
+ final_screenshot_full_page: viewportFinalScreenshotFullPage ?? null,
10788
10863
  setup_screenshots: profileSetupScreenshotLabels(results),
10789
10864
  clicked_total: clickedItems.length,
10790
10865
  clicked_truncated: clickedItems.length > clicked.length,
@@ -10799,6 +10874,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
10799
10874
  window_call_captured_total: windowCallCapturedTotal,
10800
10875
  window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
10801
10876
  window_call: sampledWindowCallReceipts,
10877
+ window_eval_total: windowEvalReceipts.length,
10878
+ window_eval_stored_total: windowEvalStoredTotal,
10879
+ window_eval_captured_total: windowEvalCapturedTotal,
10880
+ window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
10881
+ window_eval: sampledWindowEvalReceipts,
10802
10882
  clicked,
10803
10883
  text_samples: textSamples,
10804
10884
  failed: failed.map((result) => ({
@@ -10969,7 +11049,7 @@ function assessProfile(profile, evidence) {
10969
11049
  && (viewport.setup_action_results || []).every((result) => !result || result.ok !== false || result.optional === true),
10970
11050
  result_count: (viewport.setup_action_results || []).length,
10971
11051
  })),
10972
- setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport),
11052
+ setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport, profile.target && profile.target.screenshot_full_page),
10973
11053
  failed,
10974
11054
  },
10975
11055
  message: failed.length ? "Setup actions failed in " + failed.length + " viewport action(s)." : undefined,
@@ -11779,6 +11859,49 @@ async function setupCallWindowFunction(context, path, args, storeReturnTo, captu
11779
11859
  }
11780
11860
  }, { path, args, storeReturnTo, captureReturn });
11781
11861
  }
11862
+ async function setupEvaluateWindowScript(context, script, args, storeReturnTo, captureReturn) {
11863
+ return await context.evaluate(async ({ script, args, storeReturnTo, captureReturn }) => {
11864
+ const toJsonValue = (value) => {
11865
+ if (value === null || value === undefined) return null;
11866
+ if (typeof value === "string" || typeof value === "boolean") return value;
11867
+ if (typeof value === "number") return Number.isFinite(value) ? value : null;
11868
+ if (Array.isArray(value)) return value.map(toJsonValue);
11869
+ if (typeof value === "object") {
11870
+ return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, toJsonValue(child)]));
11871
+ }
11872
+ return String(value);
11873
+ };
11874
+ const storeWindowReturn = (storePath, value) => {
11875
+ const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
11876
+ if (pathParts[0] === "window") pathParts.shift();
11877
+ if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
11878
+ let target = window;
11879
+ for (let index = 0; index < pathParts.length - 1; index += 1) {
11880
+ const part = pathParts[index];
11881
+ if (target[part] === null || typeof target[part] !== "object") target[part] = {};
11882
+ target = target[part];
11883
+ }
11884
+ target[pathParts[pathParts.length - 1]] = value;
11885
+ return { ok: true, path: pathParts.join(".") };
11886
+ };
11887
+ const body = String(script || "");
11888
+ if (!body.trim()) return { ok: false, reason: "missing_script" };
11889
+ try {
11890
+ const run = new Function("args", "\"use strict\"; return (async () => {\\n" + body + "\\n})();");
11891
+ const returned = await run(Array.isArray(args) ? args : []);
11892
+ const jsonReturned = toJsonValue(returned);
11893
+ const returnedForResult = captureReturn === false ? undefined : jsonReturned;
11894
+ if (storeReturnTo) {
11895
+ const stored = storeWindowReturn(storeReturnTo, jsonReturned);
11896
+ if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
11897
+ return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
11898
+ }
11899
+ return { ok: true, returned: returnedForResult };
11900
+ } catch (error) {
11901
+ return { ok: false, reason: "script_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
11902
+ }
11903
+ }, { script, args, storeReturnTo, captureReturn });
11904
+ }
11782
11905
  function setupFrameSelector(action) {
11783
11906
  return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
11784
11907
  }
@@ -12292,6 +12415,44 @@ async function executeSetupAction(action, ordinal, viewport) {
12292
12415
  }
12293
12416
  return { ...base, ...setupScopeEvidence(scope), ok: true, storage, reload: action.reload === true };
12294
12417
  }
12418
+ if (type === "window_eval") {
12419
+ const script = String(action.script || action.code || action.source || action.body || "");
12420
+ const args = Array.isArray(action.args) ? action.args : [];
12421
+ const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
12422
+ if (!script.trim()) return { ...base, reason: "missing_script" };
12423
+ const scope = await setupActionScope(action, timeout);
12424
+ if (!scope.ok) return setupScopeFailure(base, scope);
12425
+ const hasExpectation = setupHasOwn(action, "expect_return")
12426
+ || setupHasOwn(action, "expectReturn")
12427
+ || setupHasOwn(action, "expected_return")
12428
+ || setupHasOwn(action, "expectedReturn");
12429
+ const expected = setupHasOwn(action, "expect_return")
12430
+ ? action.expect_return
12431
+ : setupHasOwn(action, "expectReturn")
12432
+ ? action.expectReturn
12433
+ : setupHasOwn(action, "expected_return")
12434
+ ? action.expected_return
12435
+ : action.expectedReturn;
12436
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
12437
+ ? hasExpectation
12438
+ : true;
12439
+ const result = await setupEvaluateWindowScript(scope.context, script, args, storeReturnTo, captureReturn);
12440
+ const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
12441
+ return {
12442
+ ...base,
12443
+ ...setupScopeEvidence(scope),
12444
+ ok: Boolean(result.ok && expectationMet),
12445
+ script_length: script.length,
12446
+ arg_count: args.length,
12447
+ returned: captureReturn ? setupJsonValue(result.returned) : undefined,
12448
+ return_captured: captureReturn,
12449
+ expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
12450
+ return_stored_to: result.return_stored_to || storeReturnTo || undefined,
12451
+ reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
12452
+ store_reason: result.store_reason || undefined,
12453
+ error: result.error || undefined,
12454
+ };
12455
+ }
12295
12456
  if (type === "window_call") {
12296
12457
  const path = String(action.path || action.function_path || action.functionPath || "");
12297
12458
  const args = Array.isArray(action.args) ? action.args : [];
@@ -13847,9 +14008,13 @@ async function captureViewport(viewport) {
13847
14008
  }
13848
14009
  }
13849
14010
  const screenshotLabel = profileSlug + "-" + viewport.name;
14011
+ let screenshotFullPage = null;
13850
14012
  try {
13851
14013
  const screenshotOptions = {};
13852
- if (profile.target && profile.target.screenshot_full_page !== undefined) screenshotOptions.fullPage = profile.target.screenshot_full_page !== false;
14014
+ if (profile.target && profile.target.screenshot_full_page !== undefined) {
14015
+ screenshotFullPage = profile.target.screenshot_full_page !== false;
14016
+ screenshotOptions.fullPage = screenshotFullPage;
14017
+ }
13853
14018
  if (typeof saveScreenshot === "function") await saveScreenshot(screenshotLabel, screenshotOptions);
13854
14019
  } catch (error) {
13855
14020
  pageErrors.push({ message: "saveScreenshot failed: " + String(error && error.message ? error.message : error).slice(0, 500) });
@@ -13917,6 +14082,7 @@ async function captureViewport(viewport) {
13917
14082
  route_inventory: routeInventory,
13918
14083
  setup_action_results: setupActionResults,
13919
14084
  screenshot_label: screenshotLabel,
14085
+ screenshot_full_page: screenshotFullPage,
13920
14086
  navigation_error: navigationError,
13921
14087
  wait_error: waitError,
13922
14088
  };
@@ -14673,6 +14839,8 @@ function profileSetupSummaryMarkdown(result) {
14673
14839
  if (!viewports.length) return [];
14674
14840
  const declaredActions = cliFiniteNumber(setupSummary.action_count);
14675
14841
  const totalResults = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.result_count) || 0), 0);
14842
+ const finalScreenshotCount = cliFiniteNumber(setupSummary.final_screenshot_count) ?? viewports.reduce((sum, viewport) => sum + (cliString(viewport.final_screenshot) || cliString(viewport.screenshot_label) ? 1 : 0), 0);
14843
+ const finalScreenshotMode = cliString(setupSummary.final_screenshot_mode);
14676
14844
  const setupScreenshots = viewports.reduce((sum, viewport) => {
14677
14845
  const labels = Array.isArray(viewport.setup_screenshots) ? viewport.setup_screenshots : [];
14678
14846
  return sum + labels.filter((label) => typeof label === "string" && label.trim()).length;
@@ -14683,11 +14851,15 @@ function profileSetupSummaryMarkdown(result) {
14683
14851
  const windowCallTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_total) || 0), 0);
14684
14852
  const windowCallStoredTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_stored_total) || 0), 0);
14685
14853
  const windowCallCapturedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_captured_total) || 0), 0);
14854
+ const windowEvalTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_total) || 0), 0);
14855
+ const windowEvalStoredTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_stored_total) || 0), 0);
14856
+ const windowEvalCapturedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_captured_total) || 0), 0);
14686
14857
  const windowCallUntilTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_total) || 0), 0);
14687
14858
  const windowCallUntilCallTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_call_total) || 0), 0);
14688
14859
  const failedTotal = viewports.reduce((sum, viewport) => sum + (Array.isArray(viewport.failed) ? viewport.failed.length : 0), 0);
14689
14860
  const lines = [
14690
14861
  `- setup actions: ${declaredActions === void 0 ? "unknown" : declaredActions} declared, ${totalResults} recorded result(s) across ${viewports.length} viewport(s)`,
14862
+ ...finalScreenshotMode ? [`- final screenshots: ${finalScreenshotCount}, mode ${finalScreenshotMode}`] : [],
14691
14863
  `- setup screenshots: ${setupScreenshots}`,
14692
14864
  `- clicked targets: ${clickedTotal}${failedTotal ? `; failed setup actions: ${failedTotal}` : ""}`
14693
14865
  ];
@@ -14697,6 +14869,9 @@ function profileSetupSummaryMarkdown(result) {
14697
14869
  if (windowCallTotal) {
14698
14870
  lines.push(`- window_call: ${windowCallTotal} action(s), stored returns ${windowCallStoredTotal}, captured returns ${windowCallCapturedTotal}`);
14699
14871
  }
14872
+ if (windowEvalTotal) {
14873
+ lines.push(`- window_eval: ${windowEvalTotal} action(s), stored returns ${windowEvalStoredTotal}, captured returns ${windowEvalCapturedTotal}`);
14874
+ }
14700
14875
  if (windowCallUntilTotal) {
14701
14876
  lines.push(`- window_call_until: ${windowCallUntilTotal} action(s), call_count total ${windowCallUntilCallTotal}`);
14702
14877
  }
@@ -14710,10 +14885,13 @@ function profileSetupSummaryMarkdown(result) {
14710
14885
  const windowCallActions = cliFiniteNumber(viewport.window_call_total) || 0;
14711
14886
  const windowCallStored = cliFiniteNumber(viewport.window_call_stored_total) || 0;
14712
14887
  const windowCallCaptured = cliFiniteNumber(viewport.window_call_captured_total) || 0;
14888
+ const windowEvalActions = cliFiniteNumber(viewport.window_eval_total) || 0;
14889
+ const windowEvalStored = cliFiniteNumber(viewport.window_eval_stored_total) || 0;
14890
+ const windowEvalCaptured = cliFiniteNumber(viewport.window_eval_captured_total) || 0;
14713
14891
  const windowCallUntilActions = cliFiniteNumber(viewport.window_call_until_total) || 0;
14714
14892
  const windowCallUntilCalls = cliFiniteNumber(viewport.window_call_until_call_total) || 0;
14715
14893
  const observedPath = cliString(viewport.observed_path);
14716
- lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
14894
+ lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowEvalActions ? `, ${windowEvalActions} window_eval action(s), ${windowEvalStored} stored return(s), ${windowEvalCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
14717
14895
  }
14718
14896
  const windowCallDetails = viewports.flatMap((viewport) => {
14719
14897
  const name = cliString(viewport.name) || "viewport";
@@ -14731,6 +14909,22 @@ function profileSetupSummaryMarkdown(result) {
14731
14909
  lines.push(`- ${name} window_call: ${ok}, ${markdownInlineCode(path7)}${storedTo ? `, stored ${markdownInlineCode(storedTo)}` : ""}, return ${captured}${expected === void 0 ? "" : `, expected ${markdownInlineCode(expected, 80)}`}${returned === void 0 ? "" : `, returned ${markdownInlineCode(returned, 80)}`}${reason ? `, reason ${markdownInlineCode(reason, 100)}` : ""}`);
14732
14910
  }
14733
14911
  if (windowCallDetails.length > 12) lines.push(`- ${windowCallDetails.length - 12} additional window_call receipt(s) omitted.`);
14912
+ const windowEvalDetails = viewports.flatMap((viewport) => {
14913
+ const name = cliString(viewport.name) || "viewport";
14914
+ const receipts = Array.isArray(viewport.window_eval) ? viewport.window_eval.map(cliRecord).filter((item) => Boolean(item)) : [];
14915
+ return receipts.map((receipt) => ({ name, receipt }));
14916
+ });
14917
+ for (const { name, receipt } of windowEvalDetails.slice(0, 12)) {
14918
+ const scriptLength = cliFiniteNumber(receipt.script_length);
14919
+ const storedTo = cliString(receipt.return_stored_to);
14920
+ const returned = cliValueLabel(receipt.returned);
14921
+ const expected = cliValueLabel(receipt.expected_return);
14922
+ const captured = receipt.return_captured === true ? "captured" : receipt.return_captured === false ? "not captured" : "capture unknown";
14923
+ const ok = receipt.ok === false ? "failed" : "ok";
14924
+ const reason = cliString(receipt.reason);
14925
+ lines.push(`- ${name} window_eval: ${ok}${scriptLength === void 0 ? "" : `, script ${scriptLength} chars`}${storedTo ? `, stored ${markdownInlineCode(storedTo)}` : ""}, return ${captured}${expected === void 0 ? "" : `, expected ${markdownInlineCode(expected, 80)}`}${returned === void 0 ? "" : `, returned ${markdownInlineCode(returned, 80)}`}${reason ? `, reason ${markdownInlineCode(reason, 100)}` : ""}`);
14926
+ }
14927
+ if (windowEvalDetails.length > 12) lines.push(`- ${windowEvalDetails.length - 12} additional window_eval receipt(s) omitted.`);
14734
14928
  const windowCallUntilDetails = viewports.flatMap((viewport) => {
14735
14929
  const name = cliString(viewport.name) || "viewport";
14736
14930
  const receipts = Array.isArray(viewport.window_call_until) ? viewport.window_call_until.map(cliRecord).filter((item) => Boolean(item)) : [];
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  profileStatusExitCode,
13
13
  resolveRiddleProofProfileTargetUrl,
14
14
  resolveRiddleProofProfileTimeoutSec
15
- } from "./chunk-DB6J53V5.js";
15
+ } from "./chunk-F46O7DP2.js";
16
16
  import {
17
17
  createRiddleApiClient,
18
18
  parseRiddleViewport
@@ -589,6 +589,8 @@ function profileSetupSummaryMarkdown(result) {
589
589
  if (!viewports.length) return [];
590
590
  const declaredActions = cliFiniteNumber(setupSummary.action_count);
591
591
  const totalResults = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.result_count) || 0), 0);
592
+ const finalScreenshotCount = cliFiniteNumber(setupSummary.final_screenshot_count) ?? viewports.reduce((sum, viewport) => sum + (cliString(viewport.final_screenshot) || cliString(viewport.screenshot_label) ? 1 : 0), 0);
593
+ const finalScreenshotMode = cliString(setupSummary.final_screenshot_mode);
592
594
  const setupScreenshots = viewports.reduce((sum, viewport) => {
593
595
  const labels = Array.isArray(viewport.setup_screenshots) ? viewport.setup_screenshots : [];
594
596
  return sum + labels.filter((label) => typeof label === "string" && label.trim()).length;
@@ -599,11 +601,15 @@ function profileSetupSummaryMarkdown(result) {
599
601
  const windowCallTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_total) || 0), 0);
600
602
  const windowCallStoredTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_stored_total) || 0), 0);
601
603
  const windowCallCapturedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_captured_total) || 0), 0);
604
+ const windowEvalTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_total) || 0), 0);
605
+ const windowEvalStoredTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_stored_total) || 0), 0);
606
+ const windowEvalCapturedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_captured_total) || 0), 0);
602
607
  const windowCallUntilTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_total) || 0), 0);
603
608
  const windowCallUntilCallTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_call_total) || 0), 0);
604
609
  const failedTotal = viewports.reduce((sum, viewport) => sum + (Array.isArray(viewport.failed) ? viewport.failed.length : 0), 0);
605
610
  const lines = [
606
611
  `- setup actions: ${declaredActions === void 0 ? "unknown" : declaredActions} declared, ${totalResults} recorded result(s) across ${viewports.length} viewport(s)`,
612
+ ...finalScreenshotMode ? [`- final screenshots: ${finalScreenshotCount}, mode ${finalScreenshotMode}`] : [],
607
613
  `- setup screenshots: ${setupScreenshots}`,
608
614
  `- clicked targets: ${clickedTotal}${failedTotal ? `; failed setup actions: ${failedTotal}` : ""}`
609
615
  ];
@@ -613,6 +619,9 @@ function profileSetupSummaryMarkdown(result) {
613
619
  if (windowCallTotal) {
614
620
  lines.push(`- window_call: ${windowCallTotal} action(s), stored returns ${windowCallStoredTotal}, captured returns ${windowCallCapturedTotal}`);
615
621
  }
622
+ if (windowEvalTotal) {
623
+ lines.push(`- window_eval: ${windowEvalTotal} action(s), stored returns ${windowEvalStoredTotal}, captured returns ${windowEvalCapturedTotal}`);
624
+ }
616
625
  if (windowCallUntilTotal) {
617
626
  lines.push(`- window_call_until: ${windowCallUntilTotal} action(s), call_count total ${windowCallUntilCallTotal}`);
618
627
  }
@@ -626,10 +635,13 @@ function profileSetupSummaryMarkdown(result) {
626
635
  const windowCallActions = cliFiniteNumber(viewport.window_call_total) || 0;
627
636
  const windowCallStored = cliFiniteNumber(viewport.window_call_stored_total) || 0;
628
637
  const windowCallCaptured = cliFiniteNumber(viewport.window_call_captured_total) || 0;
638
+ const windowEvalActions = cliFiniteNumber(viewport.window_eval_total) || 0;
639
+ const windowEvalStored = cliFiniteNumber(viewport.window_eval_stored_total) || 0;
640
+ const windowEvalCaptured = cliFiniteNumber(viewport.window_eval_captured_total) || 0;
629
641
  const windowCallUntilActions = cliFiniteNumber(viewport.window_call_until_total) || 0;
630
642
  const windowCallUntilCalls = cliFiniteNumber(viewport.window_call_until_call_total) || 0;
631
643
  const observedPath = cliString(viewport.observed_path);
632
- lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
644
+ lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowEvalActions ? `, ${windowEvalActions} window_eval action(s), ${windowEvalStored} stored return(s), ${windowEvalCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
633
645
  }
634
646
  const windowCallDetails = viewports.flatMap((viewport) => {
635
647
  const name = cliString(viewport.name) || "viewport";
@@ -647,6 +659,22 @@ function profileSetupSummaryMarkdown(result) {
647
659
  lines.push(`- ${name} window_call: ${ok}, ${markdownInlineCode(path2)}${storedTo ? `, stored ${markdownInlineCode(storedTo)}` : ""}, return ${captured}${expected === void 0 ? "" : `, expected ${markdownInlineCode(expected, 80)}`}${returned === void 0 ? "" : `, returned ${markdownInlineCode(returned, 80)}`}${reason ? `, reason ${markdownInlineCode(reason, 100)}` : ""}`);
648
660
  }
649
661
  if (windowCallDetails.length > 12) lines.push(`- ${windowCallDetails.length - 12} additional window_call receipt(s) omitted.`);
662
+ const windowEvalDetails = viewports.flatMap((viewport) => {
663
+ const name = cliString(viewport.name) || "viewport";
664
+ const receipts = Array.isArray(viewport.window_eval) ? viewport.window_eval.map(cliRecord).filter((item) => Boolean(item)) : [];
665
+ return receipts.map((receipt) => ({ name, receipt }));
666
+ });
667
+ for (const { name, receipt } of windowEvalDetails.slice(0, 12)) {
668
+ const scriptLength = cliFiniteNumber(receipt.script_length);
669
+ const storedTo = cliString(receipt.return_stored_to);
670
+ const returned = cliValueLabel(receipt.returned);
671
+ const expected = cliValueLabel(receipt.expected_return);
672
+ const captured = receipt.return_captured === true ? "captured" : receipt.return_captured === false ? "not captured" : "capture unknown";
673
+ const ok = receipt.ok === false ? "failed" : "ok";
674
+ const reason = cliString(receipt.reason);
675
+ lines.push(`- ${name} window_eval: ${ok}${scriptLength === void 0 ? "" : `, script ${scriptLength} chars`}${storedTo ? `, stored ${markdownInlineCode(storedTo)}` : ""}, return ${captured}${expected === void 0 ? "" : `, expected ${markdownInlineCode(expected, 80)}`}${returned === void 0 ? "" : `, returned ${markdownInlineCode(returned, 80)}`}${reason ? `, reason ${markdownInlineCode(reason, 100)}` : ""}`);
676
+ }
677
+ if (windowEvalDetails.length > 12) lines.push(`- ${windowEvalDetails.length - 12} additional window_eval receipt(s) omitted.`);
650
678
  const windowCallUntilDetails = viewports.flatMap((viewport) => {
651
679
  const name = cliString(viewport.name) || "viewport";
652
680
  const receipts = Array.isArray(viewport.window_call_until) ? viewport.window_call_until.map(cliRecord).filter((item) => Boolean(item)) : [];