@riddledc/riddle-proof 0.5.53 → 0.5.54

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.js CHANGED
@@ -1,20 +1,24 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ createRiddleApiClient,
4
+ parseRiddleViewport
5
+ } from "./chunk-UR6ADV4Y.js";
2
6
  import {
3
7
  createDisabledRiddleProofAgentAdapter,
4
8
  readRiddleProofRunStatus,
5
9
  runRiddleProofEngineHarness
6
- } from "./chunk-KYGWIA7A.js";
7
- import "./chunk-4ASMX4R6.js";
10
+ } from "./chunk-A2AWRZ5B.js";
11
+ import "./chunk-RFJ5BQF6.js";
8
12
  import "./chunk-JFQXAJH2.js";
9
13
  import {
10
14
  createCodexExecAgentAdapter,
11
15
  runCodexExecAgentDoctor
12
16
  } from "./chunk-3266V3MO.js";
13
- import "./chunk-PVUZZ2P6.js";
14
- import "./chunk-53UPEUVU.js";
17
+ import "./chunk-MO24D3PY.js";
18
+ import "./chunk-3UHWI3FO.js";
15
19
  import {
16
20
  createCheckpointResponseTemplate
17
- } from "./chunk-T5RHGGQ2.js";
21
+ } from "./chunk-33XO42CY.js";
18
22
  import "./chunk-DUFDZJOF.js";
19
23
 
20
24
  // src/cli.ts
