@riddledc/riddle-proof 0.7.135 → 0.7.137

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.
@@ -465,6 +465,21 @@ function profileSetupWindowCallUntilReceipts(results) {
465
465
  reason: result.reason ?? result.error ?? null
466
466
  }));
467
467
  }
468
+ function profileSetupWindowCallReceipts(results) {
469
+ return results.filter((result) => profileSetupResultAction(result) === "window_call").map((result) => {
470
+ const receipt = {
471
+ ordinal: result.ordinal ?? null,
472
+ ok: result.ok !== false,
473
+ path: result.path ?? null,
474
+ return_captured: result.return_captured ?? null,
475
+ return_stored_to: result.return_stored_to ?? null,
476
+ reason: result.reason ?? result.error ?? result.store_reason ?? null
477
+ };
478
+ if (result.returned !== void 0) receipt.returned = result.returned;
479
+ if (result.expected_return !== void 0) receipt.expected_return = result.expected_return;
480
+ return receipt;
481
+ });
482
+ }
468
483
  function sampleProfileSetupSummaryItems(items, limit) {
469
484
  if (items.length <= limit) return items;
470
485
  const firstCount = Math.floor(limit / 2);
@@ -493,6 +508,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
493
508
  const windowCallUntilReceipts = profileSetupWindowCallUntilReceipts(results);
494
509
  const windowCallUntilCallCounts = windowCallUntilReceipts.map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : void 0).filter((value) => value !== void 0);
495
510
  const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
