@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/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import {
2
+ runRiddleProof
3
+ } from "./chunk-RXFKKYWA.js";
1
4
  import "./chunk-6F4PWJZI.js";
2
5
  import {
3
6
  RIDDLE_PROOF_PLAYABILITY_ASSESSMENT_VERSION,
@@ -16,8 +19,25 @@ import {
16
19
  visualSessionFingerprintBasis
17
20
  } from "./chunk-ODORKNSO.js";
18
21
  import {
19
- runRiddleProof
20
- } from "./chunk-QBOKV3ES.js";
22
+ RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION,
23
+ RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION,
24
+ assessBasicGameplayEvidence,
25
+ assessBasicGameplayRoute,
26
+ extractBasicGameplayEvidence
27
+ } from "./chunk-RNGJX62B.js";
28
+ import {
29
+ DEFAULT_RIDDLE_API_BASE_URL,
30
+ DEFAULT_RIDDLE_API_KEY_FILE,
31
+ RiddleApiError,
32
+ createRiddleApiClient,
33
+ deployRiddleStaticPreview,
34
+ isTerminalRiddleJobStatus,
35
+ parseRiddleViewport,
36
+ pollRiddleJob,
37
+ resolveRiddleApiKey,
38
+ riddleRequestJson,
39
+ runRiddleScript
40
+ } from "./chunk-UR6ADV4Y.js";
21
41
  import {
22
42
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
23
43
  DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
@@ -32,14 +52,7 @@ import {
32
52
  createDisabledRiddleProofAgentAdapter,
33
53
  readRiddleProofRunStatus,
34
54
  runRiddleProofEngineHarness
35
- } from "./chunk-KYGWIA7A.js";
36
- import "./chunk-4ASMX4R6.js";
37
- import "./chunk-JFQXAJH2.js";
38
- import {
39
- createCodexExecAgentAdapter,
40
- createCodexExecJsonRunner,
41
- runCodexExecAgentDoctor
42
- } from "./chunk-3266V3MO.js";
55
+ } from "./chunk-2FBF2UDZ.js";
43
56
  import {
44
57
  RIDDLE_PROOF_RUN_STATE_VERSION,
45
58
  appendRunEvent,
@@ -51,11 +64,12 @@ import {
51
64
  normalizePrLifecycleState,
52
65
  normalizeRunParams,
53
66
  setRunStatus
54
- } from "./chunk-PVUZZ2P6.js";
67
+ } from "./chunk-MO24D3PY.js";
68
+ import "./chunk-RFJ5BQF6.js";
55
69
  import {
56
70
  RIDDLE_PROOF_RUN_CARD_VERSION,
57
71
  createRiddleProofRunCard
58
- } from "./chunk-53UPEUVU.js";
72
+ } from "./chunk-3UHWI3FO.js";
59
73
  import {
60
74
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
61
75
  RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
@@ -71,7 +85,13 @@ import {
71
85
  normalizeCheckpointResponse,
72
86
  proofContractFromAuthorCheckpointResponse,
73
87
  statePathsForRunState
74
- } from "./chunk-T5RHGGQ2.js";
88
+ } from "./chunk-33XO42CY.js";
89
+ import "./chunk-JFQXAJH2.js";
90
+ import {
91
+ createCodexExecAgentAdapter,
92
+ createCodexExecJsonRunner,
93
+ runCodexExecAgentDoctor
94
+ } from "./chunk-3266V3MO.js";
75
95
  import {
76
96
  applyTerminalMetadata,
77
97
  compactRecord,
@@ -86,6 +106,10 @@ export {
86
106
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
87
107
  DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
88
108
  DEFAULT_DIAGNOSTIC_STRING_LIMIT,
109
+ DEFAULT_RIDDLE_API_BASE_URL,
110
+ DEFAULT_RIDDLE_API_KEY_FILE,
111
+ RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION,
112
+ RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION,
89
113
  RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
90
114
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
91
115
  RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
@@ -95,11 +119,14 @@ export {
95
119
  RIDDLE_PROOF_RUN_STATE_VERSION,
96
120
  RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION,
97
121
  RIDDLE_PROOF_VISUAL_SESSION_VERSION,
122
+ RiddleApiError,
98
123
  appendCaptureDiagnostic,
99
124
  appendRunEvent,
100
125
  appendStageHeartbeat,
101
126
  applyPrLifecycleState,
102
127
  applyTerminalMetadata,
128
+ assessBasicGameplayEvidence,
129
+ assessBasicGameplayRoute,
103
130
  assessPlayabilityEvidence,
104
131
  authorPacketPayloadFromCheckpointResponse,
105
132
  buildAuthorCheckpointPacket,
@@ -118,14 +145,18 @@ export {
118
145
  createDisabledRiddleProofAgentAdapter,
119
146
  createCodexExecAgentAdapter as createLocalAgentAdapter,
120
147
  createCodexExecJsonRunner as createLocalAgentJsonRunner,
148
+ createRiddleApiClient,
121
149
  createRiddleProofRunCard,
122
150
  createRunResult,
123
151
  createRunState,
124
152
  createRunStatusSnapshot,
153
+ deployRiddleStaticPreview,
154
+ extractBasicGameplayEvidence,
125
155
  extractPlayabilityEvidence,
126
156
  isDuplicateCheckpointResponse,
127
157
  isRiddleProofPlayabilityMode,
128
158
  isSuccessfulStatus,
159
+ isTerminalRiddleJobStatus,
129
160
  isTerminalStatus,
130
161
  nonEmptyString,
131
162
  normalizeCheckpointResponse,
@@ -133,15 +164,20 @@ export {
133
164
  normalizePrLifecycleState,
134
165
  normalizeRunParams,
135
166
  normalizeTerminalMetadata,
167
+ parseRiddleViewport,
136
168
  parseVisualProofSession,
169
+ pollRiddleJob,
137
170
  proofContractFromAuthorCheckpointResponse,
138
171
  readRiddleProofRunStatus,
139
172
  recordValue,
140
173
  redactForProofDiagnostics,
174
+ resolveRiddleApiKey,
175
+ riddleRequestJson,
141
176
  runCodexExecAgentDoctor,
142
177
  runCodexExecAgentDoctor as runLocalAgentDoctor,
143
178
  runRiddleProof,
144
179
  runRiddleProofEngineHarness,
180
+ runRiddleScript,
145
181
  setRunStatus,
146
182
  statePathsForRunState,
147
183
  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 = {}) {
@@ -277,7 +277,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
277
277
  blocking?: boolean;
278
278
  details?: Record<string, unknown>;
279
279
  ok: boolean;
280
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
280
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
281
281
  state_path: string;
282
282
  stage: any;
283
283
  summary: string;
@@ -362,7 +362,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
362
362
  continueWithStage?: WorkflowStage | null;
363
363
  blocking?: boolean;
364
364
  details?: Record<string, unknown>;
365
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
365
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
366
366
  state_path: string;
367
367
  stage: any;
368
368
  checkpoint: string;
@@ -624,7 +624,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
624
624
  error?: undefined;
625
625
  } | {
626
626
  ok: boolean;
627
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
627
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
628
628
  state_path: string;
629
629
  stage: any;
630
630
  summary: string;
@@ -277,7 +277,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
277
277
  blocking?: boolean;
278
278
  details?: Record<string, unknown>;
279
279
  ok: boolean;
280
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
280
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
281
281
  state_path: string;
282
282
  stage: any;
283
283
  summary: string;
@@ -362,7 +362,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
362
362
  continueWithStage?: WorkflowStage | null;
363
363
  blocking?: boolean;
364
364
  details?: Record<string, unknown>;
365
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
365
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
366
366
  state_path: string;
367
367
  stage: any;
368
368
  checkpoint: string;
@@ -624,7 +624,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
624
624
  error?: undefined;
625
625
  } | {
626
626
  ok: boolean;
627
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
627
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
628
628
  state_path: string;
629
629
  stage: any;
630
630
  summary: string;
@@ -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";
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/riddle-client.ts
31
+ var riddle_client_exports = {};
32
+ __export(riddle_client_exports, {
33
+ DEFAULT_RIDDLE_API_BASE_URL: () => DEFAULT_RIDDLE_API_BASE_URL,
34
+ DEFAULT_RIDDLE_API_KEY_FILE: () => DEFAULT_RIDDLE_API_KEY_FILE,
35
+ RiddleApiError: () => RiddleApiError,
36
+ createRiddleApiClient: () => createRiddleApiClient,
37
+ deployRiddleStaticPreview: () => deployRiddleStaticPreview,
38
+ isTerminalRiddleJobStatus: () => isTerminalRiddleJobStatus,
39
+ parseRiddleViewport: () => parseRiddleViewport,
40
+ pollRiddleJob: () => pollRiddleJob,
41
+ resolveRiddleApiKey: () => resolveRiddleApiKey,
42
+ riddleRequestJson: () => riddleRequestJson,
43
+ runRiddleScript: () => runRiddleScript
44
+ });
45
+ module.exports = __toCommonJS(riddle_client_exports);
46
+ var import_node_child_process = require("child_process");
47
+ var import_node_fs = require("fs");
48
+ var import_node_os = require("os");
49
+ var import_node_path = __toESM(require("path"), 1);
50
+ var DEFAULT_RIDDLE_API_BASE_URL = "https://api.riddledc.com";
51
+ var DEFAULT_RIDDLE_API_KEY_FILE = "/tmp/riddle-api-key";
52
+ var RiddleApiError = class extends Error {
53
+ constructor(pathname, status, body) {
54
+ super(`Riddle API ${pathname} failed HTTP ${status}: ${body}`);
55
+ this.name = "RiddleApiError";
56
+ this.status = status;
57
+ this.body = body;
58
+ this.path = pathname;
59
+ }
60
+ };
61
+ function normalizeBaseUrl(value) {
62
+ return (value || DEFAULT_RIDDLE_API_BASE_URL).replace(/\/$/, "");
63
+ }
64
+ function fetchFor(config = {}) {
65
+ return config.fetchImpl || fetch;
66
+ }
67
+ function resolveRiddleApiKey(config = {}) {
68
+ if (config.apiKey?.trim()) return config.apiKey.trim();
69
+ if (process.env.RIDDLE_API_KEY?.trim()) return process.env.RIDDLE_API_KEY.trim();
70
+ const keyFile = config.apiKeyFile || process.env.RIDDLE_API_KEY_FILE || DEFAULT_RIDDLE_API_KEY_FILE;
71
+ if ((0, import_node_fs.existsSync)(keyFile)) {
72
+ const key = (0, import_node_fs.readFileSync)(keyFile, "utf8").trim();
73
+ if (key) return key;
74
+ }
75
+ throw new Error(`Riddle API key missing. Set RIDDLE_API_KEY or write ${DEFAULT_RIDDLE_API_KEY_FILE}.`);
76
+ }
77
+ async function riddleRequestJson(config, pathname, init = {}) {
78
+ const response = await fetchFor(config)(`${normalizeBaseUrl(config.apiBaseUrl)}${pathname}`, {
79
+ ...init,
80
+ headers: {
81
+ Authorization: `Bearer ${resolveRiddleApiKey(config)}`,
82
+ "Content-Type": "application/json",
83
+ ...init.headers || {}
84
+ }
85
+ });
86
+ const text = await response.text();
87
+ let json = null;
88
+ try {
89
+ json = JSON.parse(text);
90
+ } catch {
91
+ }
92
+ if (!response.ok) throw new RiddleApiError(pathname, response.status, text);
93
+ return json ?? text;
94
+ }
95
+ async function deployRiddleStaticPreview(config, directory, label) {
96
+ if (!directory?.trim()) throw new Error("directory is required");
97
+ if (!label?.trim()) throw new Error("label is required");
98
+ const created = await riddleRequestJson(config, "/v1/preview", {
99
+ method: "POST",
100
+ body: JSON.stringify({ framework: "spa", label })
101
+ });
102
+ const id = String(created.id || "");
103
+ const uploadUrl = String(created.upload_url || "");
104
+ if (!id || !uploadUrl) throw new Error("Riddle preview create response was missing id or upload_url.");
105
+ const scratch = (0, import_node_fs.mkdtempSync)(import_node_path.default.join((0, import_node_os.tmpdir)(), "riddle-preview-upload-"));
106
+ const tarball = import_node_path.default.join(scratch, `${id}.tar.gz`);
107
+ try {
108
+ (0, import_node_child_process.execFileSync)("tar", ["czf", tarball, "-C", directory, "."], { stdio: "pipe" });
109
+ const upload = await fetchFor(config)(uploadUrl, {
110
+ method: "PUT",
111
+ headers: { "Content-Type": "application/gzip" },
112
+ body: (0, import_node_fs.readFileSync)(tarball)
113
+ });
114
+ if (!upload.ok) {
115
+ throw new RiddleApiError(uploadUrl, upload.status, await upload.text());
116
+ }
117
+ } finally {
118
+ (0, import_node_fs.rmSync)(scratch, { recursive: true, force: true });
119
+ }
120
+ const published = await riddleRequestJson(config, `/v1/preview/${id}/publish`, {
121
+ method: "POST"
122
+ });
123
+ return {
124
+ ok: true,
125
+ id: String(published.id || id),
126
+ label,
127
+ preview_url: String(published.preview_url || ""),
128
+ file_count: typeof published.file_count === "number" ? published.file_count : void 0,
129
+ total_bytes: typeof published.total_bytes === "number" ? published.total_bytes : void 0,
130
+ expires_at: typeof created.expires_at === "string" ? created.expires_at : void 0,
131
+ raw: published
132
+ };
133
+ }
134
+ function parseRiddleViewport(value) {
135
+ if (!value) return void 0;
136
+ const match = /^(\d+)x(\d+)$/.exec(value.trim());
137
+ if (!match) throw new Error("viewport must look like 1280x720");
138
+ return { width: Number(match[1]), height: Number(match[2]) };
139
+ }
140
+ async function runRiddleScript(config, input) {
141
+ if (!input.url?.trim()) throw new Error("url is required");
142
+ if (!input.script?.trim()) throw new Error("script is required");
143
+ const payload = {
144
+ url: input.url,
145
+ script: input.script,
146
+ sync: input.sync ?? false,
147
+ timeout_sec: input.timeoutSec || 120
148
+ };
149
+ if (input.viewport) payload.viewport = input.viewport;
150
+ if (input.include) payload.include = input.include;
151
+ if (input.options) payload.options = input.options;
152
+ return riddleRequestJson(config, "/v1/run", {
153
+ method: "POST",
154
+ body: JSON.stringify(payload)
155
+ });
156
+ }
157
+ function isTerminalRiddleJobStatus(status) {
158
+ return ["completed", "complete", "completed_error", "completed_timeout", "failed"].includes(String(status || ""));
159
+ }
160
+ async function pollRiddleJob(config, jobId, options = {}) {
161
+ if (!jobId?.trim()) throw new Error("jobId is required");
162
+ const attempts = options.attempts || (options.wait ? 60 : 1);
163
+ const intervalMs = options.intervalMs || 2e3;
164
+ let job = null;
165
+ for (let index = 0; index < attempts; index += 1) {
166
+ job = await riddleRequestJson(config, `/v1/jobs/${jobId}`);
167
+ if (isTerminalRiddleJobStatus(job.status)) break;
168
+ if (index + 1 < attempts) {
169
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
170
+ }
171
+ }
172
+ const status = job?.status ? String(job.status) : null;
173
+ if (!isTerminalRiddleJobStatus(status)) {
174
+ return { ok: true, job_id: jobId, status, terminal: false, job };
175
+ }
176
+ const artifacts = await riddleRequestJson(config, `/v1/jobs/${jobId}/artifacts`);
177
+ return {
178
+ ok: status === "completed" || status === "complete",
179
+ job_id: jobId,
180
+ status,
181
+ terminal: true,
182
+ job,
183
+ artifacts
184
+ };
185
+ }
186
+ function createRiddleApiClient(config = {}) {
187
+ return {
188
+ requestJson: (pathname, init) => riddleRequestJson(config, pathname, init),
189
+ deployStaticPreview: (directory, label) => deployRiddleStaticPreview(config, directory, label),
190
+ runScript: (input) => runRiddleScript(config, input),
191
+ pollJob: (jobId, options) => pollRiddleJob(config, jobId, options)
192
+ };
193
+ }
194
+ // Annotate the CommonJS export names for ESM import in node:
195
+ 0 && (module.exports = {
196
+ DEFAULT_RIDDLE_API_BASE_URL,
197
+ DEFAULT_RIDDLE_API_KEY_FILE,
198
+ RiddleApiError,
199
+ createRiddleApiClient,
200
+ deployRiddleStaticPreview,
201
+ isTerminalRiddleJobStatus,
202
+ parseRiddleViewport,
203
+ pollRiddleJob,
204
+ resolveRiddleApiKey,
205
+ riddleRequestJson,
206
+ runRiddleScript
207
+ });
@@ -0,0 +1,71 @@
1
+ declare const DEFAULT_RIDDLE_API_BASE_URL = "https://api.riddledc.com";
2
+ declare const DEFAULT_RIDDLE_API_KEY_FILE = "/tmp/riddle-api-key";
3
+ type RiddleFetch = typeof fetch;
4
+ interface RiddleClientConfig {
5
+ apiKey?: string;
6
+ apiKeyFile?: string;
7
+ apiBaseUrl?: string;
8
+ fetchImpl?: RiddleFetch;
9
+ }
10
+ interface RiddlePreviewDeployResult {
11
+ ok: true;
12
+ id: string;
13
+ label: string;
14
+ preview_url: string;
15
+ file_count?: number;
16
+ total_bytes?: number;
17
+ expires_at?: string;
18
+ raw?: Record<string, unknown>;
19
+ }
20
+ interface RiddleRunScriptInput {
21
+ url: string;
22
+ script: string;
23
+ viewport?: {
24
+ width: number;
25
+ height: number;
26
+ };
27
+ timeoutSec?: number;
28
+ sync?: boolean;
29
+ include?: string[];
30
+ options?: Record<string, unknown>;
31
+ }
32
+ interface RiddlePollJobResult {
33
+ ok: boolean;
34
+ job_id: string;
35
+ status: string | null;
36
+ terminal: boolean;
37
+ job: Record<string, unknown> | null;
38
+ artifacts?: Record<string, unknown> | null;
39
+ }
40
+ declare class RiddleApiError extends Error {
41
+ readonly status: number;
42
+ readonly body: string;
43
+ readonly path: string;
44
+ constructor(pathname: string, status: number, body: string);
45
+ }
46
+ declare function resolveRiddleApiKey(config?: RiddleClientConfig): string;
47
+ declare function riddleRequestJson<T = unknown>(config: RiddleClientConfig, pathname: string, init?: RequestInit): Promise<T>;
48
+ declare function deployRiddleStaticPreview(config: RiddleClientConfig, directory: string, label: string): Promise<RiddlePreviewDeployResult>;
49
+ declare function parseRiddleViewport(value?: string): {
50
+ width: number;
51
+ height: number;
52
+ } | undefined;
53
+ declare function runRiddleScript(config: RiddleClientConfig, input: RiddleRunScriptInput): Promise<Record<string, unknown>>;
54
+ declare function isTerminalRiddleJobStatus(status: unknown): boolean;
55
+ declare function pollRiddleJob(config: RiddleClientConfig, jobId: string, options?: {
56
+ wait?: boolean;
57
+ attempts?: number;
58
+ intervalMs?: number;
59
+ }): Promise<RiddlePollJobResult>;
60
+ declare function createRiddleApiClient(config?: RiddleClientConfig): {
61
+ requestJson: <T = unknown>(pathname: string, init?: RequestInit) => Promise<T>;
62
+ deployStaticPreview: (directory: string, label: string) => Promise<RiddlePreviewDeployResult>;
63
+ runScript: (input: RiddleRunScriptInput) => Promise<Record<string, unknown>>;
64
+ pollJob: (jobId: string, options?: {
65
+ wait?: boolean;
66
+ attempts?: number;
67
+ intervalMs?: number;
68
+ }) => Promise<RiddlePollJobResult>;
69
+ };
70
+
71
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, type RiddleClientConfig, type RiddleFetch, type RiddlePollJobResult, type RiddlePreviewDeployResult, type RiddleRunScriptInput, createRiddleApiClient, deployRiddleStaticPreview, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, riddleRequestJson, runRiddleScript };
@@ -0,0 +1,71 @@
1
+ declare const DEFAULT_RIDDLE_API_BASE_URL = "https://api.riddledc.com";
2
+ declare const DEFAULT_RIDDLE_API_KEY_FILE = "/tmp/riddle-api-key";
3
+ type RiddleFetch = typeof fetch;
4
+ interface RiddleClientConfig {
5
+ apiKey?: string;
6
+ apiKeyFile?: string;
7
+ apiBaseUrl?: string;
8
+ fetchImpl?: RiddleFetch;
9
+ }
10
+ interface RiddlePreviewDeployResult {
11
+ ok: true;
12
+ id: string;
13
+ label: string;
14
+ preview_url: string;
15
+ file_count?: number;
16
+ total_bytes?: number;
17
+ expires_at?: string;
18
+ raw?: Record<string, unknown>;
19
+ }
20
+ interface RiddleRunScriptInput {
21
+ url: string;
22
+ script: string;
23
+ viewport?: {
24
+ width: number;
25
+ height: number;
26
+ };
27
+ timeoutSec?: number;
28
+ sync?: boolean;
29
+ include?: string[];
30
+ options?: Record<string, unknown>;
31
+ }
32
+ interface RiddlePollJobResult {
33
+ ok: boolean;
34
+ job_id: string;
35
+ status: string | null;
36
+ terminal: boolean;
37
+ job: Record<string, unknown> | null;
38
+ artifacts?: Record<string, unknown> | null;
39
+ }
40
+ declare class RiddleApiError extends Error {
41
+ readonly status: number;
42
+ readonly body: string;
43
+ readonly path: string;
44
+ constructor(pathname: string, status: number, body: string);
45
+ }
46
+ declare function resolveRiddleApiKey(config?: RiddleClientConfig): string;
47
+ declare function riddleRequestJson<T = unknown>(config: RiddleClientConfig, pathname: string, init?: RequestInit): Promise<T>;
48
+ declare function deployRiddleStaticPreview(config: RiddleClientConfig, directory: string, label: string): Promise<RiddlePreviewDeployResult>;
49
+ declare function parseRiddleViewport(value?: string): {
50
+ width: number;
51
+ height: number;
52
+ } | undefined;
53
+ declare function runRiddleScript(config: RiddleClientConfig, input: RiddleRunScriptInput): Promise<Record<string, unknown>>;
54
+ declare function isTerminalRiddleJobStatus(status: unknown): boolean;
55
+ declare function pollRiddleJob(config: RiddleClientConfig, jobId: string, options?: {
56
+ wait?: boolean;
57
+ attempts?: number;
58
+ intervalMs?: number;
59
+ }): Promise<RiddlePollJobResult>;
60
+ declare function createRiddleApiClient(config?: RiddleClientConfig): {
61
+ requestJson: <T = unknown>(pathname: string, init?: RequestInit) => Promise<T>;
62
+ deployStaticPreview: (directory: string, label: string) => Promise<RiddlePreviewDeployResult>;
63
+ runScript: (input: RiddleRunScriptInput) => Promise<Record<string, unknown>>;
64
+ pollJob: (jobId: string, options?: {
65
+ wait?: boolean;
66
+ attempts?: number;
67
+ intervalMs?: number;
68
+ }) => Promise<RiddlePollJobResult>;
69
+ };
70
+
71
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, type RiddleClientConfig, type RiddleFetch, type RiddlePollJobResult, type RiddlePreviewDeployResult, type RiddleRunScriptInput, createRiddleApiClient, deployRiddleStaticPreview, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, riddleRequestJson, runRiddleScript };
@@ -0,0 +1,26 @@
1
+ import {
2
+ DEFAULT_RIDDLE_API_BASE_URL,
3
+ DEFAULT_RIDDLE_API_KEY_FILE,
4
+ RiddleApiError,
5
+ createRiddleApiClient,
6
+ deployRiddleStaticPreview,
7
+ isTerminalRiddleJobStatus,
8
+ parseRiddleViewport,
9
+ pollRiddleJob,
10
+ resolveRiddleApiKey,
11
+ riddleRequestJson,
12
+ runRiddleScript
13
+ } from "./chunk-UR6ADV4Y.js";
14
+ export {
15
+ DEFAULT_RIDDLE_API_BASE_URL,
16
+ DEFAULT_RIDDLE_API_KEY_FILE,
17
+ RiddleApiError,
18
+ createRiddleApiClient,
19
+ deployRiddleStaticPreview,
20
+ isTerminalRiddleJobStatus,
21
+ parseRiddleViewport,
22
+ pollRiddleJob,
23
+ resolveRiddleApiKey,
24
+ riddleRequestJson,
25
+ runRiddleScript
26
+ };
package/dist/run-card.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  RIDDLE_PROOF_RUN_CARD_VERSION,
3
3
  createRiddleProofRunCard
4
- } from "./chunk-53UPEUVU.js";
5
- import "./chunk-T5RHGGQ2.js";
4
+ } from "./chunk-3UHWI3FO.js";
5
+ import "./chunk-33XO42CY.js";
6
6
  import "./chunk-DUFDZJOF.js";
7
7
  export {
8
8
  RIDDLE_PROOF_RUN_CARD_VERSION,
package/dist/runner.cjs CHANGED
@@ -204,6 +204,7 @@ function normalizeRunParams(input) {
204
204
  leave_draft: input.leave_draft,
205
205
  engine_state_path: input.engine_state_path,
206
206
  harness_state_path: input.harness_state_path,
207
+ riddle_engine_module_url: input.riddle_engine_module_url,
207
208
  max_iterations: input.max_iterations,
208
209
  auto_approve: input.auto_approve,
209
210
  dry_run: input.dry_run,
package/dist/runner.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  runRiddleProof
3
- } from "./chunk-QBOKV3ES.js";
4
- import "./chunk-PVUZZ2P6.js";
5
- import "./chunk-53UPEUVU.js";
6
- import "./chunk-T5RHGGQ2.js";
3
+ } from "./chunk-RXFKKYWA.js";
4
+ import "./chunk-MO24D3PY.js";
5
+ import "./chunk-3UHWI3FO.js";
6
+ import "./chunk-33XO42CY.js";
7
7
  import "./chunk-DUFDZJOF.js";
8
8
  export {
9
9
  runRiddleProof