@riddledc/riddle-proof 0.7.197 → 0.7.199

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -8778,6 +8778,7 @@ var RIDDLE_PROOF_PROFILE_CHECK_TYPES = [
8778
8778
  var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
8779
8779
  "click",
8780
8780
  "tap",
8781
+ "tap_until",
8781
8782
  "drag",
8782
8783
  "press",
8783
8784
  "key_down",
@@ -9348,6 +9349,30 @@ function profileSetupTapReceipts(results) {
9348
9349
  reason: result.reason ?? result.error ?? null
9349
9350
  }));
9350
9351
  }
9352
+ function profileSetupTapUntilReceipts(results) {
9353
+ return results.filter((result) => profileSetupResultAction(result) === "tap_until").map((result) => ({
9354
+ ordinal: result.ordinal ?? null,
9355
+ ok: result.ok !== false,
9356
+ selector: result.selector ?? null,
9357
+ frame_selector: result.frame_selector ?? null,
9358
+ pointer_type: result.pointer_type ?? null,
9359
+ input_dispatch: result.input_dispatch ?? null,
9360
+ coordinate_mode: result.coordinate_mode ?? null,
9361
+ x: result.x ?? null,
9362
+ y: result.y ?? null,
9363
+ duration_ms: result.duration_ms ?? null,
9364
+ until_path: result.until_path ?? null,
9365
+ until_value: result.until_value ?? null,
9366
+ until_expected_value: result.until_expected_value ?? null,
9367
+ tap_count: result.tap_count ?? null,
9368
+ max_taps: result.max_taps ?? result.max_calls ?? null,
9369
+ tap_burst_size: result.tap_burst_size ?? null,
9370
+ condition_check_count: result.condition_check_count ?? null,
9371
+ interval_ms: result.interval_ms ?? null,
9372
+ timeout_ms: result.timeout_ms ?? null,
9373
+ reason: result.reason ?? result.error ?? null
9374
+ }));
9375
+ }
9351
9376
  function profileSetupKeyboardReceipts(results) {
9352
9377
  return results.filter((result) => ["press", "key_down", "key_up"].includes(profileSetupResultAction(result))).map((result) => ({
9353
9378
  action: profileSetupResultAction(result),
@@ -9523,6 +9548,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
9523
9548
  const sampledDragReceipts = sampleProfileSetupSummaryItems(dragReceipts, 8);
9524
9549
  const tapReceipts = profileSetupTapReceipts(results);
9525
9550
  const sampledTapReceipts = sampleProfileSetupSummaryItems(tapReceipts, 8);
9551
+ const tapUntilReceipts = profileSetupTapUntilReceipts(results);
9552
+ const tapUntilTapCounts = tapUntilReceipts.map((result) => typeof result.tap_count === "number" && Number.isFinite(result.tap_count) ? result.tap_count : void 0).filter((value) => value !== void 0);
9553
+ const sampledTapUntilReceipts = sampleProfileSetupSummaryItems(tapUntilReceipts, 8);
9526
9554
  const keyboardReceipts = profileSetupKeyboardReceipts(results);
9527
9555
  const sampledKeyboardReceipts = sampleProfileSetupSummaryItems(keyboardReceipts, 8);
9528
9556
  const canvasSignatureReceipts = profileSetupCanvasSignatureReceipts(results);
@@ -9595,6 +9623,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
9595
9623
  tap_total: tapReceipts.length,
9596
9624
  tap_truncated: tapReceipts.length > sampledTapReceipts.length,
9597
9625
  tap: sampledTapReceipts,
9626
+ tap_until_total: tapUntilReceipts.length,
9627
+ tap_until_tap_total: tapUntilTapCounts.reduce((sum, value) => sum + value, 0),
9628
+ tap_until_truncated: tapUntilReceipts.length > sampledTapUntilReceipts.length,
9629
+ tap_until: sampledTapUntilReceipts,
9598
9630
  keyboard_total: keyboardReceipts.length,
9599
9631
  keyboard_truncated: keyboardReceipts.length > sampledKeyboardReceipts.length,
9600
9632
  keyboard: sampledKeyboardReceipts,
@@ -9656,7 +9688,7 @@ function isSupportedCheckType(value) {
9656
9688
  }
9657
9689
  function normalizeSetupActionType(value, index) {
9658
9690
  const normalizedInput = String(value || "").trim().replace(/-/g, "_");
9659
- 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 === "pointer_tap" || normalizedInput === "touch_tap" || normalizedInput === "canvas_tap" ? "tap" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "keyboard_down" || normalizedInput === "key_down" || normalizedInput === "keydown" || normalizedInput === "press_down" ? "key_down" : normalizedInput === "keyboard_up" || normalizedInput === "key_up" || normalizedInput === "keyup" || normalizedInput === "press_up" || normalizedInput === "release_key" || normalizedInput === "key_release" ? "key_up" : normalizedInput === "set_slider_value" || normalizedInput === "slider_value" || normalizedInput === "set_slider" || normalizedInput === "set_range" || normalizedInput === "range_value" || normalizedInput === "range_input" || normalizedInput === "set_range_input" ? "set_range_value" : normalizedInput === "deterministic_runtime" || normalizedInput === "mock_runtime" || normalizedInput === "mock_random" || normalizedInput === "mock_random_queue" || normalizedInput === "seed_random_queue" || normalizedInput === "set_random_queue" || normalizedInput === "mock_clock" || normalizedInput === "set_mock_clock" || normalizedInput === "set_runtime_determinism" || normalizedInput === "runtime_determinism" ? "deterministic_runtime" : normalizedInput === "canvas_hash" || normalizedInput === "capture_canvas_hash" || normalizedInput === "capture_canvas_signature" || normalizedInput === "canvas_state_signature" ? "canvas_signature" : 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;
9691
+ 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 === "pointer_tap" || normalizedInput === "touch_tap" || normalizedInput === "canvas_tap" ? "tap" : normalizedInput === "tap_until" || normalizedInput === "pointer_tap_until" || normalizedInput === "touch_tap_until" || normalizedInput === "canvas_tap_until" || normalizedInput === "tap_repeat_until" || normalizedInput === "repeat_tap_until" ? "tap_until" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "keyboard_down" || normalizedInput === "key_down" || normalizedInput === "keydown" || normalizedInput === "press_down" ? "key_down" : normalizedInput === "keyboard_up" || normalizedInput === "key_up" || normalizedInput === "keyup" || normalizedInput === "press_up" || normalizedInput === "release_key" || normalizedInput === "key_release" ? "key_up" : normalizedInput === "set_slider_value" || normalizedInput === "slider_value" || normalizedInput === "set_slider" || normalizedInput === "set_range" || normalizedInput === "range_value" || normalizedInput === "range_input" || normalizedInput === "set_range_input" ? "set_range_value" : normalizedInput === "deterministic_runtime" || normalizedInput === "mock_runtime" || normalizedInput === "mock_random" || normalizedInput === "mock_random_queue" || normalizedInput === "seed_random_queue" || normalizedInput === "set_random_queue" || normalizedInput === "mock_clock" || normalizedInput === "set_mock_clock" || normalizedInput === "set_runtime_determinism" || normalizedInput === "runtime_determinism" ? "deterministic_runtime" : normalizedInput === "canvas_hash" || normalizedInput === "capture_canvas_hash" || normalizedInput === "capture_canvas_signature" || normalizedInput === "canvas_state_signature" ? "canvas_signature" : 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;
9660
9692
  if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
9661
9693
  return normalized;
9662
9694
  }
@@ -9738,8 +9770,8 @@ function normalizeSetupActionCoordinateMode(value, index) {
9738
9770
  }
9739
9771
  function normalizeSetupActionPointerType(value, type, index) {
9740
9772
  if (value === void 0 || value === null || value === "") return void 0;
9741
- if (type !== "drag" && type !== "tap") {
9742
- throw new Error(`target.setup_actions[${index}].pointer_type is only supported for drag/tap actions.`);
9773
+ if (type !== "drag" && type !== "tap" && type !== "tap_until") {
9774
+ throw new Error(`target.setup_actions[${index}].pointer_type is only supported for drag/tap/tap_until actions.`);
9743
9775
  }
9744
9776
  const normalized = String(value).trim().replace(/-/g, "_").toLowerCase();
9745
9777
  if (normalized === "mouse") return "mouse";
@@ -9818,11 +9850,11 @@ function normalizeSetupAction(input, index) {
9818
9850
  if (frameIndex !== void 0 && (!Number.isInteger(frameIndex) || frameIndex < 0)) {
9819
9851
  throw new Error(`target.setup_actions[${index}].frame_index must be a non-negative integer.`);
9820
9852
  }
9821
- if ((type === "click" || type === "tap" || type === "drag" || type === "fill" || type === "set_input_value" || type === "set_range_value" || type === "canvas_signature" || type === "wait_for_selector" || type === "wait_for_text" || type === "assert_text_visible" || type === "assert_text_absent" || type === "assert_selector_count") && !selector) {
9853
+ if ((type === "click" || type === "tap" || type === "tap_until" || type === "drag" || type === "fill" || type === "set_input_value" || type === "set_range_value" || type === "canvas_signature" || type === "wait_for_selector" || type === "wait_for_text" || type === "assert_text_visible" || type === "assert_text_absent" || type === "assert_selector_count") && !selector) {
9822
9854
  throw new Error(`target.setup_actions[${index}] ${type} requires selector.`);
9823
9855
  }
9824
- const fromX = type === "click" || type === "tap" ? numberValue3(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue3(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
9825
- const fromY = type === "click" || type === "tap" ? numberValue3(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue3(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
9856
+ const fromX = type === "click" || type === "tap" || type === "tap_until" ? numberValue3(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue3(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
9857
+ const fromY = type === "click" || type === "tap" || type === "tap_until" ? numberValue3(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue3(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
9826
9858
  const toX = numberValue3(valueFromOwn(input, "to_x", "toX", "end_x", "endX", "x2"));
9827
9859
  const toY = numberValue3(valueFromOwn(input, "to_y", "toY", "end_y", "endY", "y2"));
9828
9860
  const coordinateMode = normalizeSetupActionCoordinateMode(valueFromOwn(input, "coordinate_mode", "coordinateMode", "coords", "units"), index);
@@ -9847,18 +9879,18 @@ function normalizeSetupAction(input, index) {
9847
9879
  }
9848
9880
  }
9849
9881
  }
9850
- if (type === "tap") {
9882
+ if (type === "tap" || type === "tap_until") {
9851
9883
  const hasTapCoordinate = fromX !== void 0 || fromY !== void 0;
9852
9884
  if (hasTapCoordinate && (fromX === void 0 || fromY === void 0)) {
9853
- throw new Error(`target.setup_actions[${index}] tap coordinates require both x and y.`);
9885
+ throw new Error(`target.setup_actions[${index}] ${type} coordinates require both x and y.`);
9854
9886
  }
9855
9887
  if (hasTapCoordinate && fromX !== void 0 && fromY !== void 0) {
9856
9888
  const tapCoordinates = [fromX, fromY];
9857
9889
  if (coordinateMode === "ratio" && tapCoordinates.some((value2) => value2 < 0 || value2 > 1)) {
9858
- throw new Error(`target.setup_actions[${index}] tap ratio coordinates must be between 0 and 1.`);
9890
+ throw new Error(`target.setup_actions[${index}] ${type} ratio coordinates must be between 0 and 1.`);
9859
9891
  }
9860
9892
  if ((coordinateMode === void 0 || coordinateMode === "pixels") && tapCoordinates.some((value2) => value2 < 0)) {
9861
- throw new Error(`target.setup_actions[${index}] tap pixel coordinates must be non-negative.`);
9893
+ throw new Error(`target.setup_actions[${index}] ${type} pixel coordinates must be non-negative.`);
9862
9894
  }
9863
9895
  }
9864
9896
  }
@@ -9964,7 +9996,7 @@ function normalizeSetupAction(input, index) {
9964
9996
  const captureReturn = input.capture_return === false || input.captureReturn === false || input.include_return === false || input.includeReturn === false || input.omit_return === true || input.omitReturn === true ? false : void 0;
9965
9997
  const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
9966
9998
  const hasUntilExpectedValue = hasOwn(input, "until_expected_value") || hasOwn(input, "untilExpectedValue") || hasOwn(input, "until_expected") || hasOwn(input, "untilExpected") || hasOwn(input, "until_value") || hasOwn(input, "untilValue") || hasOwn(input, "expected_value") || hasOwn(input, "expectedValue") || hasOwn(input, "expected");
9967
- if (type === "window_call_until") {
9999
+ if (type === "window_call_until" || type === "tap_until") {
9968
10000
  if (!untilPath) {
9969
10001
  throw new Error(`target.setup_actions[${index}] ${type} requires until_path.`);
9970
10002
  }
@@ -9972,12 +10004,16 @@ function normalizeSetupAction(input, index) {
9972
10004
  throw new Error(`target.setup_actions[${index}] ${type} requires until_expected_value.`);
9973
10005
  }
9974
10006
  }
9975
- const maxCalls = numberValue3(valueFromOwn(input, "max_calls", "maxCalls", "max_attempts", "maxAttempts", "attempts"));
9976
- if (type === "window_call_until" && (maxCalls === void 0 || !Number.isInteger(maxCalls) || maxCalls < 1 || maxCalls > 100)) {
10007
+ const maxCalls = numberValue3(valueFromOwn(input, "max_calls", "maxCalls", "max_attempts", "maxAttempts", "attempts", "max_taps", "maxTaps", "tap_limit", "tapLimit"));
10008
+ if ((type === "window_call_until" || type === "tap_until") && (maxCalls === void 0 || !Number.isInteger(maxCalls) || maxCalls < 1 || maxCalls > 100)) {
9977
10009
  throw new Error(`target.setup_actions[${index}].max_calls must be an integer from 1 to 100.`);
9978
10010
  }
10011
+ const tapBurstSize = type === "tap_until" ? numberValue3(valueFromOwn(input, "tap_burst_size", "tapBurstSize", "burst_size", "burstSize", "check_every_taps", "checkEveryTaps", "predicate_interval_taps", "predicateIntervalTaps")) : void 0;
10012
+ if (type === "tap_until" && tapBurstSize !== void 0 && (!Number.isInteger(tapBurstSize) || tapBurstSize < 1 || tapBurstSize > 100)) {
10013
+ throw new Error(`target.setup_actions[${index}].tap_burst_size must be an integer from 1 to 100.`);
10014
+ }
9979
10015
  const intervalMs = numberValue3(valueFromOwn(input, "interval_ms", "intervalMs", "poll_ms", "pollMs", "call_interval_ms", "callIntervalMs"));
9980
- if (type === "window_call_until" && intervalMs !== void 0 && (!Number.isInteger(intervalMs) || intervalMs < 0 || intervalMs > 5e3)) {
10016
+ if ((type === "window_call_until" || type === "tap_until") && intervalMs !== void 0 && (!Number.isInteger(intervalMs) || intervalMs < 0 || intervalMs > 5e3)) {
9981
10017
  throw new Error(`target.setup_actions[${index}].interval_ms must be an integer from 0 to 5000.`);
9982
10018
  }
9983
10019
  const steps = numberValue3(input.steps);
@@ -10023,6 +10059,7 @@ function normalizeSetupAction(input, index) {
10023
10059
  until_path: untilPath,
10024
10060
  until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
10025
10061
  max_calls: maxCalls,
10062
+ tap_burst_size: tapBurstSize,
10026
10063
  interval_ms: intervalMs,
10027
10064
  expected_value: hasExpectedValue ? toJsonValue(rawExpectedValue) : void 0,
10028
10065
  min_value: minValue,
@@ -13243,6 +13280,32 @@ function profileSetupTapReceipts(results) {
13243
13280
  reason: result.reason || result.error || null,
13244
13281
  }));
13245
13282
  }
13283
+ function profileSetupTapUntilReceipts(results) {
13284
+ return (results || [])
13285
+ .filter((result) => result && profileSetupResultAction(result) === "tap_until")
13286
+ .map((result) => ({
13287
+ ordinal: result.ordinal ?? null,
13288
+ ok: result.ok !== false,
13289
+ selector: result.selector ?? null,
13290
+ frame_selector: result.frame_selector ?? null,
13291
+ pointer_type: result.pointer_type ?? null,
13292
+ input_dispatch: result.input_dispatch ?? null,
13293
+ coordinate_mode: result.coordinate_mode ?? null,
13294
+ x: result.x ?? null,
13295
+ y: result.y ?? null,
13296
+ duration_ms: result.duration_ms ?? null,
13297
+ until_path: result.until_path ?? null,
13298
+ until_value: result.until_value ?? null,
13299
+ until_expected_value: result.until_expected_value ?? null,
13300
+ tap_count: result.tap_count ?? null,
13301
+ max_taps: result.max_taps ?? result.max_calls ?? null,
13302
+ tap_burst_size: result.tap_burst_size ?? null,
13303
+ condition_check_count: result.condition_check_count ?? null,
13304
+ interval_ms: result.interval_ms ?? null,
13305
+ timeout_ms: result.timeout_ms ?? null,
13306
+ reason: result.reason || result.error || null,
13307
+ }));
13308
+ }
13246
13309
  function profileSetupKeyboardReceipts(results) {
13247
13310
  return (results || [])
13248
13311
  .filter((result) => result && ["press", "key_down", "key_up"].includes(profileSetupResultAction(result)))
@@ -13445,6 +13508,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
13445
13508
  const sampledDragReceipts = sampleProfileSetupSummaryItems(dragReceipts, 8);
13446
13509
  const tapReceipts = profileSetupTapReceipts(results);
13447
13510
  const sampledTapReceipts = sampleProfileSetupSummaryItems(tapReceipts, 8);
13511
+ const tapUntilReceipts = profileSetupTapUntilReceipts(results);
13512
+ const tapUntilTapCounts = tapUntilReceipts
13513
+ .map((result) => typeof result.tap_count === "number" && Number.isFinite(result.tap_count) ? result.tap_count : undefined)
13514
+ .filter((value) => value !== undefined);
13515
+ const sampledTapUntilReceipts = sampleProfileSetupSummaryItems(tapUntilReceipts, 8);
13448
13516
  const keyboardReceipts = profileSetupKeyboardReceipts(results);
13449
13517
  const sampledKeyboardReceipts = sampleProfileSetupSummaryItems(keyboardReceipts, 8);
13450
13518
  const canvasSignatureReceipts = profileSetupCanvasSignatureReceipts(results);
@@ -13527,6 +13595,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
13527
13595
  tap_total: tapReceipts.length,
13528
13596
  tap_truncated: tapReceipts.length > sampledTapReceipts.length,
13529
13597
  tap: sampledTapReceipts,
13598
+ tap_until_total: tapUntilReceipts.length,
13599
+ tap_until_tap_total: tapUntilTapCounts.reduce((sum, value) => sum + value, 0),
13600
+ tap_until_truncated: tapUntilReceipts.length > sampledTapUntilReceipts.length,
13601
+ tap_until: sampledTapUntilReceipts,
13530
13602
  keyboard_total: keyboardReceipts.length,
13531
13603
  keyboard_truncated: keyboardReceipts.length > sampledKeyboardReceipts.length,
13532
13604
  keyboard: sampledKeyboardReceipts,
@@ -14473,6 +14545,108 @@ async function waitForAnyVisibleSelector(context, selector, timeout) {
14473
14545
  }
14474
14546
  throw new Error("No visible match for selector " + selector + ": " + lastReason);
14475
14547
  }
14548
+ async function dispatchSetupTapPoint(point, pointerType, durationMs) {
14549
+ if (pointerType === "touch" || pointerType === "pen") {
14550
+ const client = await page.context().newCDPSession(page);
14551
+ try {
14552
+ if (pointerType === "touch") {
14553
+ const touchPoint = {
14554
+ x: point.x,
14555
+ y: point.y,
14556
+ radiusX: 1,
14557
+ radiusY: 1,
14558
+ force: 1,
14559
+ id: 11,
14560
+ };
14561
+ await client.send("Input.dispatchTouchEvent", {
14562
+ type: "touchStart",
14563
+ touchPoints: [touchPoint],
14564
+ });
14565
+ if (durationMs) await page.waitForTimeout(durationMs);
14566
+ await client.send("Input.dispatchTouchEvent", {
14567
+ type: "touchEnd",
14568
+ touchPoints: [],
14569
+ });
14570
+ } else {
14571
+ await client.send("Input.dispatchMouseEvent", {
14572
+ type: "mousePressed",
14573
+ x: point.x,
14574
+ y: point.y,
14575
+ button: "left",
14576
+ buttons: 1,
14577
+ clickCount: 1,
14578
+ pointerType: "pen",
14579
+ });
14580
+ if (durationMs) await page.waitForTimeout(durationMs);
14581
+ await client.send("Input.dispatchMouseEvent", {
14582
+ type: "mouseReleased",
14583
+ x: point.x,
14584
+ y: point.y,
14585
+ button: "left",
14586
+ buttons: 0,
14587
+ clickCount: 1,
14588
+ pointerType: "pen",
14589
+ });
14590
+ }
14591
+ } finally {
14592
+ await client.detach().catch(() => {});
14593
+ }
14594
+ } else {
14595
+ await page.mouse.click(point.x, point.y);
14596
+ }
14597
+ }
14598
+ async function resolveSetupTapTarget(action, base, scope, timeout) {
14599
+ const locator = scope.context.locator(action.selector);
14600
+ const count = await locator.count();
14601
+ if (!count) return { result: { ...base, ...setupScopeEvidence(scope), reason: "selector_not_found", count } };
14602
+ const targetIndex = Number.isInteger(action.index) ? action.index : 0;
14603
+ if (targetIndex < 0 || targetIndex >= count) return { result: { ...base, ...setupScopeEvidence(scope), reason: "index_out_of_range", count, target_index: targetIndex } };
14604
+ const target = locator.nth(targetIndex);
14605
+ await target.waitFor({ state: "visible", timeout });
14606
+ const box = await target.boundingBox();
14607
+ if (!box) return { result: { ...base, ...setupScopeEvidence(scope), reason: "bounding_box_unavailable", count, target_index: targetIndex } };
14608
+ const fromX = setupFiniteNumber(action.from_x ?? action.fromX ?? action.x ?? action.click_x ?? action.clickX);
14609
+ const fromY = setupFiniteNumber(action.from_y ?? action.fromY ?? action.y ?? action.click_y ?? action.clickY);
14610
+ const hasTapPosition = fromX !== undefined || fromY !== undefined;
14611
+ if (hasTapPosition && (fromX === undefined || fromY === undefined)) return { result: { ...base, ...setupScopeEvidence(scope), reason: "missing_tap_coordinates", count, target_index: targetIndex } };
14612
+ const mode = String(action.coordinate_mode || action.coordinateMode || (hasTapPosition ? "pixels" : "ratio")).trim();
14613
+ if (hasTapPosition && mode === "ratio" && [fromX, fromY].some((value) => value < 0 || value > 1)) return { result: { ...base, ...setupScopeEvidence(scope), reason: "invalid_ratio_coordinates", count, target_index: targetIndex } };
14614
+ if (hasTapPosition && mode !== "ratio" && [fromX, fromY].some((value) => value < 0)) return { result: { ...base, ...setupScopeEvidence(scope), reason: "invalid_pixel_coordinates", count, target_index: targetIndex } };
14615
+ const coordinate = (value, size) => mode === "ratio" ? value * size : value;
14616
+ const localX = hasTapPosition && fromX !== undefined ? fromX : 0.5;
14617
+ const localY = hasTapPosition && fromY !== undefined ? fromY : 0.5;
14618
+ const point = {
14619
+ x: box.x + coordinate(localX, box.width),
14620
+ y: box.y + coordinate(localY, box.height),
14621
+ };
14622
+ const durationMs = setupNumber(action.duration_ms ?? action.durationMs, 0);
14623
+ const pointerType = String(action.pointer_type || action.pointerType || "touch").trim().toLowerCase();
14624
+ return {
14625
+ target: {
14626
+ count,
14627
+ targetIndex,
14628
+ point,
14629
+ mode,
14630
+ fromX,
14631
+ fromY,
14632
+ hasTapPosition,
14633
+ pointerType,
14634
+ durationMs,
14635
+ },
14636
+ };
14637
+ }
14638
+ function setupTapTargetEvidence(tapTarget) {
14639
+ return {
14640
+ count: tapTarget.count,
14641
+ target_index: tapTarget.targetIndex,
14642
+ coordinate_mode: tapTarget.hasTapPosition ? tapTarget.mode : undefined,
14643
+ x: tapTarget.hasTapPosition ? tapTarget.fromX : undefined,
14644
+ y: tapTarget.hasTapPosition ? tapTarget.fromY : undefined,
14645
+ pointer_type: tapTarget.pointerType,
14646
+ input_dispatch: tapTarget.pointerType === "touch" || tapTarget.pointerType === "pen" ? "cdp" : "playwright_mouse",
14647
+ duration_ms: tapTarget.durationMs || undefined,
14648
+ };
14649
+ }
14476
14650
  function setupHasOwn(action, key) {
14477
14651
  return Boolean(action) && Object.keys(action).includes(key);
14478
14652
  }
@@ -15075,91 +15249,121 @@ async function executeSetupAction(action, ordinal, viewport) {
15075
15249
  if (type === "tap") {
15076
15250
  const scope = await setupActionScope(action, timeout);
15077
15251
  if (!scope.ok) return setupScopeFailure(base, scope);
15078
- const locator = scope.context.locator(action.selector);
15079
- const count = await locator.count();
15080
- if (!count) return { ...base, ...setupScopeEvidence(scope), reason: "selector_not_found", count };
15081
- const targetIndex = Number.isInteger(action.index) ? action.index : 0;
15082
- if (targetIndex < 0 || targetIndex >= count) return { ...base, ...setupScopeEvidence(scope), reason: "index_out_of_range", count, target_index: targetIndex };
15083
- const target = locator.nth(targetIndex);
15084
- await target.waitFor({ state: "visible", timeout });
15085
- const box = await target.boundingBox();
15086
- if (!box) return { ...base, ...setupScopeEvidence(scope), reason: "bounding_box_unavailable", count, target_index: targetIndex };
15087
- const fromX = setupFiniteNumber(action.from_x ?? action.fromX ?? action.x ?? action.click_x ?? action.clickX);
15088
- const fromY = setupFiniteNumber(action.from_y ?? action.fromY ?? action.y ?? action.click_y ?? action.clickY);
15089
- const hasTapPosition = fromX !== undefined || fromY !== undefined;
15090
- if (hasTapPosition && (fromX === undefined || fromY === undefined)) return { ...base, ...setupScopeEvidence(scope), reason: "missing_tap_coordinates", count, target_index: targetIndex };
15091
- const mode = String(action.coordinate_mode || action.coordinateMode || (hasTapPosition ? "pixels" : "ratio")).trim();
15092
- if (hasTapPosition && mode === "ratio" && [fromX, fromY].some((value) => value < 0 || value > 1)) return { ...base, ...setupScopeEvidence(scope), reason: "invalid_ratio_coordinates", count, target_index: targetIndex };
15093
- if (hasTapPosition && mode !== "ratio" && [fromX, fromY].some((value) => value < 0)) return { ...base, ...setupScopeEvidence(scope), reason: "invalid_pixel_coordinates", count, target_index: targetIndex };
15094
- const coordinate = (value, size) => mode === "ratio" ? value * size : value;
15095
- const localX = hasTapPosition && fromX !== undefined ? fromX : 0.5;
15096
- const localY = hasTapPosition && fromY !== undefined ? fromY : 0.5;
15097
- const point = {
15098
- x: box.x + coordinate(localX, box.width),
15099
- y: box.y + coordinate(localY, box.height),
15252
+ const prepared = await resolveSetupTapTarget(action, base, scope, timeout);
15253
+ if (prepared.result) return prepared.result;
15254
+ await dispatchSetupTapPoint(prepared.target.point, prepared.target.pointerType, prepared.target.durationMs);
15255
+ return {
15256
+ ...base,
15257
+ ...setupScopeEvidence(scope),
15258
+ ok: true,
15259
+ ...setupTapTargetEvidence(prepared.target),
15100
15260
  };
15101
- const durationMs = setupNumber(action.duration_ms ?? action.durationMs, 0);
15102
- const pointerType = String(action.pointer_type || action.pointerType || "touch").trim().toLowerCase();
15103
- if (pointerType === "touch" || pointerType === "pen") {
15104
- const client = await page.context().newCDPSession(page);
15105
- try {
15106
- if (pointerType === "touch") {
15107
- const touchPoint = {
15108
- x: point.x,
15109
- y: point.y,
15110
- radiusX: 1,
15111
- radiusY: 1,
15112
- force: 1,
15113
- id: 11,
15114
- };
15115
- await client.send("Input.dispatchTouchEvent", {
15116
- type: "touchStart",
15117
- touchPoints: [touchPoint],
15118
- });
15119
- if (durationMs) await page.waitForTimeout(durationMs);
15120
- await client.send("Input.dispatchTouchEvent", {
15121
- type: "touchEnd",
15122
- touchPoints: [],
15123
- });
15124
- } else {
15125
- await client.send("Input.dispatchMouseEvent", {
15126
- type: "mousePressed",
15127
- x: point.x,
15128
- y: point.y,
15129
- button: "left",
15130
- buttons: 1,
15131
- clickCount: 1,
15132
- pointerType: "pen",
15133
- });
15134
- if (durationMs) await page.waitForTimeout(durationMs);
15135
- await client.send("Input.dispatchMouseEvent", {
15136
- type: "mouseReleased",
15137
- x: point.x,
15138
- y: point.y,
15139
- button: "left",
15140
- buttons: 0,
15141
- clickCount: 1,
15142
- pointerType: "pen",
15143
- });
15144
- }
15145
- } finally {
15146
- await client.detach().catch(() => {});
15261
+ }
15262
+ if (type === "tap_until") {
15263
+ const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
15264
+ const hasUntilExpected = setupHasOwn(action, "until_expected_value")
15265
+ || setupHasOwn(action, "untilExpectedValue")
15266
+ || setupHasOwn(action, "until_expected")
15267
+ || setupHasOwn(action, "untilExpected")
15268
+ || setupHasOwn(action, "until_value")
15269
+ || setupHasOwn(action, "untilValue")
15270
+ || setupHasOwn(action, "expected_value")
15271
+ || setupHasOwn(action, "expectedValue")
15272
+ || setupHasOwn(action, "expected");
15273
+ const untilExpected = setupHasOwn(action, "until_expected_value")
15274
+ ? action.until_expected_value
15275
+ : setupHasOwn(action, "untilExpectedValue")
15276
+ ? action.untilExpectedValue
15277
+ : setupHasOwn(action, "until_expected")
15278
+ ? action.until_expected
15279
+ : setupHasOwn(action, "untilExpected")
15280
+ ? action.untilExpected
15281
+ : setupHasOwn(action, "until_value")
15282
+ ? action.until_value
15283
+ : setupHasOwn(action, "untilValue")
15284
+ ? action.untilValue
15285
+ : setupHasOwn(action, "expected_value")
15286
+ ? action.expected_value
15287
+ : setupHasOwn(action, "expectedValue")
15288
+ ? action.expectedValue
15289
+ : action.expected;
15290
+ if (!untilPath) return { ...base, reason: "missing_until_path" };
15291
+ if (!hasUntilExpected) return { ...base, until_path: untilPath, reason: "missing_until_expected_value" };
15292
+ const maxTaps = Math.min(100, Math.max(1, Math.floor(setupNumber(action.max_taps ?? action.maxTaps ?? action.tap_limit ?? action.tapLimit ?? action.max_calls ?? action.maxCalls ?? action.max_attempts ?? action.maxAttempts ?? action.attempts, 1) || 1)));
15293
+ const tapBurstSize = Math.min(maxTaps, Math.min(100, Math.max(1, Math.floor(setupNumber(action.tap_burst_size ?? action.tapBurstSize ?? action.burst_size ?? action.burstSize ?? action.check_every_taps ?? action.checkEveryTaps ?? action.predicate_interval_taps ?? action.predicateIntervalTaps, 1) || 1))));
15294
+ const intervalMs = Math.min(5000, Math.max(0, Math.floor(setupNumber(action.interval_ms ?? action.intervalMs ?? action.poll_ms ?? action.pollMs ?? action.tap_interval_ms ?? action.tapIntervalMs, 100) || 0)));
15295
+ const scope = await setupActionScope(action, timeout);
15296
+ if (!scope.ok) return setupScopeFailure(base, scope);
15297
+ const prepared = await resolveSetupTapTarget(action, base, scope, timeout);
15298
+ if (prepared.result) return prepared.result;
15299
+ const startedAt = Date.now();
15300
+ let tapCount = 0;
15301
+ let conditionCheckCount = 1;
15302
+ let lastPredicateResult = await setupReadWindowValue(scope.context, untilPath);
15303
+ const targetEvidence = setupTapTargetEvidence(prepared.target);
15304
+ if (lastPredicateResult.ok && setupValuesEqual(lastPredicateResult.value, untilExpected)) {
15305
+ return {
15306
+ ...base,
15307
+ ...setupScopeEvidence(scope),
15308
+ ok: true,
15309
+ ...targetEvidence,
15310
+ until_path: untilPath,
15311
+ until_value: setupJsonValue(lastPredicateResult.value),
15312
+ until_expected_value: setupJsonValue(untilExpected),
15313
+ tap_count: tapCount,
15314
+ max_taps: maxTaps,
15315
+ max_calls: maxTaps,
15316
+ tap_burst_size: tapBurstSize,
15317
+ condition_check_count: conditionCheckCount,
15318
+ interval_ms: intervalMs,
15319
+ timeout_ms: timeout,
15320
+ };
15321
+ }
15322
+ while (tapCount < maxTaps && Date.now() - startedAt <= timeout) {
15323
+ const burstCount = Math.min(tapBurstSize, maxTaps - tapCount);
15324
+ for (let burstIndex = 0; burstIndex < burstCount && Date.now() - startedAt <= timeout; burstIndex += 1) {
15325
+ await dispatchSetupTapPoint(prepared.target.point, prepared.target.pointerType, prepared.target.durationMs);
15326
+ tapCount += 1;
15327
+ if (tapCount < maxTaps && burstIndex < burstCount - 1 && intervalMs) await page.waitForTimeout(intervalMs);
15147
15328
  }
15148
- } else {
15149
- await page.mouse.click(point.x, point.y);
15329
+ lastPredicateResult = await setupReadWindowValue(scope.context, untilPath);
15330
+ conditionCheckCount += 1;
15331
+ if (lastPredicateResult.ok && setupValuesEqual(lastPredicateResult.value, untilExpected)) {
15332
+ return {
15333
+ ...base,
15334
+ ...setupScopeEvidence(scope),
15335
+ ok: true,
15336
+ ...targetEvidence,
15337
+ until_path: untilPath,
15338
+ until_value: setupJsonValue(lastPredicateResult.value),
15339
+ until_expected_value: setupJsonValue(untilExpected),
15340
+ tap_count: tapCount,
15341
+ max_taps: maxTaps,
15342
+ max_calls: maxTaps,
15343
+ tap_burst_size: tapBurstSize,
15344
+ condition_check_count: conditionCheckCount,
15345
+ interval_ms: intervalMs,
15346
+ timeout_ms: timeout,
15347
+ };
15348
+ }
15349
+ if (tapCount < maxTaps && intervalMs) await page.waitForTimeout(intervalMs);
15150
15350
  }
15151
15351
  return {
15152
15352
  ...base,
15153
15353
  ...setupScopeEvidence(scope),
15154
- ok: true,
15155
- count,
15156
- target_index: targetIndex,
15157
- coordinate_mode: hasTapPosition ? mode : undefined,
15158
- x: hasTapPosition ? fromX : undefined,
15159
- y: hasTapPosition ? fromY : undefined,
15160
- pointer_type: pointerType,
15161
- input_dispatch: pointerType === "touch" || pointerType === "pen" ? "cdp" : "playwright_mouse",
15162
- duration_ms: durationMs || undefined,
15354
+ ...targetEvidence,
15355
+ until_path: untilPath,
15356
+ until_value: setupJsonValue(lastPredicateResult?.value),
15357
+ until_expected_value: setupJsonValue(untilExpected),
15358
+ tap_count: tapCount,
15359
+ max_taps: maxTaps,
15360
+ max_calls: maxTaps,
15361
+ tap_burst_size: tapBurstSize,
15362
+ condition_check_count: conditionCheckCount,
15363
+ interval_ms: intervalMs,
15364
+ timeout_ms: timeout,
15365
+ reason: Date.now() - startedAt > timeout ? "timeout" : "until_condition_not_met",
15366
+ missing_part: lastPredicateResult?.missing_part || undefined,
15163
15367
  };
15164
15368
  }
15165
15369
  if (type === "drag") {
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ import {
62
62
  resolveRiddleProofProfileTimeoutSec,
63
63
  slugifyRiddleProofProfileName,
64
64
  summarizeRiddleProofProfileResult
65
- } from "./chunk-EYLIXKE2.js";
65
+ } from "./chunk-EXFYPLP2.js";
66
66
  import {
67
67
  DEFAULT_RIDDLE_API_BASE_URL,
68
68
  DEFAULT_RIDDLE_API_KEY_FILE,