@riddledc/riddle-proof 0.7.165 → 0.7.166

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.
@@ -914,12 +914,27 @@ function normalizeSetupAction(input, index) {
914
914
  if ((type === "click" || 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) {
915
915
  throw new Error(`target.setup_actions[${index}] ${type} requires selector.`);
916
916
  }
917
- const fromX = numberValue(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
918
- const fromY = numberValue(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
917
+ const fromX = type === "click" ? numberValue(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
918
+ const fromY = type === "click" ? numberValue(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
919
919
  const toX = numberValue(valueFromOwn(input, "to_x", "toX", "end_x", "endX", "x2"));
920
920
  const toY = numberValue(valueFromOwn(input, "to_y", "toY", "end_y", "endY", "y2"));
921
921
  const coordinateMode = normalizeSetupActionCoordinateMode(valueFromOwn(input, "coordinate_mode", "coordinateMode", "coords", "units"), index);
922
922
  const pointerType = normalizeSetupActionPointerType(valueFromOwn(input, "pointer_type", "pointerType", "input_type", "inputType"), type, index);
923
+ if (type === "click") {
924
+ const hasClickCoordinate = fromX !== void 0 || fromY !== void 0;
925
+ if (hasClickCoordinate && (fromX === void 0 || fromY === void 0)) {
926
+ throw new Error(`target.setup_actions[${index}] click coordinates require both x and y.`);
927
+ }
928
+ if (hasClickCoordinate && fromX !== void 0 && fromY !== void 0) {
929
+ const clickCoordinates = [fromX, fromY];
930
+ if (coordinateMode === "ratio" && clickCoordinates.some((value2) => value2 < 0 || value2 > 1)) {
931
+ throw new Error(`target.setup_actions[${index}] click ratio coordinates must be between 0 and 1.`);
932
+ }
933
+ if ((coordinateMode === void 0 || coordinateMode === "pixels") && clickCoordinates.some((value2) => value2 < 0)) {
934
+ throw new Error(`target.setup_actions[${index}] click pixel coordinates must be non-negative.`);
935
+ }
936
+ }
937
+ }
923
938
  if (type === "drag") {
924
939
  if (fromX === void 0 || fromY === void 0 || toX === void 0 || toY === void 0) {
925
940
  throw new Error(`target.setup_actions[${index}] drag requires from_x, from_y, to_x, and to_y.`);
@@ -6377,8 +6392,35 @@ async function executeSetupAction(action, ordinal, viewport) {
6377
6392
  : { timeout, noWaitAfter: true };
6378
6393
  const clickCount = setupNumber(action.click_count, 1);
6379
6394
  if (Number.isInteger(clickCount) && clickCount > 1) clickOptions.clickCount = clickCount;
6395
+ const fromX = setupFiniteNumber(action.from_x ?? action.fromX ?? action.x ?? action.click_x ?? action.clickX);
6396
+ const fromY = setupFiniteNumber(action.from_y ?? action.fromY ?? action.y ?? action.click_y ?? action.clickY);
6397
+ const hasClickPosition = fromX !== undefined || fromY !== undefined;
6398
+ let position;
6399
+ let mode;
6400
+ if (hasClickPosition) {
6401
+ if (fromX === undefined || fromY === undefined) return { ...base, ...setupScopeEvidence(scope), reason: "missing_click_coordinates", count, target_index: targetIndex };
6402
+ const target = locator.nth(targetIndex);
6403
+ const box = await target.boundingBox();
6404
+ if (!box) return { ...base, ...setupScopeEvidence(scope), reason: "bounding_box_unavailable", count, target_index: targetIndex };
6405
+ mode = String(action.coordinate_mode || action.coordinateMode || "pixels").trim();
6406
+ const coordinate = (value, size) => mode === "ratio" ? value * size : value;
6407
+ position = { x: coordinate(fromX, box.width), y: coordinate(fromY, box.height) };
6408
+ clickOptions.position = position;
6409
+ }
6380
6410
  await locator.nth(targetIndex).click(clickOptions);
6381
- return { ...base, ...setupScopeEvidence(scope), ok: true, count, target_index: targetIndex, text: matchedText, force: action.force === true || undefined, click_count: clickCount > 1 ? clickCount : undefined };
6411
+ return {
6412
+ ...base,
6413
+ ...setupScopeEvidence(scope),
6414
+ ok: true,
6415
+ count,
6416
+ target_index: targetIndex,
6417
+ text: matchedText,
6418
+ force: action.force === true || undefined,
6419
+ click_count: clickCount > 1 ? clickCount : undefined,
6420
+ coordinate_mode: mode,
6421
+ x: position ? fromX : undefined,
6422
+ y: position ? fromY : undefined,
6423
+ };
6382
6424
  }
6383
6425
  if (type === "fill" || type === "set_input_value") {
6384
6426
  const scope = await setupActionScope(action, timeout);
package/dist/cli.cjs CHANGED
@@ -7871,12 +7871,27 @@ function normalizeSetupAction(input, index) {
7871
7871
  if ((type === "click" || 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) {
7872
7872
  throw new Error(`target.setup_actions[${index}] ${type} requires selector.`);
7873
7873
  }
7874
- const fromX = numberValue(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
7875
- const fromY = numberValue(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
7874
+ const fromX = type === "click" ? numberValue(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
7875
+ const fromY = type === "click" ? numberValue(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
7876
7876
  const toX = numberValue(valueFromOwn(input, "to_x", "toX", "end_x", "endX", "x2"));
7877
7877
  const toY = numberValue(valueFromOwn(input, "to_y", "toY", "end_y", "endY", "y2"));
7878
7878
  const coordinateMode = normalizeSetupActionCoordinateMode(valueFromOwn(input, "coordinate_mode", "coordinateMode", "coords", "units"), index);
7879
7879
  const pointerType = normalizeSetupActionPointerType(valueFromOwn(input, "pointer_type", "pointerType", "input_type", "inputType"), type, index);
7880
+ if (type === "click") {
7881
+ const hasClickCoordinate = fromX !== void 0 || fromY !== void 0;
7882
+ if (hasClickCoordinate && (fromX === void 0 || fromY === void 0)) {
7883
+ throw new Error(`target.setup_actions[${index}] click coordinates require both x and y.`);
7884
+ }
7885
+ if (hasClickCoordinate && fromX !== void 0 && fromY !== void 0) {
7886
+ const clickCoordinates = [fromX, fromY];
7887
+ if (coordinateMode === "ratio" && clickCoordinates.some((value2) => value2 < 0 || value2 > 1)) {
7888
+ throw new Error(`target.setup_actions[${index}] click ratio coordinates must be between 0 and 1.`);
7889
+ }
7890
+ if ((coordinateMode === void 0 || coordinateMode === "pixels") && clickCoordinates.some((value2) => value2 < 0)) {
7891
+ throw new Error(`target.setup_actions[${index}] click pixel coordinates must be non-negative.`);
7892
+ }
7893
+ }
7894
+ }
7880
7895
  if (type === "drag") {
7881
7896
  if (fromX === void 0 || fromY === void 0 || toX === void 0 || toY === void 0) {
7882
7897
  throw new Error(`target.setup_actions[${index}] drag requires from_x, from_y, to_x, and to_y.`);
@@ -13318,8 +13333,35 @@ async function executeSetupAction(action, ordinal, viewport) {
13318
13333
  : { timeout, noWaitAfter: true };
13319
13334
  const clickCount = setupNumber(action.click_count, 1);
13320
13335
  if (Number.isInteger(clickCount) && clickCount > 1) clickOptions.clickCount = clickCount;
13336
+ const fromX = setupFiniteNumber(action.from_x ?? action.fromX ?? action.x ?? action.click_x ?? action.clickX);
13337
+ const fromY = setupFiniteNumber(action.from_y ?? action.fromY ?? action.y ?? action.click_y ?? action.clickY);
13338
+ const hasClickPosition = fromX !== undefined || fromY !== undefined;
13339
+ let position;
13340
+ let mode;
13341
+ if (hasClickPosition) {
13342
+ if (fromX === undefined || fromY === undefined) return { ...base, ...setupScopeEvidence(scope), reason: "missing_click_coordinates", count, target_index: targetIndex };
13343
+ const target = locator.nth(targetIndex);
13344
+ const box = await target.boundingBox();
13345
+ if (!box) return { ...base, ...setupScopeEvidence(scope), reason: "bounding_box_unavailable", count, target_index: targetIndex };
13346
+ mode = String(action.coordinate_mode || action.coordinateMode || "pixels").trim();
13347
+ const coordinate = (value, size) => mode === "ratio" ? value * size : value;
13348
+ position = { x: coordinate(fromX, box.width), y: coordinate(fromY, box.height) };
13349
+ clickOptions.position = position;
13350
+ }
13321
13351
  await locator.nth(targetIndex).click(clickOptions);
13322
- return { ...base, ...setupScopeEvidence(scope), ok: true, count, target_index: targetIndex, text: matchedText, force: action.force === true || undefined, click_count: clickCount > 1 ? clickCount : undefined };
13352
+ return {
13353
+ ...base,
13354
+ ...setupScopeEvidence(scope),
13355
+ ok: true,
13356
+ count,
13357
+ target_index: targetIndex,
13358
+ text: matchedText,
13359
+ force: action.force === true || undefined,
13360
+ click_count: clickCount > 1 ? clickCount : undefined,
13361
+ coordinate_mode: mode,
13362
+ x: position ? fromX : undefined,
13363
+ y: position ? fromY : undefined,
13364
+ };
13323
13365
  }
13324
13366
  if (type === "fill" || type === "set_input_value") {
13325
13367
  const scope = await setupActionScope(action, timeout);
package/dist/cli.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  profileStatusExitCode,
14
14
  resolveRiddleProofProfileTargetUrl,
15
15
  resolveRiddleProofProfileTimeoutSec
16
- } from "./chunk-ZNPSDMJX.js";
16
+ } from "./chunk-L6WJP5IY.js";
17
17
  import {
18
18
  createRiddleApiClient,
19
19
  isTerminalRiddleJobStatus,
package/dist/index.cjs CHANGED
@@ -9647,12 +9647,27 @@ function normalizeSetupAction(input, index) {
9647
9647
  if ((type === "click" || 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) {
9648
9648
  throw new Error(`target.setup_actions[${index}] ${type} requires selector.`);
9649
9649
  }
9650
- const fromX = numberValue3(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
9651
- const fromY = numberValue3(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
9650
+ const fromX = type === "click" ? numberValue3(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue3(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
9651
+ const fromY = type === "click" ? numberValue3(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue3(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
9652
9652
  const toX = numberValue3(valueFromOwn(input, "to_x", "toX", "end_x", "endX", "x2"));
9653
9653
  const toY = numberValue3(valueFromOwn(input, "to_y", "toY", "end_y", "endY", "y2"));
9654
9654
  const coordinateMode = normalizeSetupActionCoordinateMode(valueFromOwn(input, "coordinate_mode", "coordinateMode", "coords", "units"), index);
9655
9655
  const pointerType = normalizeSetupActionPointerType(valueFromOwn(input, "pointer_type", "pointerType", "input_type", "inputType"), type, index);
9656
+ if (type === "click") {
9657
+ const hasClickCoordinate = fromX !== void 0 || fromY !== void 0;
9658
+ if (hasClickCoordinate && (fromX === void 0 || fromY === void 0)) {
9659
+ throw new Error(`target.setup_actions[${index}] click coordinates require both x and y.`);
9660
+ }
9661
+ if (hasClickCoordinate && fromX !== void 0 && fromY !== void 0) {
9662
+ const clickCoordinates = [fromX, fromY];
9663
+ if (coordinateMode === "ratio" && clickCoordinates.some((value2) => value2 < 0 || value2 > 1)) {
9664
+ throw new Error(`target.setup_actions[${index}] click ratio coordinates must be between 0 and 1.`);
9665
+ }
9666
+ if ((coordinateMode === void 0 || coordinateMode === "pixels") && clickCoordinates.some((value2) => value2 < 0)) {
9667
+ throw new Error(`target.setup_actions[${index}] click pixel coordinates must be non-negative.`);
9668
+ }
9669
+ }
9670
+ }
9656
9671
  if (type === "drag") {
9657
9672
  if (fromX === void 0 || fromY === void 0 || toX === void 0 || toY === void 0) {
9658
9673
  throw new Error(`target.setup_actions[${index}] drag requires from_x, from_y, to_x, and to_y.`);
@@ -15110,8 +15125,35 @@ async function executeSetupAction(action, ordinal, viewport) {
15110
15125
  : { timeout, noWaitAfter: true };
15111
15126
  const clickCount = setupNumber(action.click_count, 1);
15112
15127
  if (Number.isInteger(clickCount) && clickCount > 1) clickOptions.clickCount = clickCount;
15128
+ const fromX = setupFiniteNumber(action.from_x ?? action.fromX ?? action.x ?? action.click_x ?? action.clickX);
15129
+ const fromY = setupFiniteNumber(action.from_y ?? action.fromY ?? action.y ?? action.click_y ?? action.clickY);
15130
+ const hasClickPosition = fromX !== undefined || fromY !== undefined;
15131
+ let position;
15132
+ let mode;
15133
+ if (hasClickPosition) {
15134
+ if (fromX === undefined || fromY === undefined) return { ...base, ...setupScopeEvidence(scope), reason: "missing_click_coordinates", count, target_index: targetIndex };
15135
+ const target = locator.nth(targetIndex);
15136
+ const box = await target.boundingBox();
15137
+ if (!box) return { ...base, ...setupScopeEvidence(scope), reason: "bounding_box_unavailable", count, target_index: targetIndex };
15138
+ mode = String(action.coordinate_mode || action.coordinateMode || "pixels").trim();
15139
+ const coordinate = (value, size) => mode === "ratio" ? value * size : value;
15140
+ position = { x: coordinate(fromX, box.width), y: coordinate(fromY, box.height) };
15141
+ clickOptions.position = position;
15142
+ }
15113
15143
  await locator.nth(targetIndex).click(clickOptions);
15114
- return { ...base, ...setupScopeEvidence(scope), ok: true, count, target_index: targetIndex, text: matchedText, force: action.force === true || undefined, click_count: clickCount > 1 ? clickCount : undefined };
15144
+ return {
15145
+ ...base,
15146
+ ...setupScopeEvidence(scope),
15147
+ ok: true,
15148
+ count,
15149
+ target_index: targetIndex,
15150
+ text: matchedText,
15151
+ force: action.force === true || undefined,
15152
+ click_count: clickCount > 1 ? clickCount : undefined,
15153
+ coordinate_mode: mode,
15154
+ x: position ? fromX : undefined,
15155
+ y: position ? fromY : undefined,
15156
+ };
15115
15157
  }
15116
15158
  if (type === "fill" || type === "set_input_value") {
15117
15159
  const scope = await setupActionScope(action, timeout);
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ import {
62
62
  resolveRiddleProofProfileTimeoutSec,
63
63
  slugifyRiddleProofProfileName,
64
64
  summarizeRiddleProofProfileResult
65
- } from "./chunk-ZNPSDMJX.js";
65
+ } from "./chunk-L6WJP5IY.js";
66
66
  import {
67
67
  DEFAULT_RIDDLE_API_BASE_URL,
68
68
  DEFAULT_RIDDLE_API_KEY_FILE,
package/dist/profile.cjs CHANGED
@@ -961,12 +961,27 @@ function normalizeSetupAction(input, index) {
961
961
  if ((type === "click" || 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) {
962
962
  throw new Error(`target.setup_actions[${index}] ${type} requires selector.`);
963
963
  }
964
- const fromX = numberValue(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
965
- const fromY = numberValue(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
964
+ const fromX = type === "click" ? numberValue(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
965
+ const fromY = type === "click" ? numberValue(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
966
966
  const toX = numberValue(valueFromOwn(input, "to_x", "toX", "end_x", "endX", "x2"));
967
967
  const toY = numberValue(valueFromOwn(input, "to_y", "toY", "end_y", "endY", "y2"));
968
968
  const coordinateMode = normalizeSetupActionCoordinateMode(valueFromOwn(input, "coordinate_mode", "coordinateMode", "coords", "units"), index);
969
969
  const pointerType = normalizeSetupActionPointerType(valueFromOwn(input, "pointer_type", "pointerType", "input_type", "inputType"), type, index);
970
+ if (type === "click") {
971
+ const hasClickCoordinate = fromX !== void 0 || fromY !== void 0;
972
+ if (hasClickCoordinate && (fromX === void 0 || fromY === void 0)) {
973
+ throw new Error(`target.setup_actions[${index}] click coordinates require both x and y.`);
974
+ }
975
+ if (hasClickCoordinate && fromX !== void 0 && fromY !== void 0) {
976
+ const clickCoordinates = [fromX, fromY];
977
+ if (coordinateMode === "ratio" && clickCoordinates.some((value2) => value2 < 0 || value2 > 1)) {
978
+ throw new Error(`target.setup_actions[${index}] click ratio coordinates must be between 0 and 1.`);
979
+ }
980
+ if ((coordinateMode === void 0 || coordinateMode === "pixels") && clickCoordinates.some((value2) => value2 < 0)) {
981
+ throw new Error(`target.setup_actions[${index}] click pixel coordinates must be non-negative.`);
982
+ }
983
+ }
984
+ }
970
985
  if (type === "drag") {
971
986
  if (fromX === void 0 || fromY === void 0 || toX === void 0 || toY === void 0) {
972
987
  throw new Error(`target.setup_actions[${index}] drag requires from_x, from_y, to_x, and to_y.`);
@@ -6424,8 +6439,35 @@ async function executeSetupAction(action, ordinal, viewport) {
6424
6439
  : { timeout, noWaitAfter: true };
6425
6440
  const clickCount = setupNumber(action.click_count, 1);
6426
6441
  if (Number.isInteger(clickCount) && clickCount > 1) clickOptions.clickCount = clickCount;
6442
+ const fromX = setupFiniteNumber(action.from_x ?? action.fromX ?? action.x ?? action.click_x ?? action.clickX);
6443
+ const fromY = setupFiniteNumber(action.from_y ?? action.fromY ?? action.y ?? action.click_y ?? action.clickY);
6444
+ const hasClickPosition = fromX !== undefined || fromY !== undefined;
6445
+ let position;
6446
+ let mode;
6447
+ if (hasClickPosition) {
6448
+ if (fromX === undefined || fromY === undefined) return { ...base, ...setupScopeEvidence(scope), reason: "missing_click_coordinates", count, target_index: targetIndex };
6449
+ const target = locator.nth(targetIndex);
6450
+ const box = await target.boundingBox();
6451
+ if (!box) return { ...base, ...setupScopeEvidence(scope), reason: "bounding_box_unavailable", count, target_index: targetIndex };
6452
+ mode = String(action.coordinate_mode || action.coordinateMode || "pixels").trim();
6453
+ const coordinate = (value, size) => mode === "ratio" ? value * size : value;
6454
+ position = { x: coordinate(fromX, box.width), y: coordinate(fromY, box.height) };
6455
+ clickOptions.position = position;
6456
+ }
6427
6457
  await locator.nth(targetIndex).click(clickOptions);
6428
- return { ...base, ...setupScopeEvidence(scope), ok: true, count, target_index: targetIndex, text: matchedText, force: action.force === true || undefined, click_count: clickCount > 1 ? clickCount : undefined };
6458
+ return {
6459
+ ...base,
6460
+ ...setupScopeEvidence(scope),
6461
+ ok: true,
6462
+ count,
6463
+ target_index: targetIndex,
6464
+ text: matchedText,
6465
+ force: action.force === true || undefined,
6466
+ click_count: clickCount > 1 ? clickCount : undefined,
6467
+ coordinate_mode: mode,
6468
+ x: position ? fromX : undefined,
6469
+ y: position ? fromY : undefined,
6470
+ };
6429
6471
  }
6430
6472
  if (type === "fill" || type === "set_input_value") {
6431
6473
  const scope = await setupActionScope(action, timeout);
package/dist/profile.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  resolveRiddleProofProfileTimeoutSec,
24
24
  slugifyRiddleProofProfileName,
25
25
  summarizeRiddleProofProfileResult
26
- } from "./chunk-ZNPSDMJX.js";
26
+ } from "./chunk-L6WJP5IY.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.165",
3
+ "version": "0.7.166",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",