511
+ const windowCallReceipts = profileSetupWindowCallReceipts(results);
512
+ const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
513
+ const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
514
+ const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
496
515
  const clickedItems = results.filter((result) => profileSetupResultAction(result) === "click" && result.ok !== false).map((result) => {
497
516
  const clickCount = typeof result.click_count === "number" && Number.isFinite(result.click_count) && result.click_count > 1 ? result.click_count : void 0;
498
517
  return {
@@ -529,6 +548,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
529
548
  window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
530
549
  window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
531
550
  window_call_until: sampledWindowCallUntilReceipts,
551
+ window_call_total: windowCallReceipts.length,
552
+ window_call_stored_total: windowCallStoredTotal,
553
+ window_call_captured_total: windowCallCapturedTotal,
554
+ window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
555
+ window_call: sampledWindowCallReceipts,
532
556
  clicked,
533
557
  text_samples,
534
558
  failed: failed.map((result) => ({
@@ -732,6 +756,18 @@ function normalizeSetupAction(input, index) {
732
756
  }
733
757
  }
734
758
  const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
759
+ const storeReturnTo = stringFromOwn(
760
+ input,
761
+ "store_return_to",
762
+ "storeReturnTo",
763
+ "save_return_to",
764
+ "saveReturnTo",
765
+ "assign_return_to",
766
+ "assignReturnTo",
767
+ "return_state_path",
768
+ "returnStatePath"
769
+ );
770
+ 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
771
  const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
736
772
  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
773
  if (type === "window_call_until") {
@@ -776,6 +812,8 @@ function normalizeSetupAction(input, index) {
776
812
  path,
777
813
  args,
778
814
  expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
815
+ store_return_to: storeReturnTo,
816
+ capture_return: captureReturn,
779
817
  until_path: untilPath,
780
818
  until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
781
819
  max_calls: maxCalls,
@@ -3668,6 +3706,23 @@ function profileSetupWindowCallUntilReceipts(results) {
3668
3706
  reason: result.reason || result.error || null,
3669
3707
  }));
3670
3708
  }
3709
+ function profileSetupWindowCallReceipts(results) {
3710
+ return (results || [])
3711
+ .filter((result) => result && profileSetupResultAction(result) === "window_call")
3712
+ .map((result) => {
3713
+ const receipt = {
3714
+ ordinal: result.ordinal ?? null,
3715
+ ok: result.ok !== false,
3716
+ path: result.path ?? null,
3717
+ return_captured: result.return_captured ?? null,
3718
+ return_stored_to: result.return_stored_to ?? null,
3719
+ reason: result.reason || result.error || result.store_reason || null,
3720
+ };
3721
+ if (result.returned !== undefined) receipt.returned = result.returned;
3722
+ if (result.expected_return !== undefined) receipt.expected_return = result.expected_return;
3723
+ return receipt;
3724
+ });
3725
+ }
3671
3726
  function sampleProfileSetupSummaryItems(items, limit) {
3672
3727
  if ((items || []).length <= limit) return items || [];
3673
3728
  const firstCount = Math.floor(limit / 2);
@@ -3702,6 +3757,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
3702
3757
  .map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : undefined)
3703
3758
  .filter((value) => value !== undefined);
3704
3759
  const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
3760
+ const windowCallReceipts = profileSetupWindowCallReceipts(results);
3761
+ const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
3762
+ const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
3763
+ const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
3705
3764
  const clickedItems = results
3706
3765
  .filter((result) => result && profileSetupResultAction(result) === "click" && result.ok !== false)
3707
3766
  .map((result) => {
@@ -3748,6 +3807,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
3748
3807
  window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
3749
3808
  window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
3750
3809
  window_call_until: sampledWindowCallUntilReceipts,
3810
+ window_call_total: windowCallReceipts.length,
3811
+ window_call_stored_total: windowCallStoredTotal,
3812
+ window_call_captured_total: windowCallCapturedTotal,
3813
+ window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
3814
+ window_call: sampledWindowCallReceipts,
3751
3815
  clicked,
3752
3816
  text_samples: textSamples,
3753
3817
  failed: failed.map((result) => ({
@@ -4680,8 +4744,8 @@ async function setupReadWindowValue(context, path) {
4680
4744
  return { ok: true, value: toJsonValue(current) };
4681
4745
  }, { path });
4682
4746
  }
4683
- async function setupCallWindowFunction(context, path, args) {
4684
- return await context.evaluate(async ({ path, args }) => {
4747
+ async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
4748
+ return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
4685
4749
  const toJsonValue = (value) => {
4686
4750
  if (value === null || value === undefined) return null;
4687
4751
  if (typeof value === "string" || typeof value === "boolean") return value;
@@ -4692,6 +4756,19 @@ async function setupCallWindowFunction(context, path, args) {
4692
4756
  }
4693
4757
  return String(value);
4694
4758
  };
4759
+ const storeWindowReturn = (storePath, value) => {
4760
+ const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
4761
+ if (pathParts[0] === "window") pathParts.shift();
4762
+ if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
4763
+ let target = window;
4764
+ for (let index = 0; index < pathParts.length - 1; index += 1) {
4765
+ const part = pathParts[index];
4766
+ if (target[part] === null || typeof target[part] !== "object") target[part] = {};
4767
+ target = target[part];
4768
+ }
4769
+ target[pathParts[pathParts.length - 1]] = value;
4770
+ return { ok: true, path: pathParts.join(".") };
4771
+ };
4695
4772
  const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
4696
4773
  let parent = window;
4697
4774
  let current = window;
@@ -4702,11 +4779,18 @@ async function setupCallWindowFunction(context, path, args) {
4702
4779
  if (typeof current !== "function") return { ok: false, reason: "missing_function" };
4703
4780
  try {
4704
4781
  const returned = await current.apply(parent, Array.isArray(args) ? args : []);
4705
- return { ok: true, returned: toJsonValue(returned) };
4782
+ const jsonReturned = toJsonValue(returned);
4783
+ const returnedForResult = captureReturn === false ? undefined : jsonReturned;
4784
+ if (storeReturnTo) {
4785
+ const stored = storeWindowReturn(storeReturnTo, jsonReturned);
4786
+ if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
4787
+ return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
4788
+ }
4789
+ return { ok: true, returned: returnedForResult };
4706
4790
  } catch (error) {
4707
4791
  return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
4708
4792
  }
4709
- }, { path, args });
4793
+ }, { path, args, storeReturnTo, captureReturn });
4710
4794
  }
4711
4795
  function setupFrameSelector(action) {
4712
4796
  return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
@@ -5222,10 +5306,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5222
5306
  if (type === "window_call") {
5223
5307
  const path = String(action.path || action.function_path || action.functionPath || "");
5224
5308
  const args = Array.isArray(action.args) ? action.args : [];
5309
+ 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();
5225
5310
  if (!path) return { ...base, path, reason: "missing_path" };
5226
5311
  const scope = await setupActionScope(action, timeout);
5227
5312
  if (!scope.ok) return setupScopeFailure(base, scope);
5228
- const result = await setupCallWindowFunction(scope.context, path, args);
5229
5313
  const hasExpectation = setupHasOwn(action, "expect_return")
5230
5314
  || setupHasOwn(action, "expectReturn")
5231
5315
  || setupHasOwn(action, "expected_return")
@@ -5234,9 +5318,13 @@ async function executeSetupAction(action, ordinal, viewport) {
5234
5318
  ? action.expect_return
5235
5319
  : setupHasOwn(action, "expectReturn")
5236
5320
  ? action.expectReturn
5237
- : setupHasOwn(action, "expected_return")
5238
- ? action.expected_return
5239
- : action.expectedReturn;
5321
+ : setupHasOwn(action, "expected_return")
5322
+ ? action.expected_return
5323
+ : action.expectedReturn;
5324
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
5325
+ ? hasExpectation
5326
+ : true;
5327
+ const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
5240
5328
  const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
5241
5329
  return {
5242
5330
  ...base,
@@ -5244,9 +5332,12 @@ async function executeSetupAction(action, ordinal, viewport) {
5244
5332
  ok: Boolean(result.ok && expectationMet),
5245
5333
  path,
5246
5334
  arg_count: args.length,
5247
- returned: setupJsonValue(result.returned),
5335
+ returned: captureReturn ? setupJsonValue(result.returned) : undefined,
5336
+ return_captured: captureReturn,
5248
5337
  expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
5338
+ return_stored_to: result.return_stored_to || storeReturnTo || undefined,
5249
5339
  reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
5340
+ store_reason: result.store_reason || undefined,
5250
5341
  error: result.error || undefined,
5251
5342
  };
5252
5343
  }
@@ -5254,6 +5345,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5254
5345
  const path = String(action.path || action.function_path || action.functionPath || "");
5255
5346
  const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
5256
5347
  const args = Array.isArray(action.args) ? action.args : [];
5348
+ 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();
5257
5349
  if (!path) return { ...base, path, reason: "missing_path" };
5258
5350
  if (!untilPath) return { ...base, path, reason: "missing_until_path" };
5259
5351
  const hasUntilExpected = setupHasOwn(action, "until_expected_value")
@@ -5296,6 +5388,9 @@ async function executeSetupAction(action, ordinal, viewport) {
5296
5388
  : setupHasOwn(action, "expected_return")
5297
5389
  ? action.expected_return
5298
5390
  : action.expectedReturn;
5391
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
5392
+ ? hasReturnExpectation
5393
+ : true;
5299
5394
  const scope = await setupActionScope(action, timeout);
5300
5395
  if (!scope.ok) return setupScopeFailure(base, scope);
5301
5396
  const startedAt = Date.now();
@@ -5319,7 +5414,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5319
5414
  };
5320
5415
  }
5321
5416
  while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
5322
- lastCallResult = await setupCallWindowFunction(scope.context, path, args);
5417
+ lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
5323
5418
  callCount += 1;
5324
5419
  if (!lastCallResult.ok) break;
5325
5420
  if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
@@ -5331,8 +5426,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5331
5426
  ok: true,
5332
5427
  path,
5333
5428
  arg_count: args.length,
5334
- returned: setupJsonValue(lastCallResult.returned),
5429
+ returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
5430
+ return_captured: captureReturn,
5335
5431
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
5432
+ return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
5336
5433
  until_path: untilPath,
5337
5434
  until_value: setupJsonValue(lastPredicateResult.value),
5338
5435
  until_expected_value: setupJsonValue(untilExpected),
@@ -5350,8 +5447,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5350
5447
  ...setupScopeEvidence(scope),
5351
5448
  path,
5352
5449
  arg_count: args.length,
5353
- returned: setupJsonValue(lastCallResult?.returned),
5450
+ returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
5451
+ return_captured: captureReturn,
5354
5452
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
5453
+ return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
5355
5454
  until_path: untilPath,
5356
5455
  until_value: setupJsonValue(lastPredicateResult?.value),
5357
5456
  until_expected_value: setupJsonValue(untilExpected),
@@ -5367,6 +5466,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5367
5466
  ? "timeout"
5368
5467
  : "until_condition_not_met",
5369
5468
  error: lastCallResult?.error || undefined,
5469
+ store_reason: lastCallResult?.store_reason || undefined,
5370
5470
  missing_part: lastPredicateResult?.missing_part || undefined,
5371
5471
  };
5372
5472
  }
package/dist/cli.cjs CHANGED
@@ -7402,6 +7402,21 @@ function profileSetupWindowCallUntilReceipts(results) {
7402
7402
  reason: result.reason ?? result.error ?? null
7403
7403
  }));
7404
7404
  }
7405
+ function profileSetupWindowCallReceipts(results) {
7406
+ return results.filter((result) => profileSetupResultAction(result) === "window_call").map((result) => {
7407
+ const receipt = {
7408
+ ordinal: result.ordinal ?? null,
7409
+ ok: result.ok !== false,
7410
+ path: result.path ?? null,
7411
+ return_captured: result.return_captured ?? null,
7412
+ return_stored_to: result.return_stored_to ?? null,
7413
+ reason: result.reason ?? result.error ?? result.store_reason ?? null
7414
+ };
7415
+ if (result.returned !== void 0) receipt.returned = result.returned;
7416
+ if (result.expected_return !== void 0) receipt.expected_return = result.expected_return;
7417
+ return receipt;
7418
+ });
7419
+ }
7405
7420
  function sampleProfileSetupSummaryItems(items, limit) {
7406
7421
  if (items.length <= limit) return items;
7407
7422
  const firstCount = Math.floor(limit / 2);
@@ -7430,6 +7445,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
7430
7445
  const windowCallUntilReceipts = profileSetupWindowCallUntilReceipts(results);
7431
7446
  const windowCallUntilCallCounts = windowCallUntilReceipts.map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : void 0).filter((value) => value !== void 0);
7432
7447
  const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
7448
+ const windowCallReceipts = profileSetupWindowCallReceipts(results);
7449
+ const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
7450
+ const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
7451
+ const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
7433
7452
  const clickedItems = results.filter((result) => profileSetupResultAction(result) === "click" && result.ok !== false).map((result) => {
7434
7453
  const clickCount = typeof result.click_count === "number" && Number.isFinite(result.click_count) && result.click_count > 1 ? result.click_count : void 0;
7435
7454
  return {
@@ -7466,6 +7485,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
7466
7485
  window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
7467
7486
  window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
7468
7487
  window_call_until: sampledWindowCallUntilReceipts,
7488
+ window_call_total: windowCallReceipts.length,
7489
+ window_call_stored_total: windowCallStoredTotal,
7490
+ window_call_captured_total: windowCallCapturedTotal,
7491
+ window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
7492
+ window_call: sampledWindowCallReceipts,
7469
7493
  clicked,
7470
7494
  text_samples,
7471
7495
  failed: failed.map((result) => ({
@@ -7669,6 +7693,18 @@ function normalizeSetupAction(input, index) {
7669
7693
  }
7670
7694
  }
7671
7695
  const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
7696
+ const storeReturnTo = stringFromOwn(
7697
+ input,
7698
+ "store_return_to",
7699
+ "storeReturnTo",
7700
+ "save_return_to",
7701
+ "saveReturnTo",
7702
+ "assign_return_to",
7703
+ "assignReturnTo",
7704
+ "return_state_path",
7705
+ "returnStatePath"
7706
+ );
7707
+ 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
7708
  const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
7673
7709
  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
7710
  if (type === "window_call_until") {
@@ -7713,6 +7749,8 @@ function normalizeSetupAction(input, index) {
7713
7749
  path: path7,
7714
7750
  args,
7715
7751
  expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
7752
+ store_return_to: storeReturnTo,
7753
+ capture_return: captureReturn,
7716
7754
  until_path: untilPath,
7717
7755
  until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
7718
7756
  max_calls: maxCalls,
@@ -10589,6 +10627,23 @@ function profileSetupWindowCallUntilReceipts(results) {
10589
10627
  reason: result.reason || result.error || null,
10590
10628
  }));
10591
10629
  }
10630
+ function profileSetupWindowCallReceipts(results) {
10631
+ return (results || [])
10632
+ .filter((result) => result && profileSetupResultAction(result) === "window_call")
10633
+ .map((result) => {
10634
+ const receipt = {
10635
+ ordinal: result.ordinal ?? null,
10636
+ ok: result.ok !== false,
10637
+ path: result.path ?? null,
10638
+ return_captured: result.return_captured ?? null,
10639
+ return_stored_to: result.return_stored_to ?? null,
10640
+ reason: result.reason || result.error || result.store_reason || null,
10641
+ };
10642
+ if (result.returned !== undefined) receipt.returned = result.returned;
10643
+ if (result.expected_return !== undefined) receipt.expected_return = result.expected_return;
10644
+ return receipt;
10645
+ });
10646
+ }
10592
10647
  function sampleProfileSetupSummaryItems(items, limit) {
10593
10648
  if ((items || []).length <= limit) return items || [];
10594
10649
  const firstCount = Math.floor(limit / 2);
@@ -10623,6 +10678,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
10623
10678
  .map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : undefined)
10624
10679
  .filter((value) => value !== undefined);
10625
10680
  const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
10681
+ const windowCallReceipts = profileSetupWindowCallReceipts(results);
10682
+ const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
10683
+ const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
10684
+ const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
10626
10685
  const clickedItems = results
10627
10686
  .filter((result) => result && profileSetupResultAction(result) === "click" && result.ok !== false)
10628
10687
  .map((result) => {
@@ -10669,6 +10728,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
10669
10728
  window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
10670
10729
  window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
10671
10730
  window_call_until: sampledWindowCallUntilReceipts,
10731
+ window_call_total: windowCallReceipts.length,
10732
+ window_call_stored_total: windowCallStoredTotal,
10733
+ window_call_captured_total: windowCallCapturedTotal,
10734
+ window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
10735
+ window_call: sampledWindowCallReceipts,
10672
10736
  clicked,
10673
10737
  text_samples: textSamples,
10674
10738
  failed: failed.map((result) => ({
@@ -11601,8 +11665,8 @@ async function setupReadWindowValue(context, path) {
11601
11665
  return { ok: true, value: toJsonValue(current) };
11602
11666
  }, { path });
11603
11667
  }
11604
- async function setupCallWindowFunction(context, path, args) {
11605
- return await context.evaluate(async ({ path, args }) => {
11668
+ async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
11669
+ return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
11606
11670
  const toJsonValue = (value) => {
11607
11671
  if (value === null || value === undefined) return null;
11608
11672
  if (typeof value === "string" || typeof value === "boolean") return value;
@@ -11613,6 +11677,19 @@ async function setupCallWindowFunction(context, path, args) {
11613
11677
  }
11614
11678
  return String(value);
11615
11679
  };
11680
+ const storeWindowReturn = (storePath, value) => {
11681
+ const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
11682
+ if (pathParts[0] === "window") pathParts.shift();
11683
+ if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
11684
+ let target = window;
11685
+ for (let index = 0; index < pathParts.length - 1; index += 1) {
11686
+ const part = pathParts[index];
11687
+ if (target[part] === null || typeof target[part] !== "object") target[part] = {};
11688
+ target = target[part];
11689
+ }
11690
+ target[pathParts[pathParts.length - 1]] = value;
11691
+ return { ok: true, path: pathParts.join(".") };
11692
+ };
11616
11693
  const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
11617
11694
  let parent = window;
11618
11695
  let current = window;
@@ -11623,11 +11700,18 @@ async function setupCallWindowFunction(context, path, args) {
11623
11700
  if (typeof current !== "function") return { ok: false, reason: "missing_function" };
11624
11701
  try {
11625
11702
  const returned = await current.apply(parent, Array.isArray(args) ? args : []);
11626
- return { ok: true, returned: toJsonValue(returned) };
11703
+ const jsonReturned = toJsonValue(returned);
11704
+ const returnedForResult = captureReturn === false ? undefined : jsonReturned;
11705
+ if (storeReturnTo) {
11706
+ const stored = storeWindowReturn(storeReturnTo, jsonReturned);
11707
+ if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
11708
+ return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
11709
+ }
11710
+ return { ok: true, returned: returnedForResult };
11627
11711
  } catch (error) {
11628
11712
  return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
11629
11713
  }
11630
- }, { path, args });
11714
+ }, { path, args, storeReturnTo, captureReturn });
11631
11715
  }
11632
11716
  function setupFrameSelector(action) {
11633
11717
  return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
@@ -12143,10 +12227,10 @@ async function executeSetupAction(action, ordinal, viewport) {
12143
12227
  if (type === "window_call") {
12144
12228
  const path = String(action.path || action.function_path || action.functionPath || "");
12145
12229
  const args = Array.isArray(action.args) ? action.args : [];
12230
+ 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();
12146
12231
  if (!path) return { ...base, path, reason: "missing_path" };
12147
12232
  const scope = await setupActionScope(action, timeout);
12148
12233
  if (!scope.ok) return setupScopeFailure(base, scope);
12149
- const result = await setupCallWindowFunction(scope.context, path, args);
12150
12234
  const hasExpectation = setupHasOwn(action, "expect_return")
12151
12235
  || setupHasOwn(action, "expectReturn")
12152
12236
  || setupHasOwn(action, "expected_return")
@@ -12155,9 +12239,13 @@ async function executeSetupAction(action, ordinal, viewport) {
12155
12239
  ? action.expect_return
12156
12240
  : setupHasOwn(action, "expectReturn")
12157
12241
  ? action.expectReturn
12158
- : setupHasOwn(action, "expected_return")
12159
- ? action.expected_return
12160
- : action.expectedReturn;
12242
+ : setupHasOwn(action, "expected_return")
12243
+ ? action.expected_return
12244
+ : action.expectedReturn;
12245
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
12246
+ ? hasExpectation
12247
+ : true;
12248
+ const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
12161
12249
  const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
12162
12250
  return {
12163
12251
  ...base,
@@ -12165,9 +12253,12 @@ async function executeSetupAction(action, ordinal, viewport) {
12165
12253
  ok: Boolean(result.ok && expectationMet),
12166
12254
  path,
12167
12255
  arg_count: args.length,
12168
- returned: setupJsonValue(result.returned),
12256
+ returned: captureReturn ? setupJsonValue(result.returned) : undefined,
12257
+ return_captured: captureReturn,
12169
12258
  expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
12259
+ return_stored_to: result.return_stored_to || storeReturnTo || undefined,
12170
12260
  reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
12261
+ store_reason: result.store_reason || undefined,
12171
12262
  error: result.error || undefined,
12172
12263
  };
12173
12264
  }
@@ -12175,6 +12266,7 @@ async function executeSetupAction(action, ordinal, viewport) {
12175
12266
  const path = String(action.path || action.function_path || action.functionPath || "");
12176
12267
  const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
12177
12268
  const args = Array.isArray(action.args) ? action.args : [];
12269
+ 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();
12178
12270
  if (!path) return { ...base, path, reason: "missing_path" };
12179
12271
  if (!untilPath) return { ...base, path, reason: "missing_until_path" };
12180
12272
  const hasUntilExpected = setupHasOwn(action, "until_expected_value")
@@ -12217,6 +12309,9 @@ async function executeSetupAction(action, ordinal, viewport) {
12217
12309
  : setupHasOwn(action, "expected_return")
12218
12310
  ? action.expected_return
12219
12311
  : action.expectedReturn;
12312
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
12313
+ ? hasReturnExpectation
12314
+ : true;
12220
12315
  const scope = await setupActionScope(action, timeout);
12221
12316
  if (!scope.ok) return setupScopeFailure(base, scope);
12222
12317
  const startedAt = Date.now();
@@ -12240,7 +12335,7 @@ async function executeSetupAction(action, ordinal, viewport) {
12240
12335
  };
12241
12336
  }
12242
12337
  while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
12243
- lastCallResult = await setupCallWindowFunction(scope.context, path, args);
12338
+ lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
12244
12339
  callCount += 1;
12245
12340
  if (!lastCallResult.ok) break;
12246
12341
  if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
@@ -12252,8 +12347,10 @@ async function executeSetupAction(action, ordinal, viewport) {
12252
12347
  ok: true,
12253
12348
  path,
12254
12349
  arg_count: args.length,
12255
- returned: setupJsonValue(lastCallResult.returned),
12350
+ returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
12351
+ return_captured: captureReturn,
12256
12352
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
12353
+ return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
12257
12354
  until_path: untilPath,
12258
12355
  until_value: setupJsonValue(lastPredicateResult.value),
12259
12356
  until_expected_value: setupJsonValue(untilExpected),
@@ -12271,8 +12368,10 @@ async function executeSetupAction(action, ordinal, viewport) {
12271
12368
  ...setupScopeEvidence(scope),
12272
12369
  path,
12273
12370
  arg_count: args.length,
12274
- returned: setupJsonValue(lastCallResult?.returned),
12371
+ returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
12372
+ return_captured: captureReturn,
12275
12373
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
12374
+ return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
12276
12375
  until_path: untilPath,
12277
12376
  until_value: setupJsonValue(lastPredicateResult?.value),
12278
12377
  until_expected_value: setupJsonValue(untilExpected),
@@ -12288,6 +12387,7 @@ async function executeSetupAction(action, ordinal, viewport) {
12288
12387
  ? "timeout"
12289
12388
  : "until_condition_not_met",
12290
12389
  error: lastCallResult?.error || undefined,
12390
+ store_reason: lastCallResult?.store_reason || undefined,
12291
12391
  missing_part: lastPredicateResult?.missing_part || undefined,
12292
12392
  };
12293
12393
  }
@@ -14510,6 +14610,9 @@ function profileSetupSummaryMarkdown(result) {
14510
14610
  const clickedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.clicked_total) || 0), 0);
14511
14611
  const clickCountActionTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.click_count_action_total) || 0), 0);
14512
14612
  const clickCountValueTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.click_count_value_total) || 0), 0);
14613
+ const windowCallTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_total) || 0), 0);
14614
+ const windowCallStoredTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_stored_total) || 0), 0);
14615
+ const windowCallCapturedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_captured_total) || 0), 0);
14513
14616
  const windowCallUntilTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_total) || 0), 0);
