@riddledc/riddle-proof 0.5.45 → 0.5.47

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