@riddledc/riddle-proof 0.5.52 → 0.5.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/checkpoint.cjs +2 -2
- package/dist/checkpoint.js +1 -1
- package/dist/{chunk-T5RHGGQ2.js → chunk-33XO42CY.js} +2 -2
- package/dist/{chunk-53UPEUVU.js → chunk-3UHWI3FO.js} +1 -1
- package/dist/{chunk-KYGWIA7A.js → chunk-A2AWRZ5B.js} +4 -4
- package/dist/{chunk-PVUZZ2P6.js → chunk-MO24D3PY.js} +2 -1
- package/dist/{chunk-4ASMX4R6.js → chunk-RFJ5BQF6.js} +1 -0
- package/dist/{chunk-QBOKV3ES.js → chunk-RXFKKYWA.js} +1 -1
- package/dist/chunk-UR6ADV4Y.js +163 -0
- package/dist/cli.cjs +289 -13
- package/dist/cli.js +137 -9
- package/dist/engine-harness.cjs +4 -2
- package/dist/engine-harness.js +5 -5
- package/dist/index.cjs +179 -5
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +30 -6
- package/dist/openclaw.cjs +1 -0
- package/dist/openclaw.js +3 -3
- package/dist/proof-run-core.cjs +1 -0
- package/dist/proof-run-core.d.cts +1 -1
- package/dist/proof-run-core.d.ts +1 -1
- package/dist/proof-run-core.js +1 -1
- package/dist/proof-run-engine.cjs +1 -0
- package/dist/proof-run-engine.js +1 -1
- package/dist/riddle-client.cjs +207 -0
- package/dist/riddle-client.d.cts +71 -0
- package/dist/riddle-client.d.ts +71 -0
- package/dist/riddle-client.js +26 -0
- package/dist/run-card.js +2 -2
- package/dist/runner.cjs +1 -0
- package/dist/runner.js +4 -4
- package/dist/state.cjs +1 -0
- package/dist/state.js +3 -3
- package/dist/types.d.cts +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +7 -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
|
|
1411
|
-
cleanup.fetch =
|
|
1412
|
-
if (
|
|
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
|
|
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(
|
|
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,15 +6398,168 @@ 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 [
|
|
6402
6554
|
"Usage:",
|
|
6403
6555
|
" riddle-proof-loop run --request-json <file|json|-> [--agent disabled|local] [--checkpoint-mode yield|auto]",
|
|
6404
|
-
" riddle-proof-loop checkpoint --state-path <path> [--decision <decision>]",
|
|
6556
|
+
" riddle-proof-loop checkpoint --state-path <path> [--decision <decision>] [--format json|markdown]",
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
}
|
|
@@ -6474,6 +6629,65 @@ function hasPlaceholderValue(value) {
|
|
|
6474
6629
|
}
|
|
6475
6630
|
return false;
|
|
6476
6631
|
}
|
|
6632
|
+
function markdownJson(value) {
|
|
6633
|
+
return JSON.stringify(value ?? null, null, 2);
|
|
6634
|
+
}
|
|
6635
|
+
function formatCheckpointMarkdown(input) {
|
|
6636
|
+
const packet = input.checkpointPacket;
|
|
6637
|
+
const runCard = input.runCard;
|
|
6638
|
+
const lines = [
|
|
6639
|
+
"# Riddle Proof Checkpoint",
|
|
6640
|
+
"",
|
|
6641
|
+
`Run: ${packet.run_id}`,
|
|
6642
|
+
`State: ${input.statePath}`,
|
|
6643
|
+
`Status: ${input.status || "awaiting_checkpoint"}`,
|
|
6644
|
+
`Stage: ${packet.stage}`,
|
|
6645
|
+
`Checkpoint: ${packet.checkpoint}`,
|
|
6646
|
+
`Kind: ${packet.kind}`,
|
|
6647
|
+
"",
|
|
6648
|
+
"## Goal",
|
|
6649
|
+
"",
|
|
6650
|
+
runCard?.goal?.change_request || packet.change_request,
|
|
6651
|
+
"",
|
|
6652
|
+
"## Next Action",
|
|
6653
|
+
"",
|
|
6654
|
+
packet.question,
|
|
6655
|
+
"",
|
|
6656
|
+
"## Allowed Decisions",
|
|
6657
|
+
"",
|
|
6658
|
+
...packet.allowed_decisions.map((decision) => `- ${decision}`),
|
|
6659
|
+
""
|
|
6660
|
+
];
|
|
6661
|
+
if (packet.artifacts?.length) {
|
|
6662
|
+
lines.push("## Artifacts", "");
|
|
6663
|
+
for (const artifact of packet.artifacts) {
|
|
6664
|
+
lines.push(`- ${artifact.role}: ${artifact.url || artifact.path || artifact.name || "available"}`);
|
|
6665
|
+
}
|
|
6666
|
+
lines.push("");
|
|
6667
|
+
}
|
|
6668
|
+
if (packet.evidence_excerpt && Object.keys(packet.evidence_excerpt).length) {
|
|
6669
|
+
lines.push("## Evidence Excerpt", "", "```json", markdownJson(packet.evidence_excerpt), "```", "");
|
|
6670
|
+
}
|
|
6671
|
+
if (packet.state_excerpt && Object.keys(packet.state_excerpt).length) {
|
|
6672
|
+
lines.push("## State Excerpt", "", "```json", markdownJson(packet.state_excerpt), "```", "");
|
|
6673
|
+
}
|
|
6674
|
+
lines.push(
|
|
6675
|
+
"## Response Template",
|
|
6676
|
+
"",
|
|
6677
|
+
"```json",
|
|
6678
|
+
markdownJson(input.responseTemplate),
|
|
6679
|
+
"```",
|
|
6680
|
+
"",
|
|
6681
|
+
"## Next Command",
|
|
6682
|
+
"",
|
|
6683
|
+
"```sh",
|
|
6684
|
+
`riddle-proof-loop respond --state-path ${input.statePath} --decision ${input.responseTemplate.decision} --summary <summary> --payload-json <file|json|->`,
|
|
6685
|
+
"```",
|
|
6686
|
+
""
|
|
6687
|
+
);
|
|
6688
|
+
return `${lines.join("\n")}
|
|
6689
|
+
`;
|
|
6690
|
+
}
|
|
6477
6691
|
function checkpointResponseForFlags(statePath, options) {
|
|
6478
6692
|
const state = readRunState(statePath);
|
|
6479
6693
|
if (!state.checkpoint_packet) {
|
|
@@ -6526,14 +6740,28 @@ function agentFor(options) {
|
|
|
6526
6740
|
if (agentMode === "disabled") return createDisabledRiddleProofAgentAdapter();
|
|
6527
6741
|
throw new Error(`Unsupported --agent ${agentMode}. Use disabled or local.`);
|
|
6528
6742
|
}
|
|
6743
|
+
function riddleClientConfig(options) {
|
|
6744
|
+
return {
|
|
6745
|
+
apiKey: optionString(options, "apiKey"),
|
|
6746
|
+
apiKeyFile: optionString(options, "apiKeyFile"),
|
|
6747
|
+
apiBaseUrl: optionString(options, "apiBaseUrl")
|
|
6748
|
+
};
|
|
6749
|
+
}
|
|
6529
6750
|
function requestForRun(options) {
|
|
6530
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
|
+
};
|
|
6531
6756
|
if (optionString(options, "requestJson")) {
|
|
6532
|
-
return readJsonValue(optionString(options, "requestJson"), "--request-json");
|
|
6757
|
+
return withEngineModuleUrl(readJsonValue(optionString(options, "requestJson"), "--request-json"));
|
|
6533
6758
|
}
|
|
6534
|
-
if (statePath) return readRunState(statePath).request;
|
|
6759
|
+
if (statePath) return withEngineModuleUrl(readRunState(statePath).request);
|
|
6535
6760
|
throw new Error("--request-json is required unless --state-path points to an existing run state.");
|
|
6536
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
|
+
}
|
|
6537
6765
|
function checkpointModeFor(options) {
|
|
6538
6766
|
const explicit = optionString(options, "checkpointMode");
|
|
6539
6767
|
if (explicit) return explicit;
|
|
@@ -6565,6 +6793,42 @@ async function main() {
|
|
|
6565
6793
|
`);
|
|
6566
6794
|
return;
|
|
6567
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
|
+
}
|
|
6568
6832
|
if (command === "checkpoint") {
|
|
6569
6833
|
const statePath = optionString(options, "statePath");
|
|
6570
6834
|
if (!statePath) throw new Error("--state-path is required.");
|
|
@@ -6577,6 +6841,18 @@ async function main() {
|
|
|
6577
6841
|
decision: optionString(options, "decision"),
|
|
6578
6842
|
source_kind: optionString(options, "sourceKind") || "codex"
|
|
6579
6843
|
});
|
|
6844
|
+
const format = optionString(options, "format") || "json";
|
|
6845
|
+
if (format === "markdown" || format === "md") {
|
|
6846
|
+
process.stdout.write(formatCheckpointMarkdown({
|
|
6847
|
+
statePath,
|
|
6848
|
+
status: snapshot?.status || state.status,
|
|
6849
|
+
checkpointPacket: state.checkpoint_packet,
|
|
6850
|
+
runCard: snapshot?.run_card || state.run_card || null,
|
|
6851
|
+
responseTemplate
|
|
6852
|
+
}));
|
|
6853
|
+
return;
|
|
6854
|
+
}
|
|
6855
|
+
if (format !== "json") throw new Error("--format must be json or markdown.");
|
|
6580
6856
|
process.stdout.write(`${JSON.stringify({
|
|
6581
6857
|
checkpoint_packet: state.checkpoint_packet,
|
|
6582
6858
|
run_card: snapshot?.run_card || state.run_card || null,
|
|
@@ -6603,7 +6879,7 @@ async function main() {
|
|
|
6603
6879
|
agent: agentFor(options),
|
|
6604
6880
|
config: {
|
|
6605
6881
|
stateDir: optionString(options, "stateDir"),
|
|
6606
|
-
riddleEngineModuleUrl:
|
|
6882
|
+
riddleEngineModuleUrl: riddleEngineModuleUrlFor(options, request),
|
|
6607
6883
|
riddleProofDir: optionString(options, "riddleProofDir"),
|
|
6608
6884
|
defaultReviewer: optionString(options, "defaultReviewer"),
|
|
6609
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-
|
|
7
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-A2AWRZ5B.js";
|
|
11
|
+
import "./chunk-RFJ5BQF6.js";
|
|
8
12
|
import "./chunk-JFQXAJH2.js";
|
|
9
13
|
import {
|
|
10
14
|
createCodexExecAgentAdapter,
|
|
11
15
|
runCodexExecAgentDoctor
|
|
12
16
|
} from "./chunk-3266V3MO.js";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-MO24D3PY.js";
|
|
18
|
+
import "./chunk-3UHWI3FO.js";
|
|
15
19
|
import {
|
|
16
20
|
createCheckpointResponseTemplate
|
|
17
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-33XO42CY.js";
|
|
18
22
|
import "./chunk-DUFDZJOF.js";
|
|
19
23
|
|
|
20
24
|
// src/cli.ts
|
|
@@ -23,10 +27,13 @@ function usage() {
|
|
|
23
27
|
return [
|
|
24
28
|
"Usage:",
|
|
25
29
|
" riddle-proof-loop run --request-json <file|json|-> [--agent disabled|local] [--checkpoint-mode yield|auto]",
|
|
26
|
-
" riddle-proof-loop checkpoint --state-path <path> [--decision <decision>]",
|
|
30
|
+
" riddle-proof-loop checkpoint --state-path <path> [--decision <decision>] [--format json|markdown]",
|
|
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.",
|
|
@@ -96,6 +103,65 @@ function hasPlaceholderValue(value) {
|
|
|
96
103
|
}
|
|
97
104
|
return false;
|
|
98
105
|
}
|
|
106
|
+
function markdownJson(value) {
|
|
107
|
+
return JSON.stringify(value ?? null, null, 2);
|
|
108
|
+
}
|
|
109
|
+
function formatCheckpointMarkdown(input) {
|
|
110
|
+
const packet = input.checkpointPacket;
|
|
111
|
+
const runCard = input.runCard;
|
|
112
|
+
const lines = [
|
|
113
|
+
"# Riddle Proof Checkpoint",
|
|
114
|
+
"",
|
|
115
|
+
`Run: ${packet.run_id}`,
|
|
116
|
+
`State: ${input.statePath}`,
|
|
117
|
+
`Status: ${input.status || "awaiting_checkpoint"}`,
|
|
118
|
+
`Stage: ${packet.stage}`,
|
|
119
|
+
`Checkpoint: ${packet.checkpoint}`,
|
|
120
|
+
`Kind: ${packet.kind}`,
|
|
121
|
+
"",
|
|
122
|
+
"## Goal",
|
|
123
|
+
"",
|
|
124
|
+
runCard?.goal?.change_request || packet.change_request,
|
|
125
|
+
"",
|
|
126
|
+
"## Next Action",
|
|
127
|
+
"",
|
|
128
|
+
packet.question,
|
|
129
|
+
"",
|
|
130
|
+
"## Allowed Decisions",
|
|
131
|
+
"",
|
|
132
|
+
...packet.allowed_decisions.map((decision) => `- ${decision}`),
|
|
133
|
+
""
|
|
134
|
+
];
|
|
135
|
+
if (packet.artifacts?.length) {
|
|
136
|
+
lines.push("## Artifacts", "");
|
|
137
|
+
for (const artifact of packet.artifacts) {
|
|
138
|
+
lines.push(`- ${artifact.role}: ${artifact.url || artifact.path || artifact.name || "available"}`);
|
|
139
|
+
}
|
|
140
|
+
lines.push("");
|
|
141
|
+
}
|
|
142
|
+
if (packet.evidence_excerpt && Object.keys(packet.evidence_excerpt).length) {
|
|
143
|
+
lines.push("## Evidence Excerpt", "", "```json", markdownJson(packet.evidence_excerpt), "```", "");
|
|
144
|
+
}
|
|
145
|
+
if (packet.state_excerpt && Object.keys(packet.state_excerpt).length) {
|
|
146
|
+
lines.push("## State Excerpt", "", "```json", markdownJson(packet.state_excerpt), "```", "");
|
|
147
|
+
}
|
|
148
|
+
lines.push(
|
|
149
|
+
"## Response Template",
|
|
150
|
+
"",
|
|
151
|
+
"```json",
|
|
152
|
+
markdownJson(input.responseTemplate),
|
|
153
|
+
"```",
|
|
154
|
+
"",
|
|
155
|
+
"## Next Command",
|
|
156
|
+
"",
|
|
157
|
+
"```sh",
|
|
158
|
+
`riddle-proof-loop respond --state-path ${input.statePath} --decision ${input.responseTemplate.decision} --summary <summary> --payload-json <file|json|->`,
|
|
159
|
+
"```",
|
|
160
|
+
""
|
|
161
|
+
);
|
|
162
|
+
return `${lines.join("\n")}
|
|
163
|
+
`;
|
|
164
|
+
}
|
|
99
165
|
function checkpointResponseForFlags(statePath, options) {
|
|
100
166
|
const state = readRunState(statePath);
|
|
101
167
|
if (!state.checkpoint_packet) {
|
|
@@ -148,14 +214,28 @@ function agentFor(options) {
|
|
|
148
214
|
if (agentMode === "disabled") return createDisabledRiddleProofAgentAdapter();
|
|
149
215
|
throw new Error(`Unsupported --agent ${agentMode}. Use disabled or local.`);
|
|
150
216
|
}
|
|
217
|
+
function riddleClientConfig(options) {
|
|
218
|
+
return {
|
|
219
|
+
apiKey: optionString(options, "apiKey"),
|
|
220
|
+
apiKeyFile: optionString(options, "apiKeyFile"),
|
|
221
|
+
apiBaseUrl: optionString(options, "apiBaseUrl")
|
|
222
|
+
};
|
|
223
|
+
}
|
|
151
224
|
function requestForRun(options) {
|
|
152
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
|
+
};
|
|
153
230
|
if (optionString(options, "requestJson")) {
|
|
154
|
-
return readJsonValue(optionString(options, "requestJson"), "--request-json");
|
|
231
|
+
return withEngineModuleUrl(readJsonValue(optionString(options, "requestJson"), "--request-json"));
|
|
155
232
|
}
|
|
156
|
-
if (statePath) return readRunState(statePath).request;
|
|
233
|
+
if (statePath) return withEngineModuleUrl(readRunState(statePath).request);
|
|
157
234
|
throw new Error("--request-json is required unless --state-path points to an existing run state.");
|
|
158
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
|
+
}
|
|
159
239
|
function checkpointModeFor(options) {
|
|
160
240
|
const explicit = optionString(options, "checkpointMode");
|
|
161
241
|
if (explicit) return explicit;
|
|
@@ -187,6 +267,42 @@ async function main() {
|
|
|
187
267
|
`);
|
|
188
268
|
return;
|
|
189
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
|
+
}
|
|
190
306
|
if (command === "checkpoint") {
|
|
191
307
|
const statePath = optionString(options, "statePath");
|
|
192
308
|
if (!statePath) throw new Error("--state-path is required.");
|
|
@@ -199,6 +315,18 @@ async function main() {
|
|
|
199
315
|
decision: optionString(options, "decision"),
|
|
200
316
|
source_kind: optionString(options, "sourceKind") || "codex"
|
|
201
317
|
});
|
|
318
|
+
const format = optionString(options, "format") || "json";
|
|
319
|
+
if (format === "markdown" || format === "md") {
|
|
320
|
+
process.stdout.write(formatCheckpointMarkdown({
|
|
321
|
+
statePath,
|
|
322
|
+
status: snapshot?.status || state.status,
|
|
323
|
+
checkpointPacket: state.checkpoint_packet,
|
|
324
|
+
runCard: snapshot?.run_card || state.run_card || null,
|
|
325
|
+
responseTemplate
|
|
326
|
+
}));
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (format !== "json") throw new Error("--format must be json or markdown.");
|
|
202
330
|
process.stdout.write(`${JSON.stringify({
|
|
203
331
|
checkpoint_packet: state.checkpoint_packet,
|
|
204
332
|
run_card: snapshot?.run_card || state.run_card || null,
|
|
@@ -225,7 +353,7 @@ async function main() {
|
|
|
225
353
|
agent: agentFor(options),
|
|
226
354
|
config: {
|
|
227
355
|
stateDir: optionString(options, "stateDir"),
|
|
228
|
-
riddleEngineModuleUrl:
|
|
356
|
+
riddleEngineModuleUrl: riddleEngineModuleUrlFor(options, request),
|
|
229
357
|
riddleProofDir: optionString(options, "riddleProofDir"),
|
|
230
358
|
defaultReviewer: optionString(options, "defaultReviewer"),
|
|
231
359
|
defaultShipMode: optionString(options, "defaultShipMode")
|
package/dist/engine-harness.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 = {}) {
|
|
@@ -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(
|
|
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,
|
package/dist/engine-harness.js
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
createDisabledRiddleProofAgentAdapter,
|
|
3
3
|
readRiddleProofRunStatus,
|
|
4
4
|
runRiddleProofEngineHarness
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-A2AWRZ5B.js";
|
|
6
|
+
import "./chunk-RFJ5BQF6.js";
|
|
7
|
+
import "./chunk-MO24D3PY.js";
|
|
8
|
+
import "./chunk-3UHWI3FO.js";
|
|
9
|
+
import "./chunk-33XO42CY.js";
|
|
10
10
|
import "./chunk-DUFDZJOF.js";
|
|
11
11
|
export {
|
|
12
12
|
createDisabledRiddleProofAgentAdapter,
|