@riddledc/riddle-proof 0.5.33 → 0.5.34

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.
Files changed (39) hide show
  1. package/dist/{chunk-A5AWVY5A.js → chunk-4YCWZVBN.js} +20 -2
  2. package/dist/{chunk-CHKYSZLU.js → chunk-7R6ZQE3X.js} +5 -5
  3. package/dist/{chunk-TMMKRKY5.js → chunk-J2MERROF.js} +1 -0
  4. package/dist/{chunk-F6VFKS7K.js → chunk-MQ2BHHLX.js} +2 -2
  5. package/dist/{chunk-7ZJAUEUN.js → chunk-OASB3CYU.js} +6 -1
  6. package/dist/chunk-ODORKNSO.js +121 -0
  7. package/dist/engine-harness.cjs +26 -2
  8. package/dist/engine-harness.js +4 -4
  9. package/dist/index.cjs +154 -4
  10. package/dist/index.d.cts +2 -1
  11. package/dist/index.d.ts +2 -1
  12. package/dist/index.js +24 -8
  13. package/dist/openclaw.cjs +5 -0
  14. package/dist/openclaw.js +2 -2
  15. package/dist/proof-run-core.cjs +20 -2
  16. package/dist/proof-run-core.d.cts +16 -0
  17. package/dist/proof-run-core.d.ts +16 -0
  18. package/dist/proof-run-core.js +1 -1
  19. package/dist/proof-run-engine.cjs +20 -2
  20. package/dist/proof-run-engine.d.cts +24 -0
  21. package/dist/proof-run-engine.d.ts +24 -0
  22. package/dist/proof-run-engine.js +1 -1
  23. package/dist/proof-session.cjs +151 -0
  24. package/dist/proof-session.d.cts +37 -0
  25. package/dist/proof-session.d.ts +37 -0
  26. package/dist/proof-session.js +18 -0
  27. package/dist/result.cjs +1 -0
  28. package/dist/result.js +1 -1
  29. package/dist/runner.cjs +6 -0
  30. package/dist/runner.js +3 -3
  31. package/dist/state.cjs +5 -0
  32. package/dist/state.js +2 -2
  33. package/dist/types.d.cts +67 -1
  34. package/dist/types.d.ts +67 -1
  35. package/package.json +7 -2
  36. package/runtime/lib/preflight.py +42 -2
  37. package/runtime/lib/util.py +237 -0
  38. package/runtime/lib/verify.py +55 -2
  39. package/runtime/tests/recon_verify_smoke.py +120 -1
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import {
2
+ runRiddleProof
3
+ } from "./chunk-MQ2BHHLX.js";
1
4
  import "./chunk-6F4PWJZI.js";
