@riddledc/riddle-proof 0.5.46 → 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.
- package/README.md +6 -1
- package/dist/{chunk-X3AQ2WUM.js → chunk-ALP5KOS2.js} +1 -1
- package/dist/chunk-JFQXAJH2.js +0 -0
- package/dist/{chunk-JTNMEH57.js → chunk-JOXTKWX6.js} +1 -1
- package/dist/{chunk-L26NTZOU.js → chunk-N3ZNBRIG.js} +1 -1
- package/dist/cli.cjs +13 -8
- package/dist/cli.js +19 -13
- package/dist/engine-harness.cjs +1 -1
- package/dist/engine-harness.js +2 -2
- package/dist/index.cjs +7 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -16
- package/dist/local-agent.cjs +792 -0
- package/dist/local-agent.d.cts +3 -0
- package/dist/local-agent.d.ts +3 -0
- package/dist/local-agent.js +11 -0
- package/dist/openclaw.js +1 -1
- package/dist/runner.js +2 -2
- package/dist/state.cjs +1 -1
- package/dist/state.js +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -63,9 +63,10 @@ Codex/CLI-style testing:
|
|
|
63
63
|
|
|
64
64
|
```sh
|
|
65
65
|
riddle-proof-loop run --request-json request.json --checkpoint-mode yield
|
|
66
|
+
riddle-proof-loop run --request-json request.json --agent local
|
|
66
67
|
riddle-proof-loop status --state-path /tmp/riddle-proof-run.json
|
|
67
68
|
riddle-proof-loop respond --state-path /tmp/riddle-proof-run.json --response-json response.json
|
|
68
|
-
riddle-proof-loop doctor
|
|
69
|
+
riddle-proof-loop doctor local
|
|
69
70
|
```
|
|
70
71
|
|
|
71
72
|
In yield mode, the harness returns portable checkpoint packets for recon,
|
|
@@ -73,6 +74,10 @@ authoring, implementation, proof assessment, and evidence recovery. A host can
|
|
|
73
74
|
answer those packets with `riddle-proof.checkpoint_response.v1` JSON without
|
|
74
75
|
needing OpenClaw-specific proof semantics.
|
|
75
76
|
|
|
77
|
+
`--agent local` is the generic CLI executor slot. The current implementation
|
|
78
|
+
uses the local Codex CLI adapter underneath, but the loop contract and CLI
|
|
79
|
+
surface are intentionally not Codex-specific.
|
|
80
|
+
|
|
76
81
|
## Runner Harness
|
|
77
82
|
|
|
78
83
|
`runRiddleProof` is the reusable idea-to-PR workflow driver. It does not ship
|
|
File without changes
|
|
@@ -213,7 +213,7 @@ function createRunStatusSnapshot(state, at = timestamp()) {
|
|
|
213
213
|
checkpoint_summary: state.checkpoint_summary,
|
|
214
214
|
state_paths: state.state_paths,
|
|
215
215
|
proof_contract: state.proof_contract,
|
|
216
|
-
run_card: createRiddleProofRunCard(state, { at }),
|
|
216
|
+
run_card: state.run_card || createRiddleProofRunCard(state, { at }),
|
|
217
217
|
latest_event: latestEvent
|
|
218
218
|
});
|
|
219
219
|
}
|
package/dist/cli.cjs
CHANGED
|
@@ -3931,7 +3931,7 @@ function createRunStatusSnapshot(state, at = timestamp2()) {
|
|
|
3931
3931
|
checkpoint_summary: state.checkpoint_summary,
|
|
3932
3932
|
state_paths: state.state_paths,
|
|
3933
3933
|
proof_contract: state.proof_contract,
|
|
3934
|
-
run_card: createRiddleProofRunCard(state, { at }),
|
|
3934
|
+
run_card: state.run_card || createRiddleProofRunCard(state, { at }),
|
|
3935
3935
|
latest_event: latestEvent
|
|
3936
3936
|
});
|
|
3937
3937
|
}
|
|
@@ -5988,12 +5988,13 @@ async function runCodexExecAgentDoctor(config = {}, runner = createCodexExecJson
|
|
|
5988
5988
|
function usage() {
|
|
5989
5989
|
return [
|
|
5990
5990
|
"Usage:",
|
|
5991
|
-
" riddle-proof-loop run --request-json <file|json|-> [--agent disabled|
|
|
5991
|
+
" riddle-proof-loop run --request-json <file|json|-> [--agent disabled|local] [--checkpoint-mode yield|auto]",
|
|
5992
5992
|
" riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
|
|
5993
5993
|
" riddle-proof-loop status --state-path <path>",
|
|
5994
|
-
" riddle-proof-loop doctor
|
|
5994
|
+
" riddle-proof-loop doctor local [--codex-command <path>]",
|
|
5995
5995
|
"",
|
|
5996
|
-
"The default CLI run mode is checkpoint-mode=yield unless --agent
|
|
5996
|
+
"The default CLI run mode is checkpoint-mode=yield unless --agent local is used.",
|
|
5997
|
+
"Compatibility aliases: --agent codex_exec and doctor codex_exec."
|
|
5997
5998
|
].join("\n");
|
|
5998
5999
|
}
|
|
5999
6000
|
function parseArgs(argv) {
|
|
@@ -6050,11 +6051,14 @@ function codexConfig(options) {
|
|
|
6050
6051
|
codexFullAuto: codexFullAuto === "false" ? false : void 0
|
|
6051
6052
|
};
|
|
6052
6053
|
}
|
|
6054
|
+
function isLocalAgentMode(value) {
|
|
6055
|
+
return value === "local" || value === "local_exec" || value === "codex_exec";
|
|
6056
|
+
}
|
|
6053
6057
|
function agentFor(options) {
|
|
6054
6058
|
const agentMode = optionString(options, "agent") || "disabled";
|
|
6055
|
-
if (agentMode
|
|
6059
|
+
if (isLocalAgentMode(agentMode)) return createCodexExecAgentAdapter(codexConfig(options));
|
|
6056
6060
|
if (agentMode === "disabled") return createDisabledRiddleProofAgentAdapter();
|
|
6057
|
-
throw new Error(`Unsupported --agent ${agentMode}. Use disabled or
|
|
6061
|
+
throw new Error(`Unsupported --agent ${agentMode}. Use disabled or local.`);
|
|
6058
6062
|
}
|
|
6059
6063
|
function requestForRun(options) {
|
|
6060
6064
|
const statePath = optionString(options, "statePath");
|
|
@@ -6067,7 +6071,7 @@ function requestForRun(options) {
|
|
|
6067
6071
|
function checkpointModeFor(options) {
|
|
6068
6072
|
const explicit = optionString(options, "checkpointMode");
|
|
6069
6073
|
if (explicit) return explicit;
|
|
6070
|
-
return optionString(options, "agent")
|
|
6074
|
+
return isLocalAgentMode(optionString(options, "agent")) ? "auto" : "yield";
|
|
6071
6075
|
}
|
|
6072
6076
|
async function main() {
|
|
6073
6077
|
const { positional, options } = parseArgs(process.argv.slice(2));
|
|
@@ -6079,7 +6083,7 @@ async function main() {
|
|
|
6079
6083
|
}
|
|
6080
6084
|
if (command === "doctor") {
|
|
6081
6085
|
const subject = positional[1];
|
|
6082
|
-
if (subject
|
|
6086
|
+
if (!isLocalAgentMode(subject)) throw new Error("Only `doctor local` is supported.");
|
|
6083
6087
|
const result = await runCodexExecAgentDoctor(codexConfig(options));
|
|
6084
6088
|
process.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
6085
6089
|
`);
|
|
@@ -6109,6 +6113,7 @@ async function main() {
|
|
|
6109
6113
|
agent: agentFor(options),
|
|
6110
6114
|
config: {
|
|
6111
6115
|
stateDir: optionString(options, "stateDir"),
|
|
6116
|
+
riddleEngineModuleUrl: optionString(options, "riddleEngineModuleUrl"),
|
|
6112
6117
|
riddleProofDir: optionString(options, "riddleProofDir"),
|
|
6113
6118
|
defaultReviewer: optionString(options, "defaultReviewer"),
|
|
6114
6119
|
defaultShipMode: optionString(options, "defaultShipMode")
|
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
createCodexExecAgentAdapter,
|
|
4
|
-
runCodexExecAgentDoctor
|
|
5
|
-
} from "./chunk-NOBFZDZG.js";
|
|
6
2
|
import {
|
|
7
3
|
createDisabledRiddleProofAgentAdapter,
|
|
8
4
|
readRiddleProofRunStatus,
|
|
9
5
|
runRiddleProofEngineHarness
|
|
10
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ALP5KOS2.js";
|
|
11
7
|
import "./chunk-4ASMX4R6.js";
|
|
12
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-JFQXAJH2.js";
|
|
9
|
+
import {
|
|
10
|
+
createCodexExecAgentAdapter,
|
|
11
|
+
runCodexExecAgentDoctor
|
|
12
|
+
} from "./chunk-NOBFZDZG.js";
|
|
13
|
+
import "./chunk-JOXTKWX6.js";
|
|
13
14
|
import "./chunk-PLSGW2GI.js";
|
|
14
15
|
import "./chunk-R6SCWJCI.js";
|
|
15
16
|
import "./chunk-DUFDZJOF.js";
|
|
@@ -19,12 +20,13 @@ import { existsSync, readFileSync } from "fs";
|
|
|
19
20
|
function usage() {
|
|
20
21
|
return [
|
|
21
22
|
"Usage:",
|
|
22
|
-
" riddle-proof-loop run --request-json <file|json|-> [--agent disabled|
|
|
23
|
+
" riddle-proof-loop run --request-json <file|json|-> [--agent disabled|local] [--checkpoint-mode yield|auto]",
|
|
23
24
|
" riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
|
|
24
25
|
" riddle-proof-loop status --state-path <path>",
|
|
25
|
-
" riddle-proof-loop doctor
|
|
26
|
+
" riddle-proof-loop doctor local [--codex-command <path>]",
|
|
26
27
|
"",
|
|
27
|
-
"The default CLI run mode is checkpoint-mode=yield unless --agent
|
|
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."
|
|
28
30
|
].join("\n");
|
|
29
31
|
}
|
|
30
32
|
function parseArgs(argv) {
|
|
@@ -81,11 +83,14 @@ function codexConfig(options) {
|
|
|
81
83
|
codexFullAuto: codexFullAuto === "false" ? false : void 0
|
|
82
84
|
};
|
|
83
85
|
}
|
|
86
|
+
function isLocalAgentMode(value) {
|
|
87
|
+
return value === "local" || value === "local_exec" || value === "codex_exec";
|
|
88
|
+
}
|
|
84
89
|
function agentFor(options) {
|
|
85
90
|
const agentMode = optionString(options, "agent") || "disabled";
|
|
86
|
-
if (agentMode
|
|
91
|
+
if (isLocalAgentMode(agentMode)) return createCodexExecAgentAdapter(codexConfig(options));
|
|
87
92
|
if (agentMode === "disabled") return createDisabledRiddleProofAgentAdapter();
|
|
88
|
-
throw new Error(`Unsupported --agent ${agentMode}. Use disabled or
|
|
93
|
+
throw new Error(`Unsupported --agent ${agentMode}. Use disabled or local.`);
|
|
89
94
|
}
|
|
90
95
|
function requestForRun(options) {
|
|
91
96
|
const statePath = optionString(options, "statePath");
|
|
@@ -98,7 +103,7 @@ function requestForRun(options) {
|
|
|
98
103
|
function checkpointModeFor(options) {
|
|
99
104
|
const explicit = optionString(options, "checkpointMode");
|
|
100
105
|
if (explicit) return explicit;
|
|
101
|
-
return optionString(options, "agent")
|
|
106
|
+
return isLocalAgentMode(optionString(options, "agent")) ? "auto" : "yield";
|
|
102
107
|
}
|
|
103
108
|
async function main() {
|
|
104
109
|
const { positional, options } = parseArgs(process.argv.slice(2));
|
|
@@ -110,7 +115,7 @@ async function main() {
|
|
|
110
115
|
}
|
|
111
116
|
if (command === "doctor") {
|
|
112
117
|
const subject = positional[1];
|
|
113
|
-
if (subject
|
|
118
|
+
if (!isLocalAgentMode(subject)) throw new Error("Only `doctor local` is supported.");
|
|
114
119
|
const result = await runCodexExecAgentDoctor(codexConfig(options));
|
|
115
120
|
process.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
116
121
|
`);
|
|
@@ -140,6 +145,7 @@ async function main() {
|
|
|
140
145
|
agent: agentFor(options),
|
|
141
146
|
config: {
|
|
142
147
|
stateDir: optionString(options, "stateDir"),
|
|
148
|
+
riddleEngineModuleUrl: optionString(options, "riddleEngineModuleUrl"),
|
|
143
149
|
riddleProofDir: optionString(options, "riddleProofDir"),
|
|
144
150
|
defaultReviewer: optionString(options, "defaultReviewer"),
|
|
145
151
|
defaultShipMode: optionString(options, "defaultShipMode")
|
package/dist/engine-harness.cjs
CHANGED
|
@@ -3935,7 +3935,7 @@ function createRunStatusSnapshot(state, at = timestamp2()) {
|
|
|
3935
3935
|
checkpoint_summary: state.checkpoint_summary,
|
|
3936
3936
|
state_paths: state.state_paths,
|
|
3937
3937
|
proof_contract: state.proof_contract,
|
|
3938
|
-
run_card: createRiddleProofRunCard(state, { at }),
|
|
3938
|
+
run_card: state.run_card || createRiddleProofRunCard(state, { at }),
|
|
3939
3939
|
latest_event: latestEvent
|
|
3940
3940
|
});
|
|
3941
3941
|
}
|
package/dist/engine-harness.js
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
createDisabledRiddleProofAgentAdapter,
|
|
3
3
|
readRiddleProofRunStatus,
|
|
4
4
|
runRiddleProofEngineHarness
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ALP5KOS2.js";
|
|
6
6
|
import "./chunk-4ASMX4R6.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-JOXTKWX6.js";
|
|
8
8
|
import "./chunk-PLSGW2GI.js";
|
|
9
9
|
import "./chunk-R6SCWJCI.js";
|
|
10
10
|
import "./chunk-DUFDZJOF.js";
|
package/dist/index.cjs
CHANGED
|
@@ -2785,6 +2785,8 @@ __export(index_exports, {
|
|
|
2785
2785
|
createCodexExecAgentAdapter: () => createCodexExecAgentAdapter,
|
|
2786
2786
|
createCodexExecJsonRunner: () => createCodexExecJsonRunner,
|
|
2787
2787
|
createDisabledRiddleProofAgentAdapter: () => createDisabledRiddleProofAgentAdapter,
|
|
2788
|
+
createLocalAgentAdapter: () => createCodexExecAgentAdapter,
|
|
2789
|
+
createLocalAgentJsonRunner: () => createCodexExecJsonRunner,
|
|
2788
2790
|
createRiddleProofRunCard: () => createRiddleProofRunCard,
|
|
2789
2791
|
createRunResult: () => createRunResult,
|
|
2790
2792
|
createRunState: () => createRunState,
|
|
@@ -2806,6 +2808,7 @@ __export(index_exports, {
|
|
|
2806
2808
|
recordValue: () => recordValue,
|
|
2807
2809
|
redactForProofDiagnostics: () => redactForProofDiagnostics,
|
|
2808
2810
|
runCodexExecAgentDoctor: () => runCodexExecAgentDoctor,
|
|
2811
|
+
runLocalAgentDoctor: () => runCodexExecAgentDoctor,
|
|
2809
2812
|
runRiddleProof: () => runRiddleProof,
|
|
2810
2813
|
runRiddleProofEngineHarness: () => runRiddleProofEngineHarness,
|
|
2811
2814
|
setRunStatus: () => setRunStatus,
|
|
@@ -4018,7 +4021,7 @@ function createRunStatusSnapshot(state, at = timestamp2()) {
|
|
|
4018
4021
|
checkpoint_summary: state.checkpoint_summary,
|
|
4019
4022
|
state_paths: state.state_paths,
|
|
4020
4023
|
proof_contract: state.proof_contract,
|
|
4021
|
-
run_card: createRiddleProofRunCard(state, { at }),
|
|
4024
|
+
run_card: state.run_card || createRiddleProofRunCard(state, { at }),
|
|
4022
4025
|
latest_event: latestEvent
|
|
4023
4026
|
});
|
|
4024
4027
|
}
|
|
@@ -7215,6 +7218,8 @@ function parseJson(value) {
|
|
|
7215
7218
|
createCodexExecAgentAdapter,
|
|
7216
7219
|
createCodexExecJsonRunner,
|
|
7217
7220
|
createDisabledRiddleProofAgentAdapter,
|
|
7221
|
+
createLocalAgentAdapter,
|
|
7222
|
+
createLocalAgentJsonRunner,
|
|
7218
7223
|
createRiddleProofRunCard,
|
|
7219
7224
|
createRunResult,
|
|
7220
7225
|
createRunState,
|
|
@@ -7236,6 +7241,7 @@ function parseJson(value) {
|
|
|
7236
7241
|
recordValue,
|
|
7237
7242
|
redactForProofDiagnostics,
|
|
7238
7243
|
runCodexExecAgentDoctor,
|
|
7244
|
+
runLocalAgentDoctor,
|
|
7239
7245
|
runRiddleProof,
|
|
7240
7246
|
runRiddleProofEngineHarness,
|
|
7241
7247
|
setRunStatus,
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONS
|
|
|
5
5
|
export { RIDDLE_PROOF_RUN_CARD_VERSION, createRiddleProofRunCard } from './run-card.cjs';
|
|
6
6
|
export { RiddleProofRunnerAdapters, RunRiddleProofInput, runRiddleProof } from './runner.cjs';
|
|
7
7
|
export { RiddleProofAgentAdapter, RiddleProofAgentPayload, RiddleProofCheckpointMode, RiddleProofEngine, RiddleProofEngineHarnessConfig, RiddleProofEngineHarnessContext, RiddleProofEngineResult, RiddleProofShipMode, RiddleProofWorkflowParams, RunRiddleProofEngineHarnessInput, createDisabledRiddleProofAgentAdapter, readRiddleProofRunStatus, runRiddleProofEngineHarness } from './engine-harness.cjs';
|
|
8
|
-
export { CodexExecAgentConfig, CodexJsonRequest, CodexJsonResult, CodexJsonRunner, createCodexExecAgentAdapter, createCodexExecJsonRunner, runCodexExecAgentDoctor } from './codex-exec-agent.cjs';
|
|
8
|
+
export { CodexExecAgentConfig, CodexJsonRequest, CodexJsonResult, CodexJsonRunner, CodexExecAgentConfig as LocalAgentConfig, CodexJsonRequest as LocalAgentJsonRequest, CodexJsonResult as LocalAgentJsonResult, CodexJsonRunner as LocalAgentJsonRunner, createCodexExecAgentAdapter, createCodexExecJsonRunner, createCodexExecAgentAdapter as createLocalAgentAdapter, createCodexExecJsonRunner as createLocalAgentJsonRunner, runCodexExecAgentDoctor, runCodexExecAgentDoctor as runLocalAgentDoctor } from './codex-exec-agent.cjs';
|
|
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';
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONS
|
|
|
5
5
|
export { RIDDLE_PROOF_RUN_CARD_VERSION, createRiddleProofRunCard } from './run-card.js';
|
|
6
6
|
export { RiddleProofRunnerAdapters, RunRiddleProofInput, runRiddleProof } from './runner.js';
|
|
7
7
|
export { RiddleProofAgentAdapter, RiddleProofAgentPayload, RiddleProofCheckpointMode, RiddleProofEngine, RiddleProofEngineHarnessConfig, RiddleProofEngineHarnessContext, RiddleProofEngineResult, RiddleProofShipMode, RiddleProofWorkflowParams, RunRiddleProofEngineHarnessInput, createDisabledRiddleProofAgentAdapter, readRiddleProofRunStatus, runRiddleProofEngineHarness } from './engine-harness.js';
|
|
8
|
-
export { CodexExecAgentConfig, CodexJsonRequest, CodexJsonResult, CodexJsonRunner, createCodexExecAgentAdapter, createCodexExecJsonRunner, runCodexExecAgentDoctor } from './codex-exec-agent.js';
|
|
8
|
+
export { CodexExecAgentConfig, CodexJsonRequest, CodexJsonResult, CodexJsonRunner, CodexExecAgentConfig as LocalAgentConfig, CodexJsonRequest as LocalAgentJsonRequest, CodexJsonResult as LocalAgentJsonResult, CodexJsonRunner as LocalAgentJsonRunner, createCodexExecAgentAdapter, createCodexExecJsonRunner, createCodexExecAgentAdapter as createLocalAgentAdapter, createCodexExecJsonRunner as createLocalAgentJsonRunner, runCodexExecAgentDoctor, runCodexExecAgentDoctor as runLocalAgentDoctor } from './codex-exec-agent.js';
|
|
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';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import "./chunk-6F4PWJZI.js";
|
|
2
|
+
import {
|
|
3
|
+
RIDDLE_PROOF_PLAYABILITY_ASSESSMENT_VERSION,
|
|
4
|
+
RIDDLE_PROOF_PLAYABILITY_VERSION,
|
|
5
|
+
assessPlayabilityEvidence,
|
|
6
|
+
extractPlayabilityEvidence,
|
|
7
|
+
isRiddleProofPlayabilityMode
|
|
8
|
+
} from "./chunk-NSWT3VSV.js";
|
|
1
9
|
import {
|
|
2
10
|
RIDDLE_PROOF_VISUAL_SESSION_FINGERPRINT_VERSION,
|
|
3
11
|
RIDDLE_PROOF_VISUAL_SESSION_VERSION,
|
|
@@ -9,13 +17,7 @@ import {
|
|
|
9
17
|
} from "./chunk-ODORKNSO.js";
|
|
10
18
|
import {
|
|
11
19
|
runRiddleProof
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-6F4PWJZI.js";
|
|
14
|
-
import {
|
|
15
|
-
createCodexExecAgentAdapter,
|
|
16
|
-
createCodexExecJsonRunner,
|
|
17
|
-
runCodexExecAgentDoctor
|
|
18
|
-
} from "./chunk-NOBFZDZG.js";
|
|
20
|
+
} from "./chunk-N3ZNBRIG.js";
|
|
19
21
|
import {
|
|
20
22
|
DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
|
|
21
23
|
DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
|
|
@@ -30,8 +32,14 @@ import {
|
|
|
30
32
|
createDisabledRiddleProofAgentAdapter,
|
|
31
33
|
readRiddleProofRunStatus,
|
|
32
34
|
runRiddleProofEngineHarness
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-ALP5KOS2.js";
|
|
34
36
|
import "./chunk-4ASMX4R6.js";
|
|
37
|
+
import "./chunk-JFQXAJH2.js";
|
|
38
|
+
import {
|
|
39
|
+
createCodexExecAgentAdapter,
|
|
40
|
+
createCodexExecJsonRunner,
|
|
41
|
+
runCodexExecAgentDoctor
|
|
42
|
+
} from "./chunk-NOBFZDZG.js";
|
|
35
43
|
import {
|
|
36
44
|
RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
37
45
|
appendRunEvent,
|
|
@@ -43,7 +51,7 @@ import {
|
|
|
43
51
|
normalizePrLifecycleState,
|
|
44
52
|
normalizeRunParams,
|
|
45
53
|
setRunStatus
|
|
46
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-JOXTKWX6.js";
|
|
47
55
|
import {
|
|
48
56
|
RIDDLE_PROOF_RUN_CARD_VERSION,
|
|
49
57
|
createRiddleProofRunCard
|
|
@@ -73,13 +81,6 @@ import {
|
|
|
73
81
|
normalizeTerminalMetadata,
|
|
74
82
|
recordValue
|
|
75
83
|
} from "./chunk-DUFDZJOF.js";
|
|
76
|
-
import {
|
|
77
|
-
RIDDLE_PROOF_PLAYABILITY_ASSESSMENT_VERSION,
|
|
78
|
-
RIDDLE_PROOF_PLAYABILITY_VERSION,
|
|
79
|
-
assessPlayabilityEvidence,
|
|
80
|
-
extractPlayabilityEvidence,
|
|
81
|
-
isRiddleProofPlayabilityMode
|
|
82
|
-
} from "./chunk-NSWT3VSV.js";
|
|
83
84
|
export {
|
|
84
85
|
DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
|
|
85
86
|
DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
|
|
@@ -113,6 +114,8 @@ export {
|
|
|
113
114
|
createCodexExecAgentAdapter,
|
|
114
115
|
createCodexExecJsonRunner,
|
|
115
116
|
createDisabledRiddleProofAgentAdapter,
|
|
117
|
+
createCodexExecAgentAdapter as createLocalAgentAdapter,
|
|
118
|
+
createCodexExecJsonRunner as createLocalAgentJsonRunner,
|
|
116
119
|
createRiddleProofRunCard,
|
|
117
120
|
createRunResult,
|
|
118
121
|
createRunState,
|
|
@@ -134,6 +137,7 @@ export {
|
|
|
134
137
|
recordValue,
|
|
135
138
|
redactForProofDiagnostics,
|
|
136
139
|
runCodexExecAgentDoctor,
|
|
140
|
+
runCodexExecAgentDoctor as runLocalAgentDoctor,
|
|
137
141
|
runRiddleProof,
|
|
138
142
|
runRiddleProofEngineHarness,
|
|
139
143
|
setRunStatus,
|
|
@@ -0,0 +1,792 @@
|
|
|
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/local-agent.ts
|
|
31
|
+
var local_agent_exports = {};
|
|
32
|
+
__export(local_agent_exports, {
|
|
33
|
+
createLocalAgentAdapter: () => createCodexExecAgentAdapter,
|
|
34
|
+
createLocalAgentJsonRunner: () => createCodexExecJsonRunner,
|
|
35
|
+
runLocalAgentDoctor: () => runCodexExecAgentDoctor
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(local_agent_exports);
|
|
38
|
+
|
|
39
|
+
// src/codex-exec-agent.ts
|
|
40
|
+
var import_node_child_process = require("child_process");
|
|
41
|
+
var import_node_fs = require("fs");
|
|
42
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
43
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
44
|
+
var REFINED_INPUTS_SCHEMA = {
|
|
45
|
+
type: "object",
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
required: ["server_path", "wait_for_selector", "reference"],
|
|
48
|
+
properties: {
|
|
49
|
+
server_path: { type: ["string", "null"] },
|
|
50
|
+
wait_for_selector: { type: ["string", "null"] },
|
|
51
|
+
reference: { enum: ["before", "prod", "both", null] }
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var BASELINE_UNDERSTANDING_SCHEMA = {
|
|
55
|
+
type: "object",
|
|
56
|
+
additionalProperties: false,
|
|
57
|
+
required: [
|
|
58
|
+
"reference",
|
|
59
|
+
"target_route",
|
|
60
|
+
"before_evidence_url",
|
|
61
|
+
"visible_before_state",
|
|
62
|
+
"relevant_elements",
|
|
63
|
+
"requested_change",
|
|
64
|
+
"proof_focus",
|
|
65
|
+
"stop_condition",
|
|
66
|
+
"quality_risks"
|
|
67
|
+
],
|
|
68
|
+
properties: {
|
|
69
|
+
reference: { type: "string", enum: ["before", "prod", "both", "unknown"] },
|
|
70
|
+
target_route: { type: "string" },
|
|
71
|
+
before_evidence_url: { type: "string" },
|
|
72
|
+
visible_before_state: { type: "string" },
|
|
73
|
+
relevant_elements: { type: "array", items: { type: "string" } },
|
|
74
|
+
requested_change: { type: "string" },
|
|
75
|
+
proof_focus: { type: "string" },
|
|
76
|
+
stop_condition: { type: "string" },
|
|
77
|
+
quality_risks: { type: "array", items: { type: "string" } }
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var RECON_SCHEMA = {
|
|
81
|
+
type: "object",
|
|
82
|
+
additionalProperties: false,
|
|
83
|
+
required: [
|
|
84
|
+
"decision",
|
|
85
|
+
"summary",
|
|
86
|
+
"baseline_understanding",
|
|
87
|
+
"continue_with_stage",
|
|
88
|
+
"escalation_target",
|
|
89
|
+
"refined_inputs",
|
|
90
|
+
"reasons",
|
|
91
|
+
"source"
|
|
92
|
+
],
|
|
93
|
+
properties: {
|
|
94
|
+
decision: { type: "string", enum: ["retry_recon", "ready_for_author", "recon_stuck"] },
|
|
95
|
+
summary: { type: "string" },
|
|
96
|
+
baseline_understanding: BASELINE_UNDERSTANDING_SCHEMA,
|
|
97
|
+
continue_with_stage: { type: "string", enum: ["recon", "author"] },
|
|
98
|
+
escalation_target: { type: "string", enum: ["agent", "human"] },
|
|
99
|
+
refined_inputs: REFINED_INPUTS_SCHEMA,
|
|
100
|
+
reasons: { type: "array", items: { type: "string" } },
|
|
101
|
+
source: { type: "string", enum: ["supervising_agent"] }
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var AUTHOR_SCHEMA = {
|
|
105
|
+
type: "object",
|
|
106
|
+
additionalProperties: false,
|
|
107
|
+
required: [
|
|
108
|
+
"proof_plan",
|
|
109
|
+
"capture_script",
|
|
110
|
+
"baseline_understanding_used",
|
|
111
|
+
"refined_inputs",
|
|
112
|
+
"rationale",
|
|
113
|
+
"confidence",
|
|
114
|
+
"summary"
|
|
115
|
+
],
|
|
116
|
+
properties: {
|
|
117
|
+
proof_plan: { type: "string" },
|
|
118
|
+
capture_script: { type: "string" },
|
|
119
|
+
baseline_understanding_used: BASELINE_UNDERSTANDING_SCHEMA,
|
|
120
|
+
refined_inputs: REFINED_INPUTS_SCHEMA,
|
|
121
|
+
rationale: { type: "array", items: { type: "string" } },
|
|
122
|
+
confidence: { type: "string", enum: ["low", "medium", "high"] },
|
|
123
|
+
summary: { type: "string" }
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var IMPLEMENT_SCHEMA = {
|
|
127
|
+
type: "object",
|
|
128
|
+
additionalProperties: false,
|
|
129
|
+
required: ["summary", "implementation_notes", "changed_files", "tests_run", "blockers"],
|
|
130
|
+
properties: {
|
|
131
|
+
summary: { type: "string" },
|
|
132
|
+
implementation_notes: { type: "string" },
|
|
133
|
+
changed_files: { type: "array", items: { type: "string" } },
|
|
134
|
+
tests_run: { type: "array", items: { type: "string" } },
|
|
135
|
+
blockers: { type: "array", items: { type: "string" } }
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var PROOF_SCHEMA = {
|
|
139
|
+
type: "object",
|
|
140
|
+
additionalProperties: false,
|
|
141
|
+
required: [
|
|
142
|
+
"decision",
|
|
143
|
+
"summary",
|
|
144
|
+
"recommended_stage",
|
|
145
|
+
"continue_with_stage",
|
|
146
|
+
"escalation_target",
|
|
147
|
+
"reasons",
|
|
148
|
+
"source"
|
|
149
|
+
],
|
|
150
|
+
properties: {
|
|
151
|
+
decision: {
|
|
152
|
+
type: "string",
|
|
153
|
+
enum: [
|
|
154
|
+
"ready_to_ship",
|
|
155
|
+
"needs_richer_proof",
|
|
156
|
+
"revise_capture",
|
|
157
|
+
"needs_recon",
|
|
158
|
+
"needs_implementation"
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
summary: { type: "string" },
|
|
162
|
+
recommended_stage: { type: "string", enum: ["ship", "author", "implement", "recon", "verify"] },
|
|
163
|
+
continue_with_stage: { type: "string", enum: ["ship", "author", "implement", "recon", "verify"] },
|
|
164
|
+
escalation_target: { type: "string", enum: ["agent", "human"] },
|
|
165
|
+
reasons: { type: "array", items: { type: "string" } },
|
|
166
|
+
source: { type: "string", enum: ["supervising_agent"] }
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var PROMPT_STRING_LIMIT = 2e3;
|
|
170
|
+
var PROMPT_ARRAY_LIMIT = 12;
|
|
171
|
+
var PROMPT_OBJECT_KEY_LIMIT = 70;
|
|
172
|
+
var PROMPT_BLOCK_LIMIT = 12e4;
|
|
173
|
+
var PROMPT_KEY_PRIORITY = [
|
|
174
|
+
"ok",
|
|
175
|
+
"status",
|
|
176
|
+
"stage",
|
|
177
|
+
"checkpoint",
|
|
178
|
+
"summary",
|
|
179
|
+
"state_path",
|
|
180
|
+
"repo",
|
|
181
|
+
"branch",
|
|
182
|
+
"change_request",
|
|
183
|
+
"context",
|
|
184
|
+
"success_criteria",
|
|
185
|
+
"verification_mode",
|
|
186
|
+
"reference",
|
|
187
|
+
"server_path",
|
|
188
|
+
"wait_for_selector",
|
|
189
|
+
"before_cdn",
|
|
190
|
+
"prod_cdn",
|
|
191
|
+
"after_cdn",
|
|
192
|
+
"before_baseline",
|
|
193
|
+
"prod_baseline",
|
|
194
|
+
"recon_assessment",
|
|
195
|
+
"baseline_understanding",
|
|
196
|
+
"supervisor_author_packet",
|
|
197
|
+
"proof_plan",
|
|
198
|
+
"capture_script",
|
|
199
|
+
"implementation_status",
|
|
200
|
+
"implementation_summary",
|
|
201
|
+
"implementation_notes",
|
|
202
|
+
"changed_files",
|
|
203
|
+
"verify_status",
|
|
204
|
+
"verify_summary",
|
|
205
|
+
"proof_assessment",
|
|
206
|
+
"proof_assessment_request",
|
|
207
|
+
"semantic_context",
|
|
208
|
+
"visual_delta",
|
|
209
|
+
"proof_evidence_present",
|
|
210
|
+
"proof_evidence_sample",
|
|
211
|
+
"artifacts",
|
|
212
|
+
"assertions",
|
|
213
|
+
"checkpointContract",
|
|
214
|
+
"shipGate",
|
|
215
|
+
"last_error",
|
|
216
|
+
"errors",
|
|
217
|
+
"events"
|
|
218
|
+
];
|
|
219
|
+
var PROMPT_PRIORITY_INDEX = new Map(PROMPT_KEY_PRIORITY.map((key, index) => [key, index]));
|
|
220
|
+
function truncatePromptString(value, limit = PROMPT_STRING_LIMIT) {
|
|
221
|
+
if (value.length <= limit) return value;
|
|
222
|
+
return `${value.slice(0, limit)}
|
|
223
|
+
...[truncated ${value.length - limit} chars]`;
|
|
224
|
+
}
|
|
225
|
+
function compactPromptValue(value, depth = 0, key = "") {
|
|
226
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") return value;
|
|
227
|
+
if (typeof value === "string") {
|
|
228
|
+
const lowerKey = key.toLowerCase();
|
|
229
|
+
const looksLikeUrl = /^https?:\/\//.test(value);
|
|
230
|
+
if (!looksLikeUrl && (lowerKey.includes("base64") || lowerKey.includes("data_url") || lowerKey.includes("screenshot_blob"))) {
|
|
231
|
+
return `[omitted ${value.length} chars from ${key || "large artifact"}]`;
|
|
232
|
+
}
|
|
233
|
+
const limit = looksLikeUrl ? 1e3 : depth <= 1 ? PROMPT_STRING_LIMIT : 1200;
|
|
234
|
+
return truncatePromptString(value, limit);
|
|
235
|
+
}
|
|
236
|
+
if (Array.isArray(value)) {
|
|
237
|
+
const lowerKey = key.toLowerCase();
|
|
238
|
+
const items = lowerKey.includes("event") || lowerKey.includes("histor") || lowerKey.includes("retry") ? value.slice(-PROMPT_ARRAY_LIMIT) : value.slice(0, PROMPT_ARRAY_LIMIT);
|
|
239
|
+
const compacted = items.map((item) => compactPromptValue(item, depth + 1, key));
|
|
240
|
+
if (value.length > items.length) {
|
|
241
|
+
const omitted = value.length - items.length;
|
|
242
|
+
return lowerKey.includes("event") || lowerKey.includes("histor") || lowerKey.includes("retry") ? [{ omittedEarlierItems: omitted }, ...compacted] : [...compacted, { omittedItems: omitted }];
|
|
243
|
+
}
|
|
244
|
+
return compacted;
|
|
245
|
+
}
|
|
246
|
+
if (!value || typeof value !== "object") return String(value);
|
|
247
|
+
const entries = Object.entries(value).sort(([left], [right]) => {
|
|
248
|
+
const leftPriority = PROMPT_PRIORITY_INDEX.get(left) ?? 1e3;
|
|
249
|
+
const rightPriority = PROMPT_PRIORITY_INDEX.get(right) ?? 1e3;
|
|
250
|
+
if (leftPriority !== rightPriority) return leftPriority - rightPriority;
|
|
251
|
+
return left.localeCompare(right);
|
|
252
|
+
});
|
|
253
|
+
const result = {};
|
|
254
|
+
for (const [entryKey, entryValue] of entries.slice(0, PROMPT_OBJECT_KEY_LIMIT)) {
|
|
255
|
+
result[entryKey] = compactPromptValue(entryValue, depth + 1, entryKey);
|
|
256
|
+
}
|
|
257
|
+
if (entries.length > PROMPT_OBJECT_KEY_LIMIT) {
|
|
258
|
+
result.__omitted_keys = entries.length - PROMPT_OBJECT_KEY_LIMIT;
|
|
259
|
+
}
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
function jsonBlock(label, value) {
|
|
263
|
+
let json = JSON.stringify(compactPromptValue(value), null, 2);
|
|
264
|
+
if (json.length > PROMPT_BLOCK_LIMIT) {
|
|
265
|
+
json = `${json.slice(0, PROMPT_BLOCK_LIMIT)}
|
|
266
|
+
...[truncated ${json.length - PROMPT_BLOCK_LIMIT} chars from compacted ${label}]`;
|
|
267
|
+
}
|
|
268
|
+
return `${label}:
|
|
269
|
+
${json}`;
|
|
270
|
+
}
|
|
271
|
+
function resolveWorkdir(context, fallback = "/tmp") {
|
|
272
|
+
const after = typeof context.fullRiddleState?.after_worktree === "string" ? context.fullRiddleState.after_worktree.trim() : "";
|
|
273
|
+
return after || fallback;
|
|
274
|
+
}
|
|
275
|
+
function basePrompt(context, role) {
|
|
276
|
+
return [
|
|
277
|
+
role,
|
|
278
|
+
"",
|
|
279
|
+
"You are the supervising Codex worker inside the Riddle Proof harness.",
|
|
280
|
+
"Return only JSON matching the provided output schema.",
|
|
281
|
+
"Do not ask the human to manually continue. If blocked, encode the blocker in the JSON fields allowed by the schema.",
|
|
282
|
+
"Large raw artifacts are summarized before this prompt. Use preserved state summaries, URLs, file paths, and proof evidence samples instead of expecting full raw logs or binary artifacts inline.",
|
|
283
|
+
"",
|
|
284
|
+
jsonBlock("Original request", context.request),
|
|
285
|
+
jsonBlock("Riddle checkpoint result", context.engineResult),
|
|
286
|
+
jsonBlock("Full riddle state", context.fullRiddleState || {})
|
|
287
|
+
].join("\n");
|
|
288
|
+
}
|
|
289
|
+
function schemaRequiredKeys(schema) {
|
|
290
|
+
const required = schema?.required;
|
|
291
|
+
return Array.isArray(required) ? required.filter((key) => typeof key === "string" && key.length > 0) : [];
|
|
292
|
+
}
|
|
293
|
+
function isSchemaShapedObject(value, schema) {
|
|
294
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
295
|
+
const required = schemaRequiredKeys(schema);
|
|
296
|
+
return required.every((key) => Object.prototype.hasOwnProperty.call(value, key));
|
|
297
|
+
}
|
|
298
|
+
function parseJsonCandidate(raw, schema) {
|
|
299
|
+
try {
|
|
300
|
+
const parsed = JSON.parse(raw);
|
|
301
|
+
return isSchemaShapedObject(parsed, schema) ? parsed : null;
|
|
302
|
+
} catch {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function extractJsonObjectCandidates(raw) {
|
|
307
|
+
const candidates = [];
|
|
308
|
+
let depth = 0;
|
|
309
|
+
let start = -1;
|
|
310
|
+
let inString = false;
|
|
311
|
+
let escaped = false;
|
|
312
|
+
for (let index = 0; index < raw.length; index += 1) {
|
|
313
|
+
const char = raw[index];
|
|
314
|
+
if (inString) {
|
|
315
|
+
if (escaped) {
|
|
316
|
+
escaped = false;
|
|
317
|
+
} else if (char === "\\") {
|
|
318
|
+
escaped = true;
|
|
319
|
+
} else if (char === '"') {
|
|
320
|
+
inString = false;
|
|
321
|
+
}
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (char === '"') {
|
|
325
|
+
inString = true;
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (char === "{") {
|
|
329
|
+
if (depth === 0) start = index;
|
|
330
|
+
depth += 1;
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (char === "}" && depth > 0) {
|
|
334
|
+
depth -= 1;
|
|
335
|
+
if (depth === 0 && start >= 0) {
|
|
336
|
+
candidates.push(raw.slice(start, index + 1));
|
|
337
|
+
start = -1;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return candidates;
|
|
342
|
+
}
|
|
343
|
+
function parseJsonObject(raw, schema) {
|
|
344
|
+
const trimmed = raw.trim();
|
|
345
|
+
if (!trimmed) return null;
|
|
346
|
+
const whole = parseJsonCandidate(trimmed, schema);
|
|
347
|
+
if (whole) return whole;
|
|
348
|
+
const lines = trimmed.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
349
|
+
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
350
|
+
const parsed = parseJsonCandidate(lines[index], schema);
|
|
351
|
+
if (parsed) return parsed;
|
|
352
|
+
}
|
|
353
|
+
const candidates = extractJsonObjectCandidates(trimmed);
|
|
354
|
+
for (let index = candidates.length - 1; index >= 0; index -= 1) {
|
|
355
|
+
const parsed = parseJsonCandidate(candidates[index], schema);
|
|
356
|
+
if (parsed) return parsed;
|
|
357
|
+
}
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
function isHarnessVerificationOnlyBlocker(blocker) {
|
|
361
|
+
const text = blocker.toLowerCase();
|
|
362
|
+
return (text.includes("erofs") || text.includes("read-only file system")) && text.includes("node_modules") && (text.includes(".vite-temp") || text.includes("vite.config"));
|
|
363
|
+
}
|
|
364
|
+
function createCodexExecJsonRunner(config = {}) {
|
|
365
|
+
return (request) => {
|
|
366
|
+
if (!request.workdir || !(0, import_node_fs.existsSync)(request.workdir)) {
|
|
367
|
+
return {
|
|
368
|
+
ok: false,
|
|
369
|
+
blocker: {
|
|
370
|
+
code: "codex_workdir_missing",
|
|
371
|
+
message: `Codex workdir does not exist for ${request.purpose}.`,
|
|
372
|
+
details: { workdir: request.workdir }
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
const tmpDir = (0, import_node_fs.mkdtempSync)(import_node_path.default.join(import_node_os.default.tmpdir(), "riddle-proof-codex-"));
|
|
377
|
+
const schemaPath = import_node_path.default.join(tmpDir, "schema.json");
|
|
378
|
+
const lastMessagePath = import_node_path.default.join(tmpDir, "last-message.json");
|
|
379
|
+
(0, import_node_fs.writeFileSync)(schemaPath, JSON.stringify(request.schema, null, 2));
|
|
380
|
+
const args = [
|
|
381
|
+
"exec",
|
|
382
|
+
"--json",
|
|
383
|
+
"--output-schema",
|
|
384
|
+
schemaPath,
|
|
385
|
+
"--output-last-message",
|
|
386
|
+
lastMessagePath,
|
|
387
|
+
"--cd",
|
|
388
|
+
request.workdir,
|
|
389
|
+
"--sandbox",
|
|
390
|
+
config.codexSandbox || "workspace-write",
|
|
391
|
+
"--skip-git-repo-check"
|
|
392
|
+
];
|
|
393
|
+
if (config.codexFullAuto !== false) args.push("--full-auto");
|
|
394
|
+
if (config.codexModel) args.push("-m", config.codexModel);
|
|
395
|
+
args.push("-");
|
|
396
|
+
const env = { ...process.env };
|
|
397
|
+
if (config.codexHome) env.CODEX_HOME = config.codexHome;
|
|
398
|
+
delete env.OPENAI_API_KEY;
|
|
399
|
+
try {
|
|
400
|
+
const proc = (0, import_node_child_process.spawnSync)(config.codexCommand || "codex", args, {
|
|
401
|
+
input: request.prompt,
|
|
402
|
+
encoding: "utf-8",
|
|
403
|
+
timeout: Number(config.codexTimeoutMs || 6e5),
|
|
404
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
405
|
+
env
|
|
406
|
+
});
|
|
407
|
+
if (proc.error) {
|
|
408
|
+
const timedOut = proc.error.code === "ETIMEDOUT";
|
|
409
|
+
return {
|
|
410
|
+
ok: false,
|
|
411
|
+
stdout: proc.stdout || "",
|
|
412
|
+
stderr: proc.stderr || "",
|
|
413
|
+
blocker: {
|
|
414
|
+
code: timedOut ? "codex_timeout" : "codex_exec_error",
|
|
415
|
+
message: timedOut ? `Codex timed out during ${request.purpose}.` : `Codex failed to start or complete ${request.purpose}.`,
|
|
416
|
+
details: { error: proc.error.message }
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
if (proc.status !== 0) {
|
|
421
|
+
return {
|
|
422
|
+
ok: false,
|
|
423
|
+
stdout: proc.stdout || "",
|
|
424
|
+
stderr: proc.stderr || "",
|
|
425
|
+
blocker: {
|
|
426
|
+
code: "codex_nonzero_exit",
|
|
427
|
+
message: `Codex exited with status ${proc.status} during ${request.purpose}.`,
|
|
428
|
+
details: { stdout: proc.stdout || "", stderr: proc.stderr || "" }
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
const finalText = (0, import_node_fs.existsSync)(lastMessagePath) ? (0, import_node_fs.readFileSync)(lastMessagePath, "utf-8") : String(proc.stdout || "");
|
|
433
|
+
const parsed = parseJsonObject(finalText, request.schema);
|
|
434
|
+
if (!parsed) {
|
|
435
|
+
return {
|
|
436
|
+
ok: false,
|
|
437
|
+
stdout: proc.stdout || "",
|
|
438
|
+
stderr: proc.stderr || "",
|
|
439
|
+
blocker: {
|
|
440
|
+
code: "codex_invalid_json",
|
|
441
|
+
message: `Codex completed ${request.purpose}, but did not return valid JSON.`,
|
|
442
|
+
details: { finalText, stdout: proc.stdout || "", stderr: proc.stderr || "" }
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
return {
|
|
447
|
+
ok: true,
|
|
448
|
+
json: parsed,
|
|
449
|
+
stdout: proc.stdout || "",
|
|
450
|
+
stderr: proc.stderr || ""
|
|
451
|
+
};
|
|
452
|
+
} finally {
|
|
453
|
+
(0, import_node_fs.rmSync)(tmpDir, { recursive: true, force: true });
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
async function callRunner(runner, request) {
|
|
458
|
+
return runner(request);
|
|
459
|
+
}
|
|
460
|
+
function payloadOrBlocker(raw, checkpoint) {
|
|
461
|
+
if (!raw.ok || !raw.json) {
|
|
462
|
+
const blocker = raw.blocker || {
|
|
463
|
+
code: "codex_runner_failed",
|
|
464
|
+
message: "Codex runner failed without a detailed blocker.",
|
|
465
|
+
details: { stdout: raw.stdout || "", stderr: raw.stderr || "" }
|
|
466
|
+
};
|
|
467
|
+
return {
|
|
468
|
+
ok: false,
|
|
469
|
+
blocker: {
|
|
470
|
+
...blocker,
|
|
471
|
+
checkpoint
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
return {
|
|
476
|
+
ok: true,
|
|
477
|
+
payload: raw.json,
|
|
478
|
+
summary: typeof raw.json.summary === "string" ? raw.json.summary : void 0
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function stringArray(value) {
|
|
482
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
483
|
+
}
|
|
484
|
+
function parseGitStatusPaths(status) {
|
|
485
|
+
return status.split(/\r?\n/).map((line) => line.trimEnd()).filter(Boolean).map((line) => {
|
|
486
|
+
let item = line.length > 3 ? line.slice(3) : line;
|
|
487
|
+
if (item.includes(" -> ")) item = item.split(" -> ").pop() || item;
|
|
488
|
+
return item.trim();
|
|
489
|
+
}).filter(Boolean);
|
|
490
|
+
}
|
|
491
|
+
function isToolNoisePath(filePath) {
|
|
492
|
+
return filePath === ".codex" || filePath.startsWith(".codex/") || filePath === ".oc-smoke" || filePath.startsWith(".oc-smoke/");
|
|
493
|
+
}
|
|
494
|
+
function hasGitDiff(workdir) {
|
|
495
|
+
try {
|
|
496
|
+
const status = git(["status", "--porcelain"], workdir);
|
|
497
|
+
return parseGitStatusPaths(status).some((filePath) => !isToolNoisePath(filePath));
|
|
498
|
+
} catch {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function buildImplementationPrompt(context, extraLines = []) {
|
|
503
|
+
return [
|
|
504
|
+
basePrompt(context, "Implement the requested code change in the after worktree."),
|
|
505
|
+
"Make the code changes directly in this repository.",
|
|
506
|
+
"Use the recon-approved baseline understanding in the state to decide exactly what prior UI/state is being changed.",
|
|
507
|
+
"Run focused checks when practical.",
|
|
508
|
+
"If a focused check is blocked only by the harness sandbox writing Vite temp config into a shared/symlinked node_modules path (for example EROFS on node_modules/.vite-temp/vite.config...), do not treat that as an implementation blocker when the requested git diff exists. Record it in tests_run or implementation_notes instead so the harness can advance to its own verify stage.",
|
|
509
|
+
"Leave a real git diff in the after worktree. Do not commit or push.",
|
|
510
|
+
"Before you return success, run git status --short and git diff --name-only in this repository and verify they show the intended change.",
|
|
511
|
+
"Do not return success with empty changed_files or a clean git status. If you cannot create the requested diff, explain why in blockers instead.",
|
|
512
|
+
"changed_files should match the real git diff as closely as practical.",
|
|
513
|
+
"Return changed_files, implementation_notes, tests_run, and blockers if any.",
|
|
514
|
+
"Use empty arrays for tests_run or blockers when none apply.",
|
|
515
|
+
...extraLines
|
|
516
|
+
].join("\n");
|
|
517
|
+
}
|
|
518
|
+
function createCodexExecAgentAdapter(config = {}, runner = createCodexExecJsonRunner(config)) {
|
|
519
|
+
return {
|
|
520
|
+
async assessRecon(context) {
|
|
521
|
+
const raw = await callRunner(runner, {
|
|
522
|
+
purpose: "recon assessment",
|
|
523
|
+
workdir: resolveWorkdir(context),
|
|
524
|
+
schema: RECON_SCHEMA,
|
|
525
|
+
prompt: [
|
|
526
|
+
basePrompt(context, "Judge the latest recon packet."),
|
|
527
|
+
"Decide whether recon should retry, continue to author, or escalate to the human.",
|
|
528
|
+
"This is the first intelligent before-evidence gate. It runs before proof authoring and before any code edits.",
|
|
529
|
+
"Prefer ready_for_author only when the baseline evidence is trustworthy for the requested change.",
|
|
530
|
+
"Do not approve recon just because telemetry_ready is true or a screenshot URL exists.",
|
|
531
|
+
"Inspect the baseline evidence in the state: screenshot URLs, structured pageState details, visible_text_sample, headings, buttons, links, canvas_count, large_visible_elements, observed_path, and route candidates.",
|
|
532
|
+
"Fill baseline_understanding with concrete observations about what the before/prod evidence shows, what exact user request it anchors, what proof should focus on, and what stop condition would satisfy the request.",
|
|
533
|
+
"If you cannot write a specific baseline_understanding from the current evidence, choose retry_recon or recon_stuck; do not choose ready_for_author.",
|
|
534
|
+
"Reject blank, banner-only, app-shell-only, loading-only, generic landing, source-import path, or wrong-feature baselines; retry recon with a better server_path or selector instead.",
|
|
535
|
+
"Your summary must say what is visibly present in the approved baseline or why the current baseline is not good enough.",
|
|
536
|
+
"Always include refined_inputs; use null values for server_path, wait_for_selector, or reference when no refinement is needed."
|
|
537
|
+
].join("\n")
|
|
538
|
+
});
|
|
539
|
+
return payloadOrBlocker(raw, context.checkpoint);
|
|
540
|
+
},
|
|
541
|
+
async authorProofPacket(context) {
|
|
542
|
+
const raw = await callRunner(runner, {
|
|
543
|
+
purpose: "proof packet authoring",
|
|
544
|
+
workdir: resolveWorkdir(context),
|
|
545
|
+
schema: AUTHOR_SCHEMA,
|
|
546
|
+
prompt: [
|
|
547
|
+
basePrompt(context, "Author the proof packet."),
|
|
548
|
+
"Write a proof_plan and capture_script that will verify the exact user-facing change.",
|
|
549
|
+
"Use recon_assessment.baseline_understanding as the source of truth. Do not author a proof plan unless it names the observed before state and the requested delta from that state.",
|
|
550
|
+
"Use the recon-approved route and baseline context; make the plan name the concrete target, expected before state, expected after state, and stop condition.",
|
|
551
|
+
"Choose the evidence modality from verification_mode and success_criteria: screenshots for visual/UI proof, interactions plus screenshots for interaction proof, structured metrics/logs/JSON/audio analysis for non-visual proof.",
|
|
552
|
+
"For playable/gameplay proof, treat screenshots as supporting artifacts only: start the game, send keyboard or pointer input, measure state before/after, measure non-HUD canvas/playfield pixel deltas across time, and return playability evidence with version riddle-proof.playability.v1.",
|
|
553
|
+
"For structured proof, collect meaningful measurements inside page.evaluate and set window.__riddleProofEvidence in that browser page context to a JSON-serializable object. Screenshots are optional supporting context for data/audio/log/metric/custom modes.",
|
|
554
|
+
"Do not assign globalThis.__riddleProofEvidence, window.__riddleProofEvidence, or self.__riddleProofEvidence outside page.evaluate; the Riddle worker context may not expose those globals safely.",
|
|
555
|
+
"Do not call Playwright page.* APIs inside page.evaluate; page.evaluate runs in the browser page, while page.waitForFunction, page.waitForSelector, page.click, and saveScreenshot belong in the outer capture script.",
|
|
556
|
+
"When page.evaluate needs data from the outer Playwright script, pass exactly one serializable argument object; do not pass multiple positional arguments.",
|
|
557
|
+
"When setting Playwright wait timeouts, use the correct signature: await page.waitForFunction(fn, undefined, { timeout: 60000 }). Do not write page.waitForFunction(fn, { timeout: 60000 }); that passes the object as the page argument and leaves the default timeout in place.",
|
|
558
|
+
"For audio/data/metric proof, return and persist the same evidence object: const evidence = await page.evaluate(async () => { /* browser measurements */ window.__riddleProofEvidence = { ... }; return window.__riddleProofEvidence; }); Then assert evidence fields before saving screenshots.",
|
|
559
|
+
"If a capture attempt errors or proof_evidence is absent, revise the capture_script to make structured evidence easier to collect; do not only add more screenshots for non-visual proof.",
|
|
560
|
+
"When checking visible copy, normalize text before exact matching: const normalizedText = (document.body?.innerText || '').replace(/\\s+/g, ' ').trim(); Avoid raw innerText.includes(exact sentence) because browser line wrapping can split copy.",
|
|
561
|
+
"Prefer success-oriented evidence booleans such as newCopyVisible: true and oldCopyAbsent: true. If a positive assertion is false while screenshots/text samples look right, fix the capture script instead of leaving contradictory proof evidence.",
|
|
562
|
+
"Include a short matchedSnippet or normalizedTextSample when proofing copy so assertion mismatches are diagnosable.",
|
|
563
|
+
"For visual/UI proof, include saveScreenshot('after-proof') exactly once.",
|
|
564
|
+
"Avoid generic proof language. The packet should be specific enough that verify can tell whether the requested change actually happened.",
|
|
565
|
+
"Echo the baseline understanding you used in baseline_understanding_used so later stages can detect drift.",
|
|
566
|
+
"Use refined_inputs for server_path, wait_for_selector, or reference when useful; use null values when no refinement is needed."
|
|
567
|
+
].join("\n")
|
|
568
|
+
});
|
|
569
|
+
return payloadOrBlocker(raw, context.checkpoint);
|
|
570
|
+
},
|
|
571
|
+
async implementChange(context) {
|
|
572
|
+
if (!context.workdir || !(0, import_node_fs.existsSync)(context.workdir)) {
|
|
573
|
+
return {
|
|
574
|
+
ok: false,
|
|
575
|
+
blocker: {
|
|
576
|
+
code: "implementation_workdir_missing",
|
|
577
|
+
checkpoint: context.checkpoint,
|
|
578
|
+
message: "The Riddle Proof state does not include an after worktree that exists on disk.",
|
|
579
|
+
details: { workdir: context.workdir || null }
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
const workdir = context.workdir;
|
|
584
|
+
const attemptSummaries = [];
|
|
585
|
+
const runImplementationAttempt = async (purpose, extraLines = []) => {
|
|
586
|
+
const raw = await callRunner(runner, {
|
|
587
|
+
purpose,
|
|
588
|
+
workdir,
|
|
589
|
+
schema: IMPLEMENT_SCHEMA,
|
|
590
|
+
prompt: buildImplementationPrompt(context, extraLines)
|
|
591
|
+
});
|
|
592
|
+
if (!raw.ok || !raw.json) {
|
|
593
|
+
return {
|
|
594
|
+
ok: false,
|
|
595
|
+
payload: payloadOrBlocker(raw, context.checkpoint)
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
const changedFiles = stringArray(raw.json.changed_files);
|
|
599
|
+
const blockers = stringArray(raw.json.blockers);
|
|
600
|
+
const testsRun = stringArray(raw.json.tests_run);
|
|
601
|
+
const softVerificationBlockers = changedFiles.length ? blockers.filter(isHarnessVerificationOnlyBlocker) : [];
|
|
602
|
+
const hardBlockers = blockers.filter((item) => !softVerificationBlockers.includes(item));
|
|
603
|
+
const implementationNotesRaw = typeof raw.json.implementation_notes === "string" ? raw.json.implementation_notes : "";
|
|
604
|
+
const summary = typeof raw.json.summary === "string" ? raw.json.summary : "";
|
|
605
|
+
const implementationNotes = [
|
|
606
|
+
implementationNotesRaw,
|
|
607
|
+
...softVerificationBlockers.map((item) => `Harness verification note: ${item}`)
|
|
608
|
+
].filter(Boolean).join("\n");
|
|
609
|
+
const agentDetails = {
|
|
610
|
+
agent_purpose: purpose,
|
|
611
|
+
agent_summary: summary,
|
|
612
|
+
agent_changed_files: changedFiles,
|
|
613
|
+
agent_tests_run: testsRun,
|
|
614
|
+
agent_blockers: blockers
|
|
615
|
+
};
|
|
616
|
+
attemptSummaries.push({
|
|
617
|
+
purpose,
|
|
618
|
+
summary,
|
|
619
|
+
changed_files: changedFiles,
|
|
620
|
+
tests_run: testsRun,
|
|
621
|
+
blockers
|
|
622
|
+
});
|
|
623
|
+
if (hardBlockers.length) {
|
|
624
|
+
return {
|
|
625
|
+
ok: false,
|
|
626
|
+
payload: {
|
|
627
|
+
ok: false,
|
|
628
|
+
blocker: {
|
|
629
|
+
code: "codex_implementation_blocked",
|
|
630
|
+
checkpoint: context.checkpoint,
|
|
631
|
+
message: summary || "Codex reported implementation blockers.",
|
|
632
|
+
details: {
|
|
633
|
+
blockers: hardBlockers,
|
|
634
|
+
changedFiles,
|
|
635
|
+
testsRun,
|
|
636
|
+
implementationNotes: implementationNotesRaw,
|
|
637
|
+
...agentDetails
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
return {
|
|
644
|
+
ok: true,
|
|
645
|
+
summary,
|
|
646
|
+
changedFiles,
|
|
647
|
+
testsRun,
|
|
648
|
+
implementationNotes,
|
|
649
|
+
implementationNotesRaw,
|
|
650
|
+
softVerificationBlockers,
|
|
651
|
+
hardBlockers,
|
|
652
|
+
agentDetails
|
|
653
|
+
};
|
|
654
|
+
};
|
|
655
|
+
let attempt = await runImplementationAttempt("implementation");
|
|
656
|
+
if (!attempt.ok) return attempt.payload;
|
|
657
|
+
let diffDetected = hasGitDiff(workdir);
|
|
658
|
+
if (!diffDetected) {
|
|
659
|
+
attempt = await runImplementationAttempt("implementation retry", [
|
|
660
|
+
"The previous implementation attempt returned without a detectable git diff in this repository.",
|
|
661
|
+
`Previous summary: ${attempt.summary || "(none)"}`,
|
|
662
|
+
`Previous changed_files: ${JSON.stringify(attempt.changedFiles)}`,
|
|
663
|
+
"Before you return success this time, run git status --short and git diff --name-only. If they are still empty, do not return success; either keep editing or explain the blocker."
|
|
664
|
+
]);
|
|
665
|
+
if (!attempt.ok) return attempt.payload;
|
|
666
|
+
diffDetected = hasGitDiff(workdir);
|
|
667
|
+
}
|
|
668
|
+
return {
|
|
669
|
+
ok: true,
|
|
670
|
+
summary: attempt.summary || void 0,
|
|
671
|
+
implementationNotes: attempt.implementationNotes || void 0,
|
|
672
|
+
changedFiles: attempt.changedFiles,
|
|
673
|
+
testsRun: attempt.testsRun,
|
|
674
|
+
details: {
|
|
675
|
+
...attempt.agentDetails,
|
|
676
|
+
implementation_notes: attempt.implementationNotes || attempt.implementationNotesRaw || "",
|
|
677
|
+
soft_verification_blockers: attempt.softVerificationBlockers,
|
|
678
|
+
hard_blocker_count: attempt.hardBlockers.length,
|
|
679
|
+
retry_attempted: attemptSummaries.length > 1,
|
|
680
|
+
attempt_count: attemptSummaries.length,
|
|
681
|
+
attempt_summaries: attemptSummaries,
|
|
682
|
+
post_agent_diff_detected: diffDetected
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
},
|
|
686
|
+
async assessProof(context) {
|
|
687
|
+
const raw = await callRunner(runner, {
|
|
688
|
+
purpose: "proof assessment",
|
|
689
|
+
workdir: resolveWorkdir(context),
|
|
690
|
+
schema: PROOF_SCHEMA,
|
|
691
|
+
prompt: [
|
|
692
|
+
basePrompt(context, "Judge the proof bundle."),
|
|
693
|
+
"Decide whether the evidence is ready_to_ship or which internal stage should run next.",
|
|
694
|
+
"Only use ready_to_ship when the before/prod and after evidence actually prove the requested change.",
|
|
695
|
+
"Do not assume screenshots are required for every verification_mode. For data/audio/log/metric/custom proof, inspect the structured evidence bundle, proof_evidence_sample, artifacts, assertions, and success criteria directly.",
|
|
696
|
+
"Use semantic_context.route, headings, buttons, and text anchors to ground route/content judgment before calling screenshot evidence wrong-route or unrelated.",
|
|
697
|
+
"If structured proof evidence contains failed positive assertions, such as newCopyVisible: false or hasExpectedText: false, do not choose ready_to_ship until the evidence is reconciled or a richer proof is produced.",
|
|
698
|
+
"For visual/UI proof, screenshots and route/page-state quality still matter, but capture success alone is not proof.",
|
|
699
|
+
"For playable/gameplay proof, do not choose ready_to_ship unless playability evidence shows accepted input, state/time progression, and playfield/canvas pixel motion; a static generated scene is not playable proof.",
|
|
700
|
+
"For visual/UI polish, reject changes that are technically different but not legible to a reviewer. If visual_delta.status is measured and visual_delta.passed is false, choose needs_implementation when the visible result is wrong, or needs_richer_proof only when non-visual proof artifacts are insufficient.",
|
|
701
|
+
"If required visual_delta is unmeasured, missing, or not_applicable, choose revise_capture with recommended_stage=verify and continue_with_stage=verify so the same run stays in evidence/comparison recovery; do not choose ready_to_ship or generic needs_richer_proof for that missing metric.",
|
|
702
|
+
"Do not ship if the baseline is blank, shell-only, generic, or unrelated to the requested feature.",
|
|
703
|
+
"Your summary must name the concrete change, the target that was tested, what changed between baseline and after evidence, and why the stop condition is satisfied."
|
|
704
|
+
].join("\n")
|
|
705
|
+
});
|
|
706
|
+
return payloadOrBlocker(raw, context.checkpoint);
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
function git(args, workdir) {
|
|
711
|
+
return (0, import_node_child_process.execFileSync)("git", args, {
|
|
712
|
+
cwd: workdir,
|
|
713
|
+
encoding: "utf-8",
|
|
714
|
+
timeout: 1e4
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
async function runCodexExecAgentDoctor(config = {}, runner = createCodexExecJsonRunner(config)) {
|
|
718
|
+
const workdir = (0, import_node_fs.mkdtempSync)(import_node_path.default.join(import_node_os.default.tmpdir(), "riddle-proof-codex-doctor-"));
|
|
719
|
+
const targetPath = import_node_path.default.join(workdir, "target.txt");
|
|
720
|
+
(0, import_node_fs.writeFileSync)(targetPath, "color=red\n");
|
|
721
|
+
try {
|
|
722
|
+
git(["init", "-b", "main"], workdir);
|
|
723
|
+
git(["config", "user.email", "doctor@example.com"], workdir);
|
|
724
|
+
git(["config", "user.name", "Riddle Proof Doctor"], workdir);
|
|
725
|
+
git(["add", "target.txt"], workdir);
|
|
726
|
+
git(["commit", "-m", "initial doctor fixture"], workdir);
|
|
727
|
+
} catch (error) {
|
|
728
|
+
return {
|
|
729
|
+
ok: false,
|
|
730
|
+
status: "blocked",
|
|
731
|
+
blocker: {
|
|
732
|
+
code: "doctor_git_setup_failed",
|
|
733
|
+
message: "Could not create the temporary doctor git fixture.",
|
|
734
|
+
details: { error: error instanceof Error ? error.message : String(error), workdir }
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
const raw = await callRunner(runner, {
|
|
739
|
+
purpose: "codex exec doctor implementation",
|
|
740
|
+
workdir,
|
|
741
|
+
schema: IMPLEMENT_SCHEMA,
|
|
742
|
+
prompt: [
|
|
743
|
+
"You are running a Riddle Proof Codex exec doctor check.",
|
|
744
|
+
"In this temporary git repository, edit target.txt so it says exactly: color=blue",
|
|
745
|
+
"Do not commit. Leave a git diff.",
|
|
746
|
+
"Return JSON matching the schema with changed_files containing target.txt.",
|
|
747
|
+
"Use empty arrays for tests_run and blockers."
|
|
748
|
+
].join("\n")
|
|
749
|
+
});
|
|
750
|
+
if (!raw.ok || !raw.json) {
|
|
751
|
+
return {
|
|
752
|
+
ok: false,
|
|
753
|
+
status: "blocked",
|
|
754
|
+
blocker: {
|
|
755
|
+
...raw.blocker || {
|
|
756
|
+
code: "doctor_codex_failed",
|
|
757
|
+
message: "Codex doctor runner failed.",
|
|
758
|
+
details: { stdout: raw.stdout || "", stderr: raw.stderr || "" }
|
|
759
|
+
},
|
|
760
|
+
details: {
|
|
761
|
+
...raw.blocker?.details || {},
|
|
762
|
+
workdir
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
const content = (0, import_node_fs.readFileSync)(targetPath, "utf-8");
|
|
768
|
+
const status = git(["status", "--porcelain"], workdir);
|
|
769
|
+
const changedFiles = stringArray(raw.json.changed_files);
|
|
770
|
+
const ok = content.trim() === "color=blue" && status.includes("target.txt");
|
|
771
|
+
return {
|
|
772
|
+
ok,
|
|
773
|
+
status: ok ? "passed" : "blocked",
|
|
774
|
+
workdir,
|
|
775
|
+
changedFiles,
|
|
776
|
+
implementationSummary: raw.json.summary || null,
|
|
777
|
+
implementationNotes: raw.json.implementation_notes || null,
|
|
778
|
+
gitStatus: status,
|
|
779
|
+
targetContent: content,
|
|
780
|
+
blocker: ok ? null : {
|
|
781
|
+
code: "doctor_diff_missing_or_wrong",
|
|
782
|
+
message: "Codex doctor completed, but target.txt was not changed to color=blue with a git diff.",
|
|
783
|
+
details: { workdir, changedFiles, gitStatus: status, targetContent: content }
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
788
|
+
0 && (module.exports = {
|
|
789
|
+
createLocalAgentAdapter,
|
|
790
|
+
createLocalAgentJsonRunner,
|
|
791
|
+
runLocalAgentDoctor
|
|
792
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { CodexExecAgentConfig as LocalAgentConfig, CodexJsonRequest as LocalAgentJsonRequest, CodexJsonResult as LocalAgentJsonResult, CodexJsonRunner as LocalAgentJsonRunner, createCodexExecAgentAdapter as createLocalAgentAdapter, createCodexExecJsonRunner as createLocalAgentJsonRunner, runCodexExecAgentDoctor as runLocalAgentDoctor } from './codex-exec-agent.cjs';
|
|
2
|
+
import './engine-harness.cjs';
|
|
3
|
+
import './types.cjs';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { CodexExecAgentConfig as LocalAgentConfig, CodexJsonRequest as LocalAgentJsonRequest, CodexJsonResult as LocalAgentJsonResult, CodexJsonRunner as LocalAgentJsonRunner, createCodexExecAgentAdapter as createLocalAgentAdapter, createCodexExecJsonRunner as createLocalAgentJsonRunner, runCodexExecAgentDoctor as runLocalAgentDoctor } from './codex-exec-agent.js';
|
|
2
|
+
import './engine-harness.js';
|
|
3
|
+
import './types.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./chunk-JFQXAJH2.js";
|
|
2
|
+
import {
|
|
3
|
+
createCodexExecAgentAdapter,
|
|
4
|
+
createCodexExecJsonRunner,
|
|
5
|
+
runCodexExecAgentDoctor
|
|
6
|
+
} from "./chunk-NOBFZDZG.js";
|
|
7
|
+
export {
|
|
8
|
+
createCodexExecAgentAdapter as createLocalAgentAdapter,
|
|
9
|
+
createCodexExecJsonRunner as createLocalAgentJsonRunner,
|
|
10
|
+
runCodexExecAgentDoctor as runLocalAgentDoctor
|
|
11
|
+
};
|
package/dist/openclaw.js
CHANGED
package/dist/runner.js
CHANGED
package/dist/state.cjs
CHANGED
|
@@ -419,7 +419,7 @@ function createRunStatusSnapshot(state, at = timestamp()) {
|
|
|
419
419
|
checkpoint_summary: state.checkpoint_summary,
|
|
420
420
|
state_paths: state.state_paths,
|
|
421
421
|
proof_contract: state.proof_contract,
|
|
422
|
-
run_card: createRiddleProofRunCard(state, { at }),
|
|
422
|
+
run_card: state.run_card || createRiddleProofRunCard(state, { at }),
|
|
423
423
|
latest_event: latestEvent
|
|
424
424
|
});
|
|
425
425
|
}
|
package/dist/state.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riddledc/riddle-proof",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.47",
|
|
4
4
|
"description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "RiddleDC",
|
|
@@ -59,6 +59,11 @@
|
|
|
59
59
|
"import": "./dist/codex-exec-agent.js",
|
|
60
60
|
"require": "./dist/codex-exec-agent.cjs"
|
|
61
61
|
},
|
|
62
|
+
"./local-agent": {
|
|
63
|
+
"types": "./dist/local-agent.d.ts",
|
|
64
|
+
"import": "./dist/local-agent.js",
|
|
65
|
+
"require": "./dist/local-agent.cjs"
|
|
66
|
+
},
|
|
62
67
|
"./diagnostics": {
|
|
63
68
|
"types": "./dist/diagnostics.d.ts",
|
|
64
69
|
"import": "./dist/diagnostics.js",
|
|
@@ -110,7 +115,7 @@
|
|
|
110
115
|
"typescript": "^5.4.5"
|
|
111
116
|
},
|
|
112
117
|
"scripts": {
|
|
113
|
-
"build": "tsup src/index.ts src/types.ts src/result.ts src/state.ts src/checkpoint.ts src/run-card.ts src/runner.ts src/engine-harness.ts src/codex-exec-agent.ts src/cli.ts src/diagnostics.ts src/proof-session.ts src/playability.ts src/openclaw.ts src/proof-run-core.ts src/proof-run-engine.ts --format cjs,esm --dts --out-dir dist --clean",
|
|
118
|
+
"build": "tsup src/index.ts src/types.ts src/result.ts src/state.ts src/checkpoint.ts src/run-card.ts src/runner.ts src/engine-harness.ts src/codex-exec-agent.ts src/local-agent.ts src/cli.ts src/diagnostics.ts src/proof-session.ts src/playability.ts src/openclaw.ts src/proof-run-core.ts src/proof-run-engine.ts --format cjs,esm --dts --out-dir dist --clean",
|
|
114
119
|
"clean": "rm -rf dist",
|
|
115
120
|
"lint": "echo 'lint: (not configured)'",
|
|
116
121
|
"test": "npm run build && node test.js && node proof-run.test.js"
|