@riddledc/riddle-proof 0.4.5 → 0.5.0

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/README.md CHANGED
@@ -21,6 +21,7 @@ tests.
21
21
  - State/event helpers for wrappers that need a stable run envelope
22
22
  - Runner harness for preflight -> setup -> implement -> prove -> judge -> ship -> notify
23
23
  - Stage heartbeat and run status snapshot helpers
24
+ - Capture diagnostics helpers for redacted Riddle server preview evidence
24
25
  - Worktree metadata and proof artifact role contracts
25
26
  - Terminal ship metadata normalization
26
27
  - Stable result helpers
@@ -46,6 +47,7 @@ npm install @riddledc/riddle-proof
46
47
  ```ts
47
48
  import { createRunResult, createRunState } from "@riddledc/riddle-proof";
48
49
  import { runRiddleProof } from "@riddledc/riddle-proof/runner";
50
+ import { createCaptureDiagnostic } from "@riddledc/riddle-proof/diagnostics";
49
51
  import { toRiddleProofRunParams } from "@riddledc/riddle-proof/openclaw";
50
52
  ```
51
53
 
@@ -76,6 +78,81 @@ way to a ready PR after proof and CI; `leave_draft: true` is only an explicit
76
78
  debug or user-request escape hatch. The notification adapter is where a host
77
79
  updates Discord, OpenClaw, GitHub, or another integration.
78
80
 
81
+ ## Capture Diagnostics
82
+
83
+ `@riddledc/riddle-proof/diagnostics` standardizes the evidence contract around
84
+ Riddle-backed capture calls. It is designed for state files, PR proof comments,
85
+ and agent handoffs where a reviewer needs to know whether proof failed because
86
+ the route was wrong, the preview was not ready, the capture script did not save
87
+ artifacts, or the app runtime produced weak evidence.
88
+
89
+ ```ts
90
+ import {
91
+ appendCaptureDiagnostic,
92
+ createCaptureDiagnostic,
93
+ summarizeCaptureArtifacts,
94
+ } from "@riddledc/riddle-proof/diagnostics";
95
+
96
+ const args = {
97
+ server_path: "/games/drum-sequencer?song=monkberry-moon-delight-tab&mix=profile",
98
+ wait_for_selector: "[data-proof-ready='true']",
99
+ script,
100
+ };
101
+
102
+ const payload = await runRiddleServerPreview(args);
103
+
104
+ const diagnostic = createCaptureDiagnostic({
105
+ label: "after",
106
+ tool: "riddle_server_preview",
107
+ args,
108
+ payload,
109
+ route: "/games/drum-sequencer?song=monkberry-moon-delight-tab&mix=profile",
110
+ });
111
+
112
+ appendCaptureDiagnostic(state, { label: "after", tool: "riddle_server_preview", args, payload });
113
+ console.log(summarizeCaptureArtifacts(payload));
114
+ ```
115
+
116
+ The helper redacts sensitive keys such as authorization headers, cookies,
117
+ local storage, API keys, secrets, passwords, and tokens. It preserves route,
118
+ selector, script shape, artifact names, URLs, result keys, console summary, and
119
+ artifact errors. Long strings and arrays are capped so diagnostics remain safe
120
+ to keep in a run state.
121
+
122
+ ### Runtime Evidence Contract
123
+
124
+ For browser previews, apps can expose deterministic proof data on
125
+ `globalThis.__riddleProofEvidence`. Capture scripts can return that object or
126
+ write it into a JSON artifact next to screenshots. Good evidence is usually a
127
+ mix of:
128
+
129
+ - The exact route or query params a human reviewer can open
130
+ - A readiness selector or explicit ready flag
131
+ - Screenshots and JSON artifacts saved by the capture script
132
+ - Runtime metrics from `globalThis.__riddleProofEvidence`
133
+ - Assertions that explain why the evidence is sufficient
134
+
135
+ Metrics are guardrails, not a replacement for taste or product judgment. For a
136
+ musical sequencer, useful proof might include the selected song and mix, the
137
+ transport state, current playhead time, instrument lane readiness, measured
138
+ frame drift, console errors, and screenshots of the intended view. The reviewer
139
+ still decides whether it sounds good.
140
+
141
+ ### Server Preview Usage
142
+
143
+ Server preview proof is most useful when the request, capture, and PR comment
144
+ all point at the same reproducible page. Prefer exact paths such as:
145
+
146
+ ```text
147
+ /games/drum-sequencer?song=monkberry-moon-delight-tab&mix=profile
148
+ ```
149
+
150
+ Use `wait_for_selector` for a stable application-ready signal instead of a fixed
151
+ sleep. Save screenshots and structured artifacts from the same capture script
152
+ that performs the interaction. If proof is weak, keep the diagnostics history in
153
+ the run state so the next agent can see the last route, tool status, artifact
154
+ shape, and errors without rerunning blind.
155
+
79
156
  ## OpenClaw Adapter Boundary
80
157
 
81
158
  `@riddledc/riddle-proof/openclaw` translates the current
@@ -84,6 +161,10 @@ It preserves Discord routing metadata as `integration_context` and parses
84
161
  `assertions_json` into the shared assertions field. Compatibility params such as
85
162
  `ship_after_verify` and the explicit `leave_draft` escape hatch are preserved so
86
163
  the underlying runtime can distinguish "do not merge" from "keep this draft."
164
+ Generic authenticated proof inputs are preserved as pass-through JSON strings:
165
+ `auth_localStorage_json`, `auth_cookies_json`, and `auth_headers_json`. Use
166
+ those for public integrations; reserve `use_auth` for a configured, site-specific
167
+ auth helper.
87
168
 
88
169
  The adapter does not invoke another OpenClaw plugin and does not supply a
89
170
  coding agent. It is the reusable mapping layer a future OpenClaw wrapper can