2
5
  import {
3
6
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
@@ -13,11 +16,7 @@ import {
13
16
  createDisabledRiddleProofAgentAdapter,
14
17
  readRiddleProofRunStatus,
15
18
  runRiddleProofEngineHarness
16
- } from "./chunk-CHKYSZLU.js";
17
- import "./chunk-A5AWVY5A.js";
18
- import {
19
- runRiddleProof
20
- } from "./chunk-F6VFKS7K.js";
19
+ } from "./chunk-7R6ZQE3X.js";
21
20
  import {
22
21
  RIDDLE_PROOF_RUN_STATE_VERSION,
23
22
  appendRunEvent,
@@ -29,7 +28,17 @@ import {
29
28
  normalizePrLifecycleState,
30
29
  normalizeRunParams,
31
30
  setRunStatus
32
- } from "./chunk-7ZJAUEUN.js";
31
+ } from "./chunk-OASB3CYU.js";
32
+ import "./chunk-4YCWZVBN.js";
33
+ import {
34
+ RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION,
35
+ RIDDLE_PROOF_VISUAL_SESSION_VERSION,
36
+ buildVisualProofSession,
37
+ compareVisualProofSessionFingerprint,
38
+ parseVisualProofSession,
39
+ visualSessionFingerprint,
40
+ visualSessionFingerprintBasis
41
+ } from "./chunk-ODORKNSO.js";
33
42
  import {
34
43
  applyTerminalMetadata,
35
44
  compactRecord,
@@ -39,19 +48,23 @@ import {
39
48
  nonEmptyString,
40
49
  normalizeTerminalMetadata,
41
50
  recordValue
42
- } from "./chunk-TMMKRKY5.js";
51
+ } from "./chunk-J2MERROF.js";
43
52
  export {
44
53
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
45
54
  DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
46
55
  DEFAULT_DIAGNOSTIC_STRING_LIMIT,
47
56
  RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
48
57
  RIDDLE_PROOF_RUN_STATE_VERSION,
58
+ RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION,
59
+ RIDDLE_PROOF_VISUAL_SESSION_VERSION,
49
60
  appendCaptureDiagnostic,
50
61
  appendRunEvent,
51
62
  appendStageHeartbeat,
52
63
  applyPrLifecycleState,
53
64
  applyTerminalMetadata,
65
+ buildVisualProofSession,
54
66
  compactRecord,
67
+ compareVisualProofSessionFingerprint,
55
68
  createCaptureDiagnostic,
56
69
  createDisabledRiddleProofAgentAdapter,
57
70
  createRunResult,
@@ -64,11 +77,14 @@ export {
64
77
  normalizePrLifecycleState,
65
78
  normalizeRunParams,
66
79
  normalizeTerminalMetadata,
80
+ parseVisualProofSession,
67
81
  readRiddleProofRunStatus,
68
82
  recordValue,
69
83
  redactForProofDiagnostics,
70
84
  runRiddleProof,
71
85
  runRiddleProofEngineHarness,
72
86
  setRunStatus,
73
- summarizeCaptureArtifacts
87
+ summarizeCaptureArtifacts,
88
+ visualSessionFingerprint,
89
+ visualSessionFingerprintBasis
74
90
  };
package/dist/openclaw.cjs CHANGED
@@ -64,6 +64,11 @@ function normalizeRunParams(input) {
64
64
  success_criteria: input.success_criteria,
65
65
  assertions: input.assertions,
66
66
  verification_mode: input.verification_mode,
67
+ resume_session: input.resume_session,
68
+ target_image_url: input.target_image_url,
69
+ target_image_hash: input.target_image_hash,
70
+ viewport_matrix: input.viewport_matrix,
71
+ deterministic_setup: input.deterministic_setup,
67
72
  reference: input.reference,
68
73
  base_branch: input.base_branch,
69
74
  before_ref: input.before_ref,
package/dist/openclaw.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  normalizeIntegrationContext,
3
3
  normalizeRunParams
4
- } from "./chunk-7ZJAUEUN.js";
4
+ } from "./chunk-OASB3CYU.js";
5
5
  import {
6
6
  compactRecord
7
- } from "./chunk-TMMKRKY5.js";
7
+ } from "./chunk-J2MERROF.js";
8
8
 
9
9
  // src/openclaw.ts
