@riddledc/riddle-proof 0.7.182 → 0.7.184

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -7570,7 +7570,7 @@ function profileSetupTapReceipts(results) {
7570
7570
  reason: result.reason ?? result.error ?? null
7571
7571
  }));
7572
7572
  }
7573
- function profileSetupPressReceipts(results) {
7573
+ function profileSetupKeyboardReceipts(results) {
7574
7574
  return results.filter((result) => ["press", "key_down", "key_up"].includes(profileSetupResultAction(result))).map((result) => ({
7575
7575
  action: profileSetupResultAction(result),
7576
7576
  ordinal: result.ordinal ?? null,
@@ -7745,8 +7745,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
7745
7745
  const sampledDragReceipts = sampleProfileSetupSummaryItems(dragReceipts, 8);
7746
7746
  const tapReceipts = profileSetupTapReceipts(results);
7747
7747
  const sampledTapReceipts = sampleProfileSetupSummaryItems(tapReceipts, 8);
7748
- const pressReceipts = profileSetupPressReceipts(results);
7749
- const sampledPressReceipts = sampleProfileSetupSummaryItems(pressReceipts, 8);
7748
+ const keyboardReceipts = profileSetupKeyboardReceipts(results);
7749
+ const sampledKeyboardReceipts = sampleProfileSetupSummaryItems(keyboardReceipts, 8);
7750
7750
  const canvasSignatureReceipts = profileSetupCanvasSignatureReceipts(results);
7751
7751
  const sampledCanvasSignatureReceipts = sampleProfileSetupSummaryItems(canvasSignatureReceipts, 8);
7752
7752
  const clickedItems = results.filter((result) => profileSetupResultAction(result) === "click" && result.ok !== false).map((result) => {
@@ -7814,9 +7814,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
7814
7814
  tap_total: tapReceipts.length,
7815
7815
  tap_truncated: tapReceipts.length > sampledTapReceipts.length,
7816
7816
  tap: sampledTapReceipts,
7817
- press_total: pressReceipts.length,
7818
- press_truncated: pressReceipts.length > sampledPressReceipts.length,
7819
- press: sampledPressReceipts,
7817
+ keyboard_total: keyboardReceipts.length,
7818
+ keyboard_truncated: keyboardReceipts.length > sampledKeyboardReceipts.length,
7819
+ keyboard: sampledKeyboardReceipts,
7820
7820
  canvas_signature_total: canvasSignatureReceipts.length,
7821
7821
  canvas_signature_truncated: canvasSignatureReceipts.length > sampledCanvasSignatureReceipts.length,
7822
7822
  canvas_signature: sampledCanvasSignatureReceipts,
@@ -10417,6 +10417,7 @@ function assessRiddleProofProfileEvidence(profile, evidence, options = {}) {
10417
10417
  checks,
10418
10418
  summary: summarizeRiddleProofProfileResult({ profile_name: profile.name, status, checks, viewports: evidence?.viewports || [] }),
10419
10419
  captured_at: capturedAt,
10420
+ metadata: profile.metadata,
10420
10421
  warnings: warnings.length ? warnings : void 0,
10421
10422
  evidence,
10422
10423
  riddle: options.riddle
@@ -10462,6 +10463,7 @@ function createRiddleProofProfileEnvironmentBlockedResult(input) {
10462
10463
  checks: [],
10463
10464
  summary: summarizeEnvironmentBlockedRunner(input.profile.name, environmentBlocker),
10464
10465
  captured_at: (/* @__PURE__ */ new Date()).toISOString(),
10466
+ metadata: input.profile.metadata,
10465
10467
  warnings: warnings.length ? warnings : void 0,
10466
10468
  riddle: input.riddle,
10467
10469
  environment_blocker: environmentBlocker,
@@ -10538,6 +10540,7 @@ function createRiddleProofProfileInsufficientResult(input) {
10538
10540
  checks: [],
10539
10541
  summary: `${input.profile.name} did not produce enough evidence for a profile judgment.`,
10540
10542
  captured_at: (/* @__PURE__ */ new Date()).toISOString(),
10543
+ metadata: input.profile.metadata,
10541
10544
  warnings: warnings.length ? warnings : void 0,
10542
10545
  riddle: input.riddle,
10543
10546
  error: message
@@ -11438,7 +11441,7 @@ function profileSetupTapReceipts(results) {
11438
11441
  reason: result.reason || result.error || null,
11439
11442
  }));
11440
11443
  }
11441
- function profileSetupPressReceipts(results) {
11444
+ function profileSetupKeyboardReceipts(results) {
11442
11445
  return (results || [])
11443
11446
  .filter((result) => result && ["press", "key_down", "key_up"].includes(profileSetupResultAction(result)))
11444
11447
  .map((result) => ({
@@ -11640,8 +11643,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
11640
11643
  const sampledDragReceipts = sampleProfileSetupSummaryItems(dragReceipts, 8);
11641
11644
  const tapReceipts = profileSetupTapReceipts(results);
11642
11645
  const sampledTapReceipts = sampleProfileSetupSummaryItems(tapReceipts, 8);
11643
- const pressReceipts = profileSetupPressReceipts(results);
11644
- const sampledPressReceipts = sampleProfileSetupSummaryItems(pressReceipts, 8);
11646
+ const keyboardReceipts = profileSetupKeyboardReceipts(results);
11647
+ const sampledKeyboardReceipts = sampleProfileSetupSummaryItems(keyboardReceipts, 8);
11645
11648
  const canvasSignatureReceipts = profileSetupCanvasSignatureReceipts(results);
11646
11649
  const sampledCanvasSignatureReceipts = sampleProfileSetupSummaryItems(canvasSignatureReceipts, 8);
11647
11650
  const clickedItems = results
@@ -11719,9 +11722,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
11719
11722
  tap_total: tapReceipts.length,
11720
11723
  tap_truncated: tapReceipts.length > sampledTapReceipts.length,
11721
11724
  tap: sampledTapReceipts,
11722
- press_total: pressReceipts.length,
11723
- press_truncated: pressReceipts.length > sampledPressReceipts.length,
11724
- press: sampledPressReceipts,
11725
+ keyboard_total: keyboardReceipts.length,
11726
+ keyboard_truncated: keyboardReceipts.length > sampledKeyboardReceipts.length,
11727
+ keyboard: sampledKeyboardReceipts,
11725
11728
  canvas_signature_total: canvasSignatureReceipts.length,
11726
11729
  canvas_signature_truncated: canvasSignatureReceipts.length > sampledCanvasSignatureReceipts.length,
11727
11730
  canvas_signature: sampledCanvasSignatureReceipts,
@@ -12464,6 +12467,7 @@ function assessProfile(profile, evidence) {
12464
12467
  checks,
12465
12468
  summary,
12466
12469
  captured_at: evidence.captured_at,
12470
+ metadata: profile.metadata,
12467
12471
  warnings: profileWarnings.length ? profileWarnings : undefined,
12468
12472
  evidence,
12469
12473
  };
@@ -16179,6 +16183,10 @@ function profileResultMarkdown(result) {
16179
16183
  if (result.warnings.length > 12) lines.push(`- ${result.warnings.length - 12} additional warning(s) omitted.`);
16180
16184
  lines.push("");
16181
16185
  }
16186
+ const packMetadataLines = profilePackMetadataMarkdown(result);
16187
+ if (packMetadataLines.length) {
16188
+ lines.push("## Proof Pack", "", ...packMetadataLines, "");
16189
+ }
16182
16190
  lines.push("## Checks", "");
16183
16191
  for (const check of result.checks) {
16184
16192
  lines.push(`- ${check.status}: ${profileCheckMarkdownLabel(check)}`);
@@ -16188,6 +16196,18 @@ function profileResultMarkdown(result) {
16188
16196
  if (setupSummaryLines.length) {
16189
16197
  lines.push("", "## Setup Summary", "", ...setupSummaryLines);
16190
16198
  }
16199
+ const reachabilitySummaryLines = profileReachabilitySummaryMarkdown(result);
16200
+ if (reachabilitySummaryLines.length) {
16201
+ lines.push("", "## Reachability", "", ...reachabilitySummaryLines);
16202
+ }
16203
+ const stateContractSummaryLines = profileStateContractSummaryMarkdown(result);
16204
+ if (stateContractSummaryLines.length) {
16205
+ lines.push("", "## State Contract", "", ...stateContractSummaryLines);
16206
+ }
16207
+ const sideCaveatSummaryLines = profileSideCaveatSummaryMarkdown(result);
16208
+ if (sideCaveatSummaryLines.length) {
16209
+ lines.push("", "## Side Caveats", "", ...sideCaveatSummaryLines);
16210
+ }
16191
16211
  const networkMockSummaryLines = profileNetworkMockSummaryMarkdown(result);
16192
16212
  if (networkMockSummaryLines.length) {
16193
16213
  lines.push("", "## Network Mocks", "", ...networkMockSummaryLines);
@@ -16286,6 +16306,222 @@ function profileRiddleJobMarkdown(result) {
16286
16306
  if (splitJobs.length > 12) lines.push(`- ${splitJobs.length - 12} additional split job(s) omitted.`);
16287
16307
  return lines;
16288
16308
  }
16309
+ function profileMetadataStringArray(value) {
16310
+ return Array.isArray(value) ? value.map((item) => typeof item === "string" ? item.trim() : "").filter((item) => Boolean(item)) : [];
16311
+ }
16312
+ function profileSetupSummaryRecord(result) {
16313
+ const setupCheck = result.checks.find((check) => check.type === "setup_actions_succeeded");
16314
+ return cliRecord(setupCheck?.evidence?.setup_summary);
16315
+ }
16316
+ function profileSetupSummaryViewports(result) {
16317
+ const setupSummary = profileSetupSummaryRecord(result);
16318
+ return Array.isArray(setupSummary?.viewports) ? setupSummary.viewports.map(cliRecord).filter((viewport) => Boolean(viewport)) : [];
16319
+ }
16320
+ function profileHasPassedCheck(result, types) {
16321
+ return result.checks.some((check) => types.includes(check.type) && check.status === "passed");
16322
+ }
16323
+ function profileHasCheck(result, types) {
16324
+ return result.checks.some((check) => types.includes(check.type));
16325
+ }
16326
+ function profileSetupScreenshotCount(viewports) {
16327
+ return viewports.reduce((sum, viewport) => {
16328
+ const setupScreenshots = Array.isArray(viewport.setup_screenshots) ? viewport.setup_screenshots.filter((label) => typeof label === "string" && label.trim()).length : 0;
16329
+ const finalScreenshot = cliString(viewport.final_screenshot) || cliString(viewport.screenshot_label) ? 1 : 0;
16330
+ return sum + setupScreenshots + finalScreenshot;
16331
+ }, 0);
16332
+ }
16333
+ function profileSetupReceiptTotal(viewports, key) {
16334
+ return viewports.reduce((sum, viewport) => sum + setupReceiptArray(viewport, key).filter((receipt) => receipt.ok !== false).length, 0);
16335
+ }
16336
+ function profileSetupFailureCount(viewports) {
16337
+ return viewports.reduce((sum, viewport) => {
16338
+ const failed = Array.isArray(viewport.failed) ? viewport.failed : [];
16339
+ return sum + failed.filter((failure) => Boolean(cliRecord(failure))).length;
16340
+ }, 0);
16341
+ }
16342
+ function profileSetupObstructionCount(viewports) {
16343
+ return viewports.reduce((sum, viewport) => {
16344
+ const failed = Array.isArray(viewport.failed) ? viewport.failed.map(cliRecord).filter((failure) => Boolean(failure)) : [];
16345
+ return sum + failed.filter((failure) => Boolean(setupFailureObstructionSnippet(cliString(failure.reason)))).length;
16346
+ }, 0);
16347
+ }
16348
+ function profileResultHasArtifact(result) {
16349
+ return Boolean(
16350
+ result.artifacts.proof_json || result.artifacts.console || result.artifacts.dom_summary || result.artifacts.screenshots?.length || result.artifacts.riddle_artifacts?.some((artifact) => artifact.url || artifact.path || artifact.name)
16351
+ );
16352
+ }
16353
+ function profileReceiptSignalStatus(hasSignal, presentReason, missingReason) {
16354
+ return hasSignal ? { status: "present", reason: presentReason } : { status: "missing", reason: missingReason };
16355
+ }
16356
+ function profilePackReceiptStatus(result, metadata, receipt) {
16357
+ const text = receipt.toLowerCase();
16358
+ const setupSummary = profileSetupSummaryRecord(result);
16359
+ const setupViewports = profileSetupSummaryViewports(result);
16360
+ const evidenceViewports = Array.isArray(result.evidence?.viewports) ? result.evidence.viewports : [];
16361
+ const setupResultCount = setupViewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.result_count) || 0), 0);
16362
+ const setupScreenshotCount = profileSetupScreenshotCount(setupViewports);
16363
+ const screenshotCount = (result.artifacts.screenshots?.length || 0) + evidenceViewports.filter((viewport) => cliString(viewport.screenshot_label)).length + setupScreenshotCount;
16364
+ const windowEvalCount = profileSetupReceiptTotal(setupViewports, "window_eval");
16365
+ const valueReceipts = [
16366
+ ...setupViewports.flatMap((viewport) => setupReceiptArray(viewport, "window_eval")),
16367
+ ...setupViewports.flatMap((viewport) => setupReceiptArray(viewport, "window_call"))
16368
+ ].filter((item) => item.ok !== false);
16369
+ const clickCount = setupViewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.clicked_total) || 0), 0) + profileSetupReceiptTotal(setupViewports, "click") + profileSetupReceiptTotal(setupViewports, "click_count");
16370
+ const setupFailureCount = profileSetupFailureCount(setupViewports);
16371
+ const setupObstructionCount = profileSetupObstructionCount(setupViewports);
16372
+ const inputDispatchCount = profileSetupReceiptTotal(setupViewports, "drag") + profileSetupReceiptTotal(setupViewports, "tap") + profileSetupReceiptTotal(setupViewports, "press") + profileSetupReceiptTotal(setupViewports, "keyboard_sequence");
16373
+ const canvasReceipts = setupViewports.flatMap((viewport) => setupReceiptArray(viewport, "canvas_signature"));
16374
+ const hasCanvasChange = canvasReceipts.some((item) => item.ok !== false && item.changed === true);
16375
+ const canvasSignatureHashes = canvasReceipts.filter((item) => item.ok !== false).map((item) => cliString(item.hash)).filter(Boolean);
16376
+ const hasCanvasSignatureChange = hasCanvasChange || new Set(canvasSignatureHashes).size >= 2;
16377
+ const hasNaturalInput = setupNaturalInputSummaryMarkdown(setupViewports).length > 0;
16378
+ const hasStateContract = profileStateContractSummaryMarkdown(result).length > 0 || Boolean(cliRecord(metadata.declared_state_contract));
16379
+ const hasInvalidStateReceipt = valueReceipts.some((item) => {
16380
+ const state = setupReturnSummaryValue(item, ["state", "nextState"]);
16381
+ return typeof state === "string" && state.toLowerCase().includes("invalid");
16382
+ });
16383
+ const hasErrorDetailReceipt = valueReceipts.some((item) => setupReturnSummaryValue(item, ["hasErrorDetail", "errorDetail", "error_detail"]) === true);
16384
+ const hasGridEvidence = valueReceipts.some((item) => setupReturnSummaryValue(item, ["itemCount", "grid.width", "gridWidth", "visibleGridCount"]) !== void 0);
16385
+ const hasVisibleControlReceipt = valueReceipts.some((item) => setupReturnSummaryValue(item, ["visibleButtonCount", "visibleControlCount"]) !== void 0 || setupReturnSummaryValue(item, ["buttonStillVisible", "controlStillVisible"]) === true);
16386
+ const hasToolSelectionReceipt = valueReceipts.some((item) => setupReturnSummaryValue(item, ["rectangleChecked", "toolSelected", "toolChecked", "selected"]) === true);
16387
+ const hasStateGrowthReceipt = valueReceipts.some((item) => {
16388
+ const delta = cliFiniteNumber(setupReturnSummaryValue(item, ["delta", "countDelta", "itemDelta", "stateDelta"]));
16389
+ if (delta !== void 0 && delta > 0) return true;
16390
+ const before = cliFiniteNumber(setupReturnSummaryValue(item, ["before", "beforeCount", "previousCount"]));
16391
+ const after = cliFiniteNumber(setupReturnSummaryValue(item, ["after", "afterCount", "itemCount", "count"]));
16392
+ return before !== void 0 && after !== void 0 && after > before;
16393
+ });
16394
+ const hasReachability = profileReachabilitySummaryMarkdown(result).length > 0 || result.checks.some((check) => check.type === "selector_visible" && Boolean(cliRecord(check.evidence)?.selector));
16395
+ const hasOverflowEvidence = result.checks.some((check) => check.type === "no_horizontal_overflow" || check.type === "no_mobile_horizontal_overflow" || check.type === "frame_no_horizontal_overflow") || evidenceViewports.some((viewport) => (cliFiniteNumber(viewport.overflow_px) || 0) > 0 || (cliFiniteNumber(viewport.bounds_overflow_px) || 0) > 0 || Boolean(viewport.overflow_offenders?.length));
16396
+ const hasConsoleAccounting = profileHasCheck(result, ["no_console_warnings", "no_fatal_console_errors"]) || Boolean(result.evidence?.console || result.evidence?.page_errors);
16397
+ const hasDomSummary = Boolean(result.artifacts.dom_summary || result.evidence?.dom_summary);
16398
+ const hasProofJson = Boolean(result.artifacts.proof_json || result.version === "riddle-proof.profile-result.v1");
16399
+ const hasRouteViewport = Boolean(result.route?.requested || result.route?.observed) && Boolean(evidenceViewports.length || result.route?.matched !== void 0);
16400
+ const hasSetupReceipts = setupResultCount > 0 || Boolean(setupSummary);
16401
+ const hasTextVisibility = profileHasPassedCheck(result, ["text_visible", "selector_text_visible", "selector_visible"]);
16402
+ const hasTextAbsence = profileHasPassedCheck(result, ["text_absent", "selector_text_absent"]);
16403
+ const hasMeasuredStateChange = hasNaturalInput || hasCanvasChange || valueReceipts.some((item) => setupReturnSummaryValue(item, ["changed"]) === true || setupReturnSummaryValue(item, ["nonWhiteDelta", "darkDelta", "pixelDelta", "movementDelta"]) !== void 0);
16404
+ if (text.includes("artifact link") || text.includes("artifact path")) {
16405
+ return profileReceiptSignalStatus(profileResultHasArtifact(result), "artifact references listed", "no artifact references found");
16406
+ }
16407
+ if (text.includes("proof json")) return profileReceiptSignalStatus(hasProofJson, "proof JSON artifact named", "proof JSON artifact missing");
16408
+ if (text.includes("dom summary")) return profileReceiptSignalStatus(hasDomSummary, "DOM summary evidence present", "DOM summary evidence missing");
16409
+ if (text.includes("console") || text.includes("warning") || text.includes("fatal") || text.includes("browser warning") || text.includes("graphics")) {
16410
+ return profileReceiptSignalStatus(hasConsoleAccounting, "console checks or evidence present", "console accounting evidence missing");
16411
+ }
16412
+ if (text.includes("route") && text.includes("viewport")) {
16413
+ return profileReceiptSignalStatus(hasRouteViewport, "route and viewport evidence present", "route or viewport evidence missing");
16414
+ }
16415
+ if (text.includes("setup action")) {
16416
+ return profileReceiptSignalStatus(hasSetupReceipts, "setup receipts present", "setup receipts missing");
16417
+ }
16418
+ if (text.includes("declared state contract")) {
16419
+ return profileReceiptSignalStatus(hasStateContract, "state contract metadata or receipts present", "state contract evidence missing");
16420
+ }
16421
+ if (text.includes("stale") || text.includes("absence")) {
16422
+ return profileReceiptSignalStatus(hasTextAbsence, "absence check passed", "absence check missing");
16423
+ }
16424
+ if (text.includes("recovered") || text.includes("final state")) {
16425
+ return profileReceiptSignalStatus(hasStateContract || hasTextVisibility, "final state receipt present", "final state receipt missing");
16426
+ }
16427
+ if (text.includes("error detail")) {
16428
+ const hasRequiredState = !text.includes("invalid") || hasInvalidStateReceipt;
16429
+ return profileReceiptSignalStatus(
16430
+ hasRequiredState && hasErrorDetailReceipt,
16431
+ "error-detail state receipt present",
16432
+ "error-detail state receipt missing"
16433
+ );
16434
+ }
16435
+ if (text.includes("invalid state")) {
16436
+ return profileReceiptSignalStatus(hasStateContract || hasInvalidStateReceipt, "invalid-state receipt present", "invalid-state receipt missing");
16437
+ }
16438
+ if (text.includes("retry") || text.includes("repair") || text.includes("reset") || text.includes("affordance")) {
16439
+ return profileReceiptSignalStatus(hasStateContract || clickCount > 0, "affordance or transition receipt present", "affordance receipt missing");
16440
+ }
16441
+ if (text.includes("failure") || text.includes("mutation")) {
16442
+ return profileReceiptSignalStatus(hasStateContract || windowEvalCount > 0 || clickCount > 0, "failure or mutation receipt present", "failure or mutation receipt missing");
16443
+ }
16444
+ if (text.includes("initial") && (text.includes("visible") || text.includes("state"))) {
16445
+ return profileReceiptSignalStatus(hasTextVisibility || screenshotCount > 0, "initial visible-state evidence present", "initial state evidence missing");
16446
+ }
16447
+ if (text.includes("state-growth") || text.includes("state growth") || text.includes("growth receipt") || text.includes("grid grows") || text.includes("state") && text.includes("after the click")) {
16448
+ return profileReceiptSignalStatus(hasStateGrowthReceipt, "state-growth receipt present", "state-growth receipt missing");
16449
+ }
16450
+ if (text.includes("visible grid") || text.includes("control evidence") || text.includes("grid") && text.includes("control")) {
16451
+ return profileReceiptSignalStatus(
16452
+ hasGridEvidence && (hasVisibleControlReceipt || hasReachability),
16453
+ "visible grid/control evidence present",
16454
+ "visible grid/control evidence missing"
16455
+ );
16456
+ }
16457
+ if (text.includes("tool") && text.includes("selected") || text.includes("rectangle tool")) {
16458
+ return profileReceiptSignalStatus(hasToolSelectionReceipt, "tool-selection receipt present", "tool-selection receipt missing");
16459
+ }
16460
+ if (text.includes("canvas signature")) {
16461
+ return profileReceiptSignalStatus(hasCanvasSignatureChange, "canvas signature change evidence present", "canvas signature evidence missing");
16462
+ }
16463
+ if (text.includes("selector count") || text.includes("visible count") || text.includes("control visibility") || text.includes("reachability gate") || text.includes("visible control")) {
16464
+ return profileReceiptSignalStatus(hasReachability, "selector visibility or reachability evidence present", "reachability evidence missing");
16465
+ }
16466
+ if (text.includes("overflow") || text.includes("clipped") || text.includes("fit")) {
16467
+ return profileReceiptSignalStatus(hasOverflowEvidence, "overflow evidence present", "overflow evidence missing");
16468
+ }
16469
+ if (text.includes("click receipt") || text.includes("obstruction receipt") || text.includes("state mutation")) {
16470
+ return profileReceiptSignalStatus(clickCount > 0 || setupObstructionCount > 0, "click or obstruction receipt present", "click or obstruction receipt missing");
16471
+ }
16472
+ if (text.includes("target selector") || text.includes("target selector/text")) {
16473
+ return profileReceiptSignalStatus(hasReachability || hasTextVisibility, "selector or text check evidence present", "selector/text evidence missing");
16474
+ }
16475
+ if (text.includes("intercepting element")) {
16476
+ if (setupObstructionCount > 0) return { status: "present", reason: "obstruction receipt present" };
16477
+ return setupFailureCount > 0 ? { status: "missing", reason: "setup failed without intercepting element evidence" } : { status: "manual", reason: "only applies when blocked" };
16478
+ }
16479
+ if (text.includes("before and after state")) {
16480
+ return profileReceiptSignalStatus(
16481
+ hasStateContract || valueReceipts.length >= 2 || screenshotCount >= 2,
16482
+ "before/after state evidence present",
16483
+ "before/after state evidence missing"
16484
+ );
16485
+ }
16486
+ if (text.includes("screenshot")) {
16487
+ const needsBoundaryScreenshots = text.includes("each") || text.includes("before and after") || text.includes("state boundary");
16488
+ return profileReceiptSignalStatus(
16489
+ needsBoundaryScreenshots ? screenshotCount >= 2 : screenshotCount > 0,
16490
+ needsBoundaryScreenshots ? "multiple screenshots present" : "screenshot evidence present",
16491
+ needsBoundaryScreenshots ? "multiple screenshots missing" : "screenshot evidence missing"
16492
+ );
16493
+ }
16494
+ if (text.includes("input dispatch") || text.includes("pointer") || text.includes("touch") || text.includes("key event") || text.includes("trusted-event")) {
16495
+ return profileReceiptSignalStatus(inputDispatchCount > 0 || hasNaturalInput, "input dispatch evidence present", "input dispatch evidence missing");
16496
+ }
16497
+ if (text.includes("measured") || text.includes("state-change") || text.includes("pixel delta") || text.includes("movement receipt") || text.includes("canvas hash")) {
16498
+ return profileReceiptSignalStatus(hasMeasuredStateChange, "measured-change evidence present", "measured-change evidence missing");
16499
+ }
16500
+ return { status: "manual", reason: "semantic receipt requires audit review" };
16501
+ }
16502
+ function profilePackMetadataMarkdown(result) {
16503
+ const metadata = cliRecord(result.metadata);
16504
+ if (!metadata) return [];
16505
+ const packId = cliString(metadata.pack_id);
16506
+ const packPublicName = cliString(metadata.pack_public_name);
16507
+ const requiredReceipts = profileMetadataStringArray(metadata.required_receipts);
16508
+ if (!packId && !packPublicName && !requiredReceipts.length) return [];
16509
+ const lines = [];
16510
+ const packParts = [
16511
+ packId ? markdownInlineCode(packId) : "",
16512
+ packPublicName ? packPublicName : ""
16513
+ ].filter(Boolean);
16514
+ if (packParts.length) lines.push(`- pack: ${packParts.join(" - ")}`);
16515
+ if (requiredReceipts.length) {
16516
+ lines.push(`- required receipts: ${requiredReceipts.length}`);
16517
+ for (const receipt of requiredReceipts.slice(0, 20)) {
16518
+ const item = profilePackReceiptStatus(result, metadata, receipt);
16519
+ lines.push(` - ${item.status}: ${receipt} (${item.reason})`);
16520
+ }
16521
+ if (requiredReceipts.length > 20) lines.push(` - ${requiredReceipts.length - 20} additional required receipt(s) omitted.`);
16522
+ }
16523
+ return lines;
16524
+ }
16289
16525
  function markdownInlineCode(value, maxLength = 80) {
16290
16526
  const normalized = value.replace(/\s+/g, " ").trim();
16291
16527
  const clipped = normalized.length > maxLength ? `${normalized.slice(0, Math.max(0, maxLength - 3))}...` : normalized;
@@ -16547,6 +16783,221 @@ function setupNaturalInputSummaryMarkdown(viewports) {
16547
16783
  }
16548
16784
  return lines;
16549
16785
  }
16786
+ function reachabilityFailureReason(reason) {
16787
+ if (!reason) return void 0;
16788
+ const noVisibleMatch = /No visible match for selector [\s\S]*?:\s*([^\n]+)/.exec(reason);
16789
+ if (noVisibleMatch?.[1]) return noVisibleMatch[1].trim().slice(0, 120);
16790
+ if (/no_visible_match/.test(reason)) return "no_visible_match";
16791
+ if (/not visible/i.test(reason)) return "not_visible";
16792
+ return void 0;
16793
+ }
16794
+ function viewportTopBoundsOverflowPx(viewport) {
16795
+ const direct = cliFiniteNumber(viewport.bounds_overflow_px);
16796
+ if (direct !== void 0 && direct > 0) return direct;
16797
+ const offenders = Array.isArray(viewport.overflow_offenders) ? viewport.overflow_offenders.map(cliRecord).filter((item) => Boolean(item)) : [];
16798
+ for (const offender of offenders) {
16799
+ const overflow = cliFiniteNumber(offender.bounds_overflow_px) ?? cliFiniteNumber(offender.overflow_px) ?? cliFiniteNumber(offender.overflow);
16800
+ if (overflow !== void 0 && overflow > 0) return overflow;
16801
+ }
16802
+ const scrollOverflow = cliFiniteNumber(viewport.overflow_px);
16803
+ return scrollOverflow !== void 0 && scrollOverflow > 0 ? scrollOverflow : void 0;
16804
+ }
16805
+ function profileReachabilitySummaryMarkdown(result) {
16806
+ const evidenceViewports = Array.isArray(result.evidence?.viewports) ? result.evidence.viewports.map((viewport) => cliRecord(viewport)).filter((viewport) => Boolean(viewport)) : [];
16807
+ if (!evidenceViewports.length) return [];
16808
+ const evidenceByName = /* @__PURE__ */ new Map();
16809
+ for (const viewport of evidenceViewports) {
16810
+ const name = cliString(viewport.name);
16811
+ if (name) evidenceByName.set(name, viewport);
16812
+ }
16813
+ const receipts = [];
16814
+ const seen = /* @__PURE__ */ new Set();
16815
+ const addReceipt = (viewportName, selector, reason) => {
16816
+ const viewport = evidenceByName.get(viewportName);
16817
+ if (!viewport) return;
16818
+ const selectors = cliRecord(viewport.selectors);
16819
+ const selectorEvidence = cliRecord(selectors?.[selector]);
16820
+ const count = cliFiniteNumber(selectorEvidence?.count);
16821
+ const visibleCount = cliFiniteNumber(selectorEvidence?.visible_count);
16822
+ if (count === void 0 || count <= 0 || visibleCount === void 0 || visibleCount > 0) return;
16823
+ const key = `${viewportName}\0${selector}`;
16824
+ if (seen.has(key)) return;
16825
+ seen.add(key);
16826
+ const reasonText = reason || "no_visible_match";
16827
+ const boundsOverflow = viewportTopBoundsOverflowPx(viewport);
16828
+ receipts.push(`- reachability ${viewportName}: ${markdownInlineCode(selector, 120)} exists ${count}, visible ${visibleCount}, reason ${markdownInlineCode(reasonText, 80)}${boundsOverflow === void 0 ? "" : `, top bounds overflow ${boundsOverflow}px`}`);
16829
+ };
16830
+ const setupCheck = result.checks.find((check) => check.type === "setup_actions_succeeded");
16831
+ const setupSummary = cliRecord(setupCheck?.evidence?.setup_summary);
16832
+ const setupViewports = Array.isArray(setupSummary?.viewports) ? setupSummary.viewports.map(cliRecord).filter((viewport) => Boolean(viewport)) : [];
16833
+ for (const viewport of setupViewports) {
16834
+ const viewportName = cliString(viewport.name) || "viewport";
16835
+ const failed = [
16836
+ ...Array.isArray(viewport.failed) ? viewport.failed : [],
16837
+ ...Array.isArray(viewport.optional_failed) ? viewport.optional_failed : []
16838
+ ].map(cliRecord).filter((failure) => Boolean(failure));
16839
+ for (const failure of failed) {
16840
+ const selector = cliString(failure.selector);
16841
+ const reason = reachabilityFailureReason(cliString(failure.reason));
16842
+ if (selector && reason) addReceipt(viewportName, selector, reason);
16843
+ }
16844
+ }
16845
+ for (const check of result.checks) {
16846
+ if (check.type !== "selector_visible" || check.status !== "failed") continue;
16847
+ const evidence = cliRecord(check.evidence);
16848
+ const selector = cliString(evidence?.selector);
16849
+ if (!selector) continue;
16850
+ for (const viewport of evidenceViewports) {
16851
+ const viewportName = cliString(viewport.name) || "viewport";
16852
+ addReceipt(viewportName, selector, "no_visible_match");
16853
+ }
16854
+ }
16855
+ if (receipts.length > 8) {
16856
+ return [...receipts.slice(0, 8), `- ${receipts.length - 8} additional reachability receipt(s) omitted.`];
16857
+ }
16858
+ return receipts;
16859
+ }
16860
+ function stateContractReceiptName(receipt, fallbackIndex) {
16861
+ const storedTo = cliString(receipt.return_stored_to);
16862
+ if (!storedTo) return `receipt-${fallbackIndex + 1}`;
16863
+ const parts = storedTo.split(".").map((part) => part.trim()).filter(Boolean);
16864
+ return parts[parts.length - 1] || storedTo;
16865
+ }
16866
+ function stateContractReceiptValue(receipt) {
16867
+ const value = setupReturnSummaryValue(receipt, [
16868
+ "state",
16869
+ "nextState",
16870
+ "terminalState",
16871
+ "finalState",
16872
+ "status",
16873
+ "phase"
16874
+ ]);
16875
+ return cliValueLabel(value);
16876
+ }
16877
+ function stateContractSignalParts(receipts) {
16878
+ const names = [
16879
+ "hasValidate",
16880
+ "hasTryFix",
16881
+ "hasErrorDetail",
16882
+ "hasValid",
16883
+ "hasInvalid",
16884
+ "invalidGone",
16885
+ "staleGone",
16886
+ "staleCopyGone",
16887
+ "repairedTrailingCommaGone",
16888
+ "hasSuccess",
16889
+ "hasFailure",
16890
+ "hasRetry",
16891
+ "hasError",
16892
+ "success",
16893
+ "recovered"
16894
+ ];
16895
+ const seen = /* @__PURE__ */ new Set();
16896
+ const parts = [];
16897
+ for (const receipt of receipts) {
16898
+ for (const name of names) {
16899
+ const value = setupReturnSummaryValue(receipt, [name]);
16900
+ if (value === void 0) continue;
16901
+ const label = cliValueLabel(value);
16902
+ if (label === void 0) continue;
16903
+ const part = `${name}=${label}`;
16904
+ if (seen.has(part)) continue;
16905
+ seen.add(part);
16906
+ parts.push(part);
16907
+ if (parts.length >= 8) return parts;
16908
+ }
16909
+ }
16910
+ return parts;
16911
+ }
16912
+ function profileStateContractSummaryMarkdown(result) {
16913
+ const setupCheck = result.checks.find((check) => check.type === "setup_actions_succeeded");
16914
+ const setupSummary = cliRecord(setupCheck?.evidence?.setup_summary);
16915
+ const viewports = Array.isArray(setupSummary?.viewports) ? setupSummary.viewports.map(cliRecord).filter((viewport) => Boolean(viewport)) : [];
16916
+ const lines = [];
16917
+ for (const viewport of viewports.slice(0, 8)) {
16918
+ const name = cliString(viewport.name) || "viewport";
16919
+ const receipts = [
16920
+ ...setupReceiptArray(viewport, "window_eval"),
16921
+ ...setupReceiptArray(viewport, "window_call"),
16922
+ ...setupReceiptArray(viewport, "window_call_until")
16923
+ ].filter((receipt) => receipt.ok !== false);
16924
+ const states = receipts.map((receipt, index) => ({
16925
+ name: stateContractReceiptName(receipt, index),
16926
+ state: stateContractReceiptValue(receipt)
16927
+ })).filter((receipt) => Boolean(receipt.state));
16928
+ if (states.length < 2) continue;
16929
+ const stateChain = states.slice(0, 6).map((receipt) => `${markdownInlineCode(receipt.name, 60)}=${markdownInlineCode(receipt.state, 80)}`).join(" -> ");
16930
+ const omitted = states.length > 6 ? ` (+${states.length - 6} more)` : "";
16931
+ const signals = stateContractSignalParts(receipts);
16932
+ lines.push(`- state contract ${name}: ${stateChain}${omitted}${signals.length ? `; signals ${signals.map((part) => markdownInlineCode(part, 80)).join(", ")}` : ""}`);
16933
+ }
16934
+ return lines;
16935
+ }
16936
+ function sideCaveatAllowlistPart(evidence, totalKey, allowedKey) {
16937
+ const total = cliFiniteNumber(evidence[totalKey]);
16938
+ const allowed = cliFiniteNumber(evidence[allowedKey]);
16939
+ if (total === void 0 || allowed === void 0 || allowed <= 0) return void 0;
16940
+ return `${allowed}/${total} allowed`;
16941
+ }
16942
+ function sideCaveatAllowlistCounts(evidence) {
16943
+ const textCount = Array.isArray(evidence.allowed_console_texts) ? evidence.allowed_console_texts.filter((value) => typeof value === "string" && value.trim()).length : 0;
16944
+ const patternCount = Array.isArray(evidence.allowed_console_patterns) ? evidence.allowed_console_patterns.filter((value) => typeof value === "string" && value.trim()).length : 0;
16945
+ return textCount || patternCount ? `allowlist ${textCount} text${textCount === 1 ? "" : "s"}, ${patternCount} pattern${patternCount === 1 ? "" : "s"}` : void 0;
16946
+ }
16947
+ function overflowCheckFailed(result) {
16948
+ return result.checks.some((check) => check.status === "failed" && (check.type === "no_horizontal_overflow" || check.type === "no_mobile_horizontal_overflow" || check.type === "frame_no_horizontal_overflow"));
16949
+ }
16950
+ function sideCaveatOverflowLine(viewport) {
16951
+ const name = cliString(viewport.name) || "viewport";
16952
+ const scrollOverflow = cliFiniteNumber(viewport.overflow_px);
16953
+ const boundsOverflow = cliFiniteNumber(viewport.bounds_overflow_px);
16954
+ if ((scrollOverflow === void 0 || scrollOverflow <= 0) && (boundsOverflow === void 0 || boundsOverflow <= 0)) return void 0;
16955
+ const parts = [
16956
+ scrollOverflow !== void 0 && scrollOverflow > 0 ? `scroll overflow ${scrollOverflow}px` : "",
16957
+ boundsOverflow !== void 0 && boundsOverflow > 0 ? `bounds overflow ${boundsOverflow}px` : ""
16958
+ ].filter(Boolean);
16959
+ const offenders = Array.isArray(viewport.overflow_offenders) ? viewport.overflow_offenders.map(cliRecord).filter((item) => Boolean(item)) : [];
16960
+ const offender = offenders.find((item) => {
16961
+ const overflow = cliFiniteNumber(item.bounds_overflow_px) ?? cliFiniteNumber(item.overflow_px) ?? cliFiniteNumber(item.overflow);
16962
+ return overflow !== void 0 && overflow > 0;
16963
+ });
16964
+ const offenderSelector = cliString(offender?.selector);
16965
+ const offenderOverflow = offender ? cliFiniteNumber(offender.bounds_overflow_px) ?? cliFiniteNumber(offender.overflow_px) ?? cliFiniteNumber(offender.overflow) : void 0;
16966
+ return `- side caveat layout ${name}: ${parts.join(", ")}${offenderSelector && offenderOverflow !== void 0 ? `; top offender ${markdownInlineCode(offenderSelector, 100)} ${offenderOverflow}px` : ""}`;
16967
+ }
16968
+ function profileSideCaveatSummaryMarkdown(result) {
16969
+ const lines = [];
16970
+ for (const check of result.checks) {
16971
+ if (check.status !== "passed") continue;
16972
+ const evidence = cliRecord(check.evidence);
16973
+ if (!evidence) continue;
16974
+ if (check.type === "no_console_warnings") {
16975
+ const allowed = sideCaveatAllowlistPart(evidence, "total_console_warning_count", "allowed_console_warning_count");
16976
+ if (allowed) {
16977
+ const allowlist = sideCaveatAllowlistCounts(evidence);
16978
+ lines.push(`- side caveat console warnings: ${allowed}${allowlist ? `; ${allowlist}` : ""}`);
16979
+ }
16980
+ }
16981
+ if (check.type === "no_fatal_console_errors") {
16982
+ const consoleAllowed = sideCaveatAllowlistPart(evidence, "total_console_fatal_count", "allowed_console_fatal_count");
16983
+ const pageAllowed = sideCaveatAllowlistPart(evidence, "total_page_error_count", "allowed_page_error_count");
16984
+ const parts = [
16985
+ consoleAllowed ? `console fatal ${consoleAllowed}` : "",
16986
+ pageAllowed ? `page errors ${pageAllowed}` : "",
16987
+ sideCaveatAllowlistCounts(evidence)
16988
+ ].filter(Boolean);
16989
+ if (parts.length) lines.push(`- side caveat fatal errors: ${parts.join("; ")}`);
16990
+ }
16991
+ }
16992
+ if (!overflowCheckFailed(result) && Array.isArray(result.evidence?.viewports)) {
16993
+ for (const viewport of result.evidence.viewports.slice(0, 8)) {
16994
+ const line = sideCaveatOverflowLine(cliRecord(viewport) || {});
16995
+ if (line) lines.push(line);
16996
+ }
16997
+ if (result.evidence.viewports.length > 8) lines.push(`- ${result.evidence.viewports.length - 8} additional viewport side caveat(s) omitted.`);
16998
+ }
16999
+ return lines.slice(0, 12);
17000
+ }
16550
17001
  function balancedSetupReceiptDetails(groups, limit) {
16551
17002
  if (limit <= 0) return [];
16552
17003
  const total = groups.reduce((sum, group) => sum + group.length, 0);
@@ -16694,7 +17145,10 @@ function profileSetupSummaryMarkdown(result) {
16694
17145
  const rangeValueTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.set_range_value_total) || 0), 0);
16695
17146
  const dragTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.drag_total) || 0), 0);
16696
17147
  const tapTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.tap_total) || 0), 0);
16697
- const pressTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.press_total) || 0), 0);
17148
+ const keyboardTotal = viewports.reduce((sum, viewport) => {
17149
+ const total = cliFiniteNumber(viewport.keyboard_total);
17150
+ return sum + (total === void 0 ? cliFiniteNumber(viewport.press_total) || 0 : total);
17151
+ }, 0);
16698
17152
  const canvasSignatureTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.canvas_signature_total) || 0), 0);
