@riddledc/riddle-proof 0.5.55 → 0.5.57

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/index.cjs CHANGED
@@ -2779,6 +2779,7 @@ __export(index_exports, {
2779
2779
  DEFAULT_RIDDLE_API_BASE_URL: () => DEFAULT_RIDDLE_API_BASE_URL,
2780
2780
  DEFAULT_RIDDLE_API_KEY_FILE: () => DEFAULT_RIDDLE_API_KEY_FILE,
2781
2781
  RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION: () => RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION,
2782
+ RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION: () => RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION,
2782
2783
  RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION: () => RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION,
2783
2784
  RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION: () => RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
2784
2785
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION: () => RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
@@ -2808,6 +2809,7 @@ __export(index_exports, {
2808
2809
  checkpointSummaryFromState: () => checkpointSummaryFromState,
2809
2810
  compactRecord: () => compactRecord,
2810
2811
  compareVisualProofSessionFingerprint: () => compareVisualProofSessionFingerprint,
2812
+ createBasicGameplayCatchSummary: () => createBasicGameplayCatchSummary,
2811
2813
  createCaptureDiagnostic: () => createCaptureDiagnostic,
2812
2814
  createCheckpointResponseTemplate: () => createCheckpointResponseTemplate,
2813
2815
  createCodexExecAgentAdapter: () => createCodexExecAgentAdapter,
@@ -2848,6 +2850,7 @@ __export(index_exports, {
2848
2850
  runRiddleProof: () => runRiddleProof,
2849
2851
  runRiddleProofEngineHarness: () => runRiddleProofEngineHarness,
2850
2852
  runRiddleScript: () => runRiddleScript,
2853
+ runRiddleServerPreview: () => runRiddleServerPreview,
2851
2854
  setRunStatus: () => setRunStatus,
2852
2855
  statePathsForRunState: () => statePathsForRunState,
2853
2856
  summarizeCaptureArtifacts: () => summarizeCaptureArtifacts,
@@ -7619,6 +7622,7 @@ function parseJson(value) {
7619
7622
  // src/basic-gameplay.ts
7620
7623
  var RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION = "riddle-proof.basic-gameplay.v1";
7621
7624
  var RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION = "riddle-proof.basic-gameplay.assessment.v1";
7625
+ var RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION = "riddle-proof.basic-gameplay.catch.v1";
7622
7626
  var BASIC_GAMEPLAY_CONTAINER_KEYS = [
7623
7627
  "basic_gameplay",
7624
7628
  "basicGameplay",
@@ -7728,6 +7732,37 @@ function assessBasicGameplayRoute(route, options = {}) {
7728
7732
  }
7729
7733
  };
7730
7734
  }
7735
+ function createBasicGameplayCatchSummary(input, options = {}) {
7736
+ const before = summarizeAssessment(assessBasicGameplayEvidence(input.before, options));
7737
+ const after = input.after === void 0 ? void 0 : summarizeAssessment(assessBasicGameplayEvidence(input.after, options));
7738
+ const fixed = Boolean(after && before.notable_codes.length > 0 && after.passed && after.notable_codes.length === 0);
7739
+ const title = input.title || [
7740
+ input.site || "Basic gameplay",
7741
+ input.route ? `${input.route} proof catch` : "proof catch"
7742
+ ].join(" ");
7743
+ const beforeCodes = before.notable_codes.length ? before.notable_codes.join(", ") : "no failing or warning codes";
7744
+ const afterCodes = after ? after.notable_codes.length ? after.notable_codes.join(", ") : "no failing or warning codes" : "not verified";
7745
+ const summaryLines = [
7746
+ `Before: ${before.checked_routes} checked, ${before.passing_routes} passing, codes: ${beforeCodes}.`,
7747
+ after ? `After: ${after.checked_routes} checked, ${after.passing_routes} passing, codes: ${afterCodes}.` : "After: not provided."
7748
+ ];
7749
+ if (input.fix?.summary) summaryLines.push(`Fix: ${input.fix.summary}`);
7750
+ if (input.artifacts?.length) summaryLines.push(`Artifacts: ${input.artifacts.length} attached.`);
7751
+ return {
7752
+ version: RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION,
7753
+ title,
7754
+ site: input.site,
7755
+ route: input.route,
7756
+ detected_at: input.detected_at || (/* @__PURE__ */ new Date()).toISOString(),
7757
+ before,
7758
+ after,
7759
+ fixed,
7760
+ fix: input.fix,
7761
+ artifacts: input.artifacts || [],
7762
+ summary_lines: summaryLines,
7763
+ marketing_summary: fixed ? `${title}: Riddle Proof caught ${beforeCodes}; after the fix, ${afterCodes}.` : `${title}: Riddle Proof caught ${beforeCodes}; after evidence is ${after ? "not yet clean" : "not yet attached"}.`
7764
+ };
7765
+ }
7731
7766
  function extractBasicGameplayEvidence(...sources) {
7732
7767
  const seen = /* @__PURE__ */ new Set();
7733
7768
  for (const source of sources) {
@@ -7736,6 +7771,21 @@ function extractBasicGameplayEvidence(...sources) {
7736
7771
  }
7737
7772
  return null;
7738
7773
  }
7774
+ function summarizeAssessment(assessment) {
7775
+ return {
7776
+ evidence_present: assessment.evidence_present,
7777
+ passed: assessment.passed,
7778
+ checked_routes: assessment.checked_routes,
7779
+ passing_routes: assessment.passing_routes,
7780
+ failing_routes: assessment.failing_routes,
7781
+ failure_counts: assessment.failure_counts,
7782
+ warning_counts: assessment.warning_counts,
7783
+ notable_codes: [
7784
+ ...Object.keys(assessment.failure_counts),
7785
+ ...Object.keys(assessment.warning_counts)
7786
+ ].sort()
7787
+ };
7788
+ }
7739
7789
  function findBasicGameplayEvidence(value, seen, depth = 0) {
7740
7790
  if (depth > 6 || value === null || value === void 0) return null;
7741
7791
  if (typeof value === "string") {
@@ -7925,12 +7975,94 @@ async function deployRiddleStaticPreview(config, directory, label) {
7925
7975
  raw: published
7926
7976
  };
7927
7977
  }
7978
+ function createTarball(directory, label, exclude = []) {
7979
+ const scratch = (0, import_node_fs5.mkdtempSync)(import_node_path5.default.join((0, import_node_os2.tmpdir)(), "riddle-upload-"));
7980
+ const tarball = import_node_path5.default.join(scratch, `${label}.tar.gz`);
7981
+ const excludeArgs = exclude.flatMap((item) => ["--exclude", item]);
7982
+ try {
7983
+ (0, import_node_child_process4.execFileSync)("tar", ["czf", tarball, ...excludeArgs, "-C", directory, "."], { stdio: "pipe" });
7984
+ return { scratch, tarball };
7985
+ } catch (error) {
7986
+ (0, import_node_fs5.rmSync)(scratch, { recursive: true, force: true });
7987
+ throw error;
7988
+ }
7989
+ }
7928
7990
  function parseRiddleViewport(value) {
7929
7991
  if (!value) return void 0;
7930
7992
  const match = /^(\d+)x(\d+)$/.exec(value.trim());
7931
7993
  if (!match) throw new Error("viewport must look like 1280x720");
7932
7994
  return { width: Number(match[1]), height: Number(match[2]) };
7933
7995
  }
7996
+ function scriptErrorFrom(job) {
7997
+ const nested = job?.proof_of_execution && typeof job.proof_of_execution === "object" && !Array.isArray(job.proof_of_execution) ? job.proof_of_execution : null;
7998
+ return typeof job?.script_error === "string" && job.script_error.trim() ? job.script_error : typeof nested?.script_error === "string" && nested.script_error.trim() ? nested.script_error : null;
7999
+ }
8000
+ async function runRiddleServerPreview(config, input) {
8001
+ if (!input.directory?.trim()) throw new Error("directory is required");
8002
+ if (!input.script?.trim()) throw new Error("script is required");
8003
+ const port = input.port || 3e3;
8004
+ const routePath = input.path || "/";
8005
+ const timeoutSec = input.timeoutSec || 180;
8006
+ const created = await riddleRequestJson(config, "/v1/server-preview", {
8007
+ method: "POST",
8008
+ body: JSON.stringify({
8009
+ image: input.image || "node:22-slim",
8010
+ command: input.command || "node scripts/riddleSpaPreviewServer.mjs build 3000",
8011
+ port,
8012
+ path: routePath,
8013
+ readiness_path: input.readinessPath || routePath,
8014
+ readiness_timeout: input.readinessTimeoutSec || 90,
8015
+ wait_until: input.waitUntil || "domcontentloaded",
8016
+ wait_for_selector: input.waitForSelector || "body",
8017
+ navigation_timeout: input.navigationTimeoutSec || 60,
8018
+ viewport: input.viewport,
8019
+ timeout: timeoutSec,
8020
+ script: input.script
8021
+ })
8022
+ });
8023
+ const jobId = String(created.job_id || "");
8024
+ const uploadUrl = String(created.upload_url || "");
8025
+ if (!jobId || !uploadUrl) {
8026
+ throw new Error(`Riddle server preview create response was missing job_id or upload_url.`);
8027
+ }
8028
+ const { scratch, tarball } = createTarball(input.directory, jobId, [
8029
+ ".git",
8030
+ "node_modules",
8031
+ "test-results",
8032
+ ...input.exclude || []
8033
+ ]);
8034
+ try {
8035
+ const upload = await fetchFor(config)(uploadUrl, {
8036
+ method: "PUT",
8037
+ headers: { "Content-Type": "application/gzip" },
8038
+ body: (0, import_node_fs5.readFileSync)(tarball)
8039
+ });
8040
+ if (!upload.ok) throw new RiddleApiError(uploadUrl, upload.status, await upload.text());
8041
+ } finally {
8042
+ (0, import_node_fs5.rmSync)(scratch, { recursive: true, force: true });
8043
+ }
8044
+ await riddleRequestJson(config, `/v1/server-preview/${jobId}/start`, {
8045
+ method: "POST"
8046
+ });
8047
+ let job = null;
8048
+ const attempts = input.pollAttempts || Math.ceil((timeoutSec + 90) / 2);
8049
+ const intervalMs = input.pollIntervalMs || 2e3;
8050
+ for (let index = 0; index < attempts; index += 1) {
8051
+ job = await riddleRequestJson(config, `/v1/server-preview/${jobId}`);
8052
+ if (isTerminalRiddleJobStatus(job.status)) break;
8053
+ if (index + 1 < attempts) await new Promise((resolve) => setTimeout(resolve, intervalMs));
8054
+ }
8055
+ const status = job?.status ? String(job.status) : null;
8056
+ const scriptError = scriptErrorFrom(job);
8057
+ return {
8058
+ ok: (status === "completed" || status === "complete") && !scriptError,
8059
+ job_id: jobId,
8060
+ status,
8061
+ terminal: isTerminalRiddleJobStatus(status),
8062
+ script_error: scriptError,
8063
+ job
8064
+ };
8065
+ }
7934
8066
  async function runRiddleScript(config, input) {
7935
8067
  if (!input.url?.trim()) throw new Error("url is required");
7936
8068
  if (!input.script?.trim()) throw new Error("script is required");
@@ -7982,6 +8114,7 @@ function createRiddleApiClient(config = {}) {
7982
8114
  requestJson: (pathname, init) => riddleRequestJson(config, pathname, init),
7983
8115
  deployStaticPreview: (directory, label) => deployRiddleStaticPreview(config, directory, label),
7984
8116
  runScript: (input) => runRiddleScript(config, input),
8117
+ runServerPreview: (input) => runRiddleServerPreview(config, input),
7985
8118
  pollJob: (jobId, options) => pollRiddleJob(config, jobId, options)
7986
8119
  };
7987
8120
  }
@@ -7993,6 +8126,7 @@ function createRiddleApiClient(config = {}) {
7993
8126
  DEFAULT_RIDDLE_API_BASE_URL,
7994
8127
  DEFAULT_RIDDLE_API_KEY_FILE,
7995
8128
  RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION,
8129
+ RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION,
7996
8130
  RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION,
7997
8131
  RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
7998
8132
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
@@ -8022,6 +8156,7 @@ function createRiddleApiClient(config = {}) {
8022
8156
  checkpointSummaryFromState,
8023
8157
  compactRecord,
8024
8158
  compareVisualProofSessionFingerprint,
8159
+ createBasicGameplayCatchSummary,
8025
8160
  createCaptureDiagnostic,
8026
8161
  createCheckpointResponseTemplate,
8027
8162
  createCodexExecAgentAdapter,
@@ -8062,6 +8197,7 @@ function createRiddleApiClient(config = {}) {
8062
8197
  runRiddleProof,
8063
8198
  runRiddleProofEngineHarness,
8064
8199
  runRiddleScript,
8200
+ runRiddleServerPreview,
8065
8201
  setRunStatus,
8066
8202
  statePathsForRunState,
8067
8203
  summarizeCaptureArtifacts,
package/dist/index.d.cts CHANGED
@@ -9,5 +9,5 @@ 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 { AssessBasicGameplayOptions, BasicGameplayActionResult, BasicGameplayCanvasState, BasicGameplayChangeSummary, BasicGameplayFailureCode, BasicGameplayMobileEvidence, BasicGameplaySnapshot, BasicGameplayWarningCode, RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION, RiddleProofBasicGameplayAssessment, RiddleProofBasicGameplayEvidence, RiddleProofBasicGameplayRouteAssessment, RiddleProofBasicGameplayRouteEvidence, assessBasicGameplayEvidence, assessBasicGameplayRoute, extractBasicGameplayEvidence } from './basic-gameplay.cjs';
13
- 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';
12
+ export { AssessBasicGameplayOptions, BasicGameplayActionResult, BasicGameplayAssessmentSummary, BasicGameplayCanvasState, BasicGameplayChangeSummary, BasicGameplayFailureCode, BasicGameplayFixReference, BasicGameplayMobileEvidence, BasicGameplayProofArtifact, BasicGameplaySnapshot, BasicGameplayWarningCode, CreateBasicGameplayCatchSummaryInput, RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION, RiddleProofBasicGameplayAssessment, RiddleProofBasicGameplayCatchSummary, RiddleProofBasicGameplayEvidence, RiddleProofBasicGameplayRouteAssessment, RiddleProofBasicGameplayRouteEvidence, assessBasicGameplayEvidence, assessBasicGameplayRoute, createBasicGameplayCatchSummary, extractBasicGameplayEvidence } from './basic-gameplay.cjs';
13
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleClientConfig, RiddleFetch, RiddlePollJobResult, RiddlePreviewDeployResult, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, createRiddleApiClient, deployRiddleStaticPreview, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from './riddle-client.cjs';
package/dist/index.d.ts CHANGED
@@ -9,5 +9,5 @@ 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 { AssessBasicGameplayOptions, BasicGameplayActionResult, BasicGameplayCanvasState, BasicGameplayChangeSummary, BasicGameplayFailureCode, BasicGameplayMobileEvidence, BasicGameplaySnapshot, BasicGameplayWarningCode, RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION, RiddleProofBasicGameplayAssessment, RiddleProofBasicGameplayEvidence, RiddleProofBasicGameplayRouteAssessment, RiddleProofBasicGameplayRouteEvidence, assessBasicGameplayEvidence, assessBasicGameplayRoute, extractBasicGameplayEvidence } from './basic-gameplay.js';
13
- 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';
12
+ export { AssessBasicGameplayOptions, BasicGameplayActionResult, BasicGameplayAssessmentSummary, BasicGameplayCanvasState, BasicGameplayChangeSummary, BasicGameplayFailureCode, BasicGameplayFixReference, BasicGameplayMobileEvidence, BasicGameplayProofArtifact, BasicGameplaySnapshot, BasicGameplayWarningCode, CreateBasicGameplayCatchSummaryInput, RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION, RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION, RiddleProofBasicGameplayAssessment, RiddleProofBasicGameplayCatchSummary, RiddleProofBasicGameplayEvidence, RiddleProofBasicGameplayRouteAssessment, RiddleProofBasicGameplayRouteEvidence, assessBasicGameplayEvidence, assessBasicGameplayRoute, createBasicGameplayCatchSummary, extractBasicGameplayEvidence } from './basic-gameplay.js';
13
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, RiddleClientConfig, RiddleFetch, RiddlePollJobResult, RiddlePreviewDeployResult, RiddleRunScriptInput, RiddleServerPreviewInput, RiddleServerPreviewResult, createRiddleApiClient, deployRiddleStaticPreview, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, riddleRequestJson, runRiddleScript, runRiddleServerPreview } from './riddle-client.js';
package/dist/index.js CHANGED
@@ -20,11 +20,13 @@ import {
20
20
  } from "./chunk-ODORKNSO.js";
21
21
  import {
22
22
  RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION,
23
+ RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION,
23
24
  RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION,
24
25
  assessBasicGameplayEvidence,
25
26
  assessBasicGameplayRoute,
27
+ createBasicGameplayCatchSummary,
26
28
  extractBasicGameplayEvidence
27
- } from "./chunk-RNGJX62B.js";
29
+ } from "./chunk-53DJMNQ6.js";
28
30
  import {
29
31
  DEFAULT_RIDDLE_API_BASE_URL,
30
32
  DEFAULT_RIDDLE_API_KEY_FILE,
@@ -36,8 +38,9 @@ import {
36
38
  pollRiddleJob,
37
39
  resolveRiddleApiKey,
38
40
  riddleRequestJson,
39
- runRiddleScript
40
- } from "./chunk-UR6ADV4Y.js";
41
+ runRiddleScript,
42
+ runRiddleServerPreview
43
+ } from "./chunk-3CVGVQTQ.js";
41
44
  import {
42
45
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
43
46
  DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
@@ -109,6 +112,7 @@ export {
109
112
  DEFAULT_RIDDLE_API_BASE_URL,
110
113
  DEFAULT_RIDDLE_API_KEY_FILE,
111
114
  RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION,
115
+ RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION,
112
116
  RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION,
113
117
  RIDDLE_PROOF_CAPTURE_DIAGNOSTIC_VERSION,
114
118
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
@@ -138,6 +142,7 @@ export {
138
142
  checkpointSummaryFromState,
139
143
  compactRecord,
140
144
  compareVisualProofSessionFingerprint,
145
+ createBasicGameplayCatchSummary,
141
146
  createCaptureDiagnostic,
142
147
  createCheckpointResponseTemplate,
143
148
  createCodexExecAgentAdapter,
@@ -178,6 +183,7 @@ export {
178
183
  runRiddleProof,
179
184
  runRiddleProofEngineHarness,
180
185
  runRiddleScript,
186
+ runRiddleServerPreview,
181
187
  setRunStatus,
182
188
  statePathsForRunState,
183
189
  summarizeCaptureArtifacts,
@@ -40,7 +40,8 @@ __export(riddle_client_exports, {
40
40
  pollRiddleJob: () => pollRiddleJob,
41
41
  resolveRiddleApiKey: () => resolveRiddleApiKey,
42
42
  riddleRequestJson: () => riddleRequestJson,
43
- runRiddleScript: () => runRiddleScript
43
+ runRiddleScript: () => runRiddleScript,
44
+ runRiddleServerPreview: () => runRiddleServerPreview
44
45
  });
45
46
  module.exports = __toCommonJS(riddle_client_exports);
46
47
  var import_node_child_process = require("child_process");
@@ -131,12 +132,94 @@ async function deployRiddleStaticPreview(config, directory, label) {
131
132
  raw: published
132
133
  };
133
134
  }
135
+ function createTarball(directory, label, exclude = []) {
136
+ const scratch = (0, import_node_fs.mkdtempSync)(import_node_path.default.join((0, import_node_os.tmpdir)(), "riddle-upload-"));
137
+ const tarball = import_node_path.default.join(scratch, `${label}.tar.gz`);
138
+ const excludeArgs = exclude.flatMap((item) => ["--exclude", item]);
139
+ try {
140
+ (0, import_node_child_process.execFileSync)("tar", ["czf", tarball, ...excludeArgs, "-C", directory, "."], { stdio: "pipe" });
141
+ return { scratch, tarball };
142
+ } catch (error) {
143
+ (0, import_node_fs.rmSync)(scratch, { recursive: true, force: true });
144
+ throw error;
145
+ }
146
+ }
134
147
  function parseRiddleViewport(value) {
135
148
  if (!value) return void 0;
136
149
  const match = /^(\d+)x(\d+)$/.exec(value.trim());
137
150
  if (!match) throw new Error("viewport must look like 1280x720");
138
151
  return { width: Number(match[1]), height: Number(match[2]) };
139
152
  }
153
+ function scriptErrorFrom(job) {
154
+ const nested = job?.proof_of_execution && typeof job.proof_of_execution === "object" && !Array.isArray(job.proof_of_execution) ? job.proof_of_execution : null;
155
+ return typeof job?.script_error === "string" && job.script_error.trim() ? job.script_error : typeof nested?.script_error === "string" && nested.script_error.trim() ? nested.script_error : null;
156
+ }
157
+ async function runRiddleServerPreview(config, input) {
158
+ if (!input.directory?.trim()) throw new Error("directory is required");
159
+ if (!input.script?.trim()) throw new Error("script is required");
160
+ const port = input.port || 3e3;
161
+ const routePath = input.path || "/";
162
+ const timeoutSec = input.timeoutSec || 180;
163
+ const created = await riddleRequestJson(config, "/v1/server-preview", {
164
+ method: "POST",
165
+ body: JSON.stringify({
166
+ image: input.image || "node:22-slim",
167
+ command: input.command || "node scripts/riddleSpaPreviewServer.mjs build 3000",
168
+ port,
169
+ path: routePath,
170
+ readiness_path: input.readinessPath || routePath,
171
+ readiness_timeout: input.readinessTimeoutSec || 90,
172
+ wait_until: input.waitUntil || "domcontentloaded",
173
+ wait_for_selector: input.waitForSelector || "body",
174
+ navigation_timeout: input.navigationTimeoutSec || 60,
175
+ viewport: input.viewport,
176
+ timeout: timeoutSec,
177
+ script: input.script
178
+ })
179
+ });
180
+ const jobId = String(created.job_id || "");
181
+ const uploadUrl = String(created.upload_url || "");
182
+ if (!jobId || !uploadUrl) {
183
+ throw new Error(`Riddle server preview create response was missing job_id or upload_url.`);
184
+ }
185
+ const { scratch, tarball } = createTarball(input.directory, jobId, [
186
+ ".git",
187
+ "node_modules",
188
+ "test-results",
189
+ ...input.exclude || []
190
+ ]);
191
+ try {
192
+ const upload = await fetchFor(config)(uploadUrl, {
193
+ method: "PUT",
194
+ headers: { "Content-Type": "application/gzip" },
195
+ body: (0, import_node_fs.readFileSync)(tarball)
196
+ });
197
+ if (!upload.ok) throw new RiddleApiError(uploadUrl, upload.status, await upload.text());
198
+ } finally {
199
+ (0, import_node_fs.rmSync)(scratch, { recursive: true, force: true });
200
+ }
201
+ await riddleRequestJson(config, `/v1/server-preview/${jobId}/start`, {
202
+ method: "POST"
203
+ });
204
+ let job = null;
205
+ const attempts = input.pollAttempts || Math.ceil((timeoutSec + 90) / 2);
206
+ const intervalMs = input.pollIntervalMs || 2e3;
207
+ for (let index = 0; index < attempts; index += 1) {
208
+ job = await riddleRequestJson(config, `/v1/server-preview/${jobId}`);
209
+ if (isTerminalRiddleJobStatus(job.status)) break;
210
+ if (index + 1 < attempts) await new Promise((resolve) => setTimeout(resolve, intervalMs));
211
+ }
212
+ const status = job?.status ? String(job.status) : null;
213
+ const scriptError = scriptErrorFrom(job);
214
+ return {
215
+ ok: (status === "completed" || status === "complete") && !scriptError,
216
+ job_id: jobId,
217
+ status,
218
+ terminal: isTerminalRiddleJobStatus(status),
219
+ script_error: scriptError,
220
+ job
221
+ };
222
+ }
140
223
  async function runRiddleScript(config, input) {
141
224
  if (!input.url?.trim()) throw new Error("url is required");
142
225
  if (!input.script?.trim()) throw new Error("script is required");
@@ -188,6 +271,7 @@ function createRiddleApiClient(config = {}) {
188
271
  requestJson: (pathname, init) => riddleRequestJson(config, pathname, init),
189
272
  deployStaticPreview: (directory, label) => deployRiddleStaticPreview(config, directory, label),
190
273
  runScript: (input) => runRiddleScript(config, input),
274
+ runServerPreview: (input) => runRiddleServerPreview(config, input),
191
275
  pollJob: (jobId, options) => pollRiddleJob(config, jobId, options)
192
276
  };
193
277
  }
@@ -203,5 +287,6 @@ function createRiddleApiClient(config = {}) {
203
287
  pollRiddleJob,
204
288
  resolveRiddleApiKey,
205
289
  riddleRequestJson,
206
- runRiddleScript
290
+ runRiddleScript,
291
+ runRiddleServerPreview
207
292
  });
@@ -29,6 +29,27 @@ interface RiddleRunScriptInput {
29
29
  include?: string[];
30
30
  options?: Record<string, unknown>;
31
31
  }
32
+ interface RiddleServerPreviewInput {
33
+ directory: string;
34
+ script: string;
35
+ image?: string;
36
+ command?: string;
37
+ port?: number;
38
+ path?: string;
39
+ readinessPath?: string;
40
+ readinessTimeoutSec?: number;
41
+ waitForSelector?: string;
42
+ waitUntil?: "commit" | "domcontentloaded" | "load" | "networkidle";
43
+ navigationTimeoutSec?: number;
44
+ viewport?: {
45
+ width: number;
46
+ height: number;
47
+ };
48
+ timeoutSec?: number;
49
+ pollAttempts?: number;
50
+ pollIntervalMs?: number;
51
+ exclude?: string[];
52
+ }
32
53
  interface RiddlePollJobResult {
33
54
  ok: boolean;
34
55
  job_id: string;
@@ -37,6 +58,14 @@ interface RiddlePollJobResult {
37
58
  job: Record<string, unknown> | null;
38
59
  artifacts?: Record<string, unknown> | null;
39
60
  }
61
+ interface RiddleServerPreviewResult {
62
+ ok: boolean;
63
+ job_id: string;
64
+ status: string | null;
65
+ terminal: boolean;
66
+ script_error: string | null;
67
+ job: Record<string, unknown> | null;
68
+ }
40
69
  declare class RiddleApiError extends Error {
41
70
  readonly status: number;
42
71
  readonly body: string;
@@ -50,6 +79,7 @@ declare function parseRiddleViewport(value?: string): {
50
79
  width: number;
51
80
  height: number;
52
81
  } | undefined;
82
+ declare function runRiddleServerPreview(config: RiddleClientConfig, input: RiddleServerPreviewInput): Promise<RiddleServerPreviewResult>;
53
83
  declare function runRiddleScript(config: RiddleClientConfig, input: RiddleRunScriptInput): Promise<Record<string, unknown>>;
54
84
  declare function isTerminalRiddleJobStatus(status: unknown): boolean;
55
85
  declare function pollRiddleJob(config: RiddleClientConfig, jobId: string, options?: {
@@ -61,6 +91,7 @@ declare function createRiddleApiClient(config?: RiddleClientConfig): {
61
91
  requestJson: <T = unknown>(pathname: string, init?: RequestInit) => Promise<T>;
62
92
  deployStaticPreview: (directory: string, label: string) => Promise<RiddlePreviewDeployResult>;
63
93
  runScript: (input: RiddleRunScriptInput) => Promise<Record<string, unknown>>;
94
+ runServerPreview: (input: RiddleServerPreviewInput) => Promise<RiddleServerPreviewResult>;
64
95
  pollJob: (jobId: string, options?: {
65
96
  wait?: boolean;
66
97
  attempts?: number;
@@ -68,4 +99,4 @@ declare function createRiddleApiClient(config?: RiddleClientConfig): {
68
99
  }) => Promise<RiddlePollJobResult>;
69
100
  };
70
101
 
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 };
102
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, type RiddleClientConfig, type RiddleFetch, type RiddlePollJobResult, type RiddlePreviewDeployResult, type RiddleRunScriptInput, type RiddleServerPreviewInput, type RiddleServerPreviewResult, createRiddleApiClient, deployRiddleStaticPreview, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, riddleRequestJson, runRiddleScript, runRiddleServerPreview };
@@ -29,6 +29,27 @@ interface RiddleRunScriptInput {
29
29
  include?: string[];
30
30
  options?: Record<string, unknown>;
31
31
  }
32
+ interface RiddleServerPreviewInput {
33
+ directory: string;
34
+ script: string;
35
+ image?: string;
36
+ command?: string;
37
+ port?: number;
38
+ path?: string;
39
+ readinessPath?: string;
40
+ readinessTimeoutSec?: number;
41
+ waitForSelector?: string;
42
+ waitUntil?: "commit" | "domcontentloaded" | "load" | "networkidle";
43
+ navigationTimeoutSec?: number;
44
+ viewport?: {
45
+ width: number;
46
+ height: number;
47
+ };
48
+ timeoutSec?: number;
49
+ pollAttempts?: number;
50
+ pollIntervalMs?: number;
51
+ exclude?: string[];
52
+ }
32
53
  interface RiddlePollJobResult {
33
54
  ok: boolean;
34
55
  job_id: string;
@@ -37,6 +58,14 @@ interface RiddlePollJobResult {
37
58
  job: Record<string, unknown> | null;
38
59
  artifacts?: Record<string, unknown> | null;
39
60
  }
61
+ interface RiddleServerPreviewResult {
62
+ ok: boolean;
63
+ job_id: string;
64
+ status: string | null;
65
+ terminal: boolean;
66
+ script_error: string | null;
67
+ job: Record<string, unknown> | null;
68
+ }
40
69
  declare class RiddleApiError extends Error {
41
70
  readonly status: number;
42
71
  readonly body: string;
@@ -50,6 +79,7 @@ declare function parseRiddleViewport(value?: string): {
50
79
  width: number;
51
80
  height: number;
52
81
  } | undefined;
82
+ declare function runRiddleServerPreview(config: RiddleClientConfig, input: RiddleServerPreviewInput): Promise<RiddleServerPreviewResult>;
53
83
  declare function runRiddleScript(config: RiddleClientConfig, input: RiddleRunScriptInput): Promise<Record<string, unknown>>;
54
84
  declare function isTerminalRiddleJobStatus(status: unknown): boolean;
55
85
  declare function pollRiddleJob(config: RiddleClientConfig, jobId: string, options?: {
@@ -61,6 +91,7 @@ declare function createRiddleApiClient(config?: RiddleClientConfig): {
61
91
  requestJson: <T = unknown>(pathname: string, init?: RequestInit) => Promise<T>;
62
92
  deployStaticPreview: (directory: string, label: string) => Promise<RiddlePreviewDeployResult>;
63
93
  runScript: (input: RiddleRunScriptInput) => Promise<Record<string, unknown>>;
94
+ runServerPreview: (input: RiddleServerPreviewInput) => Promise<RiddleServerPreviewResult>;
64
95
  pollJob: (jobId: string, options?: {
65
96
  wait?: boolean;
66
97
  attempts?: number;
@@ -68,4 +99,4 @@ declare function createRiddleApiClient(config?: RiddleClientConfig): {
68
99
  }) => Promise<RiddlePollJobResult>;
69
100
  };
70
101
 
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 };
102
+ export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, type RiddleClientConfig, type RiddleFetch, type RiddlePollJobResult, type RiddlePreviewDeployResult, type RiddleRunScriptInput, type RiddleServerPreviewInput, type RiddleServerPreviewResult, createRiddleApiClient, deployRiddleStaticPreview, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, riddleRequestJson, runRiddleScript, runRiddleServerPreview };
@@ -9,8 +9,9 @@ import {
9
9
  pollRiddleJob,
10
10
  resolveRiddleApiKey,
11
11
  riddleRequestJson,
12
- runRiddleScript
13
- } from "./chunk-UR6ADV4Y.js";
12
+ runRiddleScript,
13
+ runRiddleServerPreview
14
+ } from "./chunk-3CVGVQTQ.js";
14
15
  export {
15
16
  DEFAULT_RIDDLE_API_BASE_URL,
16
17
  DEFAULT_RIDDLE_API_KEY_FILE,
@@ -22,5 +23,6 @@ export {
22
23
  pollRiddleJob,
23
24
  resolveRiddleApiKey,
24
25
  riddleRequestJson,
25
- runRiddleScript
26
+ runRiddleScript,
27
+ runRiddleServerPreview
26
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.5.55",
3
+ "version": "0.5.57",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",