@riddledc/riddle-proof 0.5.53 → 0.5.55

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 (42) hide show
  1. package/dist/basic-gameplay.cjs +255 -0
  2. package/dist/basic-gameplay.d.cts +117 -0
  3. package/dist/basic-gameplay.d.ts +117 -0
  4. package/dist/basic-gameplay.js +14 -0
  5. package/dist/checkpoint.cjs +2 -2
  6. package/dist/checkpoint.js +1 -1
  7. package/dist/{chunk-KYGWIA7A.js → chunk-2FBF2UDZ.js} +8 -8
  8. package/dist/{chunk-T5RHGGQ2.js → chunk-33XO42CY.js} +2 -2
  9. package/dist/{chunk-53UPEUVU.js → chunk-3UHWI3FO.js} +1 -1
  10. package/dist/{chunk-PVUZZ2P6.js → chunk-MO24D3PY.js} +2 -1
  11. package/dist/{chunk-4ASMX4R6.js → chunk-RFJ5BQF6.js} +1 -0
  12. package/dist/chunk-RNGJX62B.js +227 -0
  13. package/dist/{chunk-QBOKV3ES.js → chunk-RXFKKYWA.js} +1 -1
  14. package/dist/chunk-UR6ADV4Y.js +163 -0
  15. package/dist/cli.cjs +217 -12
  16. package/dist/cli.js +67 -10
  17. package/dist/engine-harness.cjs +4 -2
  18. package/dist/engine-harness.js +5 -5
  19. package/dist/index.cjs +409 -5
  20. package/dist/index.d.cts +2 -0
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +49 -13
  23. package/dist/openclaw.cjs +1 -0
  24. package/dist/openclaw.js +3 -3
  25. package/dist/proof-run-core.cjs +1 -0
  26. package/dist/proof-run-core.js +1 -1
  27. package/dist/proof-run-engine.cjs +1 -0
  28. package/dist/proof-run-engine.d.cts +3 -3
  29. package/dist/proof-run-engine.d.ts +3 -3
  30. package/dist/proof-run-engine.js +1 -1
  31. package/dist/riddle-client.cjs +207 -0
  32. package/dist/riddle-client.d.cts +71 -0
  33. package/dist/riddle-client.d.ts +71 -0
  34. package/dist/riddle-client.js +26 -0
  35. package/dist/run-card.js +2 -2
  36. package/dist/runner.cjs +1 -0
  37. package/dist/runner.js +4 -4
  38. package/dist/state.cjs +1 -0
  39. package/dist/state.js +3 -3
  40. package/dist/types.d.cts +1 -0
  41. package/dist/types.d.ts +1 -0
  42. package/package.json +12 -2
package/dist/cli.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;
@@ -2770,7 +2771,7 @@ var init_proof_run_engine = __esm({
2770
2771
  });
2771
2772
 
2772
2773
  // src/cli.ts
2773
- var import_node_fs5 = require("fs");
2774
+ var import_node_fs6 = require("fs");
2774
2775
 
2775
2776
  // src/engine-harness.ts
2776
2777
  var import_node_child_process2 = require("child_process");