16699
17153
  const failedTotal = viewports.reduce((sum, viewport) => sum + (Array.isArray(viewport.failed) ? viewport.failed.length : 0), 0);
16700
17154
  const lines = [
@@ -16730,8 +17184,8 @@ function profileSetupSummaryMarkdown(result) {
16730
17184
  if (tapTotal) {
16731
17185
  lines.push(`- tap: ${tapTotal} action(s)`);
16732
17186
  }
16733
- if (pressTotal) {
16734
- lines.push(`- press: ${pressTotal} action(s)`);
17187
+ if (keyboardTotal) {
17188
+ lines.push(`- keyboard: ${keyboardTotal} action(s)`);
16735
17189
  }
16736
17190
  if (canvasSignatureTotal) {
16737
17191
  lines.push(`- canvas_signature: ${canvasSignatureTotal} action(s)`);
@@ -16757,10 +17211,10 @@ function profileSetupSummaryMarkdown(result) {
16757
17211
  const rangeValueActions = cliFiniteNumber(viewport.set_range_value_total) || 0;
16758
17212
  const dragActions = cliFiniteNumber(viewport.drag_total) || 0;
16759
17213
  const tapActions = cliFiniteNumber(viewport.tap_total) || 0;
16760
- const pressActions = cliFiniteNumber(viewport.press_total) || 0;
17214
+ const keyboardActions = cliFiniteNumber(viewport.keyboard_total) ?? cliFiniteNumber(viewport.press_total) ?? 0;
16761
17215
  const canvasSignatureActions = cliFiniteNumber(viewport.canvas_signature_total) || 0;
16762
17216
  const observedPath = cliString(viewport.observed_path);
16763
- lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickSequenceCount ? `, ${clickSequenceCount} click sequence(s)` : ""}${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${rangeValueActions ? `, ${rangeValueActions} set_range_value action(s)` : ""}${dragActions ? `, ${dragActions} drag action(s)` : ""}${tapActions ? `, ${tapActions} tap action(s)` : ""}${pressActions ? `, ${pressActions} press action(s)` : ""}${canvasSignatureActions ? `, ${canvasSignatureActions} canvas_signature action(s)` : ""}${deterministicRuntimeActions ? `, ${deterministicRuntimeActions} deterministic_runtime action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowEvalActions ? `, ${windowEvalActions} window_eval action(s), ${windowEvalStored} stored return(s), ${windowEvalCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
17217
+ lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickSequenceCount ? `, ${clickSequenceCount} click sequence(s)` : ""}${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${rangeValueActions ? `, ${rangeValueActions} set_range_value action(s)` : ""}${dragActions ? `, ${dragActions} drag action(s)` : ""}${tapActions ? `, ${tapActions} tap action(s)` : ""}${keyboardActions ? `, ${keyboardActions} keyboard action(s)` : ""}${canvasSignatureActions ? `, ${canvasSignatureActions} canvas_signature action(s)` : ""}${deterministicRuntimeActions ? `, ${deterministicRuntimeActions} deterministic_runtime action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowEvalActions ? `, ${windowEvalActions} window_eval action(s), ${windowEvalStored} stored return(s), ${windowEvalCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
16764
17218
  }
16765
17219
  const clickSequenceGroups = viewports.map((viewport) => {
16766
17220
  const name = cliString(viewport.name) || "viewport";
@@ -16827,13 +17281,14 @@ function profileSetupSummaryMarkdown(result) {
16827
17281
  lines.push(`- ${name} tap: ${ok}, ${markdownInlineCode(selector)}${pointerType ? ` ${markdownInlineCode(pointerType)}` : ""}${inputDispatch ? ` via ${markdownInlineCode(inputDispatch)}` : ""}${coordinateText}${durationMs === void 0 ? "" : `, duration ${durationMs}ms`}${reason ? `, reason ${markdownInlineCode(reason, 100)}` : ""}`);
16828
17282
  }
16829
17283
  if (tapDetails.length > sampledTapDetails.length) lines.push(`- ${tapDetails.length - sampledTapDetails.length} additional tap receipt(s) omitted.`);
16830
- const pressGroups = viewports.map((viewport) => {
17284
+ const keyboardGroups = viewports.map((viewport) => {
16831
17285
  const name = cliString(viewport.name) || "viewport";
16832
- const receipts = Array.isArray(viewport.press) ? viewport.press.map(cliRecord).filter((item) => Boolean(item)) : [];
17286
+ const rawReceipts = Array.isArray(viewport.keyboard) ? viewport.keyboard : viewport.press;
17287
+ const receipts = Array.isArray(rawReceipts) ? rawReceipts.map(cliRecord).filter((item) => Boolean(item)) : [];
16833
17288
  return receipts.map((receipt) => ({ name, receipt }));
16834
17289
  });
16835
- const pressDetails = pressGroups.flat();
16836
- for (const group of pressGroups.slice(0, 8)) {
17290
+ const keyboardDetails = keyboardGroups.flat();
17291
+ for (const group of keyboardGroups.slice(0, 8)) {
16837
17292
  if (!group.length) continue;
16838
17293
  const name = group[0].name;
16839
17294
  const keys = group.map(({ receipt }) => cliString(receipt.key) || "key").filter(Boolean);
@@ -16844,10 +17299,10 @@ function profileSetupSummaryMarkdown(result) {
16844
17299
  const omittedOrdinalCount = Math.max(0, ordinals.length - visibleOrdinals.length);
16845
17300
  const keyText = visibleKeys.join(",");
16846
17301
  const ordinalText = visibleOrdinals.join(",");
16847
- lines.push(`- ${name} press_sequence: keys ${markdownInlineCode(keyText, 200)}${omittedKeyCount ? ` (+${omittedKeyCount} omitted)` : ""}${ordinalText ? `, ordinals ${markdownInlineCode(ordinalText, 120)}${omittedOrdinalCount ? ` (+${omittedOrdinalCount} omitted)` : ""}` : ""}`);
17302
+ lines.push(`- ${name} keyboard_sequence: keys ${markdownInlineCode(keyText, 200)}${omittedKeyCount ? ` (+${omittedKeyCount} omitted)` : ""}${ordinalText ? `, ordinals ${markdownInlineCode(ordinalText, 120)}${omittedOrdinalCount ? ` (+${omittedOrdinalCount} omitted)` : ""}` : ""}`);
16848
17303
  }
16849
- const sampledPressDetails = balancedSetupReceiptDetails(pressGroups, 12);
16850
- for (const { name, receipt } of sampledPressDetails) {
17304
+ const sampledKeyboardDetails = balancedSetupReceiptDetails(keyboardGroups, 12);
17305
+ for (const { name, receipt } of sampledKeyboardDetails) {
16851
17306
  const action = cliString(receipt.action) || "press";
16852
17307
  const key = cliString(receipt.key) || "key";
16853
17308
  const selector = cliString(receipt.selector);
@@ -16857,7 +17312,7 @@ function profileSetupSummaryMarkdown(result) {
16857
17312
  const reason = cliString(receipt.reason);
16858
17313
  lines.push(`- ${name} ${action}: ${ok}, ${markdownInlineCode(key)}${selector ? ` on ${markdownInlineCode(selector)}` : ""}${frameSelector ? ` in frame ${markdownInlineCode(frameSelector)}` : ""}${holdMs === void 0 ? "" : `, held ${holdMs}ms`}${reason ? `, reason ${markdownInlineCode(reason, 100)}` : ""}`);
16859
17314
  }
16860
- if (pressDetails.length > sampledPressDetails.length) lines.push(`- ${pressDetails.length - sampledPressDetails.length} additional press receipt(s) omitted.`);
17315
+ if (keyboardDetails.length > sampledKeyboardDetails.length) lines.push(`- ${keyboardDetails.length - sampledKeyboardDetails.length} additional keyboard receipt(s) omitted.`);
16861
17316
  const canvasSignatureGroups = viewports.map((viewport) => {
16862
17317
  const name = cliString(viewport.name) || "viewport";
16863
17318
  const receipts = Array.isArray(viewport.canvas_signature) ? viewport.canvas_signature.map(cliRecord).filter((item) => Boolean(item)) : [];
@@ -17260,7 +17715,7 @@ async function readArtifactJson(artifact) {
17260
17715
  async function profileResultFromRiddleArtifacts(profile, artifacts, fallbackInputs) {
17261
17716
  for (const input of fallbackInputs) {
17262
17717
  const result = extractRiddleProofProfileResult(input);
17263
- if (result) return result;
17718
+ if (result) return withProfileMetadata(profile, result);
17264
17719
  }
17265
17720
  const proofArtifacts = artifacts.filter((artifact) => /(^|\/)proof\.json(?:\.json)?$/i.test(artifact.name || artifact.url || artifact.path || "")).sort((left, right) => {
17266
17721
  const leftName = left.name || left.url || left.path || "";
@@ -17270,7 +17725,7 @@ async function profileResultFromRiddleArtifacts(profile, artifacts, fallbackInpu
17270
17725
  for (const artifact of proofArtifacts) {
17271
17726
  const parsed = await readArtifactJson(artifact);
17272
17727
  const result = extractRiddleProofProfileResult(parsed);
17273
- if (result) return result;
17728
+ if (result) return withProfileMetadata(profile, result);
17274
17729
  }
17275
17730
  const evidenceArtifacts = artifacts.filter((artifact) => /profile-evidence|evidence\.json/i.test(artifact.name || artifact.url || artifact.path || ""));
17276
17731
  for (const artifact of evidenceArtifacts) {
@@ -17281,6 +17736,16 @@ async function profileResultFromRiddleArtifacts(profile, artifacts, fallbackInpu
17281
17736
  }
17282
17737
  return void 0;
17283
17738
  }
17739
+ function withProfileMetadata(profile, result) {
17740
+ if (!profile.metadata || !Object.keys(profile.metadata).length) return result;
17741
+ return {
17742
+ ...result,
17743
+ metadata: {
17744
+ ...profile.metadata,
17745
+ ...result.metadata || {}
17746
+ }
17747
+ };
17748
+ }
17284
17749
  function withRiddleMetadata(result, input) {
17285
17750
  const poll = input.poll;
17286
17751
  const staleJobIds = input.staleJobIds?.filter(Boolean);
@@ -17624,7 +18089,7 @@ async function runSingleRiddleProfileForCli(profile, options, input) {
17624
18089
  jobId = typeof created.job_id === "string" ? created.job_id : typeof created.id === "string" ? created.id : "";
17625
18090
  if (!jobId) {
17626
18091
  const directResult = extractRiddleProofProfileResult(created);
17627
- return directResult ? withRiddleMetadata(directResult, { artifacts: collectRiddleProfileArtifactRefs(created) }) : createRiddleProofProfileInsufficientResult({ profile, runner, error: "Riddle run response was missing job_id.", artifacts: collectRiddleProfileArtifactRefs(created) });
18092
+ return directResult ? withRiddleMetadata(withProfileMetadata(profile, directResult), { artifacts: collectRiddleProfileArtifactRefs(created) }) : createRiddleProofProfileInsufficientResult({ profile, runner, error: "Riddle run response was missing job_id.", artifacts: collectRiddleProfileArtifactRefs(created) });
17628
18093
  }
17629
18094
  poll = await client.pollJob(jobId, pollOptions);
17630
18095
  if (attempt < retryLimit && shouldRetryUnsubmittedRiddleJob(poll)) {