14514
14617
  const windowCallUntilCallTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_call_total) || 0), 0);
14515
14618
  const failedTotal = viewports.reduce((sum, viewport) => sum + (Array.isArray(viewport.failed) ? viewport.failed.length : 0), 0);
@@ -14521,6 +14624,9 @@ function profileSetupSummaryMarkdown(result) {
14521
14624
  if (clickCountActionTotal) {
14522
14625
  lines.push(`- click counts: ${clickCountActionTotal} action(s), click_count total ${clickCountValueTotal}`);
14523
14626
  }
14627
+ if (windowCallTotal) {
14628
+ lines.push(`- window_call: ${windowCallTotal} action(s), stored returns ${windowCallStoredTotal}, captured returns ${windowCallCapturedTotal}`);
14629
+ }
14524
14630
  if (windowCallUntilTotal) {
14525
14631
  lines.push(`- window_call_until: ${windowCallUntilTotal} action(s), call_count total ${windowCallUntilCallTotal}`);
14526
14632
  }
@@ -14531,11 +14637,30 @@ function profileSetupSummaryMarkdown(result) {
14531
14637
  const screenshotCount = Array.isArray(viewport.setup_screenshots) ? viewport.setup_screenshots.filter((label) => typeof label === "string" && label.trim()).length : 0;
14532
14638
  const clicked = cliFiniteNumber(viewport.clicked_total) || 0;
14533
14639
  const clickCountActions = cliFiniteNumber(viewport.click_count_action_total) || 0;
14640
+ const windowCallActions = cliFiniteNumber(viewport.window_call_total) || 0;
14641
+ const windowCallStored = cliFiniteNumber(viewport.window_call_stored_total) || 0;
14642
+ const windowCallCaptured = cliFiniteNumber(viewport.window_call_captured_total) || 0;
14534
14643
  const windowCallUntilActions = cliFiniteNumber(viewport.window_call_until_total) || 0;
14535
14644
  const windowCallUntilCalls = cliFiniteNumber(viewport.window_call_until_call_total) || 0;
14536
14645
  const observedPath = cliString(viewport.observed_path);
14537
- lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
14646
+ lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
14647
+ }
14648
+ const windowCallDetails = viewports.flatMap((viewport) => {
14649
+ const name = cliString(viewport.name) || "viewport";
14650
+ const receipts = Array.isArray(viewport.window_call) ? viewport.window_call.map(cliRecord).filter((item) => Boolean(item)) : [];
14651
+ return receipts.map((receipt) => ({ name, receipt }));
14652
+ });
14653
+ for (const { name, receipt } of windowCallDetails.slice(0, 12)) {
14654
+ const path7 = cliString(receipt.path) || "window_function";
14655
+ const storedTo = cliString(receipt.return_stored_to);
14656
+ const returned = cliValueLabel(receipt.returned);
14657
+ const expected = cliValueLabel(receipt.expected_return);
14658
+ const captured = receipt.return_captured === true ? "captured" : receipt.return_captured === false ? "not captured" : "capture unknown";
14659
+ const ok = receipt.ok === false ? "failed" : "ok";
14660
+ const reason = cliString(receipt.reason);
14661
+ lines.push(`- ${name} window_call: ${ok}, ${markdownInlineCode(path7)}${storedTo ? `, stored ${markdownInlineCode(storedTo)}` : ""}, return ${captured}${expected === void 0 ? "" : `, expected ${markdownInlineCode(expected, 80)}`}${returned === void 0 ? "" : `, returned ${markdownInlineCode(returned, 80)}`}${reason ? `, reason ${markdownInlineCode(reason, 100)}` : ""}`);
14538
14662
  }
14663
+ if (windowCallDetails.length > 12) lines.push(`- ${windowCallDetails.length - 12} additional window_call receipt(s) omitted.`);
14539
14664
  const windowCallUntilDetails = viewports.flatMap((viewport) => {
14540
14665
  const name = cliString(viewport.name) || "viewport";
14541
14666
  const receipts = Array.isArray(viewport.window_call_until) ? viewport.window_call_until.map(cliRecord).filter((item) => Boolean(item)) : [];
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  profileStatusExitCode,
13
13
  resolveRiddleProofProfileTargetUrl,
14
14
  resolveRiddleProofProfileTimeoutSec
15
- } from "./chunk-4IAUK6C6.js";
15
+ } from "./chunk-2WWSWSYA.js";
16
16
  import {
17
17
  createRiddleApiClient,
18
18
  parseRiddleViewport
@@ -596,6 +596,9 @@ function profileSetupSummaryMarkdown(result) {
596
596
  const clickedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.clicked_total) || 0), 0);