@@ -3434,8 +3435,8 @@ function buildProofAssessmentCheckpointPacket(input) {
3434
3435
  const artifactContract = recordValue(proofAssessmentRequest.artifact_contract) || recordValue(bundle?.artifact_contract);
3435
3436
  const requiredSignals = recordValue(recordValue(artifactContract)?.required);
3436
3437
  const visualDelta = visualDeltaFromState(fullState);
3437
- const verificationMode = nonEmptyString(input.request.verification_mode) || nonEmptyString(fullState.verification_mode) || nonEmptyString(bundle?.verification_mode) || "proof";
3438
- const visualDeltaRequired = requiredSignals?.visual_delta === true || verificationModeRequiresVisualDelta(verificationMode);
3438
+ const verificationMode = nonEmptyString(bundle?.verification_mode) || nonEmptyString(fullState.verification_mode) || nonEmptyString(input.request.verification_mode) || "proof";
3439
+ const visualDeltaRequired = requiredSignals?.visual_delta !== false && (requiredSignals?.visual_delta === true || verificationModeRequiresVisualDelta(verificationMode));
3439
3440
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
3440
3441
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
3441
3442
  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.";
@@ -3982,6 +3983,7 @@ function normalizeRunParams(input) {
3982
3983
  leave_draft: input.leave_draft,
3983
3984
  engine_state_path: input.engine_state_path,
3984
3985
  harness_state_path: input.harness_state_path,
3986
+ riddle_engine_module_url: input.riddle_engine_module_url,
3985
3987
  max_iterations: input.max_iterations,
3986
3988
  auto_approve: input.auto_approve,
3987
3989
  dry_run: input.dry_run,
@@ -6396,6 +6398,156 @@ async function runCodexExecAgentDoctor(config = {}, runner = createCodexExecJson
6396
6398
  };
6397
6399
  }
6398
6400
 
6401
+ // src/riddle-client.ts
6402
+ var import_node_child_process4 = require("child_process");
6403
+ var import_node_fs5 = require("fs");
6404
+ var import_node_os2 = require("os");
6405
+ var import_node_path5 = __toESM(require("path"), 1);
6406
+ var DEFAULT_RIDDLE_API_BASE_URL = "https://api.riddledc.com";
6407
+ var DEFAULT_RIDDLE_API_KEY_FILE = "/tmp/riddle-api-key";
6408
+ var RiddleApiError = class extends Error {
6409
+ constructor(pathname, status, body) {
6410
+ super(`Riddle API ${pathname} failed HTTP ${status}: ${body}`);
6411
+ this.name = "RiddleApiError";
6412
+ this.status = status;
6413
+ this.body = body;
6414
+ this.path = pathname;
6415
+ }
6416
+ };
6417
+ function normalizeBaseUrl(value) {
6418
+ return (value || DEFAULT_RIDDLE_API_BASE_URL).replace(/\/$/, "");
6419
+ }
6420
+ function fetchFor(config = {}) {
6421
+ return config.fetchImpl || fetch;
6422
+ }
6423
+ function resolveRiddleApiKey(config = {}) {
6424
+ if (config.apiKey?.trim()) return config.apiKey.trim();
6425
+ if (process.env.RIDDLE_API_KEY?.trim()) return process.env.RIDDLE_API_KEY.trim();
6426
+ const keyFile = config.apiKeyFile || process.env.RIDDLE_API_KEY_FILE || DEFAULT_RIDDLE_API_KEY_FILE;
6427
+ if ((0, import_node_fs5.existsSync)(keyFile)) {
6428
+ const key = (0, import_node_fs5.readFileSync)(keyFile, "utf8").trim();
6429
+ if (key) return key;
6430
+ }
6431
+ throw new Error(`Riddle API key missing. Set RIDDLE_API_KEY or write ${DEFAULT_RIDDLE_API_KEY_FILE}.`);
6432
+ }
6433
+ async function riddleRequestJson(config, pathname, init = {}) {
6434
+ const response = await fetchFor(config)(`${normalizeBaseUrl(config.apiBaseUrl)}${pathname}`, {
6435
+ ...init,
6436
+ headers: {
6437
+ Authorization: `Bearer ${resolveRiddleApiKey(config)}`,
6438
+ "Content-Type": "application/json",
6439
+ ...init.headers || {}
6440
+ }
6441
+ });
6442
+ const text = await response.text();
6443
+ let json = null;
6444
+ try {
6445
+ json = JSON.parse(text);
6446
+ } catch {
6447
+ }
6448
+ if (!response.ok) throw new RiddleApiError(pathname, response.status, text);
6449
+ return json ?? text;
6450
+ }
6451
+ async function deployRiddleStaticPreview(config, directory, label) {
6452
+ if (!directory?.trim()) throw new Error("directory is required");
6453
+ if (!label?.trim()) throw new Error("label is required");
6454
+ const created = await riddleRequestJson(config, "/v1/preview", {
6455
+ method: "POST",
6456
+ body: JSON.stringify({ framework: "spa", label })
6457
+ });
6458
+ const id = String(created.id || "");
6459
+ const uploadUrl = String(created.upload_url || "");
6460
+ if (!id || !uploadUrl) throw new Error("Riddle preview create response was missing id or upload_url.");
6461
+ const scratch = (0, import_node_fs5.mkdtempSync)(import_node_path5.default.join((0, import_node_os2.tmpdir)(), "riddle-preview-upload-"));
6462
+ const tarball = import_node_path5.default.join(scratch, `${id}.tar.gz`);
6463
+ try {
6464
+ (0, import_node_child_process4.execFileSync)("tar", ["czf", tarball, "-C", directory, "."], { stdio: "pipe" });
6465
+ const upload = await fetchFor(config)(uploadUrl, {
6466
+ method: "PUT",
6467
+ headers: { "Content-Type": "application/gzip" },
6468
+ body: (0, import_node_fs5.readFileSync)(tarball)
6469
+ });
6470
+ if (!upload.ok) {
6471
+ throw new RiddleApiError(uploadUrl, upload.status, await upload.text());
6472
+ }
6473
+ } finally {
6474
+ (0, import_node_fs5.rmSync)(scratch, { recursive: true, force: true });
6475
+ }
6476
+ const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
6477
+ method: "POST"
6478
+ });
6479
+ return {
6480
+ ok: true,
6481
+ id: String(published.id || id),
6482
+ label,
6483
+ preview_url: String(published.preview_url || ""),
6484
+ file_count: typeof published.file_count === "number" ? published.file_count : void 0,
6485
+ total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : void 0,
6486
+ expires_at: typeof created.expires_at === "string" ? created.expires_at : void 0,
6487
+ raw: published
6488
+ };
6489
+ }
6490
+ function parseRiddleViewport(value) {
6491
+ if (!value) return void 0;
6492
+ const match = /^(\d+)x(\d+)$/.exec(value.trim());
6493
+ if (!match) throw new Error("viewport must look like 1280x720");
6494
+ return { width: Number(match[1]), height: Number(match[2]) };
6495
+ }
6496
+ async function runRiddleScript(config, input) {
6497
+ if (!input.url?.trim()) throw new Error("url is required");
6498
+ if (!input.script?.trim()) throw new Error("script is required");
6499
+ const payload = {
6500
+ url: input.url,
6501
+ script: input.script,
6502
+ sync: input.sync ?? false,
6503
+ timeout_sec: input.timeoutSec || 120
6504
+ };
6505
+ if (input.viewport) payload.viewport = input.viewport;
6506
+ if (input.include) payload.include = input.include;
6507
+ if (input.options) payload.options = input.options;
6508
+ return riddleRequestJson(config, "/v1/run", {
6509
+ method: "POST",
6510
+ body: JSON.stringify(payload)
6511
+ });
6512
+ }
6513
+ function isTerminalRiddleJobStatus(status) {
6514
+ return ["completed", "complete", "completed_error", "completed_timeout", "failed"].includes(String(status || ""));
6515
+ }
6516
+ async function pollRiddleJob(config, jobId, options = {}) {
6517
+ if (!jobId?.trim()) throw new Error("jobId is required");
6518
+ const attempts = options.attempts || (options.wait ? 60 : 1);
6519
+ const intervalMs = options.intervalMs || 2e3;
6520
+ let job = null;
6521
+ for (let index = 0; index < attempts; index += 1) {
6522
+ job = await riddleRequestJson(config, `/v1/jobs/${jobId}`);
6523
+ if (isTerminalRiddleJobStatus(job.status)) break;
6524
+ if (index + 1 < attempts) {
6525
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
6526
+ }
6527
+ }
6528
+ const status = job?.status ? String(job.status) : null;
6529
+ if (!isTerminalRiddleJobStatus(status)) {
6530
+ return { ok: true, job_id: jobId, status, terminal: false, job };
6531
+ }
6532
+ const artifacts = await riddleRequestJson(config, `/v1/jobs/${jobId}/artifacts`);
6533
+ return {
6534
+ ok: status === "completed" || status === "complete",
6535
+ job_id: jobId,
6536
+ status,
6537
+ terminal: true,
6538
+ job,
6539
+ artifacts
6540
+ };
6541
+ }
6542
+ function createRiddleApiClient(config = {}) {
6543
+ return {
6544
+ requestJson: (pathname, init) => riddleRequestJson(config, pathname, init),
6545
+ deployStaticPreview: (directory, label) => deployRiddleStaticPreview(config, directory, label),
6546
+ runScript: (input) => runRiddleScript(config, input),
6547
+ pollJob: (jobId, options) => pollRiddleJob(config, jobId, options)
6548
+ };
6549
+ }
6550
+
6399
6551
  // src/cli.ts