10
10
  function parseOpenClawAssertions(value) {
@@ -122,6 +122,11 @@ function ensureAction(action) {
122
122
  function workflowFile(riddleProofDir, action) {
123
123
  return import_node_path.default.join(riddleProofDir, "pipelines", `riddle-proof-${action}.lobster`);
124
124
  }
125
+ function asJsonString(value) {
126
+ if (value === void 0 || value === null || value === "") return "";
127
+ if (typeof value === "string") return value;
128
+ return JSON.stringify(value);
129
+ }
125
130
  function buildSetupArgs(params, config) {
126
131
  if (!params.repo) throw new Error("repo is required for setup/run");
127
132
  if (!params.change_request) throw new Error("change_request is required for setup/run");
@@ -137,8 +142,13 @@ function buildSetupArgs(params, config) {
137
142
  prod_url: params.prod_url || "",
138
143
  capture_script: captureScript,
139
144
  success_criteria: params.success_criteria || "",
140
- assertions_json: params.assertions_json || "",
145
+ assertions_json: params.assertions_json || asJsonString(params.assertions),
141
146
  verification_mode: params.verification_mode || "proof",
147
+ resume_session: params.resume_session || "",
148
+ target_image_url: params.target_image_url || "",
149
+ target_image_hash: params.target_image_hash || "",
150
+ viewport_matrix_json: params.viewport_matrix_json || asJsonString(params.viewport_matrix),
151
+ deterministic_setup_json: params.deterministic_setup_json || asJsonString(params.deterministic_setup),
142
152
  reference: requestedReference,
143
153
  base_branch: params.base_branch || "main",
144
154
  before_ref: params.before_ref || "",
@@ -708,6 +718,11 @@ function mergeStateFromParams(statePath, params) {
708
718
  "success_criteria",
709
719
  "assertions_json",
710
720
  "verification_mode",
721
+ "resume_session",
722
+ "target_image_url",
723
+ "target_image_hash",
724
+ "viewport_matrix_json",
725
+ "deterministic_setup_json",
711
726
  "base_branch",
712
727
  "before_ref",
713
728
  "context",
@@ -939,7 +954,10 @@ function summarizeState(state) {
939
954
  explicit_stage_gate: Boolean(state.explicit_stage_gate),
940
955
  last_requested_advance_stage: state.last_requested_advance_stage || null,
941
956
  recon_results: state.recon_results || null,
942
- verify_results: state.verify_results || null
957
+ verify_results: state.verify_results || null,
958
+ proof_session: state.proof_session || null,
959
+ parent_proof_session: state.parent_proof_session || null,
960
+ proof_session_artifact_url: state.proof_session_artifact_url || null
943
961
  };
944
962
  const parts = [
945
963
  state.workspace_ready ? "workspace ready" : "workspace not ready",
@@ -10,8 +10,16 @@ interface WorkflowParams {
10
10
  prod_url?: string;
11
11
  capture_script?: string;
12
12
  success_criteria?: string;
13
+ assertions?: unknown;
13
14
  assertions_json?: string;
14
15
  verification_mode?: string;
16
+ resume_session?: string;
17
+ target_image_url?: string;
18
+ target_image_hash?: string;
19
+ viewport_matrix?: unknown;
20
+ viewport_matrix_json?: string;
21
+ deterministic_setup?: unknown;
22
+ deterministic_setup_json?: string;
15
23
  reference?: "prod" | "before" | "both";
16
24
  base_branch?: string;
17
25
  before_ref?: string;
@@ -102,6 +110,11 @@ declare function buildSetupArgs(params: WorkflowParams, config: ReturnType<typeo
102
110
  success_criteria: string;
103
111
  assertions_json: string;
104
112
  verification_mode: string;
113
+ resume_session: string;
114
+ target_image_url: string;
115
+ target_image_hash: string;
116
+ viewport_matrix_json: string;
117
+ deterministic_setup_json: string;
105
118
  reference: "prod" | "before" | "both";
106
119
  base_branch: string;
107
120
  before_ref: string;
@@ -287,6 +300,9 @@ declare function summarizeState(state: any): {
287
300
  last_requested_advance_stage: any;
288
301
  recon_results: any;
289
302
  verify_results: any;
303
+ proof_session: any;
304
+ parent_proof_session: any;
305
+ proof_session_artifact_url: any;
290
306
  };
291
307
  };
292
308
 
@@ -10,8 +10,16 @@ interface WorkflowParams {
10
10
  prod_url?: string;
11
11
  capture_script?: string;
12
12
  success_criteria?: string;
13
+ assertions?: unknown;
13
14
  assertions_json?: string;
14
15
  verification_mode?: string;
16
+ resume_session?: string;
17
+ target_image_url?: string;
18
+ target_image_hash?: string;
19
+ viewport_matrix?: unknown;
20
+ viewport_matrix_json?: string;
21
+ deterministic_setup?: unknown;
22
+ deterministic_setup_json?: string;
15
23
  reference?: "prod" | "before" | "both";
16
24
  base_branch?: string;
17
25
  before_ref?: string;
@@ -102,6 +110,11 @@ declare function buildSetupArgs(params: WorkflowParams, config: ReturnType<typeo
102
110
  success_criteria: string;
103
111
  assertions_json: string;
104
112
  verification_mode: string;
113
+ resume_session: string;
114
+ target_image_url: string;
115
+ target_image_hash: string;
116
+ viewport_matrix_json: string;
117
+ deterministic_setup_json: string;
105
118
  reference: "prod" | "before" | "both";
106
119
  base_branch: string;
107
120
  before_ref: string;
@@ -287,6 +300,9 @@ declare function summarizeState(state: any): {
287
300
  last_requested_advance_stage: any;
288
301
  recon_results: any;
289
302
  verify_results: any;
303
+ proof_session: any;
304
+ parent_proof_session: any;
305
+ proof_session_artifact_url: any;
290
306
  };
291
307
  };
292
308
 
@@ -24,7 +24,7 @@ import {
24
24
  visualDeltaShipGateReason,
25
25
  workflowFile,
26
26
  writeState
27
- } from "./chunk-A5AWVY5A.js";
27
+ } from "./chunk-4YCWZVBN.js";
28
28
  export {
29
29
  BUNDLED_RIDDLE_PROOF_DIR,
30
30
  CHECKPOINT_CONTRACT_VERSION,
@@ -104,6 +104,11 @@ function ensureAction(action) {
104
104
  function workflowFile(riddleProofDir, action) {
105
105
  return import_node_path.default.join(riddleProofDir, "pipelines", `riddle-proof-${action}.lobster`);
106
106
  }
107
+ function asJsonString(value) {
108
+ if (value === void 0 || value === null || value === "") return "";
109
+ if (typeof value === "string") return value;
110
+ return JSON.stringify(value);
111
+ }
107
112
  function buildSetupArgs(params, config) {
108
113
  if (!params.repo) throw new Error("repo is required for setup/run");
109
114
  if (!params.change_request) throw new Error("change_request is required for setup/run");
@@ -119,8 +124,13 @@ function buildSetupArgs(params, config) {
119
124
  prod_url: params.prod_url || "",
120
125
  capture_script: captureScript,
121
126
  success_criteria: params.success_criteria || "",
122
- assertions_json: params.assertions_json || "",
127
+ assertions_json: params.assertions_json || asJsonString(params.assertions),
123
128
  verification_mode: params.verification_mode || "proof",
129
+ resume_session: params.resume_session || "",
130
+ target_image_url: params.target_image_url || "",
131
+ target_image_hash: params.target_image_hash || "",
132
+ viewport_matrix_json: params.viewport_matrix_json || asJsonString(params.viewport_matrix),
133
+ deterministic_setup_json: params.deterministic_setup_json || asJsonString(params.deterministic_setup),
124
134
  reference: requestedReference,
125
135
  base_branch: params.base_branch || "main",
126
136
  before_ref: params.before_ref || "",
@@ -690,6 +700,11 @@ function mergeStateFromParams(statePath, params) {
690
700
  "success_criteria",
691
701
  "assertions_json",
692
702
  "verification_mode",
703
+ "resume_session",
704
+ "target_image_url",
705
+ "target_image_hash",
706
+ "viewport_matrix_json",
707
+ "deterministic_setup_json",
693
708
  "base_branch",
694
709
  "before_ref",
695
710
  "context",
@@ -921,7 +936,10 @@ function summarizeState(state) {
921
936
  explicit_stage_gate: Boolean(state.explicit_stage_gate),
922
937
  last_requested_advance_stage: state.last_requested_advance_stage || null,
923
938
  recon_results: state.recon_results || null,
924
- verify_results: state.verify_results || null
939
+ verify_results: state.verify_results || null,
940
+ proof_session: state.proof_session || null,
941
+ parent_proof_session: state.parent_proof_session || null,
942
+ proof_session_artifact_url: state.proof_session_artifact_url || null
925
943
  };
926
944
  const parts = [
927
945
  state.workspace_ready ? "workspace ready" : "workspace not ready",
@@ -83,6 +83,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
83
83
  last_requested_advance_stage: any;
84
84
  recon_results: any;
85
85
  verify_results: any;
86
+ proof_session: any;
87
+ parent_proof_session: any;
88
+ proof_session_artifact_url: any;
86
89
  } | null;
87
90
  pr_state: {
88
91
  status: string;
@@ -172,6 +175,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
172
175
  last_requested_advance_stage: any;
173
176
  recon_results: any;
174
177
  verify_results: any;
178
+ proof_session: any;
179
+ parent_proof_session: any;
180
+ proof_session_artifact_url: any;
175
181
  } | null;
176
182
  pr_state: {
177
183
  status: string;
@@ -259,6 +265,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
259
265
  last_requested_advance_stage: any;
260
266
  recon_results: any;
261
267
  verify_results: any;
268
+ proof_session: any;
269
+ parent_proof_session: any;
270
+ proof_session_artifact_url: any;
262
271
  } | null;
263
272
  pr_state: any;
264
273
  cleanup: Record<string, unknown> | null;
@@ -339,6 +348,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
339
348
  last_requested_advance_stage: any;
340
349
  recon_results: any;
341
350
  verify_results: any;
351
+ proof_session: any;
352
+ parent_proof_session: any;
353
+ proof_session_artifact_url: any;
342
354
  } | null;
343
355
  approval: any;
344
356
  error: any;
@@ -422,6 +434,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
422
434
  last_requested_advance_stage: any;
423
435
  recon_results: any;
424
436
  verify_results: any;
437
+ proof_session: any;
438
+ parent_proof_session: any;
439
+ proof_session_artifact_url: any;
425
440
  } | null;
426
441
  decisionRequest: any;
427
442
  checkpointContract: any;
@@ -509,6 +524,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
509
524
  last_requested_advance_stage: any;
510
525
  recon_results: any;
511
526
  verify_results: any;
527
+ proof_session: any;
528
+ parent_proof_session: any;
529
+ proof_session_artifact_url: any;
512
530
  };
513
531
  state_path: string;
514
532
  ok?: undefined;
@@ -594,6 +612,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
594
612
  last_requested_advance_stage: any;
595
613
  recon_results: any;
596
614
  verify_results: any;
615
+ proof_session: any;
616
+ parent_proof_session: any;
617
+ proof_session_artifact_url: any;
597
618
  } | null;
598
619
  shipReport: any;
599
620
  checkpointContract: Record<string, unknown>;
@@ -674,6 +695,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
674
695
  last_requested_advance_stage: any;
675
696
  recon_results: any;
676
697
  verify_results: any;
698
+ proof_session: any;
699
+ parent_proof_session: any;
700
+ proof_session_artifact_url: any;
677
701
  } | null;
678
702
  approval: null;
679
703
  autoApproved: any;
@@ -83,6 +83,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
83
83
  last_requested_advance_stage: any;
84
84
  recon_results: any;
85
85
  verify_results: any;
86
+ proof_session: any;
87
+ parent_proof_session: any;
88
+ proof_session_artifact_url: any;
86
89
  } | null;
87
90
  pr_state: {
88
91
  status: string;
@@ -172,6 +175,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
172
175
  last_requested_advance_stage: any;
173
176
  recon_results: any;
174
177
  verify_results: any;
178
+ proof_session: any;
179
+ parent_proof_session: any;
180
+ proof_session_artifact_url: any;
175
181
  } | null;
176
182
  pr_state: {
177
183
  status: string;
@@ -259,6 +265,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
259
265
  last_requested_advance_stage: any;
260
266
  recon_results: any;
261
267
  verify_results: any;
268
+ proof_session: any;
269
+ parent_proof_session: any;
270
+ proof_session_artifact_url: any;
262
271
  } | null;
263
272
  pr_state: any;
264
273
  cleanup: Record<string, unknown> | null;
@@ -339,6 +348,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
339
348
  last_requested_advance_stage: any;
340
349
  recon_results: any;
341
350
  verify_results: any;
351
+ proof_session: any;
352
+ parent_proof_session: any;
353
+ proof_session_artifact_url: any;
342
354
  } | null;
343
355
  approval: any;
344
356
  error: any;
@@ -422,6 +434,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
422
434
  last_requested_advance_stage: any;
423
435
  recon_results: any;
424
436
  verify_results: any;
437
+ proof_session: any;
438
+ parent_proof_session: any;
439
+ proof_session_artifact_url: any;
425
440
  } | null;
426
441
  decisionRequest: any;
427
442
  checkpointContract: any;
@@ -509,6 +524,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
509
524
  last_requested_advance_stage: any;
510
525
  recon_results: any;
511
526
  verify_results: any;
527
+ proof_session: any;
528
+ parent_proof_session: any;
529
+ proof_session_artifact_url: any;
512
530
  };
513
531
  state_path: string;
514
532
  ok?: undefined;
@@ -594,6 +612,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
594
612
  last_requested_advance_stage: any;
595
613
  recon_results: any;
596
614
  verify_results: any;
615
+ proof_session: any;
616
+ parent_proof_session: any;
617
+ proof_session_artifact_url: any;
597
618
  } | null;
598
619
  shipReport: any;
599
620
  checkpointContract: Record<string, unknown>;
@@ -674,6 +695,9 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
674
695
  last_requested_advance_stage: any;
675
696
  recon_results: any;
676
697
  verify_results: any;
698
+ proof_session: any;
699
+ parent_proof_session: any;
700
+ proof_session_artifact_url: any;
677
701
  } | null;
678
702
  approval: null;
679
703
  autoApproved: any;
@@ -14,7 +14,7 @@ import {
14
14
  validateShipGate,
15
15
  workflowFile,
16
16
  writeState
17
- } from "./chunk-A5AWVY5A.js";
17
+ } from "./chunk-4YCWZVBN.js";
18
18
 
