@riddledc/riddle-proof 0.5.44 → 0.5.46
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 +17 -0
- package/dist/checkpoint.cjs +366 -0
- package/dist/checkpoint.d.cts +44 -1
- package/dist/checkpoint.d.ts +44 -1
- package/dist/checkpoint.js +8 -2
- package/dist/{chunk-W7VTDN4T.js → chunk-DUFDZJOF.js} +1 -0
- package/dist/{chunk-7S7O3NKF.js → chunk-JTNMEH57.js} +6 -1
- package/dist/{chunk-MRSYJMF4.js → chunk-L26NTZOU.js} +2 -2
- package/dist/chunk-NOBFZDZG.js +754 -0
- package/dist/chunk-PLSGW2GI.js +161 -0
- package/dist/chunk-R6SCWJCI.js +656 -0
- package/dist/{chunk-MJD37CLH.js → chunk-X3AQ2WUM.js} +201 -18
- package/dist/cli.cjs +6129 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +160 -0
- package/dist/codex-exec-agent.cjs +790 -0
- package/dist/codex-exec-agent.d.cts +91 -0
- package/dist/codex-exec-agent.d.ts +91 -0
- package/dist/codex-exec-agent.js +10 -0
- package/dist/engine-harness.cjs +1013 -323
- package/dist/engine-harness.js +5 -4
- package/dist/index.cjs +1702 -247
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +37 -17
- package/dist/openclaw.js +4 -2
- package/dist/proof-run-engine.d.cts +3 -3
- package/dist/proof-run-engine.d.ts +3 -3
- package/dist/result.cjs +1 -0
- package/dist/result.js +1 -1
- package/dist/run-card.cjs +212 -0
- package/dist/run-card.d.cts +10 -0
- package/dist/run-card.d.ts +10 -0
- package/dist/run-card.js +10 -0
- package/dist/runner.cjs +2 -0
- package/dist/runner.js +5 -3
- package/dist/state.cjs +174 -5
- package/dist/state.d.cts +2 -1
- package/dist/state.d.ts +2 -1
- package/dist/state.js +4 -2
- package/dist/types.d.cts +64 -2
- package/dist/types.d.ts +64 -2
- package/package.json +15 -2
- package/dist/chunk-RI25RGQP.js +0 -293
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
createCodexExecAgentAdapter,
|
|
4
|
+
runCodexExecAgentDoctor
|
|
5
|
+
} from "./chunk-NOBFZDZG.js";
|
|
6
|
+
import {
|
|
7
|
+
createDisabledRiddleProofAgentAdapter,
|
|
8
|
+
readRiddleProofRunStatus,
|
|
9
|
+
runRiddleProofEngineHarness
|
|
10
|
+
} from "./chunk-X3AQ2WUM.js";
|
|
11
|
+
import "./chunk-4ASMX4R6.js";
|
|
12
|
+
import "./chunk-JTNMEH57.js";
|
|
13
|
+
import "./chunk-PLSGW2GI.js";
|
|
14
|
+
import "./chunk-R6SCWJCI.js";
|
|
15
|
+
import "./chunk-DUFDZJOF.js";
|
|
16
|
+
|
|
17
|
+
// src/cli.ts
|
|
18
|
+
import { existsSync, readFileSync } from "fs";
|
|
19
|
+
function usage() {
|
|
20
|
+
return [
|
|
21
|
+
"Usage:",
|
|
22
|
+
" riddle-proof-loop run --request-json <file|json|-> [--agent disabled|codex_exec] [--checkpoint-mode yield|auto]",
|
|
23
|
+
" riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
|
|
24
|
+
" riddle-proof-loop status --state-path <path>",
|
|
25
|
+
" riddle-proof-loop doctor codex_exec [--codex-command <path>]",
|
|
26
|
+
"",
|
|
27
|
+
"The default CLI run mode is checkpoint-mode=yield unless --agent codex_exec is used."
|
|
28
|
+
].join("\n");
|
|
29
|
+
}
|
|
30
|
+
function parseArgs(argv) {
|
|
31
|
+
const positional = [];
|
|
32
|
+
const options = {};
|
|
33
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
34
|
+
const arg = argv[index];
|
|
35
|
+
if (!arg.startsWith("--")) {
|
|
36
|
+
positional.push(arg);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const key = arg.slice(2).replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
40
|
+
const next = argv[index + 1];
|
|
41
|
+
if (!next || next.startsWith("--")) {
|
|
42
|
+
options[key] = true;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
options[key] = next;
|
|
46
|
+
index += 1;
|
|
47
|
+
}
|
|
48
|
+
return { positional, options };
|
|
49
|
+
}
|
|
50
|
+
function optionString(options, key) {
|
|
51
|
+
const value = options[key];
|
|
52
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
53
|
+
}
|
|
54
|
+
function readStdin() {
|
|
55
|
+
return readFileSync(0, "utf-8");
|
|
56
|
+
}
|
|
57
|
+
function readJsonValue(value, label) {
|
|
58
|
+
if (!value) throw new Error(`${label} is required.`);
|
|
59
|
+
const raw = value === "-" ? readStdin() : existsSync(value) ? readFileSync(value, "utf-8") : value;
|
|
60
|
+
const parsed = JSON.parse(raw);
|
|
61
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
62
|
+
throw new Error(`${label} must be a JSON object.`);
|
|
63
|
+
}
|
|
64
|
+
return parsed;
|
|
65
|
+
}
|
|
66
|
+
function readRunState(statePath) {
|
|
67
|
+
const parsed = readJsonValue(statePath, "--state-path");
|
|
68
|
+
if (parsed.version !== "riddle-proof.run-state.v1" || !Array.isArray(parsed.events)) {
|
|
69
|
+
throw new Error(`${statePath} is not a riddle-proof.run-state.v1 file.`);
|
|
70
|
+
}
|
|
71
|
+
return parsed;
|
|
72
|
+
}
|
|
73
|
+
function codexConfig(options) {
|
|
74
|
+
const codexFullAuto = optionString(options, "codexFullAuto");
|
|
75
|
+
return {
|
|
76
|
+
codexCommand: optionString(options, "codexCommand"),
|
|
77
|
+
codexHome: optionString(options, "codexHome"),
|
|
78
|
+
codexModel: optionString(options, "codexModel"),
|
|
79
|
+
codexTimeoutMs: optionString(options, "codexTimeoutMs") ? Number(optionString(options, "codexTimeoutMs")) : void 0,
|
|
80
|
+
codexSandbox: optionString(options, "codexSandbox"),
|
|
81
|
+
codexFullAuto: codexFullAuto === "false" ? false : void 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function agentFor(options) {
|
|
85
|
+
const agentMode = optionString(options, "agent") || "disabled";
|
|
86
|
+
if (agentMode === "codex_exec") return createCodexExecAgentAdapter(codexConfig(options));
|
|
87
|
+
if (agentMode === "disabled") return createDisabledRiddleProofAgentAdapter();
|
|
88
|
+
throw new Error(`Unsupported --agent ${agentMode}. Use disabled or codex_exec.`);
|
|
89
|
+
}
|
|
90
|
+
function requestForRun(options) {
|
|
91
|
+
const statePath = optionString(options, "statePath");
|
|
92
|
+
if (optionString(options, "requestJson")) {
|
|
93
|
+
return readJsonValue(optionString(options, "requestJson"), "--request-json");
|
|
94
|
+
}
|
|
95
|
+
if (statePath) return readRunState(statePath).request;
|
|
96
|
+
throw new Error("--request-json is required unless --state-path points to an existing run state.");
|
|
97
|
+
}
|
|
98
|
+
function checkpointModeFor(options) {
|
|
99
|
+
const explicit = optionString(options, "checkpointMode");
|
|
100
|
+
if (explicit) return explicit;
|
|
101
|
+
return optionString(options, "agent") === "codex_exec" ? "auto" : "yield";
|
|
102
|
+
}
|
|
103
|
+
async function main() {
|
|
104
|
+
const { positional, options } = parseArgs(process.argv.slice(2));
|
|
105
|
+
const command = positional[0];
|
|
106
|
+
if (!command || command === "help" || command === "--help") {
|
|
107
|
+
process.stdout.write(`${usage()}
|
|
108
|
+
`);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (command === "doctor") {
|
|
112
|
+
const subject = positional[1];
|
|
113
|
+
if (subject !== "codex_exec") throw new Error("Only `doctor codex_exec` is supported.");
|
|
114
|
+
const result = await runCodexExecAgentDoctor(codexConfig(options));
|
|
115
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
116
|
+
`);
|
|
117
|
+
process.exitCode = result.ok ? 0 : 1;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (command === "status") {
|
|
121
|
+
const statePath = optionString(options, "statePath");
|
|
122
|
+
if (!statePath) throw new Error("--state-path is required.");
|
|
123
|
+
const snapshot = readRiddleProofRunStatus(statePath);
|
|
124
|
+
if (!snapshot) throw new Error(`${statePath} is not a readable Riddle Proof run state.`);
|
|
125
|
+
process.stdout.write(`${JSON.stringify(snapshot, null, 2)}
|
|
126
|
+
`);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (command === "run" || command === "respond") {
|
|
130
|
+
const statePath = optionString(options, "statePath");
|
|
131
|
+
const request = requestForRun(options);
|
|
132
|
+
const response = command === "respond" ? readJsonValue(optionString(options, "responseJson"), "--response-json") : void 0;
|
|
133
|
+
const result = await runRiddleProofEngineHarness({
|
|
134
|
+
request,
|
|
135
|
+
state_path: statePath,
|
|
136
|
+
checkpoint_response: response,
|
|
137
|
+
checkpoint_mode: checkpointModeFor(options),
|
|
138
|
+
checkpoint_visibility: optionString(options, "checkpointVisibility") || "manual",
|
|
139
|
+
max_iterations: optionString(options, "maxIterations") ? Number(optionString(options, "maxIterations")) : void 0,
|
|
140
|
+
agent: agentFor(options),
|
|
141
|
+
config: {
|
|
142
|
+
stateDir: optionString(options, "stateDir"),
|
|
143
|
+
riddleProofDir: optionString(options, "riddleProofDir"),
|
|
144
|
+
defaultReviewer: optionString(options, "defaultReviewer"),
|
|
145
|
+
defaultShipMode: optionString(options, "defaultShipMode")
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
149
|
+
`);
|
|
150
|
+
process.exitCode = result.ok || result.status === "awaiting_checkpoint" ? 0 : 1;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
throw new Error(`Unknown command: ${command}
|
|
154
|
+
${usage()}`);
|
|
155
|
+
}
|
|
156
|
+
main().catch((error) => {
|
|
157
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
158
|
+
`);
|
|
159
|
+
process.exitCode = 1;
|
|
160
|
+
});
|