6400
6552
  function usage() {
6401
6553
  return [
@@ -6405,6 +6557,9 @@ function usage() {
6405
6557
  " riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
6406
6558
  " riddle-proof-loop respond --state-path <path> --decision <decision> --summary <text> [--payload-json <file|json|->]",
6407
6559
  " riddle-proof-loop status --state-path <path>",
6560
+ " riddle-proof-loop riddle-preview-deploy <build-dir> <label>",
6561
+ " riddle-proof-loop riddle-run-script --url <url> --script-file <file> [--viewport 1280x720]",
6562
+ " riddle-proof-loop riddle-poll <job-id> [--wait]",
6408
6563
  " riddle-proof-loop doctor local [--codex-command <path>]",
6409
6564
  "",
6410
6565
  "The default CLI run mode is checkpoint-mode=yield unless --agent local is used.",
@@ -6436,11 +6591,11 @@ function optionString(options, key) {
6436
6591
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
6437
6592
  }
6438
6593
  function readStdin() {
6439
- return (0, import_node_fs5.readFileSync)(0, "utf-8");
6594
+ return (0, import_node_fs6.readFileSync)(0, "utf-8");
6440
6595
  }
6441
6596
  function readJsonValue(value, label) {
6442
6597
  if (!value) throw new Error(`${label} is required.`);
6443
- const raw = value === "-" ? readStdin() : (0, import_node_fs5.existsSync)(value) ? (0, import_node_fs5.readFileSync)(value, "utf-8") : value;
6598
+ const raw = value === "-" ? readStdin() : (0, import_node_fs6.existsSync)(value) ? (0, import_node_fs6.readFileSync)(value, "utf-8") : value;
6444
6599
  const parsed = JSON.parse(raw);
6445
6600
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
6446
6601
  throw new Error(`${label} must be a JSON object.`);
@@ -6453,7 +6608,7 @@ function readOptionalJsonRecord(value, label) {
6453
6608
  }
6454
6609
  function readOptionalJsonStringArray(value, label) {
6455
6610
  if (!value) return void 0;
6456
- const parsed = value === "-" ? JSON.parse(readStdin()) : (0, import_node_fs5.existsSync)(value) ? JSON.parse((0, import_node_fs5.readFileSync)(value, "utf-8")) : JSON.parse(value);
6611
+ const parsed = value === "-" ? JSON.parse(readStdin()) : (0, import_node_fs6.existsSync)(value) ? JSON.parse((0, import_node_fs6.readFileSync)(value, "utf-8")) : JSON.parse(value);
6457
6612
  if (!Array.isArray(parsed) || parsed.some((item) => typeof item !== "string")) {
6458
6613
  throw new Error(`${label} must be a JSON array of strings.`);
6459
6614
  }
@@ -6585,14 +6740,28 @@ function agentFor(options) {
6585
6740
  if (agentMode === "disabled") return createDisabledRiddleProofAgentAdapter();
6586
6741
  throw new Error(`Unsupported --agent ${agentMode}. Use disabled or local.`);
6587
6742
  }
6743
+ function riddleClientConfig(options) {
6744
+ return {
6745
+ apiKey: optionString(options, "apiKey"),
6746
+ apiKeyFile: optionString(options, "apiKeyFile"),
6747
+ apiBaseUrl: optionString(options, "apiBaseUrl")
6748
+ };
6749
+ }
6588
6750
  function requestForRun(options) {
6589
6751
  const statePath = optionString(options, "statePath");
6752
+ const withEngineModuleUrl = (request) => {
6753
+ const moduleUrl = optionString(options, "riddleEngineModuleUrl");
6754
+ return moduleUrl && !request.riddle_engine_module_url ? { ...request, riddle_engine_module_url: moduleUrl } : request;
6755
+ };
6590
6756
  if (optionString(options, "requestJson")) {
6591
- return readJsonValue(optionString(options, "requestJson"), "--request-json");
6757
+ return withEngineModuleUrl(readJsonValue(optionString(options, "requestJson"), "--request-json"));
6592
6758
  }
6593
- if (statePath) return readRunState(statePath).request;
6759
+ if (statePath) return withEngineModuleUrl(readRunState(statePath).request);
6594
6760
  throw new Error("--request-json is required unless --state-path points to an existing run state.");
6595
6761
  }
6762
+ function riddleEngineModuleUrlFor(options, request) {
6763
+ 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);
6764
+ }
6596
6765
  function checkpointModeFor(options) {
6597
6766
  const explicit = optionString(options, "checkpointMode");
6598
6767
  if (explicit) return explicit;
@@ -6624,6 +6793,42 @@ async function main() {
6624
6793
  `);
6625
6794
  return;
6626
6795
  }
6796
+ if (command === "riddle-preview-deploy") {
6797
+ const buildDir = positional[1];
6798
+ const label = positional[2];
6799
+ const result = await createRiddleApiClient(riddleClientConfig(options)).deployStaticPreview(buildDir, label);
6800
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
6801
+ `);
6802
+ return;
6803
+ }
6804
+ if (command === "riddle-run-script") {
6805
+ const url = optionString(options, "url");
6806
+ const scriptFile = optionString(options, "scriptFile");
6807
+ if (!url || !scriptFile) throw new Error("riddle-run-script requires --url and --script-file.");
6808
+ const result = await createRiddleApiClient(riddleClientConfig(options)).runScript({
6809
+ url,
6810
+ script: (0, import_node_fs6.readFileSync)(scriptFile, "utf-8"),
6811
+ viewport: parseRiddleViewport(optionString(options, "viewport")),
6812
+ timeoutSec: optionString(options, "timeout") ? Number(optionString(options, "timeout")) : void 0,
6813
+ sync: options.sync === true ? true : void 0
6814
+ });
6815
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
6816
+ `);
6817
+ return;
6818
+ }
6819
+ if (command === "riddle-poll") {
6820
+ const jobId = positional[1];
6821
+ if (!jobId) throw new Error("riddle-poll requires <job-id>.");
6822
+ const result = await createRiddleApiClient(riddleClientConfig(options)).pollJob(jobId, {
6823
+ wait: options.wait === true,
6824
+ attempts: optionString(options, "attempts") ? Number(optionString(options, "attempts")) : void 0,
6825
+ intervalMs: optionString(options, "intervalMs") ? Number(optionString(options, "intervalMs")) : void 0
6826
+ });
6827
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
6828
+ `);
6829
+ process.exitCode = result.ok ? 0 : 1;
6830
+ return;
6831
+ }
6627
6832
  if (command === "checkpoint") {
6628
6833
  const statePath = optionString(options, "statePath");
6629
6834
  if (!statePath) throw new Error("--state-path is required.");
@@ -6674,7 +6879,7 @@ async function main() {
6674
6879
  agent: agentFor(options),
6675
6880
  config: {
6676
6881
  stateDir: optionString(options, "stateDir"),
6677
- riddleEngineModuleUrl: optionString(options, "riddleEngineModuleUrl"),
6882
+ riddleEngineModuleUrl: riddleEngineModuleUrlFor(options, request),
6678
6883
  riddleProofDir: optionString(options, "riddleProofDir"),
6679
6884
  defaultReviewer: optionString(options, "defaultReviewer"),
6680
6885
  defaultShipMode: optionString(options, "defaultShipMode")
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-2FBF2UDZ.js";
11
+ import "./chunk-MO24D3PY.js";
12
+ import "./chunk-RFJ5BQF6.js";
13
+ import "./chunk-3UHWI3FO.js";
14
+ import {
15
+ createCheckpointResponseTemplate
16
+ } from "./chunk-33XO42CY.js";
8
17
  import "./chunk-JFQXAJH2.js";
9
18
  import {
10
19
  createCodexExecAgentAdapter,
11
20
  runCodexExecAgentDoctor
12
21
  } from "./chunk-3266V3MO.js";
13
- import "./chunk-PVUZZ2P6.js";
14
- import "./chunk-53UPEUVU.js";
15
- import {
16
- createCheckpointResponseTemplate
17
- } from "./chunk-T5RHGGQ2.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-2FBF2UDZ.js";
6
+ import "./chunk-MO24D3PY.js";
7
+ import "./chunk-RFJ5BQF6.js";
8
+ import "./chunk-3UHWI3FO.js";
9
+ import "./chunk-33XO42CY.js";
10
10
  import "./chunk-DUFDZJOF.js";
11
11
  export {
12
12
  createDisabledRiddleProofAgentAdapter,