597
597
  const clickCountActionTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.click_count_action_total) || 0), 0);
598
598
  const clickCountValueTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.click_count_value_total) || 0), 0);
599
+ const windowCallTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_total) || 0), 0);
600
+ const windowCallStoredTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_stored_total) || 0), 0);
601
+ const windowCallCapturedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_captured_total) || 0), 0);
599
602
  const windowCallUntilTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_total) || 0), 0);
600
603
  const windowCallUntilCallTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_call_total) || 0), 0);
601
604
  const failedTotal = viewports.reduce((sum, viewport) => sum + (Array.isArray(viewport.failed) ? viewport.failed.length : 0), 0);
@@ -607,6 +610,9 @@ function profileSetupSummaryMarkdown(result) {
607
610
  if (clickCountActionTotal) {
608
611
  lines.push(`- click counts: ${clickCountActionTotal} action(s), click_count total ${clickCountValueTotal}`);
609
612
  }
613
+ if (windowCallTotal) {
614
+ lines.push(`- window_call: ${windowCallTotal} action(s), stored returns ${windowCallStoredTotal}, captured returns ${windowCallCapturedTotal}`);
615
+ }
610
616
  if (windowCallUntilTotal) {
611
617
  lines.push(`- window_call_until: ${windowCallUntilTotal} action(s), call_count total ${windowCallUntilCallTotal}`);
612
618
  }
@@ -617,11 +623,30 @@ function profileSetupSummaryMarkdown(result) {
617
623
  const screenshotCount = Array.isArray(viewport.setup_screenshots) ? viewport.setup_screenshots.filter((label) => typeof label === "string" && label.trim()).length : 0;
618
624
  const clicked = cliFiniteNumber(viewport.clicked_total) || 0;
619
625
  const clickCountActions = cliFiniteNumber(viewport.click_count_action_total) || 0;
626
+ const windowCallActions = cliFiniteNumber(viewport.window_call_total) || 0;
627
+ const windowCallStored = cliFiniteNumber(viewport.window_call_stored_total) || 0;
628
+ const windowCallCaptured = cliFiniteNumber(viewport.window_call_captured_total) || 0;
620
629
  const windowCallUntilActions = cliFiniteNumber(viewport.window_call_until_total) || 0;
621
630
  const windowCallUntilCalls = cliFiniteNumber(viewport.window_call_until_call_total) || 0;
622
631
  const observedPath = cliString(viewport.observed_path);
623
- lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
632
+ lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
633
+ }
634
+ const windowCallDetails = viewports.flatMap((viewport) => {
635
+ const name = cliString(viewport.name) || "viewport";
636
+ const receipts = Array.isArray(viewport.window_call) ? viewport.window_call.map(cliRecord).filter((item) => Boolean(item)) : [];
637
+ return receipts.map((receipt) => ({ name, receipt }));
638
+ });
639
+ for (const { name, receipt } of windowCallDetails.slice(0, 12)) {
640
+ const path2 = cliString(receipt.path) || "window_function";
641
+ const storedTo = cliString(receipt.return_stored_to);
642
+ const returned = cliValueLabel(receipt.returned);
643
+ const expected = cliValueLabel(receipt.expected_return);
644
+ const captured = receipt.return_captured === true ? "captured" : receipt.return_captured === false ? "not captured" : "capture unknown";
645
+ const ok = receipt.ok === false ? "failed" : "ok";
646
+ const reason = cliString(receipt.reason);
647
+ lines.push(`- ${name} window_call: ${ok}, ${markdownInlineCode(path2)}${storedTo ? `, stored ${markdownInlineCode(storedTo)}` : ""}, return ${captured}${expected === void 0 ? "" : `, expected ${markdownInlineCode(expected, 80)}`}${returned === void 0 ? "" : `, returned ${markdownInlineCode(returned, 80)}`}${reason ? `, reason ${markdownInlineCode(reason, 100)}` : ""}`);
624
648
  }
649
+ if (windowCallDetails.length > 12) lines.push(`- ${windowCallDetails.length - 12} additional window_call receipt(s) omitted.`);
625
650
  const windowCallUntilDetails = viewports.flatMap((viewport) => {
626
651
  const name = cliString(viewport.name) || "viewport";
627
652
  const receipts = Array.isArray(viewport.window_call_until) ? viewport.window_call_until.map(cliRecord).filter((item) => Boolean(item)) : [];
package/dist/index.cjs CHANGED
@@ -9198,6 +9198,21 @@ function profileSetupWindowCallUntilReceipts(results) {
9198
9198
  reason: result.reason ?? result.error ?? null
9199
9199
  }));
9200
9200
  }
