@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/profile.cjs CHANGED
@@ -92,6 +92,7 @@ var RIDDLE_PROOF_PROFILE_CHECK_TYPES = [
92
92
  var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
93
93
  "click",
94
94
  "tap",
95
+ "tap_until",
95
96
  "drag",
96
97
  "press",
97
98
  "key_down",
@@ -662,6 +663,30 @@ function profileSetupTapReceipts(results) {
662
663
  reason: result.reason ?? result.error ?? null
663
664
  }));
664
665
  }
666
+ function profileSetupTapUntilReceipts(results) {
667
+ return results.filter((result) => profileSetupResultAction(result) === "tap_until").map((result) => ({
668
+ ordinal: result.ordinal ?? null,
669
+ ok: result.ok !== false,
670
+ selector: result.selector ?? null,
671
+ frame_selector: result.frame_selector ?? null,
672
+ pointer_type: result.pointer_type ?? null,
673
+ input_dispatch: result.input_dispatch ?? null,
674
+ coordinate_mode: result.coordinate_mode ?? null,
675
+ x: result.x ?? null,
676
+ y: result.y ?? null,
677
+ duration_ms: result.duration_ms ?? null,
678
+ until_path: result.until_path ?? null,
679
+ until_value: result.until_value ?? null,
680
+ until_expected_value: result.until_expected_value ?? null,
681
+ tap_count: result.tap_count ?? null,
682
+ max_taps: result.max_taps ?? result.max_calls ?? null,
683
+ tap_burst_size: result.tap_burst_size ?? null,
684
+ condition_check_count: result.condition_check_count ?? null,
685
+ interval_ms: result.interval_ms ?? null,
686
+ timeout_ms: result.timeout_ms ?? null,
687
+ reason: result.reason ?? result.error ?? null
688
+ }));
689
+ }
665
690
  function profileSetupKeyboardReceipts(results) {
666
691
  return results.filter((result) => ["press", "key_down", "key_up"].includes(profileSetupResultAction(result))).map((result) => ({
667
692
  action: profileSetupResultAction(result),
@@ -837,6 +862,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
837
862
  const sampledDragReceipts = sampleProfileSetupSummaryItems(dragReceipts, 8);
838
863
  const tapReceipts = profileSetupTapReceipts(results);
839
864
  const sampledTapReceipts = sampleProfileSetupSummaryItems(tapReceipts, 8);
865
+ const tapUntilReceipts = profileSetupTapUntilReceipts(results);
866
+ 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);
867
+ const sampledTapUntilReceipts = sampleProfileSetupSummaryItems(tapUntilReceipts, 8);
840
868
  const keyboardReceipts = profileSetupKeyboardReceipts(results);
841
869
  const sampledKeyboardReceipts = sampleProfileSetupSummaryItems(keyboardReceipts, 8);
842
870
  const canvasSignatureReceipts = profileSetupCanvasSignatureReceipts(results);
@@ -909,6 +937,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
909
937
  tap_total: tapReceipts.length,
910
938
  tap_truncated: tapReceipts.length > sampledTapReceipts.length,
911
939
  tap: sampledTapReceipts,
940
+ tap_until_total: tapUntilReceipts.length,
941
+ tap_until_tap_total: tapUntilTapCounts.reduce((sum, value) => sum + value, 0),
942
+ tap_until_truncated: tapUntilReceipts.length > sampledTapUntilReceipts.length,
943
+ tap_until: sampledTapUntilReceipts,
912
944
  keyboard_total: keyboardReceipts.length,
913
945
  keyboard_truncated: keyboardReceipts.length > sampledKeyboardReceipts.length,
914
946
  keyboard: sampledKeyboardReceipts,
@@ -970,7 +1002,7 @@ function isSupportedCheckType(value) {
970
1002
  }
971
1003
  function normalizeSetupActionType(value, index) {
972
1004
  const normalizedInput = String(value || "").trim().replace(/-/g, "_");
973
- 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;
1005
+ 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;
974
1006
  if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
975
1007
  return normalized;
976
1008
  }
@@ -1052,8 +1084,8 @@ function normalizeSetupActionCoordinateMode(value, index) {
1052
1084
  }
1053
1085
  function normalizeSetupActionPointerType(value, type, index) {
1054
1086
  if (value === void 0 || value === null || value === "") return void 0;
1055
- if (type !== "drag" && type !== "tap") {
1056
- throw new Error(`target.setup_actions[${index}].pointer_type is only supported for drag/tap actions.`);
1087
+ if (type !== "drag" && type !== "tap" && type !== "tap_until") {
1088
+ throw new Error(`target.setup_actions[${index}].pointer_type is only supported for drag/tap/tap_until actions.`);
1057
1089
  }
1058
1090
  const normalized = String(value).trim().replace(/-/g, "_").toLowerCase();
1059
1091
  if (normalized === "mouse") return "mouse";
@@ -1132,11 +1164,11 @@ function normalizeSetupAction(input, index) {
1132
1164
  if (frameIndex !== void 0 && (!Number.isInteger(frameIndex) || frameIndex < 0)) {
1133
1165
  throw new Error(`target.setup_actions[${index}].frame_index must be a non-negative integer.`);
1134
1166
  }
1135
- 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) {
1167
+ 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) {
1136
1168
  throw new Error(`target.setup_actions[${index}] ${type} requires selector.`);
1137
1169
  }
1138
- const fromX = type === "click" || type === "tap" ? numberValue(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
1139
- const fromY = type === "click" || type === "tap" ? numberValue(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
1170
+ const fromX = type === "click" || type === "tap" || type === "tap_until" ? numberValue(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
1171
+ const fromY = type === "click" || type === "tap" || type === "tap_until" ? numberValue(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
1140
1172
  const toX = numberValue(valueFromOwn(input, "to_x", "toX", "end_x", "endX", "x2"));
1141
1173
  const toY = numberValue(valueFromOwn(input, "to_y", "toY", "end_y", "endY", "y2"));
1142
1174
  const coordinateMode = normalizeSetupActionCoordinateMode(valueFromOwn(input, "coordinate_mode", "coordinateMode", "coords", "units"), index);
@@ -1161,18 +1193,18 @@ function normalizeSetupAction(input, index) {
1161
1193
  }
1162
1194
  }
1163
1195
  }
1164
- if (type === "tap") {
1196
+ if (type === "tap" || type === "tap_until") {
1165
1197
  const hasTapCoordinate = fromX !== void 0 || fromY !== void 0;
1166
1198
  if (hasTapCoordinate && (fromX === void 0 || fromY === void 0)) {
1167
- throw new Error(`target.setup_actions[${index}] tap coordinates require both x and y.`);
1199
+ throw new Error(`target.setup_actions[${index}] ${type} coordinates require both x and y.`);
1168
1200
  }
1169
1201
  if (hasTapCoordinate && fromX !== void 0 && fromY !== void 0) {
1170
1202
  const tapCoordinates = [fromX, fromY];
1171
1203
  if (coordinateMode === "ratio" && tapCoordinates.some((value2) => value2 < 0 || value2 > 1)) {
1172
- throw new Error(`target.setup_actions[${index}] tap ratio coordinates must be between 0 and 1.`);
1204
+ throw new Error(`target.setup_actions[${index}] ${type} ratio coordinates must be between 0 and 1.`);
1173
1205
  }
1174
1206
  if ((coordinateMode === void 0 || coordinateMode === "pixels") && tapCoordinates.some((value2) => value2 < 0)) {
1175
- throw new Error(`target.setup_actions[${index}] tap pixel coordinates must be non-negative.`);
1207
+ throw new Error(`target.setup_actions[${index}] ${type} pixel coordinates must be non-negative.`);
1176
1208
  }
1177
1209
  }
1178
1210
  }
@@ -1278,7 +1310,7 @@ function normalizeSetupAction(input, index) {
1278
1310
  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;
1279
1311
  const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
1280
1312
  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");
1281
- if (type === "window_call_until") {
1313
+ if (type === "window_call_until" || type === "tap_until") {
1282
1314
  if (!untilPath) {
1283
1315
  throw new Error(`target.setup_actions[${index}] ${type} requires until_path.`);
1284
1316
  }
@@ -1286,12 +1318,16 @@ function normalizeSetupAction(input, index) {
1286
1318
  throw new Error(`target.setup_actions[${index}] ${type} requires until_expected_value.`);
1287
1319
  }
1288
1320
  }
1289
- const maxCalls = numberValue(valueFromOwn(input, "max_calls", "maxCalls", "max_attempts", "maxAttempts", "attempts"));
1290
- if (type === "window_call_until" && (maxCalls === void 0 || !Number.isInteger(maxCalls) || maxCalls < 1 || maxCalls > 100)) {
1321
+ const maxCalls = numberValue(valueFromOwn(input, "max_calls", "maxCalls", "max_attempts", "maxAttempts", "attempts", "max_taps", "maxTaps", "tap_limit", "tapLimit"));
1322
+ if ((type === "window_call_until" || type === "tap_until") && (maxCalls === void 0 || !Number.isInteger(maxCalls) || maxCalls < 1 || maxCalls > 100)) {
1291
1323
  throw new Error(`target.setup_actions[${index}].max_calls must be an integer from 1 to 100.`);
1292
1324
  }
1325
+ const tapBurstSize = type === "tap_until" ? numberValue(valueFromOwn(input, "tap_burst_size", "tapBurstSize", "burst_size", "burstSize", "check_every_taps", "checkEveryTaps", "predicate_interval_taps", "predicateIntervalTaps")) : void 0;
1326
+ if (type === "tap_until" && tapBurstSize !== void 0 && (!Number.isInteger(tapBurstSize) || tapBurstSize < 1 || tapBurstSize > 100)) {
1327
+ throw new Error(`target.setup_actions[${index}].tap_burst_size must be an integer from 1 to 100.`);
1328
+ }
1293
1329
  const intervalMs = numberValue(valueFromOwn(input, "interval_ms", "intervalMs", "poll_ms", "pollMs", "call_interval_ms", "callIntervalMs"));
1294
- if (type === "window_call_until" && intervalMs !== void 0 && (!Number.isInteger(intervalMs) || intervalMs < 0 || intervalMs > 5e3)) {
1330
+ if ((type === "window_call_until" || type === "tap_until") && intervalMs !== void 0 && (!Number.isInteger(intervalMs) || intervalMs < 0 || intervalMs > 5e3)) {
1295
1331
  throw new Error(`target.setup_actions[${index}].interval_ms must be an integer from 0 to 5000.`);
1296
1332
  }
1297
1333
  const steps = numberValue(input.steps);
@@ -1337,6 +1373,7 @@ function normalizeSetupAction(input, index) {
1337
1373
  until_path: untilPath,
1338
1374
  until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
1339
1375
  max_calls: maxCalls,
1376
+ tap_burst_size: tapBurstSize,
1340
1377
  interval_ms: intervalMs,
1341
1378
  expected_value: hasExpectedValue ? toJsonValue(rawExpectedValue) : void 0,
1342
1379
  min_value: minValue,
@@ -4557,6 +4594,32 @@ function profileSetupTapReceipts(results) {
4557
4594
  reason: result.reason || result.error || null,
4558
4595
  }));
4559
4596
  }
4597
+ function profileSetupTapUntilReceipts(results) {
4598
+ return (results || [])
4599
+ .filter((result) => result && profileSetupResultAction(result) === "tap_until")
4600
+ .map((result) => ({
4601
+ ordinal: result.ordinal ?? null,
4602
+ ok: result.ok !== false,
4603
+ selector: result.selector ?? null,
4604
+ frame_selector: result.frame_selector ?? null,
4605
+ pointer_type: result.pointer_type ?? null,
4606
+ input_dispatch: result.input_dispatch ?? null,
4607
+ coordinate_mode: result.coordinate_mode ?? null,
4608
+ x: result.x ?? null,
4609
+ y: result.y ?? null,
4610
+ duration_ms: result.duration_ms ?? null,
4611
+ until_path: result.until_path ?? null,
4612
+ until_value: result.until_value ?? null,
4613
+ until_expected_value: result.until_expected_value ?? null,
4614
+ tap_count: result.tap_count ?? null,
4615
+ max_taps: result.max_taps ?? result.max_calls ?? null,
4616
+ tap_burst_size: result.tap_burst_size ?? null,
4617
+ condition_check_count: result.condition_check_count ?? null,
4618
+ interval_ms: result.interval_ms ?? null,
4619
+ timeout_ms: result.timeout_ms ?? null,
4620
+ reason: result.reason || result.error || null,
4621
+ }));
4622
+ }
4560
4623
  function profileSetupKeyboardReceipts(results) {
4561
4624
  return (results || [])
4562
4625
  .filter((result) => result && ["press", "key_down", "key_up"].includes(profileSetupResultAction(result)))
@@ -4759,6 +4822,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
4759
4822
  const sampledDragReceipts = sampleProfileSetupSummaryItems(dragReceipts, 8);
4760
4823
  const tapReceipts = profileSetupTapReceipts(results);
4761
4824
  const sampledTapReceipts = sampleProfileSetupSummaryItems(tapReceipts, 8);
4825
+ const tapUntilReceipts = profileSetupTapUntilReceipts(results);
4826
+ const tapUntilTapCounts = tapUntilReceipts
4827
+ .map((result) => typeof result.tap_count === "number" && Number.isFinite(result.tap_count) ? result.tap_count : undefined)
4828
+ .filter((value) => value !== undefined);
4829
+ const sampledTapUntilReceipts = sampleProfileSetupSummaryItems(tapUntilReceipts, 8);
4762
4830
  const keyboardReceipts = profileSetupKeyboardReceipts(results);
4763
4831
  const sampledKeyboardReceipts = sampleProfileSetupSummaryItems(keyboardReceipts, 8);
4764
4832
  const canvasSignatureReceipts = profileSetupCanvasSignatureReceipts(results);
@@ -4841,6 +4909,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
4841
4909
  tap_total: tapReceipts.length,
4842
4910
  tap_truncated: tapReceipts.length > sampledTapReceipts.length,
4843
4911
  tap: sampledTapReceipts,
4912
+ tap_until_total: tapUntilReceipts.length,
4913
+ tap_until_tap_total: tapUntilTapCounts.reduce((sum, value) => sum + value, 0),
4914
+ tap_until_truncated: tapUntilReceipts.length > sampledTapUntilReceipts.length,
4915
+ tap_until: sampledTapUntilReceipts,
4844
4916
  keyboard_total: keyboardReceipts.length,
4845
4917
  keyboard_truncated: keyboardReceipts.length > sampledKeyboardReceipts.length,
4846
4918
  keyboard: sampledKeyboardReceipts,
@@ -5787,6 +5859,108 @@ async function waitForAnyVisibleSelector(context, selector, timeout) {
5787
5859
  }
5788
5860
  throw new Error("No visible match for selector " + selector + ": " + lastReason);
5789
5861
  }
5862
+ async function dispatchSetupTapPoint(point, pointerType, durationMs) {
5863
+ if (pointerType === "touch" || pointerType === "pen") {
5864
+ const client = await page.context().newCDPSession(page);
5865
+ try {
5866
+ if (pointerType === "touch") {
5867
+ const touchPoint = {
5868
+ x: point.x,
5869
+ y: point.y,
5870
+ radiusX: 1,
5871
+ radiusY: 1,
5872
+ force: 1,
5873
+ id: 11,
5874
+ };
5875
+ await client.send("Input.dispatchTouchEvent", {
5876
+ type: "touchStart",
5877
+ touchPoints: [touchPoint],
5878
+ });
5879
+ if (durationMs) await page.waitForTimeout(durationMs);
5880
+ await client.send("Input.dispatchTouchEvent", {
5881
+ type: "touchEnd",
5882
+ touchPoints: [],
5883
+ });
5884
+ } else {
5885
+ await client.send("Input.dispatchMouseEvent", {
5886
+ type: "mousePressed",
5887
+ x: point.x,
5888
+ y: point.y,
5889
+ button: "left",
5890
+ buttons: 1,
5891
+ clickCount: 1,
5892
+ pointerType: "pen",
5893
+ });
5894
+ if (durationMs) await page.waitForTimeout(durationMs);
5895
+ await client.send("Input.dispatchMouseEvent", {
5896
+ type: "mouseReleased",
5897
+ x: point.x,
5898
+ y: point.y,
5899
+ button: "left",
5900
+ buttons: 0,
5901
+ clickCount: 1,
5902
+ pointerType: "pen",
5903
+ });
5904
+ }
5905
+ } finally {
5906
+ await client.detach().catch(() => {});
5907
+ }
5908
+ } else {
5909
+ await page.mouse.click(point.x, point.y);
5910
+ }
5911
+ }
5912
+ async function resolveSetupTapTarget(action, base, scope, timeout) {
5913
+ const locator = scope.context.locator(action.selector);
5914
+ const count = await locator.count();
5915
+ if (!count) return { result: { ...base, ...setupScopeEvidence(scope), reason: "selector_not_found", count } };
5916
+ const targetIndex = Number.isInteger(action.index) ? action.index : 0;
5917
+ if (targetIndex < 0 || targetIndex >= count) return { result: { ...base, ...setupScopeEvidence(scope), reason: "index_out_of_range", count, target_index: targetIndex } };
5918
+ const target = locator.nth(targetIndex);
5919
+ await target.waitFor({ state: "visible", timeout });
5920
+ const box = await target.boundingBox();
5921
+ if (!box) return { result: { ...base, ...setupScopeEvidence(scope), reason: "bounding_box_unavailable", count, target_index: targetIndex } };
5922
+ const fromX = setupFiniteNumber(action.from_x ?? action.fromX ?? action.x ?? action.click_x ?? action.clickX);
5923
+ const fromY = setupFiniteNumber(action.from_y ?? action.fromY ?? action.y ?? action.click_y ?? action.clickY);
5924
+ const hasTapPosition = fromX !== undefined || fromY !== undefined;
5925
+ if (hasTapPosition && (fromX === undefined || fromY === undefined)) return { result: { ...base, ...setupScopeEvidence(scope), reason: "missing_tap_coordinates", count, target_index: targetIndex } };
5926
+ const mode = String(action.coordinate_mode || action.coordinateMode || (hasTapPosition ? "pixels" : "ratio")).trim();
5927
+ 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 } };
5928
+ if (hasTapPosition && mode !== "ratio" && [fromX, fromY].some((value) => value < 0)) return { result: { ...base, ...setupScopeEvidence(scope), reason: "invalid_pixel_coordinates", count, target_index: targetIndex } };
5929
+ const coordinate = (value, size) => mode === "ratio" ? value * size : value;
5930
+ const localX = hasTapPosition && fromX !== undefined ? fromX : 0.5;
5931
+ const localY = hasTapPosition && fromY !== undefined ? fromY : 0.5;
5932
+ const point = {
5933
+ x: box.x + coordinate(localX, box.width),
5934
+ y: box.y + coordinate(localY, box.height),
5935
+ };
5936
+ const durationMs = setupNumber(action.duration_ms ?? action.durationMs, 0);
5937
+ const pointerType = String(action.pointer_type || action.pointerType || "touch").trim().toLowerCase();
5938
+ return {
5939
+ target: {
5940
+ count,
5941
+ targetIndex,
5942
+ point,
5943
+ mode,
5944
+ fromX,
5945
+ fromY,
5946
+ hasTapPosition,
5947
+ pointerType,
5948
+ durationMs,
5949
+ },
5950
+ };
5951
+ }
5952
+ function setupTapTargetEvidence(tapTarget) {
5953
+ return {
5954
+ count: tapTarget.count,
5955
+ target_index: tapTarget.targetIndex,
5956
+ coordinate_mode: tapTarget.hasTapPosition ? tapTarget.mode : undefined,
5957
+ x: tapTarget.hasTapPosition ? tapTarget.fromX : undefined,
5958
+ y: tapTarget.hasTapPosition ? tapTarget.fromY : undefined,
5959
+ pointer_type: tapTarget.pointerType,
5960
+ input_dispatch: tapTarget.pointerType === "touch" || tapTarget.pointerType === "pen" ? "cdp" : "playwright_mouse",
5961
+ duration_ms: tapTarget.durationMs || undefined,
5962
+ };
5963
+ }
5790
5964
  function setupHasOwn(action, key) {
5791
5965
  return Boolean(action) && Object.keys(action).includes(key);
5792
5966
  }
@@ -6389,91 +6563,121 @@ async function executeSetupAction(action, ordinal, viewport) {
6389
6563
  if (type === "tap") {
6390
6564
  const scope = await setupActionScope(action, timeout);
6391
6565
  if (!scope.ok) return setupScopeFailure(base, scope);
6392
- const locator = scope.context.locator(action.selector);
6393
- const count = await locator.count();
6394
- if (!count) return { ...base, ...setupScopeEvidence(scope), reason: "selector_not_found", count };
6395
- const targetIndex = Number.isInteger(action.index) ? action.index : 0;
6396
- if (targetIndex < 0 || targetIndex >= count) return { ...base, ...setupScopeEvidence(scope), reason: "index_out_of_range", count, target_index: targetIndex };
6397
- const target = locator.nth(targetIndex);
6398
- await target.waitFor({ state: "visible", timeout });
6399
- const box = await target.boundingBox();
6400
- if (!box) return { ...base, ...setupScopeEvidence(scope), reason: "bounding_box_unavailable", count, target_index: targetIndex };
6401
- const fromX = setupFiniteNumber(action.from_x ?? action.fromX ?? action.x ?? action.click_x ?? action.clickX);
6402
- const fromY = setupFiniteNumber(action.from_y ?? action.fromY ?? action.y ?? action.click_y ?? action.clickY);
6403
- const hasTapPosition = fromX !== undefined || fromY !== undefined;
6404
- if (hasTapPosition && (fromX === undefined || fromY === undefined)) return { ...base, ...setupScopeEvidence(scope), reason: "missing_tap_coordinates", count, target_index: targetIndex };
6405
- const mode = String(action.coordinate_mode || action.coordinateMode || (hasTapPosition ? "pixels" : "ratio")).trim();
6406
- if (hasTapPosition && mode === "ratio" && [fromX, fromY].some((value) => value < 0 || value > 1)) return { ...base, ...setupScopeEvidence(scope), reason: "invalid_ratio_coordinates", count, target_index: targetIndex };
6407
- if (hasTapPosition && mode !== "ratio" && [fromX, fromY].some((value) => value < 0)) return { ...base, ...setupScopeEvidence(scope), reason: "invalid_pixel_coordinates", count, target_index: targetIndex };
6408
- const coordinate = (value, size) => mode === "ratio" ? value * size : value;
6409
- const localX = hasTapPosition && fromX !== undefined ? fromX : 0.5;
6410
- const localY = hasTapPosition && fromY !== undefined ? fromY : 0.5;
6411
- const point = {
6412
- x: box.x + coordinate(localX, box.width),
6413
- y: box.y + coordinate(localY, box.height),
6566
+ const prepared = await resolveSetupTapTarget(action, base, scope, timeout);
6567
+ if (prepared.result) return prepared.result;
6568
+ await dispatchSetupTapPoint(prepared.target.point, prepared.target.pointerType, prepared.target.durationMs);
6569
+ return {
6570
+ ...base,
6571
+ ...setupScopeEvidence(scope),
6572
+ ok: true,
6573
+ ...setupTapTargetEvidence(prepared.target),
6414
6574
  };
6415
- const durationMs = setupNumber(action.duration_ms ?? action.durationMs, 0);
6416
- const pointerType = String(action.pointer_type || action.pointerType || "touch").trim().toLowerCase();
6417
- if (pointerType === "touch" || pointerType === "pen") {
6418
- const client = await page.context().newCDPSession(page);
6419
- try {
6420
- if (pointerType === "touch") {
6421
- const touchPoint = {
6422
- x: point.x,
6423
- y: point.y,
6424
- radiusX: 1,
6425
- radiusY: 1,
6426
- force: 1,
6427
- id: 11,
6428
- };
6429
- await client.send("Input.dispatchTouchEvent", {
6430
- type: "touchStart",
6431
- touchPoints: [touchPoint],
6432
- });
6433
- if (durationMs) await page.waitForTimeout(durationMs);
6434
- await client.send("Input.dispatchTouchEvent", {
6435
- type: "touchEnd",
6436
- touchPoints: [],
6437
- });
6438
- } else {
6439
- await client.send("Input.dispatchMouseEvent", {
6440
- type: "mousePressed",
6441
- x: point.x,
6442
- y: point.y,
6443
- button: "left",
6444
- buttons: 1,
6445
- clickCount: 1,
6446
- pointerType: "pen",
6447
- });
6448
- if (durationMs) await page.waitForTimeout(durationMs);
6449
- await client.send("Input.dispatchMouseEvent", {
6450
- type: "mouseReleased",
6451
- x: point.x,
6452
- y: point.y,
6453
- button: "left",
6454
- buttons: 0,
6455
- clickCount: 1,
6456
- pointerType: "pen",
6457
- });
6458
- }
6459
- } finally {
6460
- await client.detach().catch(() => {});
6575
+ }
6576
+ if (type === "tap_until") {
6577
+ const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
6578
+ const hasUntilExpected = setupHasOwn(action, "until_expected_value")
6579
+ || setupHasOwn(action, "untilExpectedValue")
6580
+ || setupHasOwn(action, "until_expected")
6581
+ || setupHasOwn(action, "untilExpected")
6582
+ || setupHasOwn(action, "until_value")
6583
+ || setupHasOwn(action, "untilValue")
6584
+ || setupHasOwn(action, "expected_value")
6585
+ || setupHasOwn(action, "expectedValue")
6586
+ || setupHasOwn(action, "expected");
6587
+ const untilExpected = setupHasOwn(action, "until_expected_value")
6588
+ ? action.until_expected_value
6589
+ : setupHasOwn(action, "untilExpectedValue")
6590
+ ? action.untilExpectedValue
6591
+ : setupHasOwn(action, "until_expected")
6592
+ ? action.until_expected
6593
+ : setupHasOwn(action, "untilExpected")
6594
+ ? action.untilExpected
6595
+ : setupHasOwn(action, "until_value")
6596
+ ? action.until_value
6597
+ : setupHasOwn(action, "untilValue")
6598
+ ? action.untilValue
6599
+ : setupHasOwn(action, "expected_value")
6600
+ ? action.expected_value
6601
+ : setupHasOwn(action, "expectedValue")
6602
+ ? action.expectedValue
6603
+ : action.expected;
6604
+ if (!untilPath) return { ...base, reason: "missing_until_path" };
6605
+ if (!hasUntilExpected) return { ...base, until_path: untilPath, reason: "missing_until_expected_value" };
6606
+ 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)));
6607
+ 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))));
6608
+ 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)));
6609
+ const scope = await setupActionScope(action, timeout);
6610
+ if (!scope.ok) return setupScopeFailure(base, scope);
6611
+ const prepared = await resolveSetupTapTarget(action, base, scope, timeout);
6612
+ if (prepared.result) return prepared.result;
6613
+ const startedAt = Date.now();
6614
+ let tapCount = 0;
6615
+ let conditionCheckCount = 1;
6616
+ let lastPredicateResult = await setupReadWindowValue(scope.context, untilPath);
6617
+ const targetEvidence = setupTapTargetEvidence(prepared.target);
6618
+ if (lastPredicateResult.ok && setupValuesEqual(lastPredicateResult.value, untilExpected)) {
6619
+ return {
6620
+ ...base,
6621
+ ...setupScopeEvidence(scope),
6622
+ ok: true,
6623
+ ...targetEvidence,
6624
+ until_path: untilPath,
6625
+ until_value: setupJsonValue(lastPredicateResult.value),
6626
+ until_expected_value: setupJsonValue(untilExpected),
6627
+ tap_count: tapCount,
6628
+ max_taps: maxTaps,
6629
+ max_calls: maxTaps,
6630
+ tap_burst_size: tapBurstSize,
6631
+ condition_check_count: conditionCheckCount,
6632
+ interval_ms: intervalMs,
6633
+ timeout_ms: timeout,
6634
+ };
6635
+ }
6636
+ while (tapCount < maxTaps && Date.now() - startedAt <= timeout) {
6637
+ const burstCount = Math.min(tapBurstSize, maxTaps - tapCount);
6638
+ for (let burstIndex = 0; burstIndex < burstCount && Date.now() - startedAt <= timeout; burstIndex += 1) {
6639
+ await dispatchSetupTapPoint(prepared.target.point, prepared.target.pointerType, prepared.target.durationMs);
6640
+ tapCount += 1;
6641
+ if (tapCount < maxTaps && burstIndex < burstCount - 1 && intervalMs) await page.waitForTimeout(intervalMs);
6461
6642
  }
6462
- } else {
6463
- await page.mouse.click(point.x, point.y);
6643
+ lastPredicateResult = await setupReadWindowValue(scope.context, untilPath);
6644
+ conditionCheckCount += 1;
6645
+ if (lastPredicateResult.ok && setupValuesEqual(lastPredicateResult.value, untilExpected)) {
6646
+ return {
6647
+ ...base,
6648
+ ...setupScopeEvidence(scope),
6649
+ ok: true,
6650
+ ...targetEvidence,
6651
+ until_path: untilPath,
6652
+ until_value: setupJsonValue(lastPredicateResult.value),
6653
+ until_expected_value: setupJsonValue(untilExpected),
6654
+ tap_count: tapCount,
6655
+ max_taps: maxTaps,
6656
+ max_calls: maxTaps,
6657
+ tap_burst_size: tapBurstSize,
6658
+ condition_check_count: conditionCheckCount,
6659
+ interval_ms: intervalMs,
6660
+ timeout_ms: timeout,
6661
+ };
6662
+ }
6663
+ if (tapCount < maxTaps && intervalMs) await page.waitForTimeout(intervalMs);
6464
6664
  }
6465
6665
  return {
6466
6666
  ...base,
6467
6667
  ...setupScopeEvidence(scope),
6468
- ok: true,
6469
- count,
6470
- target_index: targetIndex,
6471
- coordinate_mode: hasTapPosition ? mode : undefined,
6472
- x: hasTapPosition ? fromX : undefined,
6473
- y: hasTapPosition ? fromY : undefined,
6474
- pointer_type: pointerType,
6475
- input_dispatch: pointerType === "touch" || pointerType === "pen" ? "cdp" : "playwright_mouse",
6476
- duration_ms: durationMs || undefined,
6668
+ ...targetEvidence,
6669
+ until_path: untilPath,
6670
+ until_value: setupJsonValue(lastPredicateResult?.value),
6671
+ until_expected_value: setupJsonValue(untilExpected),
6672
+ tap_count: tapCount,
6673
+ max_taps: maxTaps,
6674
+ max_calls: maxTaps,
6675
+ tap_burst_size: tapBurstSize,
6676
+ condition_check_count: conditionCheckCount,
6677
+ interval_ms: intervalMs,
6678
+ timeout_ms: timeout,
6679
+ reason: Date.now() - startedAt > timeout ? "timeout" : "until_condition_not_met",
6680
+ missing_part: lastPredicateResult?.missing_part || undefined,
6477
6681
  };
6478
6682
  }
6479
6683
  if (type === "drag") {
@@ -5,7 +5,7 @@ declare const RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION: "riddle-proof.profile-evide
5
5
  declare const RIDDLE_PROOF_PROFILE_RESULT_VERSION: "riddle-proof.profile-result.v1";
6
6
  declare const RIDDLE_PROOF_PROFILE_STATUSES: readonly ["passed", "product_regression", "proof_insufficient", "environment_blocked", "configuration_error", "needs_human_review"];
7
7
  declare const RIDDLE_PROOF_PROFILE_CHECK_TYPES: readonly ["route_loaded", "url_search_param_equals", "url_search_param_absent", "selector_visible", "selector_absent", "selector_count_at_least", "selector_count_equals", "selector_count_equal", "selector_count_eq", "dialog_count_equals", "dialog_accept_count_equals", "dialog_dismiss_count_equals", "selector_text_visible", "selector_text_absent", "selector_text_order", "observe_within", "frame_text_visible", "frame_url_equals", "frame_url_matches", "frame_no_horizontal_overflow", "text_visible", "text_absent", "http_status", "link_status", "artifact_link_status", "route_inventory", "no_horizontal_overflow", "no_mobile_horizontal_overflow", "no_fatal_console_errors", "no_console_warnings"];
8
- declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "tap", "drag", "press", "key_down", "key_up", "fill", "set_input_value", "set_range_value", "deterministic_runtime", "canvas_signature", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
8
+ declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "tap", "tap_until", "drag", "press", "key_down", "key_up", "fill", "set_input_value", "set_range_value", "deterministic_runtime", "canvas_signature", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
9
9
  type RiddleProofProfileStatus = typeof RIDDLE_PROOF_PROFILE_STATUSES[number];
10
10
  type RiddleProofProfileCheckType = typeof RIDDLE_PROOF_PROFILE_CHECK_TYPES[number];
11
11
  type RiddleProofProfileSetupActionType = typeof RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES[number];
@@ -146,6 +146,7 @@ interface RiddleProofProfileSetupAction {
146
146
  until_path?: string;
147
147
  until_expected_value?: JsonValue;
148
148
  max_calls?: number;
149
+ tap_burst_size?: number;
149
150
  interval_ms?: number;
150
151
  expected_value?: JsonValue;
151
152
  min_value?: number;
package/dist/profile.d.ts CHANGED
@@ -5,7 +5,7 @@ declare const RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION: "riddle-proof.profile-evide
5
5
  declare const RIDDLE_PROOF_PROFILE_RESULT_VERSION: "riddle-proof.profile-result.v1";
6
6
  declare const RIDDLE_PROOF_PROFILE_STATUSES: readonly ["passed", "product_regression", "proof_insufficient", "environment_blocked", "configuration_error", "needs_human_review"];
7
7
  declare const RIDDLE_PROOF_PROFILE_CHECK_TYPES: readonly ["route_loaded", "url_search_param_equals", "url_search_param_absent", "selector_visible", "selector_absent", "selector_count_at_least", "selector_count_equals", "selector_count_equal", "selector_count_eq", "dialog_count_equals", "dialog_accept_count_equals", "dialog_dismiss_count_equals", "selector_text_visible", "selector_text_absent", "selector_text_order", "observe_within", "frame_text_visible", "frame_url_equals", "frame_url_matches", "frame_no_horizontal_overflow", "text_visible", "text_absent", "http_status", "link_status", "artifact_link_status", "route_inventory", "no_horizontal_overflow", "no_mobile_horizontal_overflow", "no_fatal_console_errors", "no_console_warnings"];
8
- declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "tap", "drag", "press", "key_down", "key_up", "fill", "set_input_value", "set_range_value", "deterministic_runtime", "canvas_signature", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
8
+ declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "tap", "tap_until", "drag", "press", "key_down", "key_up", "fill", "set_input_value", "set_range_value", "deterministic_runtime", "canvas_signature", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
9
9
  type RiddleProofProfileStatus = typeof RIDDLE_PROOF_PROFILE_STATUSES[number];
10
10
  type RiddleProofProfileCheckType = typeof RIDDLE_PROOF_PROFILE_CHECK_TYPES[number];
11
11
  type RiddleProofProfileSetupActionType = typeof RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES[number];
@@ -146,6 +146,7 @@ interface RiddleProofProfileSetupAction {
146
146
  until_path?: string;
147
147
  until_expected_value?: JsonValue;
148
148
  max_calls?: number;
149
+ tap_burst_size?: number;
149
150
  interval_ms?: number;
150
151
  expected_value?: JsonValue;
151
152
  min_value?: number;
package/dist/profile.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  resolveRiddleProofProfileTimeoutSec,
24
24
  slugifyRiddleProofProfileName,
25
25
  summarizeRiddleProofProfileResult
26
- } from "./chunk-EYLIXKE2.js";
26
+ } from "./chunk-EXFYPLP2.js";
27
27
  export {
28
28
  RIDDLE_PROOF_PROFILE_CHECK_TYPES,
29
29
  RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.7.197",
3
+ "version": "0.7.199",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",