19
19
  // src/proof-run-engine.ts
20
20
  import { execFileSync } from "child_process";
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/proof-session.ts
21
+ var proof_session_exports = {};
22
+ __export(proof_session_exports, {
23
+ RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION: () => RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION,
24
+ RIDDLE_PROOF_VISUAL_SESSION_VERSION: () => RIDDLE_PROOF_VISUAL_SESSION_VERSION,
25
+ buildVisualProofSession: () => buildVisualProofSession,
26
+ compareVisualProofSessionFingerprint: () => compareVisualProofSessionFingerprint,
27
+ parseVisualProofSession: () => parseVisualProofSession,
28
+ visualSessionFingerprint: () => visualSessionFingerprint,
29
+ visualSessionFingerprintBasis: () => visualSessionFingerprintBasis
30
+ });
31
+ module.exports = __toCommonJS(proof_session_exports);
32
+ var import_node_crypto = require("crypto");
33
+ var RIDDLE_PROOF_VISUAL_SESSION_VERSION = "riddle-proof.visual-session.v1";
34
+ var RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION = "riddle-proof.visual-session.fingerprint.v1";
35
+ function trim(value) {
36
+ const text = String(value ?? "").trim();
37
+ return text || void 0;
38
+ }
39
+ function hashString(value) {
40
+ const text = trim(value);
41
+ if (!text) return void 0;
42
+ return (0, import_node_crypto.createHash)("sha256").update(text).digest("hex");
43
+ }
44
+ function stableJson(value) {
45
+ if (value === void 0) return "null";
46
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
47
+ if (Array.isArray(value)) return `[${value.map((item) => stableJson(item)).join(",")}]`;
48
+ const record = value;
49
+ return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${stableJson(record[key])}`).join(",")}}`;
50
+ }
51
+ function withoutUndefined(record) {
52
+ for (const key of Object.keys(record)) {
53
+ if (record[key] === void 0) delete record[key];
54
+ }
55
+ return record;
56
+ }
57
+ function visualSessionFingerprintBasis(input) {
58
+ return withoutUndefined({
59
+ version: RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION,
60
+ repo: trim(input.repo),
61
+ route: trim(input.route),
62
+ wait_for_selector: trim(input.wait_for_selector),
63
+ reference: trim(input.reference),
64
+ verification_mode: trim(input.verification_mode)?.toLowerCase(),
65
+ target_image_url: trim(input.target_image_url),
66
+ target_image_hash: trim(input.target_image_hash),
67
+ viewport_matrix: input.viewport_matrix,
68
+ deterministic_setup: input.deterministic_setup,
69
+ assertions: input.assertions,
70
+ capture_script_hash: hashString(input.capture_script)
71
+ });
72
+ }
73
+ function visualSessionFingerprint(input) {
74
+ const basis = input.version === RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION ? input : visualSessionFingerprintBasis(input);
75
+ return (0, import_node_crypto.createHash)("sha256").update(stableJson(basis)).digest("hex");
76
+ }
77
+ function buildVisualProofSession(input) {
78
+ const basis = visualSessionFingerprintBasis(input);
79
+ const fingerprint = visualSessionFingerprint(basis);
80
+ const session = {
81
+ version: RIDDLE_PROOF_VISUAL_SESSION_VERSION,
82
+ session_id: `rps_${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:.TZ]/g, "").slice(0, 14)}_${(0, import_node_crypto.randomUUID)().slice(0, 8)}`,
83
+ run_id: trim(input.run_id),
84
+ parent_session_id: input.parent?.session_id || null,
85
+ parent_fingerprint: input.parent?.fingerprint || null,
86
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
87
+ fingerprint,
88
+ fingerprint_basis: basis,
89
+ repo: trim(input.repo),
90
+ branch: trim(input.branch),
91
+ route: withoutUndefined({
92
+ path: trim(input.route),
93
+ observed_after_path: trim(input.observed_after_path)
94
+ }),
95
+ reference: trim(input.reference),
96
+ verification_mode: trim(input.verification_mode),
97
+ target_image: withoutUndefined({
98
+ url: trim(input.target_image_url),
99
+ hash: trim(input.target_image_hash)
100
+ }),
101
+ viewport_matrix: input.viewport_matrix,
102
+ deterministic_setup: input.deterministic_setup,
103
+ capture: withoutUndefined({
104
+ proof_plan: trim(input.proof_plan),
105
+ capture_script: trim(input.capture_script),
106
+ wait_for_selector: trim(input.wait_for_selector)
107
+ }),
108
+ assertions: input.assertions,
109
+ artifacts: input.artifacts,
110
+ evidence: input.evidence,
111
+ status: trim(input.status)
112
+ };
113
+ return JSON.parse(JSON.stringify(session));
114
+ }
115
+ function parseVisualProofSession(value) {
116
+ const parsed = typeof value === "string" ? JSON.parse(value) : value;
117
+ if (!parsed || typeof parsed !== "object") throw new Error("proof session must be a JSON object");
118
+ const session = parsed;
119
+ if (session.version !== RIDDLE_PROOF_VISUAL_SESSION_VERSION) {
120
+ throw new Error(`unsupported proof session version: ${String(session.version || "")}`);
121
+ }
122
+ if (!session.session_id) throw new Error("proof session missing session_id");
123
+ if (!session.fingerprint) throw new Error("proof session missing fingerprint");
124
+ return session;
125
+ }
126
+ function compareVisualProofSessionFingerprint(parent, input) {
127
+ const actual = visualSessionFingerprintBasis(input);
128
+ const expected = parent.fingerprint_basis || {};
129
+ const keys = /* @__PURE__ */ new Set([...Object.keys(expected), ...Object.keys(actual)]);
130
+ const expectedRecord = expected;
131
+ const actualRecord = actual;
132
+ const mismatches = [];
133
+ for (const key of keys) {
134
+ const expectedValue = expectedRecord[key];
135
+ const actualValue = actualRecord[key];
136
+ if (stableJson(expectedValue) !== stableJson(actualValue)) {
137
+ mismatches.push({ key, expected: expectedValue, actual: actualValue });
138
+ }
139
+ }
140
+ return mismatches;
141
+ }
142
+ // Annotate the CommonJS export names for ESM import in node:
143
+ 0 && (module.exports = {
144
+ RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION,
145
+ RIDDLE_PROOF_VISUAL_SESSION_VERSION,
146
+ buildVisualProofSession,
147
+ compareVisualProofSessionFingerprint,
148
+ parseVisualProofSession,
149
+ visualSessionFingerprint,
150
+ visualSessionFingerprintBasis
151
+ });
@@ -0,0 +1,37 @@
1
+ import { RiddleProofVisualSession, JsonValue, RiddleProofVisualSessionFingerprintBasis } from './types.cjs';
2
+
3
+ declare const RIDDLE_PROOF_VISUAL_SESSION_VERSION: "riddle-proof.visual-session.v1";
4
+ declare const RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION: "riddle-proof.visual-session.fingerprint.v1";
5
+ interface BuildVisualProofSessionInput {
6
+ run_id?: string;
7
+ parent?: RiddleProofVisualSession | null;
8
+ repo?: string;
9
+ branch?: string;
10
+ route?: string;
11
+ observed_after_path?: string;
12
+ reference?: string;
13
+ verification_mode?: string;
14
+ target_image_url?: string;
15
+ target_image_hash?: string;
16
+ viewport_matrix?: JsonValue;
17
+ deterministic_setup?: JsonValue;
18
+ proof_plan?: string;
19
+ capture_script?: string;
20
+ wait_for_selector?: string;
21
+ assertions?: JsonValue;
22
+ artifacts?: RiddleProofVisualSession["artifacts"];
23
+ evidence?: RiddleProofVisualSession["evidence"];
24
+ status?: string;
25
+ }
26
+ interface VisualProofSessionMismatch {
27
+ key: string;
28
+ expected: JsonValue | undefined;
29
+ actual: JsonValue | undefined;
30
+ }
31
+ declare function visualSessionFingerprintBasis(input: BuildVisualProofSessionInput): RiddleProofVisualSessionFingerprintBasis;
32
+ declare function visualSessionFingerprint(input: BuildVisualProofSessionInput | RiddleProofVisualSessionFingerprintBasis): string;
33
+ declare function buildVisualProofSession(input: BuildVisualProofSessionInput): RiddleProofVisualSession;
34
+ declare function parseVisualProofSession(value: unknown): RiddleProofVisualSession;
35
+ declare function compareVisualProofSessionFingerprint(parent: RiddleProofVisualSession, input: BuildVisualProofSessionInput): VisualProofSessionMismatch[];
36
+
37
+ export { type BuildVisualProofSessionInput, RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION, RIDDLE_PROOF_VISUAL_SESSION_VERSION, type VisualProofSessionMismatch, buildVisualProofSession, compareVisualProofSessionFingerprint, parseVisualProofSession, visualSessionFingerprint, visualSessionFingerprintBasis };