9201
+ function profileSetupWindowCallReceipts(results) {
9202
+ return results.filter((result) => profileSetupResultAction(result) === "window_call").map((result) => {
9203
+ const receipt = {
9204
+ ordinal: result.ordinal ?? null,
9205
+ ok: result.ok !== false,
9206
+ path: result.path ?? null,
9207
+ return_captured: result.return_captured ?? null,
9208
+ return_stored_to: result.return_stored_to ?? null,
9209
+ reason: result.reason ?? result.error ?? result.store_reason ?? null
9210
+ };
9211
+ if (result.returned !== void 0) receipt.returned = result.returned;
9212
+ if (result.expected_return !== void 0) receipt.expected_return = result.expected_return;
9213
+ return receipt;
9214
+ });
9215
+ }
9201
9216
  function sampleProfileSetupSummaryItems(items, limit) {
9202
9217
  if (items.length <= limit) return items;
9203
9218
  const firstCount = Math.floor(limit / 2);
@@ -9226,6 +9241,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
9226
9241
  const windowCallUntilReceipts = profileSetupWindowCallUntilReceipts(results);
9227
9242
  const windowCallUntilCallCounts = windowCallUntilReceipts.map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : void 0).filter((value) => value !== void 0);
9228
9243
  const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
9244
+ const windowCallReceipts = profileSetupWindowCallReceipts(results);
9245
+ const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
9246
+ const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
9247
+ const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
9229
9248
  const clickedItems = results.filter((result) => profileSetupResultAction(result) === "click" && result.ok !== false).map((result) => {
9230
9249
  const clickCount = typeof result.click_count === "number" && Number.isFinite(result.click_count) && result.click_count > 1 ? result.click_count : void 0;
9231
9250
  return {
@@ -9262,6 +9281,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
9262
9281
  window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
9263
9282
  window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
9264
9283
  window_call_until: sampledWindowCallUntilReceipts,
9284
+ window_call_total: windowCallReceipts.length,
9285
+ window_call_stored_total: windowCallStoredTotal,
9286
+ window_call_captured_total: windowCallCapturedTotal,
9287
+ window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
9288
+ window_call: sampledWindowCallReceipts,
9265
9289
  clicked,
9266
9290
  text_samples,
9267
9291
  failed: failed.map((result) => ({
@@ -9465,6 +9489,18 @@ function normalizeSetupAction(input, index) {
9465
9489
  }
9466
9490
  }
9467
9491
  const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
9492
+ const storeReturnTo = stringFromOwn(
9493
+ input,
9494
+ "store_return_to",
9495
+ "storeReturnTo",
9496
+ "save_return_to",
9497
+ "saveReturnTo",
9498
+ "assign_return_to",
9499
+ "assignReturnTo",
9500
+ "return_state_path",
9501
+ "returnStatePath"
9502
+ );
9503
+ 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
9504
  const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
9469
9505
  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
9506
  if (type === "window_call_until") {
@@ -9509,6 +9545,8 @@ function normalizeSetupAction(input, index) {
9509
9545
  path: path6,
9510
9546
  args,
9511
9547
  expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
9548
+ store_return_to: storeReturnTo,
9549
+ capture_return: captureReturn,
9512
9550
  until_path: untilPath,
9513
9551
  until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
9514
9552
  max_calls: maxCalls,
@@ -12401,6 +12439,23 @@ function profileSetupWindowCallUntilReceipts(results) {
12401
12439
  reason: result.reason || result.error || null,
12402
12440
  }));
12403
12441
  }
12442
+ function profileSetupWindowCallReceipts(results) {
12443
+ return (results || [])
12444
+ .filter((result) => result && profileSetupResultAction(result) === "window_call")
12445
+ .map((result) => {
12446
+ const receipt = {
12447
+ ordinal: result.ordinal ?? null,
12448
+ ok: result.ok !== false,
12449
+ path: result.path ?? null,
12450
+ return_captured: result.return_captured ?? null,
12451
+ return_stored_to: result.return_stored_to ?? null,
12452
+ reason: result.reason || result.error || result.store_reason || null,
12453
+ };
12454
+ if (result.returned !== undefined) receipt.returned = result.returned;
12455
+ if (result.expected_return !== undefined) receipt.expected_return = result.expected_return;
12456
+ return receipt;
12457
+ });
12458
+ }
12404
12459
  function sampleProfileSetupSummaryItems(items, limit) {
12405
12460
  if ((items || []).length <= limit) return items || [];
12406
12461
  const firstCount = Math.floor(limit / 2);
@@ -12435,6 +12490,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
12435
12490
  .map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : undefined)
12436
12491
  .filter((value) => value !== undefined);
12437
12492
  const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
12493
+ const windowCallReceipts = profileSetupWindowCallReceipts(results);
12494
+ const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
12495
+ const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
12496
+ const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
12438
12497
  const clickedItems = results
12439
12498
  .filter((result) => result && profileSetupResultAction(result) === "click" && result.ok !== false)
12440
12499
  .map((result) => {
@@ -12481,6 +12540,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
12481
12540
  window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
12482
12541
  window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
12483
12542
  window_call_until: sampledWindowCallUntilReceipts,
12543
+ window_call_total: windowCallReceipts.length,
12544
+ window_call_stored_total: windowCallStoredTotal,
12545
+ window_call_captured_total: windowCallCapturedTotal,
12546
+ window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
12547
+ window_call: sampledWindowCallReceipts,
12484
12548
  clicked,
12485
12549
  text_samples: textSamples,
12486
12550
  failed: failed.map((result) => ({
@@ -13413,8 +13477,8 @@ async function setupReadWindowValue(context, path) {
13413
13477
  return { ok: true, value: toJsonValue(current) };
13414
13478
  }, { path });
13415
13479
  }
13416
- async function setupCallWindowFunction(context, path, args) {
13417
- return await context.evaluate(async ({ path, args }) => {
13480
+ async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
13481
+ return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
13418
13482
  const toJsonValue = (value) => {
13419
13483
  if (value === null || value === undefined) return null;
13420
13484
  if (typeof value === "string" || typeof value === "boolean") return value;
@@ -13425,6 +13489,19 @@ async function setupCallWindowFunction(context, path, args) {
13425
13489
  }
13426
13490
  return String(value);
13427
13491
  };
13492
+ const storeWindowReturn = (storePath, value) => {
13493
+ const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
13494
+ if (pathParts[0] === "window") pathParts.shift();
13495
+ if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
13496
+ let target = window;
13497
+ for (let index = 0; index < pathParts.length - 1; index += 1) {
13498
+ const part = pathParts[index];
13499
+ if (target[part] === null || typeof target[part] !== "object") target[part] = {};
13500
+ target = target[part];
13501
+ }
13502
+ target[pathParts[pathParts.length - 1]] = value;
13503
+ return { ok: true, path: pathParts.join(".") };
13504
+ };
13428
13505
  const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
13429
13506
  let parent = window;
13430
13507
  let current = window;
@@ -13435,11 +13512,18 @@ async function setupCallWindowFunction(context, path, args) {
13435
13512
  if (typeof current !== "function") return { ok: false, reason: "missing_function" };
13436
13513
  try {
13437
13514
  const returned = await current.apply(parent, Array.isArray(args) ? args : []);
13438
- return { ok: true, returned: toJsonValue(returned) };
13515
+ const jsonReturned = toJsonValue(returned);
13516
+ const returnedForResult = captureReturn === false ? undefined : jsonReturned;
13517
+ if (storeReturnTo) {
13518
+ const stored = storeWindowReturn(storeReturnTo, jsonReturned);
13519
+ if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
13520
+ return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
13521
+ }
13522
+ return { ok: true, returned: returnedForResult };
13439
13523
  } catch (error) {
13440
13524
  return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
13441
13525
  }
13442
- }, { path, args });
13526
+ }, { path, args, storeReturnTo, captureReturn });
13443
13527
  }
13444
13528
  function setupFrameSelector(action) {
13445
13529
  return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
@@ -13955,10 +14039,10 @@ async function executeSetupAction(action, ordinal, viewport) {
13955
14039
  if (type === "window_call") {
13956
14040
  const path = String(action.path || action.function_path || action.functionPath || "");
13957
14041
  const args = Array.isArray(action.args) ? action.args : [];
14042
+ 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();
13958
14043
  if (!path) return { ...base, path, reason: "missing_path" };
13959
14044
  const scope = await setupActionScope(action, timeout);
13960
14045
  if (!scope.ok) return setupScopeFailure(base, scope);
13961
- const result = await setupCallWindowFunction(scope.context, path, args);
13962
14046
  const hasExpectation = setupHasOwn(action, "expect_return")
13963
14047
  || setupHasOwn(action, "expectReturn")
13964
14048
  || setupHasOwn(action, "expected_return")
@@ -13967,9 +14051,13 @@ async function executeSetupAction(action, ordinal, viewport) {
13967
14051
  ? action.expect_return
13968
14052
  : setupHasOwn(action, "expectReturn")
13969
14053
  ? action.expectReturn
13970
- : setupHasOwn(action, "expected_return")
13971
- ? action.expected_return
13972
- : action.expectedReturn;
14054
+ : setupHasOwn(action, "expected_return")
14055
+ ? action.expected_return
14056
+ : action.expectedReturn;
14057
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
14058
+ ? hasExpectation
14059
+ : true;
14060
+ const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
13973
14061
  const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
13974
14062
  return {
13975
14063
  ...base,
@@ -13977,9 +14065,12 @@ async function executeSetupAction(action, ordinal, viewport) {
13977
14065
  ok: Boolean(result.ok && expectationMet),
13978
14066
  path,
13979
14067
  arg_count: args.length,
13980
- returned: setupJsonValue(result.returned),
14068
+ returned: captureReturn ? setupJsonValue(result.returned) : undefined,
14069
+ return_captured: captureReturn,
13981
14070
  expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
14071
+ return_stored_to: result.return_stored_to || storeReturnTo || undefined,
13982
14072
  reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
14073
+ store_reason: result.store_reason || undefined,
13983
14074
  error: result.error || undefined,
13984
14075
  };
13985
14076
  }
@@ -13987,6 +14078,7 @@ async function executeSetupAction(action, ordinal, viewport) {
13987
14078
  const path = String(action.path || action.function_path || action.functionPath || "");
13988
14079
  const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
13989
14080
  const args = Array.isArray(action.args) ? action.args : [];
14081
+ 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();
13990
14082
  if (!path) return { ...base, path, reason: "missing_path" };
13991
14083
  if (!untilPath) return { ...base, path, reason: "missing_until_path" };
13992
14084
  const hasUntilExpected = setupHasOwn(action, "until_expected_value")
@@ -14029,6 +14121,9 @@ async function executeSetupAction(action, ordinal, viewport) {
14029
14121
  : setupHasOwn(action, "expected_return")
14030
14122
  ? action.expected_return
14031
14123
  : action.expectedReturn;
14124
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
14125
+ ? hasReturnExpectation
14126
+ : true;
14032
14127
  const scope = await setupActionScope(action, timeout);
14033
14128
  if (!scope.ok) return setupScopeFailure(base, scope);
14034
14129
  const startedAt = Date.now();
@@ -14052,7 +14147,7 @@ async function executeSetupAction(action, ordinal, viewport) {
14052
14147
  };
14053
14148
  }
14054
14149
  while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
14055
- lastCallResult = await setupCallWindowFunction(scope.context, path, args);
14150
+ lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
14056
14151
  callCount += 1;
14057
14152
  if (!lastCallResult.ok) break;
14058
14153
  if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
@@ -14064,8 +14159,10 @@ async function executeSetupAction(action, ordinal, viewport) {
14064
14159
  ok: true,
14065
14160
  path,
14066
14161
  arg_count: args.length,
14067
- returned: setupJsonValue(lastCallResult.returned),
14162
+ returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
14163
+ return_captured: captureReturn,
14068
14164
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
14165
+ return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
14069
14166
  until_path: untilPath,
14070
14167
  until_value: setupJsonValue(lastPredicateResult.value),
14071
14168
  until_expected_value: setupJsonValue(untilExpected),
@@ -14083,8 +14180,10 @@ async function executeSetupAction(action, ordinal, viewport) {
14083
14180
  ...setupScopeEvidence(scope),
14084
14181
  path,
14085
14182
  arg_count: args.length,
14086
- returned: setupJsonValue(lastCallResult?.returned),
14183
+ returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
14184
+ return_captured: captureReturn,
14087
14185
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
14186
+ return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
14088
14187
  until_path: untilPath,
14089
14188
  until_value: setupJsonValue(lastPredicateResult?.value),
14090
14189
  until_expected_value: setupJsonValue(untilExpected),
@@ -14100,6 +14199,7 @@ async function executeSetupAction(action, ordinal, viewport) {
14100
14199
  ? "timeout"
14101
14200
  : "until_condition_not_met",
14102
14201
  error: lastCallResult?.error || undefined,
14202
+ store_reason: lastCallResult?.store_reason || undefined,
14103
14203
  missing_part: lastPredicateResult?.missing_part || undefined,
14104
14204
  };
14105
14205
  }
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ import {
62
62
  resolveRiddleProofProfileTimeoutSec,
63
63
  slugifyRiddleProofProfileName,
64
64
  summarizeRiddleProofProfileResult
65
- } from "./chunk-4IAUK6C6.js";
65
+ } from "./chunk-2WWSWSYA.js";
66
66
  import {
67
67
  DEFAULT_RIDDLE_API_BASE_URL,
68
68
  DEFAULT_RIDDLE_API_KEY_FILE,
package/dist/profile.cjs CHANGED
@@ -512,6 +512,21 @@ function profileSetupWindowCallUntilReceipts(results) {
512
512
  reason: result.reason ?? result.error ?? null
513
513
  }));
514
514
  }
515
+ function profileSetupWindowCallReceipts(results) {
516
+ return results.filter((result) => profileSetupResultAction(result) === "window_call").map((result) => {
517
+ const receipt = {
518
+ ordinal: result.ordinal ?? null,
519
+ ok: result.ok !== false,
520
+ path: result.path ?? null,
521
+ return_captured: result.return_captured ?? null,
522
+ return_stored_to: result.return_stored_to ?? null,
523
+ reason: result.reason ?? result.error ?? result.store_reason ?? null
524
+ };
525
+ if (result.returned !== void 0) receipt.returned = result.returned;
526
+ if (result.expected_return !== void 0) receipt.expected_return = result.expected_return;
527
+ return receipt;
528
+ });
529
+ }
515
530
  function sampleProfileSetupSummaryItems(items, limit) {
516
531
  if (items.length <= limit) return items;
517
532
  const firstCount = Math.floor(limit / 2);
@@ -540,6 +555,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
540
555
  const windowCallUntilReceipts = profileSetupWindowCallUntilReceipts(results);
541
556
  const windowCallUntilCallCounts = windowCallUntilReceipts.map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : void 0).filter((value) => value !== void 0);
542
557
  const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
558
+ const windowCallReceipts = profileSetupWindowCallReceipts(results);
559
+ const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
560
+ const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
561
+ const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
543
562
  const clickedItems = results.filter((result) => profileSetupResultAction(result) === "click" && result.ok !== false).map((result) => {
544
563
  const clickCount = typeof result.click_count === "number" && Number.isFinite(result.click_count) && result.click_count > 1 ? result.click_count : void 0;
545
564
  return {
@@ -576,6 +595,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
576
595
  window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
577
596
  window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
578
597
  window_call_until: sampledWindowCallUntilReceipts,
598
+ window_call_total: windowCallReceipts.length,
599
+ window_call_stored_total: windowCallStoredTotal,
600
+ window_call_captured_total: windowCallCapturedTotal,
601
+ window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
602
+ window_call: sampledWindowCallReceipts,
579
603
  clicked,
580
604
  text_samples,
581
605
  failed: failed.map((result) => ({
@@ -779,6 +803,18 @@ function normalizeSetupAction(input, index) {
779
803
  }
780
804
  }
781
805
  const hasExpectedReturn = hasOwn(input, "expect_return") || hasOwn(input, "expectReturn") || hasOwn(input, "expected_return") || hasOwn(input, "expectedReturn");
806
+ const storeReturnTo = stringFromOwn(
807
+ input,
808
+ "store_return_to",
809
+ "storeReturnTo",
810
+ "save_return_to",
811
+ "saveReturnTo",
812
+ "assign_return_to",
813
+ "assignReturnTo",
814
+ "return_state_path",
815
+ "returnStatePath"
816
+ );
817
+ 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
818
  const untilPath = stringFromOwn(input, "until_path", "untilPath", "until_state_path", "untilStatePath", "until_window_path", "untilWindowPath", "until");
783
819
  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
820
  if (type === "window_call_until") {
@@ -823,6 +859,8 @@ function normalizeSetupAction(input, index) {
823
859
  path,
824
860
  args,
825
861
  expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
862
+ store_return_to: storeReturnTo,
863
+ capture_return: captureReturn,
826
864
  until_path: untilPath,
827
865
  until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
828
866
  max_calls: maxCalls,
@@ -3715,6 +3753,23 @@ function profileSetupWindowCallUntilReceipts(results) {
3715
3753
  reason: result.reason || result.error || null,
3716
3754
  }));
3717
3755
  }
3756
+ function profileSetupWindowCallReceipts(results) {
3757
+ return (results || [])
3758
+ .filter((result) => result && profileSetupResultAction(result) === "window_call")
3759
+ .map((result) => {
3760
+ const receipt = {
3761
+ ordinal: result.ordinal ?? null,
3762
+ ok: result.ok !== false,
3763
+ path: result.path ?? null,
3764
+ return_captured: result.return_captured ?? null,
3765
+ return_stored_to: result.return_stored_to ?? null,
3766
+ reason: result.reason || result.error || result.store_reason || null,
3767
+ };
3768
+ if (result.returned !== undefined) receipt.returned = result.returned;
3769
+ if (result.expected_return !== undefined) receipt.expected_return = result.expected_return;
3770
+ return receipt;
3771
+ });
3772
+ }
3718
3773
  function sampleProfileSetupSummaryItems(items, limit) {
3719
3774
  if ((items || []).length <= limit) return items || [];
3720
3775
  const firstCount = Math.floor(limit / 2);
@@ -3749,6 +3804,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
3749
3804
  .map((result) => typeof result.call_count === "number" && Number.isFinite(result.call_count) ? result.call_count : undefined)
3750
3805
  .filter((value) => value !== undefined);
3751
3806
  const sampledWindowCallUntilReceipts = sampleProfileSetupSummaryItems(windowCallUntilReceipts, 8);
3807
+ const windowCallReceipts = profileSetupWindowCallReceipts(results);
3808
+ const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
3809
+ const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
3810
+ const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
3752
3811
  const clickedItems = results
3753
3812
  .filter((result) => result && profileSetupResultAction(result) === "click" && result.ok !== false)
3754
3813
  .map((result) => {
@@ -3795,6 +3854,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
3795
3854
  window_call_until_call_total: windowCallUntilCallCounts.reduce((sum, value) => sum + value, 0),
3796
3855
  window_call_until_truncated: windowCallUntilReceipts.length > sampledWindowCallUntilReceipts.length,
3797
3856
  window_call_until: sampledWindowCallUntilReceipts,
3857
+ window_call_total: windowCallReceipts.length,
3858
+ window_call_stored_total: windowCallStoredTotal,
3859
+ window_call_captured_total: windowCallCapturedTotal,
3860
+ window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
3861
+ window_call: sampledWindowCallReceipts,
3798
3862
  clicked,
3799
3863
  text_samples: textSamples,
3800
3864
  failed: failed.map((result) => ({
@@ -4727,8 +4791,8 @@ async function setupReadWindowValue(context, path) {
4727
4791
  return { ok: true, value: toJsonValue(current) };
4728
4792
  }, { path });
4729
4793
  }
4730
- async function setupCallWindowFunction(context, path, args) {
4731
- return await context.evaluate(async ({ path, args }) => {
4794
+ async function setupCallWindowFunction(context, path, args, storeReturnTo, captureReturn) {
4795
+ return await context.evaluate(async ({ path, args, storeReturnTo, captureReturn }) => {
4732
4796
  const toJsonValue = (value) => {
4733
4797
  if (value === null || value === undefined) return null;
4734
4798
  if (typeof value === "string" || typeof value === "boolean") return value;
@@ -4739,6 +4803,19 @@ async function setupCallWindowFunction(context, path, args) {
4739
4803
  }
4740
4804
  return String(value);
4741
4805
  };
4806
+ const storeWindowReturn = (storePath, value) => {
4807
+ const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
4808
+ if (pathParts[0] === "window") pathParts.shift();
4809
+ if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
4810
+ let target = window;
4811
+ for (let index = 0; index < pathParts.length - 1; index += 1) {
4812
+ const part = pathParts[index];
4813
+ if (target[part] === null || typeof target[part] !== "object") target[part] = {};
4814
+ target = target[part];
4815
+ }
4816
+ target[pathParts[pathParts.length - 1]] = value;
4817
+ return { ok: true, path: pathParts.join(".") };
4818
+ };
4742
4819
  const pathParts = String(path || "").split(".").map((part) => part.trim()).filter(Boolean);
4743
4820
  let parent = window;
4744
4821
  let current = window;
@@ -4749,11 +4826,18 @@ async function setupCallWindowFunction(context, path, args) {
4749
4826
  if (typeof current !== "function") return { ok: false, reason: "missing_function" };
4750
4827
  try {
4751
4828
  const returned = await current.apply(parent, Array.isArray(args) ? args : []);
4752
- return { ok: true, returned: toJsonValue(returned) };
4829
+ const jsonReturned = toJsonValue(returned);
4830
+ const returnedForResult = captureReturn === false ? undefined : jsonReturned;
4831
+ if (storeReturnTo) {
4832
+ const stored = storeWindowReturn(storeReturnTo, jsonReturned);
4833
+ if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
4834
+ return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
4835
+ }
4836
+ return { ok: true, returned: returnedForResult };
4753
4837
  } catch (error) {
4754
4838
  return { ok: false, reason: "function_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
4755
4839
  }
4756
- }, { path, args });
4840
+ }, { path, args, storeReturnTo, captureReturn });
4757
4841
  }
4758
4842
  function setupFrameSelector(action) {
4759
4843
  return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
@@ -5269,10 +5353,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5269
5353
  if (type === "window_call") {
5270
5354
  const path = String(action.path || action.function_path || action.functionPath || "");
5271
5355
  const args = Array.isArray(action.args) ? action.args : [];
5356
+ 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();
5272
5357
  if (!path) return { ...base, path, reason: "missing_path" };
5273
5358
  const scope = await setupActionScope(action, timeout);
5274
5359
  if (!scope.ok) return setupScopeFailure(base, scope);
5275
- const result = await setupCallWindowFunction(scope.context, path, args);
5276
5360
  const hasExpectation = setupHasOwn(action, "expect_return")
5277
5361
  || setupHasOwn(action, "expectReturn")
5278
5362
  || setupHasOwn(action, "expected_return")
@@ -5281,9 +5365,13 @@ async function executeSetupAction(action, ordinal, viewport) {
5281
5365
  ? action.expect_return
5282
5366
  : setupHasOwn(action, "expectReturn")
5283
5367
  ? action.expectReturn
5284
- : setupHasOwn(action, "expected_return")
5285
- ? action.expected_return
5286
- : action.expectedReturn;
5368
+ : setupHasOwn(action, "expected_return")
5369
+ ? action.expected_return
5370
+ : action.expectedReturn;
5371
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
5372
+ ? hasExpectation
5373
+ : true;
5374
+ const result = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
5287
5375
  const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
5288
5376
  return {
5289
5377
  ...base,
@@ -5291,9 +5379,12 @@ async function executeSetupAction(action, ordinal, viewport) {
5291
5379
  ok: Boolean(result.ok && expectationMet),
5292
5380
  path,
5293
5381
  arg_count: args.length,
5294
- returned: setupJsonValue(result.returned),
5382
+ returned: captureReturn ? setupJsonValue(result.returned) : undefined,
5383
+ return_captured: captureReturn,
5295
5384
  expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
5385
+ return_stored_to: result.return_stored_to || storeReturnTo || undefined,
5296
5386
  reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
5387
+ store_reason: result.store_reason || undefined,
5297
5388
  error: result.error || undefined,
5298
5389
  };
5299
5390
  }
@@ -5301,6 +5392,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5301
5392
  const path = String(action.path || action.function_path || action.functionPath || "");
5302
5393
  const untilPath = String(action.until_path || action.untilPath || action.until_state_path || action.untilStatePath || action.until_window_path || action.untilWindowPath || action.until || "");
5303
5394
  const args = Array.isArray(action.args) ? action.args : [];
5395
+ 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();
5304
5396
  if (!path) return { ...base, path, reason: "missing_path" };
5305
5397
  if (!untilPath) return { ...base, path, reason: "missing_until_path" };
5306
5398
  const hasUntilExpected = setupHasOwn(action, "until_expected_value")
@@ -5343,6 +5435,9 @@ async function executeSetupAction(action, ordinal, viewport) {
5343
5435
  : setupHasOwn(action, "expected_return")
5344
5436
  ? action.expected_return
5345
5437
  : action.expectedReturn;
5438
+ const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
5439
+ ? hasReturnExpectation
5440
+ : true;
5346
5441
  const scope = await setupActionScope(action, timeout);
5347
5442
  if (!scope.ok) return setupScopeFailure(base, scope);
5348
5443
  const startedAt = Date.now();
@@ -5366,7 +5461,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5366
5461
  };
5367
5462
  }
5368
5463
  while (callCount < maxCalls && Date.now() - startedAt <= timeout) {
5369
- lastCallResult = await setupCallWindowFunction(scope.context, path, args);
5464
+ lastCallResult = await setupCallWindowFunction(scope.context, path, args, storeReturnTo, captureReturn);
5370
5465
  callCount += 1;
5371
5466
  if (!lastCallResult.ok) break;
5372
5467
  if (hasReturnExpectation && !setupValuesEqual(lastCallResult.returned, expectedReturn)) break;
@@ -5378,8 +5473,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5378
5473
  ok: true,
5379
5474
  path,
5380
5475
  arg_count: args.length,
5381
- returned: setupJsonValue(lastCallResult.returned),
5476
+ returned: captureReturn ? setupJsonValue(lastCallResult.returned) : undefined,
5477
+ return_captured: captureReturn,
5382
5478
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
5479
+ return_stored_to: lastCallResult.return_stored_to || storeReturnTo || undefined,
5383
5480
  until_path: untilPath,
5384
5481
  until_value: setupJsonValue(lastPredicateResult.value),
5385
5482
  until_expected_value: setupJsonValue(untilExpected),
@@ -5397,8 +5494,10 @@ async function executeSetupAction(action, ordinal, viewport) {
5397
5494
  ...setupScopeEvidence(scope),
5398
5495
  path,
5399
5496
  arg_count: args.length,
5400
- returned: setupJsonValue(lastCallResult?.returned),
5497
+ returned: captureReturn ? setupJsonValue(lastCallResult?.returned) : undefined,
5498
+ return_captured: captureReturn,
5401
5499
  expected_return: hasReturnExpectation ? setupJsonValue(expectedReturn) : undefined,
5500
+ return_stored_to: lastCallResult?.return_stored_to || storeReturnTo || undefined,
5402
5501
  until_path: untilPath,
5403
5502
  until_value: setupJsonValue(lastPredicateResult?.value),
5404
5503
  until_expected_value: setupJsonValue(untilExpected),
@@ -5414,6 +5513,7 @@ async function executeSetupAction(action, ordinal, viewport) {
5414
5513
  ? "timeout"
5415
5514
  : "until_condition_not_met",
5416
5515
  error: lastCallResult?.error || undefined,
5516
+ store_reason: lastCallResult?.store_reason || undefined,
5417
5517
  missing_part: lastPredicateResult?.missing_part || undefined,
5418
5518
  };
5419
5519
  }
@@ -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-4IAUK6C6.js";
26
+ } from "./chunk-2WWSWSYA.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.135",
3
+ "version": "0.7.137",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",