@riddledc/riddle-proof 0.7.134 → 0.7.136

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.
@@ -732,6 +732,18 @@ function normalizeSetupAction(input, index) {
732
732
  }
733
733
  }
734
734
  const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
735
+ const storeReturnTo = stringFromOwn(
736
+ input,
737
+ "store_return_to",
738
+ "storeReturnTo",
739
+ "save_return_to",
740
+ "saveReturnTo",
741
+ "assign_return_to",
742
+ "assignReturnTo",
743
+ "return_state_path",
744
+ "returnStatePath"
745
+ );
746
+ 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;
735
747
  const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
736
748
  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");
737
749
  if (type === "window_call_until") {
@@ -776,6 +788,8 @@ function normalizeSetupAction(input, index) {
776
788
  path,
777
789
  args,
778
790
  expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
791
+ store_return_to: storeReturnTo,
792
+ capture_return: captureReturn,
779
793
  until_path: untilPath,
780
794
  until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
781
795
  max_calls: maxCalls,
@@ -3653,6 +3667,21 @@ function profileSetupScreenshotLabels(results) {
3653
3667
  .map((result) => result.screenshot_label)
3654
3668
  .filter(Boolean);
3655
3669
  }
3670
+ function profileSetupWindowCallUntilReceipts(results) {
3671
+ return (results || [])
3672
+ .filter((result) => result && profileSetupResultAction(result) === "window_call_until")
3673
+ .map((result) => ({
3674
+ ordinal: result.ordinal ?? null,
3675
+ ok: result.ok !== false,
3676
+ path: result.path ?? null,
3677
+ until_path: result.until_path ?? null,
3678
+ until_value: result.until_value ?? null,
3679
+ until_expected_value: result.until_expected_value ?? null,
3680
+ call_count: result.call_count ?? null,
3681
+ max_calls: result.max_calls ?? null,
3682
+ reason: result.reason || result.error || null,
3683
+ }));
3684
+ }
3656
3685
  function sampleProfileSetupSummaryItems(items, limit) {
3657
3686
  if ((items || []).length <= limit) return items || [];
3658
3687
  const firstCount = Math.floor(limit / 2);
@@ -3682,6 +3711,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
3682
3711
  const clickCountValues = successfulClicks
3683
3712
  .map((result) => typeof result.click_count === "number" && Number.isFinite(result.click_count) && result.click_count > 1 ? result.click_count : undefined)
3684
3713
  .filter((value) => value !== undefined);
3714
+ const windowCallUntilReceipts = profileSetupWindowCallUntilReceipts(results);
3715
+ const windowCallUntilCallCounts = windowCallUntilReceipts
3716
+ .map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : undefined)
3717
+ .filter((value) => value !== undefined);
3718
+ const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
3685
3719
  const clickedItems = results
3686
3720
  .filter((result) => result && profileSetupResultAction(result) === "click" && result.ok !== false)
3687
3721
  .map((result) => {
@@ -3724,6 +3758,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
3724
3758
  clicked_truncated: clickedItems.length > clicked.length,
3725
3759
  click_count_action_total: clickCountValues.length,
3726
3760
  click_count_value_total: clickCountValues.reduce((sum, value) => sum + value, 0),
3761
+ window_call_until_total: windowCallUntilReceipts.length,
3762
+ window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
3763
+ window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
3764
+ window_call_until: sampledWindowCallUntilReceipts,
3727
3765
  clicked,
3728
3766
  text_samples: textSamples,
3729
3767
  failed: failed.map((result) => ({
@@ -4656,8 +4694,8 @@ async function setupReadWindowValue(context, path) {
4656
4694
  return { ok: true, value: toJsonValue(current) };
4657
4695
  }, { path });
4658
4696
  }
4659
- async function setupCallWindowFunction(context, path, args) {
4660
- return await context.evaluate(async ({ path, args }) => {
4697
+ async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
4698
+ return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
4661
4699
  const toJsonValue = (value) => {
4662
4700
  if (value === null || value === undefined) return null;
4663
4701
  if (typeof value === "string" || typeof value === "boolean") return value;
@@ -4668,6 +4706,19 @@ async function setupCallWindowFunction(context, path, args) {
4668
4706
  }
4669
4707
  return String(value);
4670
4708
  };
4709
+ const storeWindowReturn = (storePath, value) => {
4710
+ const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
4711
+ if (pathParts[0] === "window") pathParts.shift();
4712
+ if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
4713
+ let target = window;
4714
+ for (let index = 0; index < pathParts.length - 1; index += 1) {
4715
+ const part = pathParts[index];
4716
+ if (target[part] === null || typeof target[part] !== "object") target[part] = {};
4717
+ target = target[part];
4718
+ }
4719
+ target[pathParts[pathParts.length - 1]] = value;
4720
+ return { ok: true, path: pathParts.join(".") };
4721
+ };
4671
4722
  const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
4672
4723
  let parent = window;
4673
4724
  let current = window;
@@ -4678,11 +4729,18 @@ async function setupCallWindowFunction(context, path, args) {
4678
4729
  if (typeof current !== "function") return { ok: false, reason: "missing_function" };
4679
4730
  try {
4680
4731
  const returned = await current.apply(parent, Array.isArray(args) ? args : []);
4681
- return { ok: true, returned: toJsonValue(returned) };
4732
+ const jsonReturned = toJsonValue(returned);
4733
+ const returnedForResult = captureReturn === false ? undefined : jsonReturned;
4734
+ if (storeReturnTo) {
4735
+ const stored = storeWindowReturn(storeReturnTo, jsonReturned);
4736
+ if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
4737
+ return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
4738
+ }
4739
+ return { ok: true, returned: returnedForResult };
4682
4740
  } catch (error) {
4683
4741
  return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
4684
4742
  }
4685
- }, { path, args });
4743
+ }, { path, args, storeReturnTo, captureReturn });
4686
4744
  }
4687
4745
  function setupFrameSelector(action) {
4688
4746
  return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
@@ -5198,10 +5256,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5198
5256
  if (type === "window_call") {
5199
5257
  const path = String(action.path || action.function_path || action.functionPath || "");
5200
5258
  const args = Array.isArray(action.args) ? action.args : [];
5259
+ const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
5201
5260
  if (!path) return { ...base, path, reason: "missing_path" };
5202
5261
  const scope = await setupActionScope(action, timeout);
5203
5262
  if (!scope.ok) return setupScopeFailure(base, scope);
5204
- const result = await setupCallWindowFunction(scope.context, path, args);
5205
5263
  const hasExpectation = setupHasOwn(action, "expect_return")
5206
5264
  || setupHasOwn(action, "expectReturn")
5207
5265
  || setupHasOwn(action, "expected_return")
@@ -5210,9 +5268,13 @@ async function executeSetupAction(action, ordinal, viewport) {
5210
5268
  ? action.expect_return
5211
5269
  : setupHasOwn(action, "expectReturn")
5212
5270
  ? action.expectReturn
5213
- : setupHasOwn(action, "expected_return")
5214
- ? action.expected_return
5215
- : action.expectedReturn;
5271
+ : setupHasOwn(action, "expected_return")
5272
+ ? action.expected_return
5273
+ : action.expectedReturn;
5274
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
5275
+ ? hasExpectation
5276
+ : true;
5277
+ const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
5216
5278
  const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
5217
5279
  return {
5218
5280
  ...base,
@@ -5220,9 +5282,12 @@ async function executeSetupAction(action, ordinal, viewport) {
5220
5282
  ok: Boolean(result.ok && expectationMet),
5221
5283
  path,
5222
5284
  arg_count: args.length,
5223
- returned: setupJsonValue(result.returned),
5285
+ returned: captureReturn ? setupJsonValue(result.returned) : undefined,
5286
+ return_captured: captureReturn,
5224
5287
  expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
5288
+ return_stored_to: result.return_stored_to || storeReturnTo || undefined,
5225
5289
  reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
5290
+ store_reason: result.store_reason || undefined,
5226
5291
  error: result.error || undefined,
5227
5292
  };
5228
5293
  }
@@ -5230,6 +5295,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5230
5295
  const path = String(action.path || action.function_path || action.functionPath || "");
5231
5296
  const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
5232
5297
  const args = Array.isArray(action.args) ? action.args : [];
5298
+ const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
5233
5299
  if (!path) return { ...base, path, reason: "missing_path" };
5234
5300
  if (!untilPath) return { ...base, path, reason: "missing_until_path" };
5235
5301
  const hasUntilExpected = setupHasOwn(action, "until_expected_value")
@@ -5272,6 +5338,9 @@ async function executeSetupAction(action, ordinal, viewport) {
5272
5338
  : setupHasOwn(action, "expected_return")
5273
5339
  ? action.expected_return
5274
5340
  : action.expectedReturn;
5341
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
5342
+ ? hasReturnExpectation
5343
+ : true;
5275
5344
  const scope = await setupActionScope(action, timeout);
5276
5345
  if (!scope.ok) return setupScopeFailure(base, scope);
5277
5346
  const startedAt = Date.now();
@@ -5295,7 +5364,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5295
5364
  };
5296
5365
  }
5297
5366
  while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
5298
- lastCallResult = await setupCallWindowFunction(scope.context, path, args);
5367
+ lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
5299
5368
  callCount += 1;
5300
5369
  if (!lastCallResult.ok) break;
5301
5370
  if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
@@ -5307,8 +5376,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5307
5376
  ok: true,
5308
5377
  path,
5309
5378
  arg_count: args.length,
5310
- returned: setupJsonValue(lastCallResult.returned),
5379
+ returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
5380
+ return_captured: captureReturn,
5311
5381
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
5382
+ return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
5312
5383
  until_path: untilPath,
5313
5384
  until_value: setupJsonValue(lastPredicateResult.value),
5314
5385
  until_expected_value: setupJsonValue(untilExpected),
@@ -5326,8 +5397,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5326
5397
  ...setupScopeEvidence(scope),
5327
5398
  path,
5328
5399
  arg_count: args.length,
5329
- returned: setupJsonValue(lastCallResult?.returned),
5400
+ returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
5401
+ return_captured: captureReturn,
5330
5402
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
5403
+ return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
5331
5404
  until_path: untilPath,
5332
5405
  until_value: setupJsonValue(lastPredicateResult?.value),
5333
5406
  until_expected_value: setupJsonValue(untilExpected),
@@ -5343,6 +5416,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5343
5416
  ? "timeout"
5344
5417
  : "until_condition_not_met",
5345
5418
  error: lastCallResult?.error || undefined,
5419
+ store_reason: lastCallResult?.store_reason || undefined,
5346
5420
  missing_part: lastPredicateResult?.missing_part || undefined,
5347
5421
  };
5348
5422
  }
package/dist/cli.cjs CHANGED
@@ -7669,6 +7669,18 @@ function normalizeSetupAction(input, index) {
7669
7669
  }
7670
7670
  }
7671
7671
  const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
7672
+ const storeReturnTo = stringFromOwn(
7673
+ input,
7674
+ "store_return_to",
7675
+ "storeReturnTo",
7676
+ "save_return_to",
7677
+ "saveReturnTo",
7678
+ "assign_return_to",
7679
+ "assignReturnTo",
7680
+ "return_state_path",
7681
+ "returnStatePath"
7682
+ );
7683
+ 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;
7672
7684
  const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
7673
7685
  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");
7674
7686
  if (type === "window_call_until") {
@@ -7713,6 +7725,8 @@ function normalizeSetupAction(input, index) {
7713
7725
  path: path7,
7714
7726
  args,
7715
7727
  expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
7728
+ store_return_to: storeReturnTo,
7729
+ capture_return: captureReturn,
7716
7730
  until_path: untilPath,
7717
7731
  until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
7718
7732
  max_calls: maxCalls,
@@ -10574,6 +10588,21 @@ function profileSetupScreenshotLabels(results) {
10574
10588
  .map((result) => result.screenshot_label)
10575
10589
  .filter(Boolean);
10576
10590
  }
10591
+ function profileSetupWindowCallUntilReceipts(results) {
10592
+ return (results || [])
10593
+ .filter((result) => result && profileSetupResultAction(result) === "window_call_until")
10594
+ .map((result) => ({
10595
+ ordinal: result.ordinal ?? null,
10596
+ ok: result.ok !== false,
10597
+ path: result.path ?? null,
10598
+ until_path: result.until_path ?? null,
10599
+ until_value: result.until_value ?? null,
10600
+ until_expected_value: result.until_expected_value ?? null,
10601
+ call_count: result.call_count ?? null,
10602
+ max_calls: result.max_calls ?? null,
10603
+ reason: result.reason || result.error || null,
10604
+ }));
10605
+ }
10577
10606
  function sampleProfileSetupSummaryItems(items, limit) {
10578
10607
  if ((items || []).length <= limit) return items || [];
10579
10608
  const firstCount = Math.floor(limit / 2);
@@ -10603,6 +10632,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
10603
10632
  const clickCountValues = successfulClicks
10604
10633
  .map((result) => typeof result.click_count === "number" && Number.isFinite(result.click_count) && result.click_count > 1 ? result.click_count : undefined)
10605
10634
  .filter((value) => value !== undefined);
10635
+ const windowCallUntilReceipts = profileSetupWindowCallUntilReceipts(results);
10636
+ const windowCallUntilCallCounts = windowCallUntilReceipts
10637
+ .map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : undefined)
10638
+ .filter((value) => value !== undefined);
10639
+ const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
10606
10640
  const clickedItems = results
10607
10641
  .filter((result) => result && profileSetupResultAction(result) === "click" && result.ok !== false)
10608
10642
  .map((result) => {
@@ -10645,6 +10679,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
10645
10679
  clicked_truncated: clickedItems.length > clicked.length,
10646
10680
  click_count_action_total: clickCountValues.length,
10647
10681
  click_count_value_total: clickCountValues.reduce((sum, value) => sum + value, 0),
10682
+ window_call_until_total: windowCallUntilReceipts.length,
10683
+ window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
10684
+ window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
10685
+ window_call_until: sampledWindowCallUntilReceipts,
10648
10686
  clicked,
10649
10687
  text_samples: textSamples,
10650
10688
  failed: failed.map((result) => ({
@@ -11577,8 +11615,8 @@ async function setupReadWindowValue(context, path) {
11577
11615
  return { ok: true, value: toJsonValue(current) };
11578
11616
  }, { path });
11579
11617
  }
11580
- async function setupCallWindowFunction(context, path, args) {
11581
- return await context.evaluate(async ({ path, args }) => {
11618
+ async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
11619
+ return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
11582
11620
  const toJsonValue = (value) => {
11583
11621
  if (value === null || value === undefined) return null;
11584
11622
  if (typeof value === "string" || typeof value === "boolean") return value;
@@ -11589,6 +11627,19 @@ async function setupCallWindowFunction(context, path, args) {
11589
11627
  }
11590
11628
  return String(value);
11591
11629
  };
11630
+ const storeWindowReturn = (storePath, value) => {
11631
+ const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
11632
+ if (pathParts[0] === "window") pathParts.shift();
11633
+ if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
11634
+ let target = window;
11635
+ for (let index = 0; index < pathParts.length - 1; index += 1) {
11636
+ const part = pathParts[index];
11637
+ if (target[part] === null || typeof target[part] !== "object") target[part] = {};
11638
+ target = target[part];
11639
+ }
11640
+ target[pathParts[pathParts.length - 1]] = value;
11641
+ return { ok: true, path: pathParts.join(".") };
11642
+ };
11592
11643
  const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
11593
11644
  let parent = window;
11594
11645
  let current = window;
@@ -11599,11 +11650,18 @@ async function setupCallWindowFunction(context, path, args) {
11599
11650
  if (typeof current !== "function") return { ok: false, reason: "missing_function" };
11600
11651
  try {
11601
11652
  const returned = await current.apply(parent, Array.isArray(args) ? args : []);
11602
- return { ok: true, returned: toJsonValue(returned) };
11653
+ const jsonReturned = toJsonValue(returned);
11654
+ const returnedForResult = captureReturn === false ? undefined : jsonReturned;
11655
+ if (storeReturnTo) {
11656
+ const stored = storeWindowReturn(storeReturnTo, jsonReturned);
11657
+ if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
11658
+ return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
11659
+ }
11660
+ return { ok: true, returned: returnedForResult };
11603
11661
  } catch (error) {
11604
11662
  return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
11605
11663
  }
11606
- }, { path, args });
11664
+ }, { path, args, storeReturnTo, captureReturn });
11607
11665
  }
11608
11666
  function setupFrameSelector(action) {
11609
11667
  return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
@@ -12119,10 +12177,10 @@ async function executeSetupAction(action, ordinal, viewport) {
12119
12177
  if (type === "window_call") {
12120
12178
  const path = String(action.path || action.function_path || action.functionPath || "");
12121
12179
  const args = Array.isArray(action.args) ? action.args : [];
12180
+ const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
12122
12181
  if (!path) return { ...base, path, reason: "missing_path" };
12123
12182
  const scope = await setupActionScope(action, timeout);
12124
12183
  if (!scope.ok) return setupScopeFailure(base, scope);
12125
- const result = await setupCallWindowFunction(scope.context, path, args);
12126
12184
  const hasExpectation = setupHasOwn(action, "expect_return")
12127
12185
  || setupHasOwn(action, "expectReturn")
12128
12186
  || setupHasOwn(action, "expected_return")
@@ -12131,9 +12189,13 @@ async function executeSetupAction(action, ordinal, viewport) {
12131
12189
  ? action.expect_return
12132
12190
  : setupHasOwn(action, "expectReturn")
12133
12191
  ? action.expectReturn
12134
- : setupHasOwn(action, "expected_return")
12135
- ? action.expected_return
12136
- : action.expectedReturn;
12192
+ : setupHasOwn(action, "expected_return")
12193
+ ? action.expected_return
12194
+ : action.expectedReturn;
12195
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
12196
+ ? hasExpectation
12197
+ : true;
12198
+ const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
12137
12199
  const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
12138
12200
  return {
12139
12201
  ...base,
@@ -12141,9 +12203,12 @@ async function executeSetupAction(action, ordinal, viewport) {
12141
12203
  ok: Boolean(result.ok && expectationMet),
12142
12204
  path,
12143
12205
  arg_count: args.length,
12144
- returned: setupJsonValue(result.returned),
12206
+ returned: captureReturn ? setupJsonValue(result.returned) : undefined,
12207
+ return_captured: captureReturn,
12145
12208
  expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
12209
+ return_stored_to: result.return_stored_to || storeReturnTo || undefined,
12146
12210
  reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
12211
+ store_reason: result.store_reason || undefined,
12147
12212
  error: result.error || undefined,
12148
12213
  };
12149
12214
  }
@@ -12151,6 +12216,7 @@ async function executeSetupAction(action, ordinal, viewport) {
12151
12216
  const path = String(action.path || action.function_path || action.functionPath || "");
12152
12217
  const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
12153
12218
  const args = Array.isArray(action.args) ? action.args : [];
12219
+ const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
12154
12220
  if (!path) return { ...base, path, reason: "missing_path" };
12155
12221
  if (!untilPath) return { ...base, path, reason: "missing_until_path" };
12156
12222
  const hasUntilExpected = setupHasOwn(action, "until_expected_value")
@@ -12193,6 +12259,9 @@ async function executeSetupAction(action, ordinal, viewport) {
12193
12259
  : setupHasOwn(action, "expected_return")
12194
12260
  ? action.expected_return
12195
12261
  : action.expectedReturn;
12262
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
12263
+ ? hasReturnExpectation
12264
+ : true;
12196
12265
  const scope = await setupActionScope(action, timeout);
12197
12266
  if (!scope.ok) return setupScopeFailure(base, scope);
12198
12267
  const startedAt = Date.now();
@@ -12216,7 +12285,7 @@ async function executeSetupAction(action, ordinal, viewport) {
12216
12285
  };
12217
12286
  }
12218
12287
  while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
12219
- lastCallResult = await setupCallWindowFunction(scope.context, path, args);
12288
+ lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
12220
12289
  callCount += 1;
12221
12290
  if (!lastCallResult.ok) break;
12222
12291
  if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
@@ -12228,8 +12297,10 @@ async function executeSetupAction(action, ordinal, viewport) {
12228
12297
  ok: true,
12229
12298
  path,
12230
12299
  arg_count: args.length,
12231
- returned: setupJsonValue(lastCallResult.returned),
12300
+ returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
12301
+ return_captured: captureReturn,
12232
12302
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
12303
+ return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
12233
12304
  until_path: untilPath,
12234
12305
  until_value: setupJsonValue(lastPredicateResult.value),
12235
12306
  until_expected_value: setupJsonValue(untilExpected),
@@ -12247,8 +12318,10 @@ async function executeSetupAction(action, ordinal, viewport) {
12247
12318
  ...setupScopeEvidence(scope),
12248
12319
  path,
12249
12320
  arg_count: args.length,
12250
- returned: setupJsonValue(lastCallResult?.returned),
12321
+ returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
12322
+ return_captured: captureReturn,
12251
12323
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
12324
+ return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
12252
12325
  until_path: untilPath,
12253
12326
  until_value: setupJsonValue(lastPredicateResult?.value),
12254
12327
  until_expected_value: setupJsonValue(untilExpected),
@@ -12264,6 +12337,7 @@ async function executeSetupAction(action, ordinal, viewport) {
12264
12337
  ? "timeout"
12265
12338
  : "until_condition_not_met",
12266
12339
  error: lastCallResult?.error || undefined,
12340
+ store_reason: lastCallResult?.store_reason || undefined,
12267
12341
  missing_part: lastPredicateResult?.missing_part || undefined,
12268
12342
  };
12269
12343
  }
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  profileStatusExitCode,
13
13
  resolveRiddleProofProfileTargetUrl,
14
14
  resolveRiddleProofProfileTimeoutSec
15
- } from "./chunk-TALHK3NV.js";
15
+ } from "./chunk-DNSJMFK6.js";
16
16
  import {
17
17
  createRiddleApiClient,
18
18
  parseRiddleViewport
package/dist/index.cjs CHANGED
@@ -9465,6 +9465,18 @@ function normalizeSetupAction(input, index) {
9465
9465
  }
9466
9466
  }
9467
9467
  const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
9468
+ const storeReturnTo = stringFromOwn(
9469
+ input,
9470
+ "store_return_to",
9471
+ "storeReturnTo",
9472
+ "save_return_to",
9473
+ "saveReturnTo",
9474
+ "assign_return_to",
9475
+ "assignReturnTo",
9476
+ "return_state_path",
9477
+ "returnStatePath"
9478
+ );
9479
+ 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;
9468
9480
  const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
9469
9481
  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");
9470
9482
  if (type === "window_call_until") {
@@ -9509,6 +9521,8 @@ function normalizeSetupAction(input, index) {
9509
9521
  path: path6,
9510
9522
  args,
9511
9523
  expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
9524
+ store_return_to: storeReturnTo,
9525
+ capture_return: captureReturn,
9512
9526
  until_path: untilPath,
9513
9527
  until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
9514
9528
  max_calls: maxCalls,
@@ -12386,6 +12400,21 @@ function profileSetupScreenshotLabels(results) {
12386
12400
  .map((result) => result.screenshot_label)
12387
12401
  .filter(Boolean);
12388
12402
  }
12403
+ function profileSetupWindowCallUntilReceipts(results) {
12404
+ return (results || [])
12405
+ .filter((result) => result && profileSetupResultAction(result) === "window_call_until")
12406
+ .map((result) => ({
12407
+ ordinal: result.ordinal ?? null,
12408
+ ok: result.ok !== false,
12409
+ path: result.path ?? null,
12410
+ until_path: result.until_path ?? null,
12411
+ until_value: result.until_value ?? null,
12412
+ until_expected_value: result.until_expected_value ?? null,
12413
+ call_count: result.call_count ?? null,
12414
+ max_calls: result.max_calls ?? null,
12415
+ reason: result.reason || result.error || null,
12416
+ }));
12417
+ }
12389
12418
  function sampleProfileSetupSummaryItems(items, limit) {
12390
12419
  if ((items || []).length <= limit) return items || [];
12391
12420
  const firstCount = Math.floor(limit / 2);
@@ -12415,6 +12444,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
12415
12444
  const clickCountValues = successfulClicks
12416
12445
  .map((result) => typeof result.click_count === "number" && Number.isFinite(result.click_count) && result.click_count > 1 ? result.click_count : undefined)
12417
12446
  .filter((value) => value !== undefined);
12447
+ const windowCallUntilReceipts = profileSetupWindowCallUntilReceipts(results);
12448
+ const windowCallUntilCallCounts = windowCallUntilReceipts
12449
+ .map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : undefined)
12450
+ .filter((value) => value !== undefined);
12451
+ const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
12418
12452
  const clickedItems = results
12419
12453
  .filter((result) => result && profileSetupResultAction(result) === "click" && result.ok !== false)
12420
12454
  .map((result) => {
@@ -12457,6 +12491,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
12457
12491
  clicked_truncated: clickedItems.length > clicked.length,
12458
12492
  click_count_action_total: clickCountValues.length,
12459
12493
  click_count_value_total: clickCountValues.reduce((sum, value) => sum + value, 0),
12494
+ window_call_until_total: windowCallUntilReceipts.length,
12495
+ window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
12496
+ window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
12497
+ window_call_until: sampledWindowCallUntilReceipts,
12460
12498
  clicked,
12461
12499
  text_samples: textSamples,
12462
12500
  failed: failed.map((result) => ({
@@ -13389,8 +13427,8 @@ async function setupReadWindowValue(context, path) {
13389
13427
  return { ok: true, value: toJsonValue(current) };
13390
13428
  }, { path });
13391
13429
  }
13392
- async function setupCallWindowFunction(context, path, args) {
13393
- return await context.evaluate(async ({ path, args }) => {
13430
+ async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
13431
+ return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
13394
13432
  const toJsonValue = (value) => {
13395
13433
  if (value === null || value === undefined) return null;
13396
13434
  if (typeof value === "string" || typeof value === "boolean") return value;
@@ -13401,6 +13439,19 @@ async function setupCallWindowFunction(context, path, args) {
13401
13439
  }
13402
13440
  return String(value);
13403
13441
  };
13442
+ const storeWindowReturn = (storePath, value) => {
13443
+ const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
13444
+ if (pathParts[0] === "window") pathParts.shift();
13445
+ if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
13446
+ let target = window;
13447
+ for (let index = 0; index < pathParts.length - 1; index += 1) {
13448
+ const part = pathParts[index];
13449
+ if (target[part] === null || typeof target[part] !== "object") target[part] = {};
13450
+ target = target[part];
13451
+ }
13452
+ target[pathParts[pathParts.length - 1]] = value;
13453
+ return { ok: true, path: pathParts.join(".") };
13454
+ };
13404
13455
  const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
13405
13456
  let parent = window;
13406
13457
  let current = window;
@@ -13411,11 +13462,18 @@ async function setupCallWindowFunction(context, path, args) {
13411
13462
  if (typeof current !== "function") return { ok: false, reason: "missing_function" };
13412
13463
  try {
13413
13464
  const returned = await current.apply(parent, Array.isArray(args) ? args : []);
13414
- return { ok: true, returned: toJsonValue(returned) };
13465
+ const jsonReturned = toJsonValue(returned);
13466
+ const returnedForResult = captureReturn === false ? undefined : jsonReturned;
13467
+ if (storeReturnTo) {
13468
+ const stored = storeWindowReturn(storeReturnTo, jsonReturned);
13469
+ if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
13470
+ return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
13471
+ }
13472
+ return { ok: true, returned: returnedForResult };
13415
13473
  } catch (error) {
13416
13474
  return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
13417
13475
  }
13418
- }, { path, args });
13476
+ }, { path, args, storeReturnTo, captureReturn });
13419
13477
  }
13420
13478
  function setupFrameSelector(action) {
13421
13479
  return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
@@ -13931,10 +13989,10 @@ async function executeSetupAction(action, ordinal, viewport) {
13931
13989
  if (type === "window_call") {
13932
13990
  const path = String(action.path || action.function_path || action.functionPath || "");
13933
13991
  const args = Array.isArray(action.args) ? action.args : [];
13992
+ const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
13934
13993
  if (!path) return { ...base, path, reason: "missing_path" };
13935
13994
  const scope = await setupActionScope(action, timeout);
13936
13995
  if (!scope.ok) return setupScopeFailure(base, scope);
13937
- const result = await setupCallWindowFunction(scope.context, path, args);
13938
13996
  const hasExpectation = setupHasOwn(action, "expect_return")
13939
13997
  || setupHasOwn(action, "expectReturn")
13940
13998
  || setupHasOwn(action, "expected_return")
@@ -13943,9 +14001,13 @@ async function executeSetupAction(action, ordinal, viewport) {
13943
14001
  ? action.expect_return
13944
14002
  : setupHasOwn(action, "expectReturn")
13945
14003
  ? action.expectReturn
13946
- : setupHasOwn(action, "expected_return")
13947
- ? action.expected_return
13948
- : action.expectedReturn;
14004
+ : setupHasOwn(action, "expected_return")
14005
+ ? action.expected_return
14006
+ : action.expectedReturn;
14007
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
14008
+ ? hasExpectation
14009
+ : true;
14010
+ const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
13949
14011
  const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
13950
14012
  return {
13951
14013
  ...base,
@@ -13953,9 +14015,12 @@ async function executeSetupAction(action, ordinal, viewport) {
13953
14015
  ok: Boolean(result.ok && expectationMet),
13954
14016
  path,
13955
14017
  arg_count: args.length,
13956
- returned: setupJsonValue(result.returned),
14018
+ returned: captureReturn ? setupJsonValue(result.returned) : undefined,
14019
+ return_captured: captureReturn,
13957
14020
  expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
14021
+ return_stored_to: result.return_stored_to || storeReturnTo || undefined,
13958
14022
  reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
14023
+ store_reason: result.store_reason || undefined,
13959
14024
  error: result.error || undefined,
13960
14025
  };
13961
14026
  }
@@ -13963,6 +14028,7 @@ async function executeSetupAction(action, ordinal, viewport) {
13963
14028
  const path = String(action.path || action.function_path || action.functionPath || "");
13964
14029
  const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
13965
14030
  const args = Array.isArray(action.args) ? action.args : [];
14031
+ const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
13966
14032
  if (!path) return { ...base, path, reason: "missing_path" };
13967
14033
  if (!untilPath) return { ...base, path, reason: "missing_until_path" };
13968
14034
  const hasUntilExpected = setupHasOwn(action, "until_expected_value")
@@ -14005,6 +14071,9 @@ async function executeSetupAction(action, ordinal, viewport) {
14005
14071
  : setupHasOwn(action, "expected_return")
14006
14072
  ? action.expected_return
14007
14073
  : action.expectedReturn;
14074
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
14075
+ ? hasReturnExpectation
14076
+ : true;
14008
14077
  const scope = await setupActionScope(action, timeout);
14009
14078
  if (!scope.ok) return setupScopeFailure(base, scope);
14010
14079
  const startedAt = Date.now();
@@ -14028,7 +14097,7 @@ async function executeSetupAction(action, ordinal, viewport) {
14028
14097
  };
14029
14098
  }
14030
14099
  while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
14031
- lastCallResult = await setupCallWindowFunction(scope.context, path, args);
14100
+ lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
14032
14101
  callCount += 1;
14033
14102
  if (!lastCallResult.ok) break;
14034
14103
  if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
@@ -14040,8 +14109,10 @@ async function executeSetupAction(action, ordinal, viewport) {
14040
14109
  ok: true,
14041
14110
  path,
14042
14111
  arg_count: args.length,
14043
- returned: setupJsonValue(lastCallResult.returned),
14112
+ returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
14113
+ return_captured: captureReturn,
14044
14114
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
14115
+ return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
14045
14116
  until_path: untilPath,
14046
14117
  until_value: setupJsonValue(lastPredicateResult.value),
14047
14118
  until_expected_value: setupJsonValue(untilExpected),
@@ -14059,8 +14130,10 @@ async function executeSetupAction(action, ordinal, viewport) {
14059
14130
  ...setupScopeEvidence(scope),
14060
14131
  path,
14061
14132
  arg_count: args.length,
14062
- returned: setupJsonValue(lastCallResult?.returned),
14133
+ returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
14134
+ return_captured: captureReturn,
14063
14135
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
14136
+ return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
14064
14137
  until_path: untilPath,
14065
14138
  until_value: setupJsonValue(lastPredicateResult?.value),
14066
14139
  until_expected_value: setupJsonValue(untilExpected),
@@ -14076,6 +14149,7 @@ async function executeSetupAction(action, ordinal, viewport) {
14076
14149
  ? "timeout"
14077
14150
  : "until_condition_not_met",
14078
14151
  error: lastCallResult?.error || undefined,
14152
+ store_reason: lastCallResult?.store_reason || undefined,
14079
14153
  missing_part: lastPredicateResult?.missing_part || undefined,
14080
14154
  };
14081
14155
  }
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ import {
62
62
  resolveRiddleProofProfileTimeoutSec,
63
63
  slugifyRiddleProofProfileName,
64
64
  summarizeRiddleProofProfileResult
65
- } from "./chunk-TALHK3NV.js";
65
+ } from "./chunk-DNSJMFK6.js";
66
66
  import {
67
67
  DEFAULT_RIDDLE_API_BASE_URL,
68
68
  DEFAULT_RIDDLE_API_KEY_FILE,
package/dist/profile.cjs CHANGED
@@ -779,6 +779,18 @@ function normalizeSetupAction(input, index) {
779
779
  }
780
780
  }
781
781
  const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
782
+ const storeReturnTo = stringFromOwn(
783
+ input,
784
+ "store_return_to",
785
+ "storeReturnTo",
786
+ "save_return_to",
787
+ "saveReturnTo",
788
+ "assign_return_to",
789
+ "assignReturnTo",
790
+ "return_state_path",
791
+ "returnStatePath"
792
+ );
793
+ 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;
782
794
  const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
783
795
  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");
784
796
  if (type === "window_call_until") {
@@ -823,6 +835,8 @@ function normalizeSetupAction(input, index) {
823
835
  path,
824
836
  args,
825
837
  expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
838
+ store_return_to: storeReturnTo,
839
+ capture_return: captureReturn,
826
840
  until_path: untilPath,
827
841
  until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
828
842
  max_calls: maxCalls,
@@ -3700,6 +3714,21 @@ function profileSetupScreenshotLabels(results) {
3700
3714
  .map((result) => result.screenshot_label)
3701
3715
  .filter(Boolean);
3702
3716
  }
3717
+ function profileSetupWindowCallUntilReceipts(results) {
3718
+ return (results || [])
3719
+ .filter((result) => result && profileSetupResultAction(result) === "window_call_until")
3720
+ .map((result) => ({
3721
+ ordinal: result.ordinal ?? null,
3722
+ ok: result.ok !== false,
3723
+ path: result.path ?? null,
3724
+ until_path: result.until_path ?? null,
3725
+ until_value: result.until_value ?? null,
3726
+ until_expected_value: result.until_expected_value ?? null,
3727
+ call_count: result.call_count ?? null,
3728
+ max_calls: result.max_calls ?? null,
3729
+ reason: result.reason || result.error || null,
3730
+ }));
3731
+ }
3703
3732
  function sampleProfileSetupSummaryItems(items, limit) {
3704
3733
  if ((items || []).length <= limit) return items || [];
3705
3734
  const firstCount = Math.floor(limit / 2);
@@ -3729,6 +3758,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
3729
3758
  const clickCountValues = successfulClicks
3730
3759
  .map((result) => typeof result.click_count === "number" && Number.isFinite(result.click_count) && result.click_count > 1 ? result.click_count : undefined)
3731
3760
  .filter((value) => value !== undefined);
3761
+ const windowCallUntilReceipts = profileSetupWindowCallUntilReceipts(results);
3762
+ const windowCallUntilCallCounts = windowCallUntilReceipts
3763
+ .map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : undefined)
3764
+ .filter((value) => value !== undefined);
3765
+ const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
3732
3766
  const clickedItems = results
3733
3767
  .filter((result) => result && profileSetupResultAction(result) === "click" && result.ok !== false)
3734
3768
  .map((result) => {
@@ -3771,6 +3805,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
3771
3805
  clicked_truncated: clickedItems.length > clicked.length,
3772
3806
  click_count_action_total: clickCountValues.length,
3773
3807
  click_count_value_total: clickCountValues.reduce((sum, value) => sum + value, 0),
3808
+ window_call_until_total: windowCallUntilReceipts.length,
3809
+ window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
3810
+ window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
3811
+ window_call_until: sampledWindowCallUntilReceipts,
3774
3812
  clicked,
3775
3813
  text_samples: textSamples,
3776
3814
  failed: failed.map((result) => ({
@@ -4703,8 +4741,8 @@ async function setupReadWindowValue(context, path) {
4703
4741
  return { ok: true, value: toJsonValue(current) };
4704
4742
  }, { path });
4705
4743
  }
4706
- async function setupCallWindowFunction(context, path, args) {
4707
- return await context.evaluate(async ({ path, args }) => {
4744
+ async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
4745
+ return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
4708
4746
  const toJsonValue = (value) => {
4709
4747
  if (value === null || value === undefined) return null;
4710
4748
  if (typeof value === "string" || typeof value === "boolean") return value;
@@ -4715,6 +4753,19 @@ async function setupCallWindowFunction(context, path, args) {
4715
4753
  }
4716
4754
  return String(value);
4717
4755
  };
4756
+ const storeWindowReturn = (storePath, value) => {
4757
+ const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
4758
+ if (pathParts[0] === "window") pathParts.shift();
4759
+ if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
4760
+ let target = window;
4761
+ for (let index = 0; index < pathParts.length - 1; index += 1) {
4762
+ const part = pathParts[index];
4763
+ if (target[part] === null || typeof target[part] !== "object") target[part] = {};
4764
+ target = target[part];
4765
+ }
4766
+ target[pathParts[pathParts.length - 1]] = value;
4767
+ return { ok: true, path: pathParts.join(".") };
4768
+ };
4718
4769
  const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
4719
4770
  let parent = window;
4720
4771
  let current = window;
@@ -4725,11 +4776,18 @@ async function setupCallWindowFunction(context, path, args) {
4725
4776
  if (typeof current !== "function") return { ok: false, reason: "missing_function" };
4726
4777
  try {
4727
4778
  const returned = await current.apply(parent, Array.isArray(args) ? args : []);
4728
- return { ok: true, returned: toJsonValue(returned) };
4779
+ const jsonReturned = toJsonValue(returned);
4780
+ const returnedForResult = captureReturn === false ? undefined : jsonReturned;
4781
+ if (storeReturnTo) {
4782
+ const stored = storeWindowReturn(storeReturnTo, jsonReturned);
4783
+ if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
4784
+ return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
4785
+ }
4786
+ return { ok: true, returned: returnedForResult };
4729
4787
  } catch (error) {
4730
4788
  return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
4731
4789
  }
4732
- }, { path, args });
4790
+ }, { path, args, storeReturnTo, captureReturn });
4733
4791
  }
4734
4792
  function setupFrameSelector(action) {
4735
4793
  return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
@@ -5245,10 +5303,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5245
5303
  if (type === "window_call") {
5246
5304
  const path = String(action.path || action.function_path || action.functionPath || "");
5247
5305
  const args = Array.isArray(action.args) ? action.args : [];
5306
+ const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
5248
5307
  if (!path) return { ...base, path, reason: "missing_path" };
5249
5308
  const scope = await setupActionScope(action, timeout);
5250
5309
  if (!scope.ok) return setupScopeFailure(base, scope);
5251
- const result = await setupCallWindowFunction(scope.context, path, args);
5252
5310
  const hasExpectation = setupHasOwn(action, "expect_return")
5253
5311
  || setupHasOwn(action, "expectReturn")
5254
5312
  || setupHasOwn(action, "expected_return")
@@ -5257,9 +5315,13 @@ async function executeSetupAction(action, ordinal, viewport) {
5257
5315
  ? action.expect_return
5258
5316
  : setupHasOwn(action, "expectReturn")
5259
5317
  ? action.expectReturn
5260
- : setupHasOwn(action, "expected_return")
5261
- ? action.expected_return
5262
- : action.expectedReturn;
5318
+ : setupHasOwn(action, "expected_return")
5319
+ ? action.expected_return
5320
+ : action.expectedReturn;
5321
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
5322
+ ? hasExpectation
5323
+ : true;
5324
+ const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
5263
5325
  const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
5264
5326
  return {
5265
5327
  ...base,
@@ -5267,9 +5329,12 @@ async function executeSetupAction(action, ordinal, viewport) {
5267
5329
  ok: Boolean(result.ok && expectationMet),
5268
5330
  path,
5269
5331
  arg_count: args.length,
5270
- returned: setupJsonValue(result.returned),
5332
+ returned: captureReturn ? setupJsonValue(result.returned) : undefined,
5333
+ return_captured: captureReturn,
5271
5334
  expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
5335
+ return_stored_to: result.return_stored_to || storeReturnTo || undefined,
5272
5336
  reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
5337
+ store_reason: result.store_reason || undefined,
5273
5338
  error: result.error || undefined,
5274
5339
  };
5275
5340
  }
@@ -5277,6 +5342,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5277
5342
  const path = String(action.path || action.function_path || action.functionPath || "");
5278
5343
  const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
5279
5344
  const args = Array.isArray(action.args) ? action.args : [];
5345
+ const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
5280
5346
  if (!path) return { ...base, path, reason: "missing_path" };
5281
5347
  if (!untilPath) return { ...base, path, reason: "missing_until_path" };
5282
5348
  const hasUntilExpected = setupHasOwn(action, "until_expected_value")
@@ -5319,6 +5385,9 @@ async function executeSetupAction(action, ordinal, viewport) {
5319
5385
  : setupHasOwn(action, "expected_return")
5320
5386
  ? action.expected_return
5321
5387
  : action.expectedReturn;
5388
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
5389
+ ? hasReturnExpectation
5390
+ : true;
5322
5391
  const scope = await setupActionScope(action, timeout);
5323
5392
  if (!scope.ok) return setupScopeFailure(base, scope);
5324
5393
  const startedAt = Date.now();
@@ -5342,7 +5411,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5342
5411
  };
5343
5412
  }
5344
5413
  while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
5345
- lastCallResult = await setupCallWindowFunction(scope.context, path, args);
5414
+ lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
5346
5415
  callCount += 1;
5347
5416
  if (!lastCallResult.ok) break;
5348
5417
  if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
@@ -5354,8 +5423,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5354
5423
  ok: true,
5355
5424
  path,
5356
5425
  arg_count: args.length,
5357
- returned: setupJsonValue(lastCallResult.returned),
5426
+ returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
5427
+ return_captured: captureReturn,
5358
5428
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
5429
+ return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
5359
5430
  until_path: untilPath,
5360
5431
  until_value: setupJsonValue(lastPredicateResult.value),
5361
5432
  until_expected_value: setupJsonValue(untilExpected),
@@ -5373,8 +5444,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5373
5444
  ...setupScopeEvidence(scope),
5374
5445
  path,
5375
5446
  arg_count: args.length,
5376
- returned: setupJsonValue(lastCallResult?.returned),
5447
+ returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
5448
+ return_captured: captureReturn,
5377
5449
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
5450
+ return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
5378
5451
  until_path: untilPath,
5379
5452
  until_value: setupJsonValue(lastPredicateResult?.value),
5380
5453
  until_expected_value: setupJsonValue(untilExpected),
@@ -5390,6 +5463,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5390
5463
  ? "timeout"
5391
5464
  : "until_condition_not_met",
5392
5465
  error: lastCallResult?.error || undefined,
5466
+ store_reason: lastCallResult?.store_reason || undefined,
5393
5467
  missing_part: lastPredicateResult?.missing_part || undefined,
5394
5468
  };
5395
5469
  }
@@ -129,6 +129,8 @@ interface RiddleProofProfileSetupAction {
129
129
  path?: string;
130
130
  args?: JsonValue[];
131
131
  expect_return?: JsonValue;
132
+ store_return_to?: string;
133
+ capture_return?: boolean;
132
134
  until_path?: string;
133
135
  until_expected_value?: JsonValue;
134
136
  max_calls?: number;
package/dist/profile.d.ts CHANGED
@@ -129,6 +129,8 @@ interface RiddleProofProfileSetupAction {
129
129
  path?: string;
130
130
  args?: JsonValue[];
131
131
  expect_return?: JsonValue;
132
+ store_return_to?: string;
133
+ capture_return?: boolean;
132
134
  until_path?: string;
133
135
  until_expected_value?: JsonValue;
134
136
  max_calls?: number;
package/dist/profile.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  resolveRiddleProofProfileTimeoutSec,
24
24
  slugifyRiddleProofProfileName,
25
25
  summarizeRiddleProofProfileResult
26
- } from "./chunk-TALHK3NV.js";
26
+ } from "./chunk-DNSJMFK6.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.134",
3
+ "version": "0.7.136",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",