@@ -27,6 +31,9 @@ function usage() {
27
31
  " riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
28
32
  " riddle-proof-loop respond --state-path <path> --decision <decision> --summary <text> [--payload-json <file|json|->]",
29
33
  " riddle-proof-loop status --state-path <path>",
34
+ " riddle-proof-loop riddle-preview-deploy <build-dir> <label>",
35
+ " riddle-proof-loop riddle-run-script --url <url> --script-file <file> [--viewport 1280x720]",
36
+ " riddle-proof-loop riddle-poll <job-id> [--wait]",
30
37
  " riddle-proof-loop doctor local [--codex-command <path>]",
31
38
  "",
32
39
  "The default CLI run mode is checkpoint-mode=yield unless --agent local is used.",
@@ -207,14 +214,28 @@ function agentFor(options) {
207
214
  if (agentMode === "disabled") return createDisabledRiddleProofAgentAdapter();
208
215
  throw new Error(`Unsupported --agent ${agentMode}. Use disabled or local.`);
209
216
  }
217
+ function riddleClientConfig(options) {
218
+ return {
219
+ apiKey: optionString(options, "apiKey"),
220
+ apiKeyFile: optionString(options, "apiKeyFile"),
221
+ apiBaseUrl: optionString(options, "apiBaseUrl")
222
+ };
223
+ }
210
224
  function requestForRun(options) {
211
225
  const statePath = optionString(options, "statePath");
226
+ const withEngineModuleUrl = (request) => {
227
+ const moduleUrl = optionString(options, "riddleEngineModuleUrl");
228
+ return moduleUrl && !request.riddle_engine_module_url ? { ...request, riddle_engine_module_url: moduleUrl } : request;
229
+ };
212
230
  if (optionString(options, "requestJson")) {
213
- return readJsonValue(optionString(options, "requestJson"), "--request-json");
231
+ return withEngineModuleUrl(readJsonValue(optionString(options, "requestJson"), "--request-json"));
214
232
  }
215
- if (statePath) return readRunState(statePath).request;
233
+ if (statePath) return withEngineModuleUrl(readRunState(statePath).request);
216
234
  throw new Error("--request-json is required unless --state-path points to an existing run state.");
217
235
  }
236
+ function riddleEngineModuleUrlFor(options, request) {
237
+ return optionString(options, "riddleEngineModuleUrl") || (typeof request.riddle_engine_module_url === "string" && request.riddle_engine_module_url.trim() ? request.riddle_engine_module_url.trim() : void 0);
238
+ }
218
239
  function checkpointModeFor(options) {
219
240
  const explicit = optionString(options, "checkpointMode");
220
241
  if (explicit) return explicit;
@@ -246,6 +267,42 @@ async function main() {
246
267
  `);
247
268
  return;
248
269
  }
270
+ if (command === "riddle-preview-deploy") {
271
+ const buildDir = positional[1];
272
+ const label = positional[2];
273
+ const result = await createRiddleApiClient(riddleClientConfig(options)).deployStaticPreview(buildDir, label);
274
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
275
+ `);
276
+ return;
277
+ }
278
+ if (command === "riddle-run-script") {
279
+ const url = optionString(options, "url");
280
+ const scriptFile = optionString(options, "scriptFile");
281
+ if (!url || !scriptFile) throw new Error("riddle-run-script requires --url and --script-file.");
282
+ const result = await createRiddleApiClient(riddleClientConfig(options)).runScript({
283
+ url,
284
+ script: readFileSync(scriptFile, "utf-8"),
285
+ viewport: parseRiddleViewport(optionString(options, "viewport")),
286
+ timeoutSec: optionString(options, "timeout") ? Number(optionString(options, "timeout")) : void 0,
287
+ sync: options.sync === true ? true : void 0
288
+ });
289
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
290
+ `);
291
+ return;
292
+ }
293
+ if (command === "riddle-poll") {
294
+ const jobId = positional[1];
295
+ if (!jobId) throw new Error("riddle-poll requires <job-id>.");
296
+ const result = await createRiddleApiClient(riddleClientConfig(options)).pollJob(jobId, {
297
+ wait: options.wait === true,
298
+ attempts: optionString(options, "attempts") ? Number(optionString(options, "attempts")) : void 0,
299
+ intervalMs: optionString(options, "intervalMs") ? Number(optionString(options, "intervalMs")) : void 0
300
+ });
301
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
302
+ `);
303
+ process.exitCode = result.ok ? 0 : 1;
304
+ return;
305
+ }
249
306
  if (command === "checkpoint") {
250
307
  const statePath = optionString(options, "statePath");
251
308
  if (!statePath) throw new Error("--state-path is required.");
@@ -296,7 +353,7 @@ async function main() {
296
353
  agent: agentFor(options),
297
354
  config: {
298
355
  stateDir: optionString(options, "stateDir"),
299
- riddleEngineModuleUrl: optionString(options, "riddleEngineModuleUrl"),
356
+ riddleEngineModuleUrl: riddleEngineModuleUrlFor(options, request),
300
357
  riddleProofDir: optionString(options, "riddleProofDir"),
301
358
  defaultReviewer: optionString(options, "defaultReviewer"),
302
359
  defaultShipMode: optionString(options, "defaultShipMode")
@@ -363,6 +363,7 @@ function visualDeltaRequiredForState(state = {}) {
363
363
  const bundle = objectValue(state?.evidence_bundle);
364
364
  const contract = objectValue(bundle.artifact_contract);
365
365
  const required = objectValue(contract.required);
366
+ if (required.visual_delta === false) return false;
366
367
  return required.visual_delta === true || VISUAL_FIRST_MODES.has(normalizedVerificationMode(state));
367
368
  }
368
369
  function visualDeltaForState(state = {}) {
@@ -3438,8 +3439,8 @@ function buildProofAssessmentCheckpointPacket(input) {
3438
3439
  const artifactContract = recordValue(proofAssessmentRequest.artifact_contract) || recordValue(bundle?.artifact_contract);
3439
3440
  const requiredSignals = recordValue(recordValue(artifactContract)?.required);
3440
3441
  const visualDelta = visualDeltaFromState(fullState);
3441
- const verificationMode = nonEmptyString(input.request.verification_mode) || nonEmptyString(fullState.verification_mode) || nonEmptyString(bundle?.verification_mode) || "proof";
3442
- const visualDeltaRequired = requiredSignals?.visual_delta === true || verificationModeRequiresVisualDelta(verificationMode);
3442
+ const verificationMode = nonEmptyString(bundle?.verification_mode) || nonEmptyString(fullState.verification_mode) || nonEmptyString(input.request.verification_mode) || "proof";
3443
+ const visualDeltaRequired = requiredSignals?.visual_delta !== false && (requiredSignals?.visual_delta === true || verificationModeRequiresVisualDelta(verificationMode));
3443
3444
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
3444
3445
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
3445
3446
  const recoveryHint = evidenceIssueCode2 ? "Required visual_delta evidence is incomplete. Keep this same run in verify/evidence recovery with decision=revise_capture and continue_with_stage=verify unless the evidence proves an implementation or recon problem." : "Assess whether the current artifacts prove the requested change, then choose the next stage.";
@@ -3912,6 +3913,7 @@ function normalizeRunParams(input) {
3912
3913
  leave_draft: input.leave_draft,
3913
3914
  engine_state_path: input.engine_state_path,
3914
3915
  harness_state_path: input.harness_state_path,
3916
+ riddle_engine_module_url: input.riddle_engine_module_url,
3915
3917
  max_iterations: input.max_iterations,
3916
3918
  auto_approve: input.auto_approve,
3917
3919
  dry_run: input.dry_run,
@@ -2,11 +2,11 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "./chunk-KYGWIA7A.js";
6
- import "./chunk-4ASMX4R6.js";
7
- import "./chunk-PVUZZ2P6.js";
8
- import "./chunk-53UPEUVU.js";
9
- import "./chunk-T5RHGGQ2.js";
5
+ } from "./chunk-A2AWRZ5B.js";
6
+ import "./chunk-RFJ5BQF6.js";
7
+ import "./chunk-MO24D3PY.js";
8
+ import "./chunk-3UHWI3FO.js";
9
+ import "./chunk-33XO42CY.js";
10
10
  import "./chunk-DUFDZJOF.js";
11
11
  export {
12
12
  createDisabledRiddleProofAgentAdapter,
package/dist/index.cjs CHANGED
@@ -363,6 +363,7 @@ function visualDeltaRequiredForState(state = {}) {
363
363
  const bundle = objectValue(state?.evidence_bundle);
364
364
  const contract = objectValue(bundle.artifact_contract);
365
365
  const required = objectValue(contract.required);
366
+ if (required.visual_delta === false) return false;
366
367
  return required.visual_delta === true || VISUAL_FIRST_MODES.has(normalizedVerificationMode(state));
367
368
  }
368
369
  function visualDeltaForState(state = {}) {
@@ -1407,9 +1408,9 @@ function cleanupMergedProofRun(state, repoDir, params, prState) {
1407
1408
  const baseBranch = stringValue(prState.base_branch) || stringValue(state?.base_branch) || "main";
1408
1409
  let fetchedBase = params.fetch_base === false;
1409
1410
  if (params.fetch_base !== false && baseBranch) {
1410
- const fetch = commandResult("git", ["fetch", "origin", baseBranch], repoDir, 12e4);
1411
- cleanup.fetch = fetch.ok ? { ok: true, base_branch: baseBranch } : { ok: false, base_branch: baseBranch, error: fetch.stderr.slice(0, 300) };
1412
- if (fetch.ok) {
1411
+ const fetch2 = commandResult("git", ["fetch", "origin", baseBranch], repoDir, 12e4);
1412
+ cleanup.fetch = fetch2.ok ? { ok: true, base_branch: baseBranch } : { ok: false, base_branch: baseBranch, error: fetch2.stderr.slice(0, 300) };
1413
+ if (fetch2.ok) {
1413
1414
  fetchedBase = true;
1414
1415
  state.base_synced_at = (/* @__PURE__ */ new Date()).toISOString();
1415
1416
  state.base_branch = baseBranch;
@@ -2775,6 +2776,8 @@ __export(index_exports, {
2775
2776
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT: () => DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
2776
2777
  DEFAULT_DIAGNOSTIC_HISTORY_LIMIT: () => DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
2777
2778
  DEFAULT_DIAGNOSTIC_STRING_LIMIT: () => DEFAULT_DIAGNOSTIC_STRING_LIMIT,
2779
+ DEFAULT_RIDDLE_API_BASE_URL: () => DEFAULT_RIDDLE_API_BASE_URL,
2780
+ DEFAULT_RIDDLE_API_KEY_FILE: () => DEFAULT_RIDDLE_API_KEY_FILE,
2778
2781
  RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION: () => RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
2779
2782
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION: () => RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
2780
2783
  RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION: () => RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
@@ -2784,6 +2787,7 @@ __export(index_exports, {
2784
2787
  RIDDLE_PROOF_RUN_STATE_VERSION: () => RIDDLE_PROOF_RUN_STATE_VERSION,
2785
2788
  RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION: () => RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION,
2786
2789
  RIDDLE_PROOF_VISUAL_SESSION_VERSION: () => RIDDLE_PROOF_VISUAL_SESSION_VERSION,
2790
+ RiddleApiError: () => RiddleApiError,
2787
2791
  appendCaptureDiagnostic: () => appendCaptureDiagnostic,
2788
2792
  appendRunEvent: () => appendRunEvent,
2789
2793
  appendStageHeartbeat: () => appendStageHeartbeat,
@@ -2807,14 +2811,17 @@ __export(index_exports, {
2807
2811
  createDisabledRiddleProofAgentAdapter: () => createDisabledRiddleProofAgentAdapter,
2808
2812
  createLocalAgentAdapter: () => createCodexExecAgentAdapter,
2809
2813
  createLocalAgentJsonRunner: () => createCodexExecJsonRunner,
2814
+ createRiddleApiClient: () => createRiddleApiClient,
2810
2815
  createRiddleProofRunCard: () => createRiddleProofRunCard,
2811
2816
  createRunResult: () => createRunResult,
2812
2817
  createRunState: () => createRunState,
2813
2818
  createRunStatusSnapshot: () => createRunStatusSnapshot,
2819
+ deployRiddleStaticPreview: () => deployRiddleStaticPreview,
2814
2820
  extractPlayabilityEvidence: () => extractPlayabilityEvidence,
2815
2821
  isDuplicateCheckpointResponse: () => isDuplicateCheckpointResponse,
2816
2822
  isRiddleProofPlayabilityMode: () => isRiddleProofPlayabilityMode,
2817
2823
  isSuccessfulStatus: () => isSuccessfulStatus,
2824
+ isTerminalRiddleJobStatus: () => isTerminalRiddleJobStatus,
2818
2825
  isTerminalStatus: () => isTerminalStatus,
2819
2826
  nonEmptyString: () => nonEmptyString,
2820
2827
  normalizeCheckpointResponse: () => normalizeCheckpointResponse,
@@ -2822,15 +2829,20 @@ __export(index_exports, {
2822
2829
  normalizePrLifecycleState: () => normalizePrLifecycleState,
2823
2830
  normalizeRunParams: () => normalizeRunParams,
2824
2831
  normalizeTerminalMetadata: () => normalizeTerminalMetadata,
2832
+ parseRiddleViewport: () => parseRiddleViewport,
2825
2833
  parseVisualProofSession: () => parseVisualProofSession,
2834
+ pollRiddleJob: () => pollRiddleJob,
2826
2835
  proofContractFromAuthorCheckpointResponse: () => proofContractFromAuthorCheckpointResponse,
2827
2836
  readRiddleProofRunStatus: () => readRiddleProofRunStatus,
2828
2837
  recordValue: () => recordValue,
2829
2838
  redactForProofDiagnostics: () => redactForProofDiagnostics,
2839
+ resolveRiddleApiKey: () => resolveRiddleApiKey,
2840
+ riddleRequestJson: () => riddleRequestJson,
2830
2841
  runCodexExecAgentDoctor: () => runCodexExecAgentDoctor,
2831
2842
  runLocalAgentDoctor: () => runCodexExecAgentDoctor,
2832
2843
  runRiddleProof: () => runRiddleProof,
2833
2844
  runRiddleProofEngineHarness: () => runRiddleProofEngineHarness,
2845
+ runRiddleScript: () => runRiddleScript,
2834
2846
  setRunStatus: () => setRunStatus,
2835
2847
  statePathsForRunState: () => statePathsForRunState,
2836
2848
  summarizeCaptureArtifacts: () => summarizeCaptureArtifacts,
@@ -3495,8 +3507,8 @@ function buildProofAssessmentCheckpointPacket(input) {
3495
3507
  const artifactContract = recordValue(proofAssessmentRequest.artifact_contract) || recordValue(bundle?.artifact_contract);
3496
3508
  const requiredSignals = recordValue(recordValue(artifactContract)?.required);
3497
3509
  const visualDelta = visualDeltaFromState(fullState);
3498
- const verificationMode = nonEmptyString(input.request.verification_mode) || nonEmptyString(fullState.verification_mode) || nonEmptyString(bundle?.verification_mode) || "proof";
3499
- const visualDeltaRequired = requiredSignals?.visual_delta === true || verificationModeRequiresVisualDelta(verificationMode);
3510
+ const verificationMode = nonEmptyString(bundle?.verification_mode) || nonEmptyString(fullState.verification_mode) || nonEmptyString(input.request.verification_mode) || "proof";
3511
+ const visualDeltaRequired = requiredSignals?.visual_delta !== false && (requiredSignals?.visual_delta === true || verificationModeRequiresVisualDelta(verificationMode));
3500
3512
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
3501
3513
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
3502
3514
  const recoveryHint = evidenceIssueCode2 ? "Required visual_delta evidence is incomplete. Keep this same run in verify/evidence recovery with decision=revise_capture and continue_with_stage=verify unless the evidence proves an implementation or recon problem." : "Assess whether the current artifacts prove the requested change, then choose the next stage.";
@@ -4073,6 +4085,7 @@ function normalizeRunParams(input) {
4073
4085
  leave_draft: input.leave_draft,
4074
4086
  engine_state_path: input.engine_state_path,
4075
4087
  harness_state_path: input.harness_state_path,
4088
+ riddle_engine_module_url: input.riddle_engine_module_url,
4076
4089
  max_iterations: input.max_iterations,
4077
4090
  auto_approve: input.auto_approve,
4078
4091
  dry_run: input.dry_run,
@@ -7597,11 +7610,163 @@ function parseJson(value) {
7597
7610
  return null;
7598
7611
  }
7599
7612
  }
7613
+
7614
+ // src/riddle-client.ts
7615
+ var import_node_child_process4 = require("child_process");
7616
+ var import_node_fs5 = require("fs");
7617
+ var import_node_os2 = require("os");
7618
+ var import_node_path5 = __toESM(require("path"), 1);
7619
+ var DEFAULT_RIDDLE_API_BASE_URL = "https://api.riddledc.com";
7620
+ var DEFAULT_RIDDLE_API_KEY_FILE = "/tmp/riddle-api-key";
7621
+ var RiddleApiError = class extends Error {
7622
+ constructor(pathname, status, body) {
7623
+ super(`Riddle API ${pathname} failed HTTP ${status}: ${body}`);
7624
+ this.name = "RiddleApiError";
7625
+ this.status = status;
7626
+ this.body = body;
7627
+ this.path = pathname;
7628
+ }
7629
+ };
7630
+ function normalizeBaseUrl(value) {
7631
+ return (value || DEFAULT_RIDDLE_API_BASE_URL).replace(/\/$/, "");
7632
+ }
7633
+ function fetchFor(config = {}) {
7634
+ return config.fetchImpl || fetch;
7635
+ }
7636
+ function resolveRiddleApiKey(config = {}) {
7637
+ if (config.apiKey?.trim()) return config.apiKey.trim();
7638
+ if (process.env.RIDDLE_API_KEY?.trim()) return process.env.RIDDLE_API_KEY.trim();
7639
+ const keyFile = config.apiKeyFile || process.env.RIDDLE_API_KEY_FILE || DEFAULT_RIDDLE_API_KEY_FILE;
7640
+ if ((0, import_node_fs5.existsSync)(keyFile)) {
7641
+ const key = (0, import_node_fs5.readFileSync)(keyFile, "utf8").trim();
7642
+ if (key) return key;
7643
+ }
7644
+ throw new Error(`Riddle API key missing. Set RIDDLE_API_KEY or write ${DEFAULT_RIDDLE_API_KEY_FILE}.`);
7645
+ }
7646
+ async function riddleRequestJson(config, pathname, init = {}) {
7647
+ const response = await fetchFor(config)(`${normalizeBaseUrl(config.apiBaseUrl)}${pathname}`, {
7648
+ ...init,
7649
+ headers: {
7650
+ Authorization: `Bearer ${resolveRiddleApiKey(config)}`,
7651
+ "Content-Type": "application/json",
7652
+ ...init.headers || {}
7653
+ }
7654
+ });
7655
+ const text = await response.text();
7656
+ let json = null;
7657
+ try {
7658
+ json = JSON.parse(text);
7659
+ } catch {
7660
+ }
7661
+ if (!response.ok) throw new RiddleApiError(pathname, response.status, text);
7662
+ return json ?? text;
7663
+ }
7664
+ async function deployRiddleStaticPreview(config, directory, label) {
7665
+ if (!directory?.trim()) throw new Error("directory is required");
7666
+ if (!label?.trim()) throw new Error("label is required");
7667
+ const created = await riddleRequestJson(config, "/v1/preview", {
7668
+ method: "POST",
7669
+ body: JSON.stringify({ framework: "spa", label })
7670
+ });
7671
+ const id = String(created.id || "");
7672
+ const uploadUrl = String(created.upload_url || "");
7673
+ if (!id || !uploadUrl) throw new Error("Riddle preview create response was missing id or upload_url.");
7674
+ const scratch = (0, import_node_fs5.mkdtempSync)(import_node_path5.default.join((0, import_node_os2.tmpdir)(), "riddle-preview-upload-"));
7675
+ const tarball = import_node_path5.default.join(scratch, `${id}.tar.gz`);
7676
+ try {
7677
+ (0, import_node_child_process4.execFileSync)("tar", ["czf", tarball, "-C", directory, "."], { stdio: "pipe" });
7678
+ const upload = await fetchFor(config)(uploadUrl, {
7679
+ method: "PUT",
7680
+ headers: { "Content-Type": "application/gzip" },
7681
+ body: (0, import_node_fs5.readFileSync)(tarball)
7682
+ });
7683
+ if (!upload.ok) {
7684
+ throw new RiddleApiError(uploadUrl, upload.status, await upload.text());
7685
+ }
7686
+ } finally {
7687
+ (0, import_node_fs5.rmSync)(scratch, { recursive: true, force: true });
7688
+ }
7689
+ const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
7690
+ method: "POST"
7691
+ });
7692
+ return {
7693
+ ok: true,
7694
+ id: String(published.id || id),
7695
+ label,
7696
+ preview_url: String(published.preview_url || ""),
7697
+ file_count: typeof published.file_count === "number" ? published.file_count : void 0,
7698
+ total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : void 0,
7699
+ expires_at: typeof created.expires_at === "string" ? created.expires_at : void 0,
7700
+ raw: published
7701
+ };
7702
+ }
7703
+ function parseRiddleViewport(value) {
7704
+ if (!value) return void 0;
7705
+ const match = /^(\d+)x(\d+)$/.exec(value.trim());
7706
+ if (!match) throw new Error("viewport must look like 1280x720");
7707
+ return { width: Number(match[1]), height: Number(match[2]) };
7708
+ }
7709
+ async function runRiddleScript(config, input) {
7710
+ if (!input.url?.trim()) throw new Error("url is required");
7711
+ if (!input.script?.trim()) throw new Error("script is required");
7712
+ const payload = {
7713
+ url: input.url,
7714
+ script: input.script,
7715
+ sync: input.sync ?? false,
7716
+ timeout_sec: input.timeoutSec || 120
7717
+ };
7718
+ if (input.viewport) payload.viewport = input.viewport;
7719
+ if (input.include) payload.include = input.include;
7720
+ if (input.options) payload.options = input.options;
7721
+ return riddleRequestJson(config, "/v1/run", {
7722
+ method: "POST",
7723
+ body: JSON.stringify(payload)
7724
+ });
7725
+ }
7726
+ function isTerminalRiddleJobStatus(status) {
7727
+ return ["completed", "complete", "completed_error", "completed_timeout", "failed"].includes(String(status || ""));
7728
+ }
7729
+ async function pollRiddleJob(config, jobId, options = {}) {
7730
+ if (!jobId?.trim()) throw new Error("jobId is required");
7731
+ const attempts = options.attempts || (options.wait ? 60 : 1);
7732
+ const intervalMs = options.intervalMs || 2e3;
7733
+ let job = null;
7734
+ for (let index = 0; index < attempts; index += 1) {
7735
+ job = await riddleRequestJson(config, `/v1/jobs/${jobId}`);
7736
+ if (isTerminalRiddleJobStatus(job.status)) break;
7737
+ if (index + 1 < attempts) {
7738
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
7739
+ }
7740
+ }
7741
+ const status = job?.status ? String(job.status) : null;
7742
+ if (!isTerminalRiddleJobStatus(status)) {
7743
+ return { ok: true, job_id: jobId, status, terminal: false, job };
7744
+ }
7745
+ const artifacts = await riddleRequestJson(config, `/v1/jobs/${jobId}/artifacts`);
7746
+ return {
7747
+ ok: status === "completed" || status === "complete",
7748
+ job_id: jobId,
7749
+ status,
7750
+ terminal: true,
7751
+ job,
7752
+ artifacts
7753
+ };
7754
+ }
7755
+ function createRiddleApiClient(config = {}) {
7756
+ return {
7757
+ requestJson: (pathname, init) => riddleRequestJson(config, pathname, init),
7758
+ deployStaticPreview: (directory, label) => deployRiddleStaticPreview(config, directory, label),
7759
+ runScript: (input) => runRiddleScript(config, input),
7760
+ pollJob: (jobId, options) => pollRiddleJob(config, jobId, options)
7761
+ };
7762
+ }
7600
7763
  // Annotate the CommonJS export names for ESM import in node:
7601
7764
  0 && (module.exports = {
7602
7765
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
7603
7766
  DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
7604
7767
  DEFAULT_DIAGNOSTIC_STRING_LIMIT,
7768
+ DEFAULT_RIDDLE_API_BASE_URL,
7769
+ DEFAULT_RIDDLE_API_KEY_FILE,
7605
7770
  RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
7606
7771
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
7607
7772
  RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
@@ -7611,6 +7776,7 @@ function parseJson(value) {
7611
7776
  RIDDLE_PROOF_RUN_STATE_VERSION,
7612
7777
  RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION,
7613
7778
  RIDDLE_PROOF_VISUAL_SESSION_VERSION,
7779
+ RiddleApiError,
7614
7780
  appendCaptureDiagnostic,
7615
7781
  appendRunEvent,
7616
7782
  appendStageHeartbeat,
@@ -7634,14 +7800,17 @@ function parseJson(value) {
7634
7800
  createDisabledRiddleProofAgentAdapter,
7635
7801
  createLocalAgentAdapter,
7636
7802
  createLocalAgentJsonRunner,
7803
+ createRiddleApiClient,
7637
7804
  createRiddleProofRunCard,
7638
7805
  createRunResult,
7639
7806
  createRunState,
7640
7807
  createRunStatusSnapshot,
7808
+ deployRiddleStaticPreview,
7641
7809
  extractPlayabilityEvidence,
7642
7810
  isDuplicateCheckpointResponse,
7643
7811
  isRiddleProofPlayabilityMode,
7644
7812
  isSuccessfulStatus,
7813
+ isTerminalRiddleJobStatus,
7645
7814
  isTerminalStatus,
7646
7815
  nonEmptyString,
7647
7816
  normalizeCheckpointResponse,
@@ -7649,15 +7818,20 @@ function parseJson(value) {
7649
7818
  normalizePrLifecycleState,
7650
7819
  normalizeRunParams,
7651
7820
  normalizeTerminalMetadata,
7821
+ parseRiddleViewport,
7652
7822
  parseVisualProofSession,
7823
+ pollRiddleJob,
7653
7824
  proofContractFromAuthorCheckpointResponse,
7654
7825
  readRiddleProofRunStatus,
7655
7826
  recordValue,
7656
7827
  redactForProofDiagnostics,
7828
+ resolveRiddleApiKey,
7829
+ riddleRequestJson,
7657
7830
  runCodexExecAgentDoctor,
7658
7831
  runLocalAgentDoctor,
7659
7832
  runRiddleProof,
7660
7833
  runRiddleProofEngineHarness,
7834
+ runRiddleScript,
7661
7835
  setRunStatus,
7662
7836
  statePathsForRunState,
7663
7837
  summarizeCaptureArtifacts,
package/dist/index.d.cts CHANGED
@@ -9,3 +9,4 @@ export { CodexExecAgentConfig, CodexJsonRequest, CodexJsonResult, CodexJsonRunne
9
9
  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';
10
10
  export { BuildVisualProofSessionInput, RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION, RIDDLE_PROOF_VISUAL_SESSION_VERSION, VisualProofSessionMismatch, buildVisualProofSession, compareVisualProofSessionFingerprint, parseVisualProofSession, visualSessionFingerprint, visualSessionFingerprintBasis } from './proof-session.cjs';
11
11
  export { AssessPlayabilityOptions, RIDDLE_PROOF_PLAYABILITY_ASSESSMENT_VERSION, RIDDLE_PROOF_PLAYABILITY_VERSION, RiddleProofPlayabilityAssessment, RiddleProofPlayabilityEvidence, assessPlayabilityEvidence, extractPlayabilityEvidence, isRiddleProofPlayabilityMode } from './playability.cjs';
12
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleClientConfig, RiddleFetch, RiddlePollJobResult, RiddlePreviewDeployResult, RiddleRunScriptInput, createRiddleApiClient, deployRiddleStaticPreview, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, riddleRequestJson, runRiddleScript } from './riddle-client.cjs';
package/dist/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export { CodexExecAgentConfig, CodexJsonRequest, CodexJsonResult, CodexJsonRunne
9
9
  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';
10
10
  export { BuildVisualProofSessionInput, RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION, RIDDLE_PROOF_VISUAL_SESSION_VERSION, VisualProofSessionMismatch, buildVisualProofSession, compareVisualProofSessionFingerprint, parseVisualProofSession, visualSessionFingerprint, visualSessionFingerprintBasis } from './proof-session.js';
11
11
  export { AssessPlayabilityOptions, RIDDLE_PROOF_PLAYABILITY_ASSESSMENT_VERSION, RIDDLE_PROOF_PLAYABILITY_VERSION, RiddleProofPlayabilityAssessment, RiddleProofPlayabilityEvidence, assessPlayabilityEvidence, extractPlayabilityEvidence, isRiddleProofPlayabilityMode } from './playability.js';
12
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleClientConfig, RiddleFetch, RiddlePollJobResult, RiddlePreviewDeployResult, RiddleRunScriptInput, createRiddleApiClient, deployRiddleStaticPreview, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, riddleRequestJson, runRiddleScript } from './riddle-client.js';
package/dist/index.js CHANGED
@@ -17,7 +17,20 @@ import {
17
17
  } from "./chunk-ODORKNSO.js";
18
18
  import {
19
19
  runRiddleProof
20
- } from "./chunk-QBOKV3ES.js";
20
+ } from "./chunk-RXFKKYWA.js";
21
+ import {
22
+ DEFAULT_RIDDLE_API_BASE_URL,
23
+ DEFAULT_RIDDLE_API_KEY_FILE,
24
+ RiddleApiError,
25
+ createRiddleApiClient,
26
+ deployRiddleStaticPreview,
27
+ isTerminalRiddleJobStatus,
28
+ parseRiddleViewport,
29
+ pollRiddleJob,
30
+ resolveRiddleApiKey,
31
+ riddleRequestJson,
32
+ runRiddleScript
33
+ } from "./chunk-UR6ADV4Y.js";
21
34
  import {
22
35
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
23
36
  DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
@@ -32,8 +45,8 @@ import {
32
45
  createDisabledRiddleProofAgentAdapter,
33
46
  readRiddleProofRunStatus,
34
47
  runRiddleProofEngineHarness
35
- } from "./chunk-KYGWIA7A.js";
36
- import "./chunk-4ASMX4R6.js";
48
+ } from "./chunk-A2AWRZ5B.js";
49
+ import "./chunk-RFJ5BQF6.js";
37
50
  import "./chunk-JFQXAJH2.js";
38
51
  import {
39
52
  createCodexExecAgentAdapter,
@@ -51,11 +64,11 @@ import {
51
64
  normalizePrLifecycleState,
52
65
  normalizeRunParams,
53
66
  setRunStatus
54
- } from "./chunk-PVUZZ2P6.js";
67
+ } from "./chunk-MO24D3PY.js";
55
68
  import {
56
69
  RIDDLE_PROOF_RUN_CARD_VERSION,
57
70
  createRiddleProofRunCard
58
- } from "./chunk-53UPEUVU.js";
71
+ } from "./chunk-3UHWI3FO.js";
59
72
  import {
60
73
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
61
74
  RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
@@ -71,7 +84,7 @@ import {
71
84
  normalizeCheckpointResponse,
72
85
  proofContractFromAuthorCheckpointResponse,
73
86
  statePathsForRunState
74
- } from "./chunk-T5RHGGQ2.js";
87
+ } from "./chunk-33XO42CY.js";
75
88
  import {
76
89
  applyTerminalMetadata,
77
90
  compactRecord,
@@ -86,6 +99,8 @@ export {
86
99
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
87
100
  DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
88
101
  DEFAULT_DIAGNOSTIC_STRING_LIMIT,
102
+ DEFAULT_RIDDLE_API_BASE_URL,
103
+ DEFAULT_RIDDLE_API_KEY_FILE,
89
104
  RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
90
105
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
91
106
  RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
@@ -95,6 +110,7 @@ export {
95
110
  RIDDLE_PROOF_RUN_STATE_VERSION,
96
111
  RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION,
97
112
  RIDDLE_PROOF_VISUAL_SESSION_VERSION,
113
+ RiddleApiError,
98
114
  appendCaptureDiagnostic,
99
115
  appendRunEvent,
100
116
  appendStageHeartbeat,
@@ -118,14 +134,17 @@ export {
118
134
  createDisabledRiddleProofAgentAdapter,
119
135
  createCodexExecAgentAdapter as createLocalAgentAdapter,
120
136
  createCodexExecJsonRunner as createLocalAgentJsonRunner,
137
+ createRiddleApiClient,
121
138
  createRiddleProofRunCard,
122
139
  createRunResult,
123
140
  createRunState,
124
141
  createRunStatusSnapshot,
142
+ deployRiddleStaticPreview,
125
143
  extractPlayabilityEvidence,
126
144
  isDuplicateCheckpointResponse,
127
145
  isRiddleProofPlayabilityMode,
128
146
  isSuccessfulStatus,
147
+ isTerminalRiddleJobStatus,
129
148
  isTerminalStatus,
130
149
  nonEmptyString,
131
150
  normalizeCheckpointResponse,
@@ -133,15 +152,20 @@ export {
133
152
  normalizePrLifecycleState,
134
153
  normalizeRunParams,
135
154
  normalizeTerminalMetadata,
155
+ parseRiddleViewport,
136
156
  parseVisualProofSession,
157
+ pollRiddleJob,
137
158
  proofContractFromAuthorCheckpointResponse,
138
159
  readRiddleProofRunStatus,
139
160
  recordValue,
140
161
  redactForProofDiagnostics,
162
+ resolveRiddleApiKey,
163
+ riddleRequestJson,
141
164
  runCodexExecAgentDoctor,
142
165
  runCodexExecAgentDoctor as runLocalAgentDoctor,
143
166
  runRiddleProof,
144
167
  runRiddleProofEngineHarness,
168
+ runRiddleScript,
145
169
  setRunStatus,
146
170
  statePathsForRunState,
147
171
  summarizeCaptureArtifacts,
package/dist/openclaw.cjs CHANGED
@@ -93,6 +93,7 @@ function normalizeRunParams(input) {
93
93
  leave_draft: input.leave_draft,
94
94
  engine_state_path: input.engine_state_path,
95
95
  harness_state_path: input.harness_state_path,
96
+ riddle_engine_module_url: input.riddle_engine_module_url,
96
97
  max_iterations: input.max_iterations,
97
98
  auto_approve: input.auto_approve,
98
99
  dry_run: input.dry_run,
package/dist/openclaw.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  normalizeIntegrationContext,
3
3
  normalizeRunParams
4
- } from "./chunk-PVUZZ2P6.js";
5
- import "./chunk-53UPEUVU.js";
6
- import "./chunk-T5RHGGQ2.js";
4
+ } from "./chunk-MO24D3PY.js";
5
+ import "./chunk-3UHWI3FO.js";
6
+ import "./chunk-33XO42CY.js";
7
7
  import {
8
8
  compactRecord
9
9
  } from "./chunk-DUFDZJOF.js";
@@ -414,6 +414,7 @@ function visualDeltaRequiredForState(state = {}) {
414
414
  const bundle = objectValue(state?.evidence_bundle);
415
415
  const contract = objectValue(bundle.artifact_contract);
416
416
  const required = objectValue(contract.required);
417
+ if (required.visual_delta === false) return false;
417
418
  return required.visual_delta === true || VISUAL_FIRST_MODES.has(normalizedVerificationMode(state));
418
419
  }
419
420
  function visualDeltaForState(state = {}) {
@@ -24,7 +24,7 @@ import {
24
24
  visualDeltaShipGateReason,
25
25
  workflowFile,
26
26
  writeState
27
- } from "./chunk-4ASMX4R6.js";
27
+ } from "./chunk-RFJ5BQF6.js";
28
28
  export {
29
29
  BUNDLED_RIDDLE_PROOF_DIR,
30
30
  CHECKPOINT_CONTRACT_VERSION,
@@ -396,6 +396,7 @@ function visualDeltaRequiredForState(state = {}) {
396
396
  const bundle = objectValue(state?.evidence_bundle);
397
397
  const contract = objectValue(bundle.artifact_contract);
398
398
  const required = objectValue(contract.required);
399
+ if (required.visual_delta === false) return false;
399
400
  return required.visual_delta === true || VISUAL_FIRST_MODES.has(normalizedVerificationMode(state));
400
401
  }
401
402
  function visualDeltaForState(state = {}) {
@@ -14,7 +14,7 @@ import {
14
14
  validateShipGate,
15
15
  workflowFile,
16
16
  writeState
17
- } from "./chunk-4ASMX4R6.js";
17
+ } from "./chunk-RFJ5BQF6.js";
18
18
 
19
19
  // src/proof-run-engine.ts
20
20
  import { execFileSync } from "child_process";