@@ -0,0 +1,150 @@
1
+ // src/diagnostics.ts
2
+ var RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION = "riddle-proof.capture-diagnostic.v1";
3
+ var DEFAULT_DIAGNOSTIC_STRING_LIMIT = 2e3;
4
+ var DEFAULT_DIAGNOSTIC_ARRAY_LIMIT = 50;
5
+ var DEFAULT_DIAGNOSTIC_HISTORY_LIMIT = 20;
6
+ var DEFAULT_REDACTED_VALUE = "[redacted]";
7
+ var DEFAULT_SENSITIVE_KEY_PATTERN = /authorization|api_?key|apikey|cookie|header|localstorage|password|secret|token/i;
8
+ function isRecord(value) {
9
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
10
+ }
11
+ function normalizeSensitiveKey(key) {
12
+ return key.toLowerCase().replace(/[^a-z0-9_]/g, "").replace(/_/g, "");
13
+ }
14
+ function isSensitiveKey(key, pattern) {
15
+ pattern.lastIndex = 0;
16
+ const rawMatch = pattern.test(key);
17
+ pattern.lastIndex = 0;
18
+ return rawMatch || pattern.test(normalizeSensitiveKey(key));
19
+ }
20
+ function truncateString(value, limit) {
21
+ if (value.length <= limit) return value;
22
+ return `${value.slice(0, limit)}... [truncated]`;
23
+ }
24
+ function sortedKeys(value) {
25
+ return isRecord(value) ? Object.keys(value).sort() : [];
26
+ }
27
+ function stringValue(value) {
28
+ if (typeof value !== "string") return void 0;
29
+ const trimmed = value.trim();
30
+ return trimmed ? trimmed : void 0;
31
+ }
32
+ function numberValue(value) {
33
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
34
+ }
35
+ function artifactItems(value) {
36
+ if (!Array.isArray(value)) return [];
37
+ return value.filter(isRecord);
38
+ }
39
+ function artifactSummary(item, source) {
40
+ const artifact = item;
41
+ const metadata = isRecord(artifact.metadata) ? artifact.metadata : void 0;
42
+ return {
43
+ name: stringValue(artifact.name) || "",
44
+ kind: stringValue(artifact.kind),
45
+ role: stringValue(artifact.role),
46
+ url: stringValue(artifact.url),
47
+ path: stringValue(artifact.path),
48
+ content_type: stringValue(artifact.content_type),
49
+ size_bytes: numberValue(artifact.size_bytes),
50
+ metadata_keys: metadata ? Object.keys(metadata).sort() : void 0,
51
+ source
52
+ };
53
+ }
54
+ function artifactErrorMap(value, redaction) {
55
+ if (!isRecord(value)) return {};
56
+ const entries = Object.entries(value).map(([key, child]) => {
57
+ const redacted = redactForProofDiagnostics(child, redaction);
58
+ return [key, typeof redacted === "string" ? redacted : JSON.stringify(redacted)];
59
+ }).sort(([left], [right]) => left.localeCompare(right));
60
+ return Object.fromEntries(entries);
61
+ }
62
+ function redactForProofDiagnostics(value, options = {}) {
63
+ const stringLimit = Math.max(1, options.string_limit ?? DEFAULT_DIAGNOSTIC_STRING_LIMIT);
64
+ const arrayLimit = Math.max(0, options.array_limit ?? DEFAULT_DIAGNOSTIC_ARRAY_LIMIT);
65
+ const redactedValue = options.redacted_value || DEFAULT_REDACTED_VALUE;
66
+ const sensitiveKeyPattern = options.sensitive_key_pattern || DEFAULT_SENSITIVE_KEY_PATTERN;
67
+ const seen = /* @__PURE__ */ new WeakSet();
68
+ function redact(child) {
69
+ if (child === null || child === void 0) return null;
70
+ if (typeof child === "string") return truncateString(child, stringLimit);
71
+ if (typeof child === "number") return Number.isFinite(child) ? child : null;
72
+ if (typeof child === "boolean") return child;
73
+ if (typeof child === "bigint" || typeof child === "symbol" || typeof child === "function") {
74
+ return truncateString(String(child), stringLimit);
75
+ }
76
+ if (Array.isArray(child)) {
77
+ return child.slice(0, arrayLimit).map((item) => redact(item));
78
+ }
79
+ if (isRecord(child)) {
80
+ if (seen.has(child)) return "[circular]";
81
+ seen.add(child);
82
+ const entries = [];
83
+ for (const [key, nested] of Object.entries(child)) {
84
+ entries.push([
85
+ key,
86
+ isSensitiveKey(key, sensitiveKeyPattern) ? redactedValue : redact(nested)
87
+ ]);
88
+ }
89
+ return Object.fromEntries(entries);
90
+ }
91
+ return truncateString(String(child), stringLimit);
92
+ }
93
+ return redact(value);
94
+ }
95
+ function summarizeCaptureArtifacts(payload) {
96
+ const record = isRecord(payload) ? payload : {};
97
+ const artifactJson = isRecord(record._artifact_json) ? record._artifact_json : {};
98
+ const proofJson = isRecord(record._proof_json) ? record._proof_json : isRecord(artifactJson["proof.json"]) ? artifactJson["proof.json"] : {};
99
+ const consoleJson = isRecord(record.console) ? record.console : isRecord(artifactJson["console.json"]) ? artifactJson["console.json"] : {};
100
+ const result = isRecord(record.result) ? record.result : isRecord(proofJson.result) ? proofJson.result : isRecord(proofJson.script_result) ? proofJson.script_result : isRecord(proofJson.return_value) ? proofJson.return_value : isRecord(proofJson.value) ? proofJson.value : {};
101
+ const consoleSummary = isRecord(consoleJson.summary) ? redactForProofDiagnostics(consoleJson.summary, { string_limit: 500 }) : void 0;
102
+ return {
103
+ outputs: artifactItems(record.outputs).slice(0, 20).map((item) => artifactSummary(item, "outputs")),
104
+ screenshots: artifactItems(record.screenshots).slice(0, 10).map((item) => artifactSummary(item, "screenshots")),
105
+ artifacts: artifactItems(record.artifacts).slice(0, 20).map((item) => artifactSummary(item, "artifacts")),
106
+ result_keys: sortedKeys(result),
107
+ artifact_json: sortedKeys(artifactJson),
108
+ artifact_errors: artifactErrorMap(record._artifact_errors),
109
+ proof_script_error: Boolean(proofJson.script_error),
110
+ console_summary: consoleSummary
111
+ };
112
+ }
113
+ function createCaptureDiagnostic(input) {
114
+ const payload = isRecord(input.payload) ? input.payload : {};
115
+ const redaction = input.redaction;
116
+ const error = input.error ?? payload.error ?? payload.stderr ?? payload.message ?? "";
117
+ return {
118
+ version: RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
119
+ label: input.label,
120
+ tool: input.tool,
121
+ captured_at: input.captured_at || (/* @__PURE__ */ new Date()).toISOString(),
122
+ ok: typeof input.ok === "boolean" ? input.ok : typeof payload.ok === "boolean" ? payload.ok : void 0,
123
+ timeout: typeof input.timeout === "boolean" ? input.timeout : Boolean(payload.timeout),
124
+ error: truncateString(String(error ?? ""), redaction?.string_limit ?? DEFAULT_DIAGNOSTIC_STRING_LIMIT),
125
+ route: input.route,
126
+ preview_url: input.preview_url,
127
+ wait_for_selector: input.wait_for_selector,
128
+ args: redactForProofDiagnostics(input.args === void 0 ? {} : input.args, redaction),
129
+ artifact_summary: summarizeCaptureArtifacts(input.payload),
130
+ evidence: input.evidence === void 0 ? void 0 : redactForProofDiagnostics(input.evidence, redaction),
131
+ notes: input.notes?.map((note) => note.trim()).filter(Boolean)
132
+ };
133
+ }
134
+ function appendCaptureDiagnostic(state, input, historyLimit = DEFAULT_DIAGNOSTIC_HISTORY_LIMIT) {
135
+ const diagnostic = createCaptureDiagnostic(input);
136
+ const existing = Array.isArray(state.capture_diagnostics) ? state.capture_diagnostics : [];
137
+ state.capture_diagnostics = [...existing, diagnostic].slice(-Math.max(1, historyLimit));
138
+ return diagnostic;
139
+ }
140
+
141
+ export {
142
+ RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
143
+ DEFAULT_DIAGNOSTIC_STRING_LIMIT,
144
+ DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
145
+ DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
146
+ redactForProofDiagnostics,
147
+ summarizeCaptureArtifacts,
148
+ createCaptureDiagnostic,
149
+ appendCaptureDiagnostic
150
+ };
@@ -90,6 +90,9 @@ function normalizeRunParams(input) {
90
90
  server_port: input.server_port,
91
91
  server_path: input.server_path,
92
92
  use_auth: input.use_auth,
93
+ auth_localStorage_json: input.auth_localStorage_json,
94
+ auth_cookies_json: input.auth_cookies_json,
95
+ auth_headers_json: input.auth_headers_json,
93
96
  color_scheme: input.color_scheme,
94
97
  wait_for_selector: input.wait_for_selector,
95
98
  ship_mode: input.ship_mode,
@@ -5,7 +5,7 @@ import {
5
5
  createRunStatusSnapshot,
6
6
  normalizeRunParams,
7
7
  setRunStatus
8
- } from "./chunk-SIQG3N6F.js";
8
+ } from "./chunk-GVPCSXN7.js";
9
9
  import {
10
10
  applyTerminalMetadata,
11
11
  compactRecord,
@@ -175,6 +175,9 @@ function initialRunParams(request, input, state) {
175
175
  server_port: request.server_port,
176
176
  server_path: request.server_path,
177
177
  use_auth: request.use_auth,
178
+ auth_localStorage_json: request.auth_localStorage_json,
179
+ auth_cookies_json: request.auth_cookies_json,
180
+ auth_headers_json: request.auth_headers_json,
178
181
  color_scheme: request.color_scheme,
179
182
  wait_for_selector: request.wait_for_selector,
180
183
  leave_draft: request.leave_draft || void 0,
@@ -3,7 +3,7 @@ import {
3
3
  appendStageHeartbeat,
4
4
  createRunState,
5
5
  setRunStatus
6
- } from "./chunk-SIQG3N6F.js";
6
+ } from "./chunk-GVPCSXN7.js";
7
7
  import {
8
8
  createRunResult
9
9
  } from "./chunk-TMMKRKY5.js";
@@ -0,0 +1,181 @@
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/diagnostics.ts
21
+ var diagnostics_exports = {};
22
+ __export(diagnostics_exports, {
23
+ DEFAULT_DIAGNOSTIC_ARRAY_LIMIT: () => DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
24
+ DEFAULT_DIAGNOSTIC_HISTORY_LIMIT: () => DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
25
+ DEFAULT_DIAGNOSTIC_STRING_LIMIT: () => DEFAULT_DIAGNOSTIC_STRING_LIMIT,
26
+ RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION: () => RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
27
+ appendCaptureDiagnostic: () => appendCaptureDiagnostic,
28
+ createCaptureDiagnostic: () => createCaptureDiagnostic,
29
+ redactForProofDiagnostics: () => redactForProofDiagnostics,
30
+ summarizeCaptureArtifacts: () => summarizeCaptureArtifacts
31
+ });
32
+ module.exports = __toCommonJS(diagnostics_exports);
33
+ var RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION = "riddle-proof.capture-diagnostic.v1";
34
+ var DEFAULT_DIAGNOSTIC_STRING_LIMIT = 2e3;
35
+ var DEFAULT_DIAGNOSTIC_ARRAY_LIMIT = 50;
36
+ var DEFAULT_DIAGNOSTIC_HISTORY_LIMIT = 20;
37
+ var DEFAULT_REDACTED_VALUE = "[redacted]";
38
+ var DEFAULT_SENSITIVE_KEY_PATTERN = /authorization|api_?key|apikey|cookie|header|localstorage|password|secret|token/i;
39
+ function isRecord(value) {
40
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
41
+ }
42
+ function normalizeSensitiveKey(key) {
43
+ return key.toLowerCase().replace(/[^a-z0-9_]/g, "").replace(/_/g, "");
44
+ }
45
+ function isSensitiveKey(key, pattern) {
46
+ pattern.lastIndex = 0;
47
+ const rawMatch = pattern.test(key);
48
+ pattern.lastIndex = 0;
49
+ return rawMatch || pattern.test(normalizeSensitiveKey(key));
50
+ }
51
+ function truncateString(value, limit) {
52
+ if (value.length <= limit) return value;
53
+ return `${value.slice(0, limit)}... [truncated]`;
54
+ }
55
+ function sortedKeys(value) {
56
+ return isRecord(value) ? Object.keys(value).sort() : [];
57
+ }
58
+ function stringValue(value) {
59
+ if (typeof value !== "string") return void 0;
60
+ const trimmed = value.trim();
61
+ return trimmed ? trimmed : void 0;
62
+ }
63
+ function numberValue(value) {
64
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
65
+ }
66
+ function artifactItems(value) {
67
+ if (!Array.isArray(value)) return [];
68
+ return value.filter(isRecord);
69
+ }
70
+ function artifactSummary(item, source) {
71
+ const artifact = item;
72
+ const metadata = isRecord(artifact.metadata) ? artifact.metadata : void 0;
73
+ return {
74
+ name: stringValue(artifact.name) || "",
75
+ kind: stringValue(artifact.kind),
76
+ role: stringValue(artifact.role),
77
+ url: stringValue(artifact.url),
78
+ path: stringValue(artifact.path),
79
+ content_type: stringValue(artifact.content_type),
80
+ size_bytes: numberValue(artifact.size_bytes),
81
+ metadata_keys: metadata ? Object.keys(metadata).sort() : void 0,
82
+ source
83
+ };
84
+ }
85
+ function artifactErrorMap(value, redaction) {
86
+ if (!isRecord(value)) return {};
87
+ const entries = Object.entries(value).map(([key, child]) => {
88
+ const redacted = redactForProofDiagnostics(child, redaction);
89
+ return [key, typeof redacted === "string" ? redacted : JSON.stringify(redacted)];
90
+ }).sort(([left], [right]) => left.localeCompare(right));
91
+ return Object.fromEntries(entries);
92
+ }
93
+ function redactForProofDiagnostics(value, options = {}) {
94
+ const stringLimit = Math.max(1, options.string_limit ?? DEFAULT_DIAGNOSTIC_STRING_LIMIT);
95
+ const arrayLimit = Math.max(0, options.array_limit ?? DEFAULT_DIAGNOSTIC_ARRAY_LIMIT);
96
+ const redactedValue = options.redacted_value || DEFAULT_REDACTED_VALUE;
97
+ const sensitiveKeyPattern = options.sensitive_key_pattern || DEFAULT_SENSITIVE_KEY_PATTERN;
98
+ const seen = /* @__PURE__ */ new WeakSet();
99
+ function redact(child) {
100
+ if (child === null || child === void 0) return null;
101
+ if (typeof child === "string") return truncateString(child, stringLimit);
102
+ if (typeof child === "number") return Number.isFinite(child) ? child : null;
103
+ if (typeof child === "boolean") return child;
104
+ if (typeof child === "bigint" || typeof child === "symbol" || typeof child === "function") {
105
+ return truncateString(String(child), stringLimit);
106
+ }
107
+ if (Array.isArray(child)) {
108
+ return child.slice(0, arrayLimit).map((item) => redact(item));
109
+ }
110
+ if (isRecord(child)) {
111
+ if (seen.has(child)) return "[circular]";
112
+ seen.add(child);
113
+ const entries = [];
114
+ for (const [key, nested] of Object.entries(child)) {
115
+ entries.push([
116
+ key,
117
+ isSensitiveKey(key, sensitiveKeyPattern) ? redactedValue : redact(nested)
118
+ ]);
119
+ }
120
+ return Object.fromEntries(entries);
121
+ }
122
+ return truncateString(String(child), stringLimit);
123
+ }
124
+ return redact(value);
125
+ }
126
+ function summarizeCaptureArtifacts(payload) {
127
+ const record = isRecord(payload) ? payload : {};
128
+ const artifactJson = isRecord(record._artifact_json) ? record._artifact_json : {};
129
+ const proofJson = isRecord(record._proof_json) ? record._proof_json : isRecord(artifactJson["proof.json"]) ? artifactJson["proof.json"] : {};
130
+ const consoleJson = isRecord(record.console) ? record.console : isRecord(artifactJson["console.json"]) ? artifactJson["console.json"] : {};
131
+ const result = isRecord(record.result) ? record.result : isRecord(proofJson.result) ? proofJson.result : isRecord(proofJson.script_result) ? proofJson.script_result : isRecord(proofJson.return_value) ? proofJson.return_value : isRecord(proofJson.value) ? proofJson.value : {};
132
+ const consoleSummary = isRecord(consoleJson.summary) ? redactForProofDiagnostics(consoleJson.summary, { string_limit: 500 }) : void 0;
133
+ return {
134
+ outputs: artifactItems(record.outputs).slice(0, 20).map((item) => artifactSummary(item, "outputs")),
135
+ screenshots: artifactItems(record.screenshots).slice(0, 10).map((item) => artifactSummary(item, "screenshots")),
136
+ artifacts: artifactItems(record.artifacts).slice(0, 20).map((item) => artifactSummary(item, "artifacts")),
137
+ result_keys: sortedKeys(result),
138
+ artifact_json: sortedKeys(artifactJson),
139
+ artifact_errors: artifactErrorMap(record._artifact_errors),
140
+ proof_script_error: Boolean(proofJson.script_error),
141
+ console_summary: consoleSummary
142
+ };
143
+ }
144
+ function createCaptureDiagnostic(input) {
145
+ const payload = isRecord(input.payload) ? input.payload : {};
146
+ const redaction = input.redaction;
147
+ const error = input.error ?? payload.error ?? payload.stderr ?? payload.message ?? "";
148
+ return {
149
+ version: RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
150
+ label: input.label,
151
+ tool: input.tool,
152
+ captured_at: input.captured_at || (/* @__PURE__ */ new Date()).toISOString(),
153
+ ok: typeof input.ok === "boolean" ? input.ok : typeof payload.ok === "boolean" ? payload.ok : void 0,
154
+ timeout: typeof input.timeout === "boolean" ? input.timeout : Boolean(payload.timeout),
155
+ error: truncateString(String(error ?? ""), redaction?.string_limit ?? DEFAULT_DIAGNOSTIC_STRING_LIMIT),
156
+ route: input.route,
157
+ preview_url: input.preview_url,
158
+ wait_for_selector: input.wait_for_selector,
159
+ args: redactForProofDiagnostics(input.args === void 0 ? {} : input.args, redaction),
160
+ artifact_summary: summarizeCaptureArtifacts(input.payload),
161
+ evidence: input.evidence === void 0 ? void 0 : redactForProofDiagnostics(input.evidence, redaction),
162
+ notes: input.notes?.map((note) => note.trim()).filter(Boolean)
163
+ };
164
+ }
165
+ function appendCaptureDiagnostic(state, input, historyLimit = DEFAULT_DIAGNOSTIC_HISTORY_LIMIT) {
166
+ const diagnostic = createCaptureDiagnostic(input);
167
+ const existing = Array.isArray(state.capture_diagnostics) ? state.capture_diagnostics : [];
168
+ state.capture_diagnostics = [...existing, diagnostic].slice(-Math.max(1, historyLimit));
169
+ return diagnostic;
170
+ }
171
+ // Annotate the CommonJS export names for ESM import in node:
172
+ 0 && (module.exports = {
173
+ DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
174
+ DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
175
+ DEFAULT_DIAGNOSTIC_STRING_LIMIT,
176
+ RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
177
+ appendCaptureDiagnostic,
178
+ createCaptureDiagnostic,
179
+ redactForProofDiagnostics,
180
+ summarizeCaptureArtifacts
181
+ });
@@ -0,0 +1,73 @@
1
+ import { JsonValue } from './types.cjs';
2
+
3
+ declare const RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION: "riddle-proof.capture-diagnostic.v1";
4
+ declare const DEFAULT_DIAGNOSTIC_STRING_LIMIT = 2000;
5
+ declare const DEFAULT_DIAGNOSTIC_ARRAY_LIMIT = 50;
6
+ declare const DEFAULT_DIAGNOSTIC_HISTORY_LIMIT = 20;
7
+ interface RiddleProofDiagnosticRedactionOptions {
8
+ string_limit?: number;
9
+ array_limit?: number;
10
+ redacted_value?: string;
11
+ sensitive_key_pattern?: RegExp;
12
+ }
13
+ interface RiddleProofArtifactSummary {
14
+ name: string;
15
+ kind?: string;
16
+ role?: string;
17
+ url?: string;
18
+ path?: string;
19
+ content_type?: string;
20
+ size_bytes?: number;
21
+ metadata_keys?: string[];
22
+ source?: "outputs" | "screenshots" | "artifacts" | (string & {});
23
+ }
24
+ interface RiddleProofCaptureArtifactSummary {
25
+ outputs: RiddleProofArtifactSummary[];
26
+ screenshots: RiddleProofArtifactSummary[];
27
+ artifacts: RiddleProofArtifactSummary[];
28
+ result_keys: string[];
29
+ artifact_json: string[];
30
+ artifact_errors: Record<string, string>;
31
+ proof_script_error: boolean;
32
+ console_summary?: JsonValue;
33
+ }
34
+ interface RiddleProofCaptureDiagnostic {
35
+ version: typeof RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION;
36
+ label?: string;
37
+ tool?: string;
38
+ captured_at: string;
39
+ ok?: boolean;
40
+ timeout?: boolean;
41
+ error?: string;
42
+ route?: string;
43
+ preview_url?: string;
44
+ wait_for_selector?: string;
45
+ args?: JsonValue;
46
+ artifact_summary: RiddleProofCaptureArtifactSummary;
47
+ evidence?: JsonValue;
48
+ notes?: string[];
49
+ }
50
+ interface CreateCaptureDiagnosticInput {
51
+ label?: string;
52
+ tool?: string;
53
+ captured_at?: string;
54
+ ok?: boolean;
55
+ timeout?: boolean;
56
+ error?: unknown;
57
+ args?: unknown;
58
+ payload?: unknown;
59
+ evidence?: unknown;
60
+ route?: string;
61
+ preview_url?: string;
62
+ wait_for_selector?: string;
63
+ notes?: string[];
64
+ redaction?: RiddleProofDiagnosticRedactionOptions;
65
+ }
66
+ declare function redactForProofDiagnostics(value: unknown, options?: RiddleProofDiagnosticRedactionOptions): JsonValue;
67
+ declare function summarizeCaptureArtifacts(payload: unknown): RiddleProofCaptureArtifactSummary;
68
+ declare function createCaptureDiagnostic(input: CreateCaptureDiagnosticInput): RiddleProofCaptureDiagnostic;
69
+ declare function appendCaptureDiagnostic<T extends {
70
+ capture_diagnostics?: RiddleProofCaptureDiagnostic[];
71
+ }>(state: T, input: CreateCaptureDiagnosticInput, historyLimit?: number): RiddleProofCaptureDiagnostic;
72
+
73
+ export { type CreateCaptureDiagnosticInput, DEFAULT_DIAGNOSTIC_ARRAY_LIMIT, DEFAULT_DIAGNOSTIC_HISTORY_LIMIT, DEFAULT_DIAGNOSTIC_STRING_LIMIT, RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION, type RiddleProofArtifactSummary, type RiddleProofCaptureArtifactSummary, type RiddleProofCaptureDiagnostic, type RiddleProofDiagnosticRedactionOptions, appendCaptureDiagnostic, createCaptureDiagnostic, redactForProofDiagnostics, summarizeCaptureArtifacts };
@@ -0,0 +1,73 @@
1
+ import { JsonValue } from './types.js';
2
+
3
+ declare const RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION: "riddle-proof.capture-diagnostic.v1";
4
+ declare const DEFAULT_DIAGNOSTIC_STRING_LIMIT = 2000;
5
+ declare const DEFAULT_DIAGNOSTIC_ARRAY_LIMIT = 50;
6
+ declare const DEFAULT_DIAGNOSTIC_HISTORY_LIMIT = 20;
7
+ interface RiddleProofDiagnosticRedactionOptions {
8
+ string_limit?: number;
9
+ array_limit?: number;
10
+ redacted_value?: string;
11
+ sensitive_key_pattern?: RegExp;
12
+ }
13
+ interface RiddleProofArtifactSummary {
14
+ name: string;
15
+ kind?: string;
16
+ role?: string;
17
+ url?: string;
18
+ path?: string;
19
+ content_type?: string;
20
+ size_bytes?: number;
21
+ metadata_keys?: string[];
22
+ source?: "outputs" | "screenshots" | "artifacts" | (string & {});
23
+ }
24
+ interface RiddleProofCaptureArtifactSummary {
25
+ outputs: RiddleProofArtifactSummary[];
26
+ screenshots: RiddleProofArtifactSummary[];
27
+ artifacts: RiddleProofArtifactSummary[];
28
+ result_keys: string[];
29
+ artifact_json: string[];
30
+ artifact_errors: Record<string, string>;
31
+ proof_script_error: boolean;
32
+ console_summary?: JsonValue;
33
+ }
34
+ interface RiddleProofCaptureDiagnostic {
35
+ version: typeof RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION;
36
+ label?: string;
37
+ tool?: string;
38
+ captured_at: string;
39
+ ok?: boolean;
40
+ timeout?: boolean;
41
+ error?: string;
42
+ route?: string;
43
+ preview_url?: string;
44
+ wait_for_selector?: string;
45
+ args?: JsonValue;
46
+ artifact_summary: RiddleProofCaptureArtifactSummary;
47
+ evidence?: JsonValue;
48
+ notes?: string[];
49
+ }
50
+ interface CreateCaptureDiagnosticInput {
51
+ label?: string;
52
+ tool?: string;
53
+ captured_at?: string;
54
+ ok?: boolean;
55
+ timeout?: boolean;
56
+ error?: unknown;
57
+ args?: unknown;
58
+ payload?: unknown;
59
+ evidence?: unknown;
60
+ route?: string;
61
+ preview_url?: string;
62
+ wait_for_selector?: string;
63
+ notes?: string[];
64
+ redaction?: RiddleProofDiagnosticRedactionOptions;
65
+ }
66
+ declare function redactForProofDiagnostics(value: unknown, options?: RiddleProofDiagnosticRedactionOptions): JsonValue;
67
+ declare function summarizeCaptureArtifacts(payload: unknown): RiddleProofCaptureArtifactSummary;
68
+ declare function createCaptureDiagnostic(input: CreateCaptureDiagnosticInput): RiddleProofCaptureDiagnostic;
69
+ declare function appendCaptureDiagnostic<T extends {
70
+ capture_diagnostics?: RiddleProofCaptureDiagnostic[];
71
+ }>(state: T, input: CreateCaptureDiagnosticInput, historyLimit?: number): RiddleProofCaptureDiagnostic;
72
+
73
+ export { type CreateCaptureDiagnosticInput, DEFAULT_DIAGNOSTIC_ARRAY_LIMIT, DEFAULT_DIAGNOSTIC_HISTORY_LIMIT, DEFAULT_DIAGNOSTIC_STRING_LIMIT, RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION, type RiddleProofArtifactSummary, type RiddleProofCaptureArtifactSummary, type RiddleProofCaptureDiagnostic, type RiddleProofDiagnosticRedactionOptions, appendCaptureDiagnostic, createCaptureDiagnostic, redactForProofDiagnostics, summarizeCaptureArtifacts };
@@ -0,0 +1,20 @@
1
+ import {
2
+ DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
3
+ DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
4
+ DEFAULT_DIAGNOSTIC_STRING_LIMIT,
5
+ RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
6
+ appendCaptureDiagnostic,
7
+ createCaptureDiagnostic,
8
+ redactForProofDiagnostics,
9
+ summarizeCaptureArtifacts
10
+ } from "./chunk-DWQK7J4U.js";
11
+ export {
12
+ DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
13
+ DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
14
+ DEFAULT_DIAGNOSTIC_STRING_LIMIT,
15
+ RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
16
+ appendCaptureDiagnostic,
17
+ createCaptureDiagnostic,
18
+ redactForProofDiagnostics,
19
+ summarizeCaptureArtifacts
20
+ };
@@ -302,6 +302,9 @@ function normalizeRunParams(input) {
302
302
  server_port: input.server_port,
303
303
  server_path: input.server_path,
304
304
  use_auth: input.use_auth,
305
+ auth_localStorage_json: input.auth_localStorage_json,
306
+ auth_cookies_json: input.auth_cookies_json,
307
+ auth_headers_json: input.auth_headers_json,
305
308
  color_scheme: input.color_scheme,
306
309
  wait_for_selector: input.wait_for_selector,
307
310
  ship_mode: input.ship_mode,
@@ -560,6 +563,9 @@ function initialRunParams(request, input, state) {
560
563
  server_port: request.server_port,
561
564
  server_path: request.server_path,
562
565
  use_auth: request.use_auth,
566
+ auth_localStorage_json: request.auth_localStorage_json,
567
+ auth_cookies_json: request.auth_cookies_json,
568
+ auth_headers_json: request.auth_headers_json,
563
569
  color_scheme: request.color_scheme,
564
570
  wait_for_selector: request.wait_for_selector,
565
571
  leave_draft: request.leave_draft || void 0,
@@ -2,8 +2,8 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "./chunk-75XY5SVT.js";
6
- import "./chunk-SIQG3N6F.js";
5
+ } from "./chunk-LVP22WE4.js";
6
+ import "./chunk-GVPCSXN7.js";
7
7
  import "./chunk-TMMKRKY5.js";
8
8
  export {
9
9
  createDisabledRiddleProofAgentAdapter,
package/dist/index.cjs CHANGED
@@ -30,12 +30,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ DEFAULT_DIAGNOSTIC_ARRAY_LIMIT: () => DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
34
+ DEFAULT_DIAGNOSTIC_HISTORY_LIMIT: () => DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
35
+ DEFAULT_DIAGNOSTIC_STRING_LIMIT: () => DEFAULT_DIAGNOSTIC_STRING_LIMIT,
36
+ RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION: () => RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
33
37
  RIDDLE_PROOF_RUN_STATE_VERSION: () => RIDDLE_PROOF_RUN_STATE_VERSION,
38
+ appendCaptureDiagnostic: () => appendCaptureDiagnostic,
34
39
  appendRunEvent: () => appendRunEvent,
35
40
  appendStageHeartbeat: () => appendStageHeartbeat,
36
41
  applyPrLifecycleState: () => applyPrLifecycleState,
37
42
  applyTerminalMetadata: () => applyTerminalMetadata,
38
43
  compactRecord: () => compactRecord,
44
+ createCaptureDiagnostic: () => createCaptureDiagnostic,
39
45
  createDisabledRiddleProofAgentAdapter: () => createDisabledRiddleProofAgentAdapter,
40
46
  createRunResult: () => createRunResult,
41
47
  createRunState: () => createRunState,
@@ -49,9 +55,11 @@ __export(index_exports, {
49
55
  normalizeTerminalMetadata: () => normalizeTerminalMetadata,
50
56
  readRiddleProofRunStatus: () => readRiddleProofRunStatus,
51
57
  recordValue: () => recordValue,
58
+ redactForProofDiagnostics: () => redactForProofDiagnostics,
52
59
  runRiddleProof: () => runRiddleProof,
53
60
  runRiddleProofEngineHarness: () => runRiddleProofEngineHarness,
54
- setRunStatus: () => setRunStatus
61
+ setRunStatus: () => setRunStatus,
62
+ summarizeCaptureArtifacts: () => summarizeCaptureArtifacts
55
63
  });
56
64
  module.exports = __toCommonJS(index_exports);
57
65
 
@@ -350,6 +358,9 @@ function normalizeRunParams(input) {
350
358
  server_port: input.server_port,
351
359
  server_path: input.server_path,
352
360
  use_auth: input.use_auth,
361
+ auth_localStorage_json: input.auth_localStorage_json,
362
+ auth_cookies_json: input.auth_cookies_json,
363
+ auth_headers_json: input.auth_headers_json,
353
364
  color_scheme: input.color_scheme,
354
365
  wait_for_selector: input.wait_for_selector,
355
366
  ship_mode: input.ship_mode,
@@ -1111,6 +1122,9 @@ function initialRunParams(request, input, state) {
1111
1122
  server_port: request.server_port,
1112
1123
  server_path: request.server_path,
1113
1124
  use_auth: request.use_auth,
1125
+ auth_localStorage_json: request.auth_localStorage_json,
1126
+ auth_cookies_json: request.auth_cookies_json,
1127
+ auth_headers_json: request.auth_headers_json,
1114
1128
  color_scheme: request.color_scheme,
1115
1129
  wait_for_selector: request.wait_for_selector,
1116
1130
  leave_draft: request.leave_draft || void 0,
@@ -1634,14 +1648,160 @@ async function runRiddleProofEngineHarness(input) {
1634
1648
  }
1635
1649
  });
1636
1650
  }
1651
+
1652
+ // src/diagnostics.ts
1653
+ var RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION = "riddle-proof.capture-diagnostic.v1";
1654
+ var DEFAULT_DIAGNOSTIC_STRING_LIMIT = 2e3;
1655
+ var DEFAULT_DIAGNOSTIC_ARRAY_LIMIT = 50;
1656
+ var DEFAULT_DIAGNOSTIC_HISTORY_LIMIT = 20;
1657
+ var DEFAULT_REDACTED_VALUE = "[redacted]";
1658
+ var DEFAULT_SENSITIVE_KEY_PATTERN = /authorization|api_?key|apikey|cookie|header|localstorage|password|secret|token/i;
1659
+ function isRecord(value) {
1660
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1661
+ }
1662
+ function normalizeSensitiveKey(key) {
1663
+ return key.toLowerCase().replace(/[^a-z0-9_]/g, "").replace(/_/g, "");
1664
+ }
1665
+ function isSensitiveKey(key, pattern) {
1666
+ pattern.lastIndex = 0;
1667
+ const rawMatch = pattern.test(key);
1668
+ pattern.lastIndex = 0;
1669
+ return rawMatch || pattern.test(normalizeSensitiveKey(key));
1670
+ }
1671
+ function truncateString(value, limit) {
1672
+ if (value.length <= limit) return value;
1673
+ return `${value.slice(0, limit)}... [truncated]`;
1674
+ }
1675
+ function sortedKeys(value) {
1676
+ return isRecord(value) ? Object.keys(value).sort() : [];
1677
+ }
1678
+ function stringValue(value) {
1679
+ if (typeof value !== "string") return void 0;
1680
+ const trimmed = value.trim();
1681
+ return trimmed ? trimmed : void 0;
1682
+ }
1683
+ function numberValue(value) {
1684
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
1685
+ }
1686
+ function artifactItems(value) {
1687
+ if (!Array.isArray(value)) return [];
1688
+ return value.filter(isRecord);
1689
+ }
1690
+ function artifactSummary(item, source) {
1691
+ const artifact = item;
1692
+ const metadata = isRecord(artifact.metadata) ? artifact.metadata : void 0;
1693
+ return {
1694
+ name: stringValue(artifact.name) || "",
1695
+ kind: stringValue(artifact.kind),
1696
+ role: stringValue(artifact.role),
1697
+ url: stringValue(artifact.url),
1698
+ path: stringValue(artifact.path),
1699
+ content_type: stringValue(artifact.content_type),
1700
+ size_bytes: numberValue(artifact.size_bytes),
1701
+ metadata_keys: metadata ? Object.keys(metadata).sort() : void 0,
1702
+ source
1703
+ };
1704
+ }
1705
+ function artifactErrorMap(value, redaction) {
1706
+ if (!isRecord(value)) return {};
1707
+ const entries = Object.entries(value).map(([key, child]) => {
1708
+ const redacted = redactForProofDiagnostics(child, redaction);
1709
+ return [key, typeof redacted === "string" ? redacted : JSON.stringify(redacted)];
1710
+ }).sort(([left], [right]) => left.localeCompare(right));
1711
+ return Object.fromEntries(entries);
1712
+ }
1713
+ function redactForProofDiagnostics(value, options = {}) {
1714
+ const stringLimit = Math.max(1, options.string_limit ?? DEFAULT_DIAGNOSTIC_STRING_LIMIT);
1715
+ const arrayLimit = Math.max(0, options.array_limit ?? DEFAULT_DIAGNOSTIC_ARRAY_LIMIT);
1716
+ const redactedValue = options.redacted_value || DEFAULT_REDACTED_VALUE;
1717
+ const sensitiveKeyPattern = options.sensitive_key_pattern || DEFAULT_SENSITIVE_KEY_PATTERN;
1718
+ const seen = /* @__PURE__ */ new WeakSet();
1719
+ function redact(child) {
1720
+ if (child === null || child === void 0) return null;
1721
+ if (typeof child === "string") return truncateString(child, stringLimit);
1722
+ if (typeof child === "number") return Number.isFinite(child) ? child : null;
1723
+ if (typeof child === "boolean") return child;
1724
+ if (typeof child === "bigint" || typeof child === "symbol" || typeof child === "function") {
1725
+ return truncateString(String(child), stringLimit);
1726
+ }
1727
+ if (Array.isArray(child)) {
1728
+ return child.slice(0, arrayLimit).map((item) => redact(item));
1729
+ }
1730
+ if (isRecord(child)) {
1731
+ if (seen.has(child)) return "[circular]";
1732
+ seen.add(child);
1733
+ const entries = [];
1734
+ for (const [key, nested] of Object.entries(child)) {
1735
+ entries.push([
1736
+ key,
1737
+ isSensitiveKey(key, sensitiveKeyPattern) ? redactedValue : redact(nested)
1738
+ ]);
1739
+ }
1740
+ return Object.fromEntries(entries);
1741
+ }
1742
+ return truncateString(String(child), stringLimit);
1743
+ }
1744
+ return redact(value);
1745
+ }
1746
+ function summarizeCaptureArtifacts(payload) {
1747
+ const record = isRecord(payload) ? payload : {};
1748
+ const artifactJson = isRecord(record._artifact_json) ? record._artifact_json : {};
1749
+ const proofJson = isRecord(record._proof_json) ? record._proof_json : isRecord(artifactJson["proof.json"]) ? artifactJson["proof.json"] : {};
1750
+ const consoleJson = isRecord(record.console) ? record.console : isRecord(artifactJson["console.json"]) ? artifactJson["console.json"] : {};
1751
+ const result = isRecord(record.result) ? record.result : isRecord(proofJson.result) ? proofJson.result : isRecord(proofJson.script_result) ? proofJson.script_result : isRecord(proofJson.return_value) ? proofJson.return_value : isRecord(proofJson.value) ? proofJson.value : {};
1752
+ const consoleSummary = isRecord(consoleJson.summary) ? redactForProofDiagnostics(consoleJson.summary, { string_limit: 500 }) : void 0;
1753
+ return {
1754
+ outputs: artifactItems(record.outputs).slice(0, 20).map((item) => artifactSummary(item, "outputs")),
1755
+ screenshots: artifactItems(record.screenshots).slice(0, 10).map((item) => artifactSummary(item, "screenshots")),
1756
+ artifacts: artifactItems(record.artifacts).slice(0, 20).map((item) => artifactSummary(item, "artifacts")),
1757
+ result_keys: sortedKeys(result),
1758
+ artifact_json: sortedKeys(artifactJson),
1759
+ artifact_errors: artifactErrorMap(record._artifact_errors),
1760
+ proof_script_error: Boolean(proofJson.script_error),
1761
+ console_summary: consoleSummary
1762
+ };
1763
+ }
1764
+ function createCaptureDiagnostic(input) {
1765
+ const payload = isRecord(input.payload) ? input.payload : {};
1766
+ const redaction = input.redaction;
1767
+ const error = input.error ?? payload.error ?? payload.stderr ?? payload.message ?? "";
1768
+ return {
1769
+ version: RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
1770
+ label: input.label,
1771
+ tool: input.tool,
1772
+ captured_at: input.captured_at || (/* @__PURE__ */ new Date()).toISOString(),
1773
+ ok: typeof input.ok === "boolean" ? input.ok : typeof payload.ok === "boolean" ? payload.ok : void 0,
1774
+ timeout: typeof input.timeout === "boolean" ? input.timeout : Boolean(payload.timeout),
1775
+ error: truncateString(String(error ?? ""), redaction?.string_limit ?? DEFAULT_DIAGNOSTIC_STRING_LIMIT),
1776
+ route: input.route,
1777
+ preview_url: input.preview_url,
1778
+ wait_for_selector: input.wait_for_selector,
1779
+ args: redactForProofDiagnostics(input.args === void 0 ? {} : input.args, redaction),
1780
+ artifact_summary: summarizeCaptureArtifacts(input.payload),
1781
+ evidence: input.evidence === void 0 ? void 0 : redactForProofDiagnostics(input.evidence, redaction),
1782
+ notes: input.notes?.map((note) => note.trim()).filter(Boolean)
1783
+ };
1784
+ }
1785
+ function appendCaptureDiagnostic(state, input, historyLimit = DEFAULT_DIAGNOSTIC_HISTORY_LIMIT) {
1786
+ const diagnostic = createCaptureDiagnostic(input);
1787
+ const existing = Array.isArray(state.capture_diagnostics) ? state.capture_diagnostics : [];
1788
+ state.capture_diagnostics = [...existing, diagnostic].slice(-Math.max(1, historyLimit));
1789
+ return diagnostic;
1790
+ }
1637
1791
  // Annotate the CommonJS export names for ESM import in node:
1638
1792
  0 && (module.exports = {
1793
+ DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
1794
+ DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
1795
+ DEFAULT_DIAGNOSTIC_STRING_LIMIT,
1796
+ RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
1639
1797
  RIDDLE_PROOF_RUN_STATE_VERSION,
1798
+ appendCaptureDiagnostic,
1640
1799
  appendRunEvent,
1641
1800
  appendStageHeartbeat,
1642
1801
  applyPrLifecycleState,
1643
1802
  applyTerminalMetadata,
1644
1803
  compactRecord,
1804
+ createCaptureDiagnostic,
1645
1805
  createDisabledRiddleProofAgentAdapter,
1646
1806
  createRunResult,
1647
1807
  createRunState,
@@ -1655,7 +1815,9 @@ async function runRiddleProofEngineHarness(input) {
1655
1815
  normalizeTerminalMetadata,
1656
1816
  readRiddleProofRunStatus,
1657
1817
  recordValue,
1818
+ redactForProofDiagnostics,
1658
1819
  runRiddleProof,
1659
1820
  runRiddleProofEngineHarness,
1660
- setRunStatus
1821
+ setRunStatus,
1822
+ summarizeCaptureArtifacts
1661
1823
  });
package/dist/index.d.cts CHANGED
@@ -3,3 +3,4 @@ export { TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunR
3
3
  export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus } from './state.cjs';
4
4
  export { RiddleProofRunnerAdapters, RunRiddleProofInput, runRiddleProof } from './runner.cjs';
5
5
  export { RiddleProofAgentAdapter, RiddleProofAgentPayload, RiddleProofEngine, RiddleProofEngineHarnessConfig, RiddleProofEngineHarnessContext, RiddleProofEngineResult, RiddleProofShipMode, RiddleProofWorkflowParams, RunRiddleProofEngineHarnessInput, createDisabledRiddleProofAgentAdapter, readRiddleProofRunStatus, runRiddleProofEngineHarness } from './engine-harness.cjs';
6
+ export { CreateCaptureDiagnosticInput, DEFAULT_DIAGNOSTIC_ARRAY_LIMIT, DEFAULT_DIAGNOSTIC_HISTORY_LIMIT, DEFAULT_DIAGNOSTIC_STRING_LIMIT, RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION, RiddleProofArtifactSummary, RiddleProofCaptureArtifactSummary, RiddleProofCaptureDiagnostic, RiddleProofDiagnosticRedactionOptions, appendCaptureDiagnostic, createCaptureDiagnostic, redactForProofDiagnostics, summarizeCaptureArtifacts } from './diagnostics.cjs';
package/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export { TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunR
3
3
  export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus } from './state.js';
4
4
  export { RiddleProofRunnerAdapters, RunRiddleProofInput, runRiddleProof } from './runner.js';
5
5
  export { RiddleProofAgentAdapter, RiddleProofAgentPayload, RiddleProofEngine, RiddleProofEngineHarnessConfig, RiddleProofEngineHarnessContext, RiddleProofEngineResult, RiddleProofShipMode, RiddleProofWorkflowParams, RunRiddleProofEngineHarnessInput, createDisabledRiddleProofAgentAdapter, readRiddleProofRunStatus, runRiddleProofEngineHarness } from './engine-harness.js';
6
+ export { CreateCaptureDiagnosticInput, DEFAULT_DIAGNOSTIC_ARRAY_LIMIT, DEFAULT_DIAGNOSTIC_HISTORY_LIMIT, DEFAULT_DIAGNOSTIC_STRING_LIMIT, RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION, RiddleProofArtifactSummary, RiddleProofCaptureArtifactSummary, RiddleProofCaptureDiagnostic, RiddleProofDiagnosticRedactionOptions, appendCaptureDiagnostic, createCaptureDiagnostic, redactForProofDiagnostics, summarizeCaptureArtifacts } from './diagnostics.js';
package/dist/index.js CHANGED
@@ -1,11 +1,21 @@
1
+ import {
2
+ DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
3
+ DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
4
+ DEFAULT_DIAGNOSTIC_STRING_LIMIT,
5
+ RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
6
+ appendCaptureDiagnostic,
7
+ createCaptureDiagnostic,
8
+ redactForProofDiagnostics,
9
+ summarizeCaptureArtifacts
10
+ } from "./chunk-DWQK7J4U.js";
1
11
  import {
2
12
  createDisabledRiddleProofAgentAdapter,
3
13
  readRiddleProofRunStatus,
4
14
  runRiddleProofEngineHarness
5
- } from "./chunk-75XY5SVT.js";
15
+ } from "./chunk-LVP22WE4.js";
6
16
  import {
7
17
  runRiddleProof
8
- } from "./chunk-PM5Q26Q6.js";
18
+ } from "./chunk-VSEKLCNU.js";
9
19
  import {
10
20
  RIDDLE_PROOF_RUN_STATE_VERSION,
11
21
  appendRunEvent,
@@ -17,7 +27,7 @@ import {
17
27
  normalizePrLifecycleState,
18
28
  normalizeRunParams,
19
29
  setRunStatus
20
- } from "./chunk-SIQG3N6F.js";
30
+ } from "./chunk-GVPCSXN7.js";
21
31
  import {
22
32
  applyTerminalMetadata,
23
33
  compactRecord,
@@ -30,12 +40,18 @@ import {
30
40
  } from "./chunk-TMMKRKY5.js";
31
41
  import "./chunk-6F4PWJZI.js";
32
42
  export {
43
+ DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
44
+ DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
45
+ DEFAULT_DIAGNOSTIC_STRING_LIMIT,
46
+ RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
33
47
  RIDDLE_PROOF_RUN_STATE_VERSION,
48
+ appendCaptureDiagnostic,
34
49
  appendRunEvent,
35
50
  appendStageHeartbeat,
36
51
  applyPrLifecycleState,
37
52
  applyTerminalMetadata,
38
53
  compactRecord,
54
+ createCaptureDiagnostic,
39
55
  createDisabledRiddleProofAgentAdapter,
40
56
  createRunResult,
41
57
  createRunState,
@@ -49,7 +65,9 @@ export {
49
65
  normalizeTerminalMetadata,
50
66
  readRiddleProofRunStatus,
51
67
  recordValue,
68
+ redactForProofDiagnostics,
52
69
  runRiddleProof,
53
70
  runRiddleProofEngineHarness,
54
- setRunStatus
71
+ setRunStatus,
72
+ summarizeCaptureArtifacts
55
73
  };
package/dist/openclaw.cjs CHANGED
@@ -78,6 +78,9 @@ function normalizeRunParams(input) {
78
78
  server_port: input.server_port,
79
79
  server_path: input.server_path,
80
80
  use_auth: input.use_auth,
81
+ auth_localStorage_json: input.auth_localStorage_json,
82
+ auth_cookies_json: input.auth_cookies_json,
83
+ auth_headers_json: input.auth_headers_json,
81
84
  color_scheme: input.color_scheme,
82
85
  wait_for_selector: input.wait_for_selector,
83
86
  ship_mode: input.ship_mode,
@@ -142,6 +145,9 @@ function toRiddleProofRunParams(params) {
142
145
  server_port: params.server_port,
143
146
  server_path: params.server_path,
144
147
  use_auth: params.use_auth,
148
+ auth_localStorage_json: params.auth_localStorage_json,
149
+ auth_cookies_json: params.auth_cookies_json,
150
+ auth_headers_json: params.auth_headers_json,
145
151
  color_scheme: params.color_scheme,
146
152
  wait_for_selector: params.wait_for_selector,
147
153
  ship_mode: params.ship_mode || (params.ship_after_verify ? "ship" : void 0),
@@ -24,6 +24,9 @@ interface OpenClawProofedChangeParams {
24
24
  server_port?: number;
25
25
  server_path?: string;
26
26
  use_auth?: boolean;
27
+ auth_localStorage_json?: string;
28
+ auth_cookies_json?: string;
29
+ auth_headers_json?: string;
27
30
  color_scheme?: "dark" | "light" | (string & {});
28
31
  wait_for_selector?: string;
29
32
  ship_after_verify?: boolean;
@@ -24,6 +24,9 @@ interface OpenClawProofedChangeParams {
24
24
  server_port?: number;
25
25
  server_path?: string;
26
26
  use_auth?: boolean;
27
+ auth_localStorage_json?: string;
28
+ auth_cookies_json?: string;
29
+ auth_headers_json?: string;
27
30
  color_scheme?: "dark" | "light" | (string & {});
28
31
  wait_for_selector?: string;
29
32
  ship_after_verify?: boolean;
package/dist/openclaw.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  normalizeIntegrationContext,
3
3
  normalizeRunParams
4
- } from "./chunk-SIQG3N6F.js";
4
+ } from "./chunk-GVPCSXN7.js";
5
5
  import {
6
6
  compactRecord
7
7
  } from "./chunk-TMMKRKY5.js";
@@ -57,6 +57,9 @@ function toRiddleProofRunParams(params) {
57
57
  server_port: params.server_port,
58
58
  server_path: params.server_path,
59
59
  use_auth: params.use_auth,
60
+ auth_localStorage_json: params.auth_localStorage_json,
61
+ auth_cookies_json: params.auth_cookies_json,
62
+ auth_headers_json: params.auth_headers_json,
60
63
  color_scheme: params.color_scheme,
61
64
  wait_for_selector: params.wait_for_selector,
62
65
  ship_mode: params.ship_mode || (params.ship_after_verify ? "ship" : void 0),
package/dist/runner.cjs CHANGED
@@ -184,6 +184,9 @@ function normalizeRunParams(input) {
184
184
  server_port: input.server_port,
185
185
  server_path: input.server_path,
186
186
  use_auth: input.use_auth,
187
+ auth_localStorage_json: input.auth_localStorage_json,
188
+ auth_cookies_json: input.auth_cookies_json,
189
+ auth_headers_json: input.auth_headers_json,
187
190
  color_scheme: input.color_scheme,
188
191
  wait_for_selector: input.wait_for_selector,
189
192
  ship_mode: input.ship_mode,
package/dist/runner.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  runRiddleProof
3
- } from "./chunk-PM5Q26Q6.js";
4
- import "./chunk-SIQG3N6F.js";
3
+ } from "./chunk-VSEKLCNU.js";
4
+ import "./chunk-GVPCSXN7.js";
5
5
  import "./chunk-TMMKRKY5.js";
6
6
  export {
7
7
  runRiddleProof
package/dist/state.cjs CHANGED
@@ -130,6 +130,9 @@ function normalizeRunParams(input) {
130
130
  server_port: input.server_port,
131
131
  server_path: input.server_path,
132
132
  use_auth: input.use_auth,
133
+ auth_localStorage_json: input.auth_localStorage_json,
134
+ auth_cookies_json: input.auth_cookies_json,
135
+ auth_headers_json: input.auth_headers_json,
133
136
  color_scheme: input.color_scheme,
134
137
  wait_for_selector: input.wait_for_selector,
135
138
  ship_mode: input.ship_mode,
package/dist/state.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  normalizePrLifecycleState,
10
10
  normalizeRunParams,
11
11
  setRunStatus
12
- } from "./chunk-SIQG3N6F.js";
12
+ } from "./chunk-GVPCSXN7.js";
13
13
  import "./chunk-TMMKRKY5.js";
14
14
  export {
15
15
  RIDDLE_PROOF_RUN_STATE_VERSION,
package/dist/types.d.cts CHANGED
@@ -33,6 +33,9 @@ interface RiddleProofRunParams {
33
33
  server_port?: number;
34
34
  server_path?: string;
35
35
  use_auth?: boolean;
36
+ auth_localStorage_json?: string;
37
+ auth_cookies_json?: string;
38
+ auth_headers_json?: string;
36
39
  color_scheme?: "dark" | "light" | (string & {});
37
40
  wait_for_selector?: string;
38
41
  ship_mode?: "none" | "ship";
package/dist/types.d.ts CHANGED
@@ -33,6 +33,9 @@ interface RiddleProofRunParams {
33
33
  server_port?: number;
34
34
  server_path?: string;
35
35
  use_auth?: boolean;
36
+ auth_localStorage_json?: string;
37
+ auth_cookies_json?: string;
38
+ auth_headers_json?: string;
36
39
  color_scheme?: "dark" | "light" | (string & {});
37
40
  wait_for_selector?: string;
38
41
  ship_mode?: "none" | "ship";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",
@@ -44,6 +44,11 @@
44
44
  "import": "./dist/engine-harness.js",
45
45
  "require": "./dist/engine-harness.cjs"
46
46
  },
47
+ "./diagnostics": {
48
+ "types": "./dist/diagnostics.d.ts",
49
+ "import": "./dist/diagnostics.js",
50
+ "require": "./dist/diagnostics.cjs"
51
+ },
47
52
  "./openclaw": {
48
53
  "types": "./dist/openclaw.d.ts",
49
54
  "import": "./dist/openclaw.js",
@@ -65,7 +70,7 @@
65
70
  "typescript": "^5.4.5"
66
71
  },
67
72
  "scripts": {
68
- "build": "tsup src/index.ts src/types.ts src/result.ts src/state.ts src/runner.ts src/engine-harness.ts src/openclaw.ts --format cjs,esm --dts --out-dir dist --clean",
73
+ "build": "tsup src/index.ts src/types.ts src/result.ts src/state.ts src/runner.ts src/engine-harness.ts src/diagnostics.ts src/openclaw.ts --format cjs,esm --dts --out-dir dist --clean",
69
74
  "clean": "rm -rf dist",
70
75
  "lint": "echo 'lint: (not configured)'",
71
76
  "test": "npm run build && node test.js"