@riddledc/riddle-proof 0.8.7 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/codex-exec-agent.cjs +75 -10
- package/dist/adapters/codex-exec-agent.js +1 -1
- package/dist/adapters/codex.cjs +75 -10
- package/dist/adapters/codex.js +1 -1
- package/dist/adapters/local-agent.cjs +75 -10
- package/dist/adapters/local-agent.js +1 -1
- package/dist/{chunk-PYCQNK66.js → chunk-EEIYUZXE.js} +75 -10
- package/dist/{chunk-V6VZ3CAI.js → chunk-RTWGGKS3.js} +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/cli.cjs +75 -10
- package/dist/cli.js +2 -2
- package/dist/codex-exec-agent.cjs +75 -10
- package/dist/codex-exec-agent.js +1 -1
- package/dist/index.cjs +75 -10
- package/dist/index.js +1 -1
- package/dist/local-agent.cjs +75 -10
- package/dist/local-agent.js +1 -1
- package/package.json +1 -1
- package/runtime/lib/verify.py +204 -5
- package/runtime/tests/recon_verify_smoke.py +19 -12
|
@@ -48,6 +48,8 @@ function compactRecord(input) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// src/codex-exec-agent.ts
|
|
51
|
+
var DEFAULT_CODEX_TIMEOUT_MS = 6e5;
|
|
52
|
+
var DEFAULT_PROOF_PACKET_AUTHOR_TIMEOUT_MS = 18e4;
|
|
51
53
|
var REFINED_INPUTS_SCHEMA = {
|
|
52
54
|
type: "object",
|
|
53
55
|
additionalProperties: false,
|
|
@@ -391,6 +393,46 @@ function parseJsonFromRunnerOutputs(outputs, schema) {
|
|
|
391
393
|
if (!combined.trim() || seen.has(combined)) return { parsed: null, source: "" };
|
|
392
394
|
return { parsed: parseJsonObject(combined, schema), source: "combined_output" };
|
|
393
395
|
}
|
|
396
|
+
function resolveCodexTimeoutMs(config, request) {
|
|
397
|
+
if (typeof config.codexTimeoutMs === "number" && Number.isFinite(config.codexTimeoutMs) && config.codexTimeoutMs > 0) {
|
|
398
|
+
return Number(config.codexTimeoutMs);
|
|
399
|
+
}
|
|
400
|
+
return request.purpose === "proof packet authoring" ? DEFAULT_PROOF_PACKET_AUTHOR_TIMEOUT_MS : DEFAULT_CODEX_TIMEOUT_MS;
|
|
401
|
+
}
|
|
402
|
+
function isCodexLifecycleEvent(value) {
|
|
403
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
404
|
+
const type = value.type;
|
|
405
|
+
return typeof type === "string" && (type.startsWith("thread.") || type.startsWith("turn.") || type.startsWith("exec.") || type.startsWith("agent.") || type.startsWith("token.") || type.startsWith("reasoning.") || type.startsWith("error."));
|
|
406
|
+
}
|
|
407
|
+
function analyzeCodexRunnerOutput(outputs) {
|
|
408
|
+
const eventTypes = /* @__PURE__ */ new Set();
|
|
409
|
+
let eventLineCount = 0;
|
|
410
|
+
let nonEventLineCount = 0;
|
|
411
|
+
const nonEventSamples = [];
|
|
412
|
+
for (const output of outputs) {
|
|
413
|
+
const lines = output.text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
414
|
+
for (const line of lines) {
|
|
415
|
+
try {
|
|
416
|
+
const parsed = JSON.parse(line);
|
|
417
|
+
if (isCodexLifecycleEvent(parsed)) {
|
|
418
|
+
eventLineCount += 1;
|
|
419
|
+
eventTypes.add(parsed.type);
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
} catch {
|
|
423
|
+
}
|
|
424
|
+
nonEventLineCount += 1;
|
|
425
|
+
if (nonEventSamples.length < 3) nonEventSamples.push(line.slice(0, 240));
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
eventLineCount,
|
|
430
|
+
eventTypes: Array.from(eventTypes),
|
|
431
|
+
nonEventLineCount,
|
|
432
|
+
nonEventSamples,
|
|
433
|
+
onlyLifecycleEvents: eventLineCount > 0 && nonEventLineCount === 0
|
|
434
|
+
};
|
|
435
|
+
}
|
|
394
436
|
function isHarnessVerificationOnlyBlocker(blocker) {
|
|
395
437
|
const text = blocker.toLowerCase();
|
|
396
438
|
return (text.includes("erofs") || text.includes("read-only file system")) && text.includes("node_modules") && (text.includes(".vite-temp") || text.includes("vite.config"));
|
|
@@ -414,21 +456,25 @@ function runnerMetrics(input) {
|
|
|
414
456
|
exit_status: input.status ?? null,
|
|
415
457
|
timed_out: input.timedOut || false,
|
|
416
458
|
error_code: input.errorCode,
|
|
459
|
+
codex_event_types: input.codexEventTypes && input.codexEventTypes.length ? input.codexEventTypes : void 0,
|
|
460
|
+
codex_event_line_count: input.codexEventLineCount,
|
|
461
|
+
codex_non_event_line_count: input.codexNonEventLineCount,
|
|
417
462
|
codex_command: input.config.codexCommand || "codex",
|
|
418
463
|
codex_model: input.config.codexModel,
|
|
419
464
|
codex_sandbox: input.config.codexSandbox || "workspace-write",
|
|
420
465
|
codex_full_auto: input.config.codexFullAuto !== false,
|
|
421
|
-
timeout_ms:
|
|
466
|
+
timeout_ms: input.timeoutMs ?? DEFAULT_CODEX_TIMEOUT_MS
|
|
422
467
|
});
|
|
423
468
|
}
|
|
424
469
|
function createCodexExecJsonRunner(config = {}) {
|
|
425
470
|
return (request) => {
|
|
426
471
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
427
472
|
const startedMs = Date.now();
|
|
473
|
+
const timeoutMs = resolveCodexTimeoutMs(config, request);
|
|
428
474
|
if (!request.workdir || !(0, import_node_fs.existsSync)(request.workdir)) {
|
|
429
475
|
return {
|
|
430
476
|
ok: false,
|
|
431
|
-
metrics: runnerMetrics({ request, config, startedAt, startedMs, errorCode: "workdir_missing" }),
|
|
477
|
+
metrics: runnerMetrics({ request, config, startedAt, startedMs, timeoutMs, errorCode: "workdir_missing" }),
|
|
432
478
|
blocker: {
|
|
433
479
|
code: "codex_workdir_missing",
|
|
434
480
|
message: `Codex workdir does not exist for ${request.purpose}.`,
|
|
@@ -463,7 +509,7 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
463
509
|
const proc = (0, import_node_child_process.spawnSync)(config.codexCommand || "codex", args, {
|
|
464
510
|
input: request.prompt,
|
|
465
511
|
encoding: "utf-8",
|
|
466
|
-
timeout:
|
|
512
|
+
timeout: timeoutMs,
|
|
467
513
|
maxBuffer: 10 * 1024 * 1024,
|
|
468
514
|
env
|
|
469
515
|
});
|
|
@@ -482,6 +528,7 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
482
528
|
stderr: proc.stderr || "",
|
|
483
529
|
status: proc.status,
|
|
484
530
|
timedOut,
|
|
531
|
+
timeoutMs,
|
|
485
532
|
errorCode: proc.error.code || "spawn_error"
|
|
486
533
|
}),
|
|
487
534
|
blocker: {
|
|
@@ -504,6 +551,7 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
504
551
|
stdout: proc.stdout || "",
|
|
505
552
|
stderr: proc.stderr || "",
|
|
506
553
|
status: proc.status,
|
|
554
|
+
timeoutMs,
|
|
507
555
|
errorCode: "nonzero_exit"
|
|
508
556
|
}),
|
|
509
557
|
blocker: {
|
|
@@ -516,12 +564,15 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
516
564
|
const finalText = (0, import_node_fs.existsSync)(lastMessagePath) ? (0, import_node_fs.readFileSync)(lastMessagePath, "utf-8") : String(proc.stdout || "");
|
|
517
565
|
const stdoutText = String(proc.stdout || "");
|
|
518
566
|
const stderrText = String(proc.stderr || "");
|
|
519
|
-
const
|
|
567
|
+
const runnerOutputs = [
|
|
520
568
|
{ source: (0, import_node_fs.existsSync)(lastMessagePath) ? "last_message" : "stdout", text: finalText },
|
|
521
569
|
{ source: "stdout", text: stdoutText },
|
|
522
570
|
{ source: "stderr", text: stderrText }
|
|
523
|
-
]
|
|
571
|
+
];
|
|
572
|
+
const { parsed, source: parsedJsonSource } = parseJsonFromRunnerOutputs(runnerOutputs, request.schema);
|
|
524
573
|
if (!parsed) {
|
|
574
|
+
const outputAnalysis = analyzeCodexRunnerOutput(runnerOutputs);
|
|
575
|
+
const errorCode = outputAnalysis.onlyLifecycleEvents ? "no_final_response" : "invalid_json";
|
|
525
576
|
return {
|
|
526
577
|
ok: false,
|
|
527
578
|
stdout: stdoutText,
|
|
@@ -535,12 +586,24 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
535
586
|
stderr: stderrText,
|
|
536
587
|
finalText,
|
|
537
588
|
status: proc.status,
|
|
538
|
-
|
|
589
|
+
timeoutMs,
|
|
590
|
+
errorCode,
|
|
591
|
+
codexEventTypes: outputAnalysis.eventTypes,
|
|
592
|
+
codexEventLineCount: outputAnalysis.eventLineCount,
|
|
593
|
+
codexNonEventLineCount: outputAnalysis.nonEventLineCount
|
|
539
594
|
}),
|
|
540
595
|
blocker: {
|
|
541
|
-
code: "codex_invalid_json",
|
|
542
|
-
message: `Codex completed ${request.purpose}, but did not return valid JSON.`,
|
|
543
|
-
details: {
|
|
596
|
+
code: outputAnalysis.onlyLifecycleEvents ? "codex_no_final_response" : "codex_invalid_json",
|
|
597
|
+
message: outputAnalysis.onlyLifecycleEvents ? `Codex emitted lifecycle events during ${request.purpose}, but did not produce a final JSON response.` : `Codex completed ${request.purpose}, but did not return valid JSON.`,
|
|
598
|
+
details: {
|
|
599
|
+
finalText,
|
|
600
|
+
stdout: stdoutText,
|
|
601
|
+
stderr: stderrText,
|
|
602
|
+
event_types: outputAnalysis.eventTypes,
|
|
603
|
+
event_line_count: outputAnalysis.eventLineCount,
|
|
604
|
+
non_event_line_count: outputAnalysis.nonEventLineCount,
|
|
605
|
+
non_event_samples: outputAnalysis.nonEventSamples
|
|
606
|
+
}
|
|
544
607
|
}
|
|
545
608
|
};
|
|
546
609
|
}
|
|
@@ -558,7 +621,8 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
558
621
|
stderr: stderrText,
|
|
559
622
|
finalText,
|
|
560
623
|
parsedJsonSource,
|
|
561
|
-
status: proc.status
|
|
624
|
+
status: proc.status,
|
|
625
|
+
timeoutMs
|
|
562
626
|
})
|
|
563
627
|
};
|
|
564
628
|
} finally {
|
|
@@ -667,6 +731,7 @@ function createCodexExecAgentAdapter(config = {}, runner = createCodexExecJsonRu
|
|
|
667
731
|
"Write a proof_plan and capture_script that will verify the exact user-facing change.",
|
|
668
732
|
"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.",
|
|
669
733
|
"Use the recon-approved route and baseline context; make the plan name the concrete target, expected before state, expected after state, and stop condition.",
|
|
734
|
+
"Do not leave this authoring stage pending for external investigation. Keep any repo inspection brief, do not modify files, and return the JSON proof packet from the available state.",
|
|
670
735
|
"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.",
|
|
671
736
|
"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.",
|
|
672
737
|
"For interaction proof, return a structured evidence object with start route/state, terminal route/state, action, assertions, and matched UI text. Catch waitForURL or selector timeouts and record them as failed assertions instead of throwing before evidence is emitted.",
|
package/dist/adapters/codex.cjs
CHANGED
|
@@ -48,6 +48,8 @@ function compactRecord(input) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// src/codex-exec-agent.ts
|
|
51
|
+
var DEFAULT_CODEX_TIMEOUT_MS = 6e5;
|
|
52
|
+
var DEFAULT_PROOF_PACKET_AUTHOR_TIMEOUT_MS = 18e4;
|
|
51
53
|
var REFINED_INPUTS_SCHEMA = {
|
|
52
54
|
type: "object",
|
|
53
55
|
additionalProperties: false,
|
|
@@ -391,6 +393,46 @@ function parseJsonFromRunnerOutputs(outputs, schema) {
|
|
|
391
393
|
if (!combined.trim() || seen.has(combined)) return { parsed: null, source: "" };
|
|
392
394
|
return { parsed: parseJsonObject(combined, schema), source: "combined_output" };
|
|
393
395
|
}
|
|
396
|
+
function resolveCodexTimeoutMs(config, request) {
|
|
397
|
+
if (typeof config.codexTimeoutMs === "number" && Number.isFinite(config.codexTimeoutMs) && config.codexTimeoutMs > 0) {
|
|
398
|
+
return Number(config.codexTimeoutMs);
|
|
399
|
+
}
|
|
400
|
+
return request.purpose === "proof packet authoring" ? DEFAULT_PROOF_PACKET_AUTHOR_TIMEOUT_MS : DEFAULT_CODEX_TIMEOUT_MS;
|
|
401
|
+
}
|
|
402
|
+
function isCodexLifecycleEvent(value) {
|
|
403
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
404
|
+
const type = value.type;
|
|
405
|
+
return typeof type === "string" && (type.startsWith("thread.") || type.startsWith("turn.") || type.startsWith("exec.") || type.startsWith("agent.") || type.startsWith("token.") || type.startsWith("reasoning.") || type.startsWith("error."));
|
|
406
|
+
}
|
|
407
|
+
function analyzeCodexRunnerOutput(outputs) {
|
|
408
|
+
const eventTypes = /* @__PURE__ */ new Set();
|
|
409
|
+
let eventLineCount = 0;
|
|
410
|
+
let nonEventLineCount = 0;
|
|
411
|
+
const nonEventSamples = [];
|
|
412
|
+
for (const output of outputs) {
|
|
413
|
+
const lines = output.text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
414
|
+
for (const line of lines) {
|
|
415
|
+
try {
|
|
416
|
+
const parsed = JSON.parse(line);
|
|
417
|
+
if (isCodexLifecycleEvent(parsed)) {
|
|
418
|
+
eventLineCount += 1;
|
|
419
|
+
eventTypes.add(parsed.type);
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
} catch {
|
|
423
|
+
}
|
|
424
|
+
nonEventLineCount += 1;
|
|
425
|
+
if (nonEventSamples.length < 3) nonEventSamples.push(line.slice(0, 240));
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
eventLineCount,
|
|
430
|
+
eventTypes: Array.from(eventTypes),
|
|
431
|
+
nonEventLineCount,
|
|
432
|
+
nonEventSamples,
|
|
433
|
+
onlyLifecycleEvents: eventLineCount > 0 && nonEventLineCount === 0
|
|
434
|
+
};
|
|
435
|
+
}
|
|
394
436
|
function isHarnessVerificationOnlyBlocker(blocker) {
|
|
395
437
|
const text = blocker.toLowerCase();
|
|
396
438
|
return (text.includes("erofs") || text.includes("read-only file system")) && text.includes("node_modules") && (text.includes(".vite-temp") || text.includes("vite.config"));
|
|
@@ -414,21 +456,25 @@ function runnerMetrics(input) {
|
|
|
414
456
|
exit_status: input.status ?? null,
|
|
415
457
|
timed_out: input.timedOut || false,
|
|
416
458
|
error_code: input.errorCode,
|
|
459
|
+
codex_event_types: input.codexEventTypes && input.codexEventTypes.length ? input.codexEventTypes : void 0,
|
|
460
|
+
codex_event_line_count: input.codexEventLineCount,
|
|
461
|
+
codex_non_event_line_count: input.codexNonEventLineCount,
|
|
417
462
|
codex_command: input.config.codexCommand || "codex",
|
|
418
463
|
codex_model: input.config.codexModel,
|
|
419
464
|
codex_sandbox: input.config.codexSandbox || "workspace-write",
|
|
420
465
|
codex_full_auto: input.config.codexFullAuto !== false,
|
|
421
|
-
timeout_ms:
|
|
466
|
+
timeout_ms: input.timeoutMs ?? DEFAULT_CODEX_TIMEOUT_MS
|
|
422
467
|
});
|
|
423
468
|
}
|
|
424
469
|
function createCodexExecJsonRunner(config = {}) {
|
|
425
470
|
return (request) => {
|
|
426
471
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
427
472
|
const startedMs = Date.now();
|
|
473
|
+
const timeoutMs = resolveCodexTimeoutMs(config, request);
|
|
428
474
|
if (!request.workdir || !(0, import_node_fs.existsSync)(request.workdir)) {
|
|
429
475
|
return {
|
|
430
476
|
ok: false,
|
|
431
|
-
metrics: runnerMetrics({ request, config, startedAt, startedMs, errorCode: "workdir_missing" }),
|
|
477
|
+
metrics: runnerMetrics({ request, config, startedAt, startedMs, timeoutMs, errorCode: "workdir_missing" }),
|
|
432
478
|
blocker: {
|
|
433
479
|
code: "codex_workdir_missing",
|
|
434
480
|
message: `Codex workdir does not exist for ${request.purpose}.`,
|
|
@@ -463,7 +509,7 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
463
509
|
const proc = (0, import_node_child_process.spawnSync)(config.codexCommand || "codex", args, {
|
|
464
510
|
input: request.prompt,
|
|
465
511
|
encoding: "utf-8",
|
|
466
|
-
timeout:
|
|
512
|
+
timeout: timeoutMs,
|
|
467
513
|
maxBuffer: 10 * 1024 * 1024,
|
|
468
514
|
env
|
|
469
515
|
});
|
|
@@ -482,6 +528,7 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
482
528
|
stderr: proc.stderr || "",
|
|
483
529
|
status: proc.status,
|
|
484
530
|
timedOut,
|
|
531
|
+
timeoutMs,
|
|
485
532
|
errorCode: proc.error.code || "spawn_error"
|
|
486
533
|
}),
|
|
487
534
|
blocker: {
|
|
@@ -504,6 +551,7 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
504
551
|
stdout: proc.stdout || "",
|
|
505
552
|
stderr: proc.stderr || "",
|
|
506
553
|
status: proc.status,
|
|
554
|
+
timeoutMs,
|
|
507
555
|
errorCode: "nonzero_exit"
|
|
508
556
|
}),
|
|
509
557
|
blocker: {
|
|
@@ -516,12 +564,15 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
516
564
|
const finalText = (0, import_node_fs.existsSync)(lastMessagePath) ? (0, import_node_fs.readFileSync)(lastMessagePath, "utf-8") : String(proc.stdout || "");
|
|
517
565
|
const stdoutText = String(proc.stdout || "");
|
|
518
566
|
const stderrText = String(proc.stderr || "");
|
|
519
|
-
const
|
|
567
|
+
const runnerOutputs = [
|
|
520
568
|
{ source: (0, import_node_fs.existsSync)(lastMessagePath) ? "last_message" : "stdout", text: finalText },
|
|
521
569
|
{ source: "stdout", text: stdoutText },
|
|
522
570
|
{ source: "stderr", text: stderrText }
|
|
523
|
-
]
|
|
571
|
+
];
|
|
572
|
+
const { parsed, source: parsedJsonSource } = parseJsonFromRunnerOutputs(runnerOutputs, request.schema);
|
|
524
573
|
if (!parsed) {
|
|
574
|
+
const outputAnalysis = analyzeCodexRunnerOutput(runnerOutputs);
|
|
575
|
+
const errorCode = outputAnalysis.onlyLifecycleEvents ? "no_final_response" : "invalid_json";
|
|
525
576
|
return {
|
|
526
577
|
ok: false,
|
|
527
578
|
stdout: stdoutText,
|
|
@@ -535,12 +586,24 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
535
586
|
stderr: stderrText,
|
|
536
587
|
finalText,
|
|
537
588
|
status: proc.status,
|
|
538
|
-
|
|
589
|
+
timeoutMs,
|
|
590
|
+
errorCode,
|
|
591
|
+
codexEventTypes: outputAnalysis.eventTypes,
|
|
592
|
+
codexEventLineCount: outputAnalysis.eventLineCount,
|
|
593
|
+
codexNonEventLineCount: outputAnalysis.nonEventLineCount
|
|
539
594
|
}),
|
|
540
595
|
blocker: {
|
|
541
|
-
code: "codex_invalid_json",
|
|
542
|
-
message: `Codex completed ${request.purpose}, but did not return valid JSON.`,
|
|
543
|
-
details: {
|
|
596
|
+
code: outputAnalysis.onlyLifecycleEvents ? "codex_no_final_response" : "codex_invalid_json",
|
|
597
|
+
message: outputAnalysis.onlyLifecycleEvents ? `Codex emitted lifecycle events during ${request.purpose}, but did not produce a final JSON response.` : `Codex completed ${request.purpose}, but did not return valid JSON.`,
|
|
598
|
+
details: {
|
|
599
|
+
finalText,
|
|
600
|
+
stdout: stdoutText,
|
|
601
|
+
stderr: stderrText,
|
|
602
|
+
event_types: outputAnalysis.eventTypes,
|
|
603
|
+
event_line_count: outputAnalysis.eventLineCount,
|
|
604
|
+
non_event_line_count: outputAnalysis.nonEventLineCount,
|
|
605
|
+
non_event_samples: outputAnalysis.nonEventSamples
|
|
606
|
+
}
|
|
544
607
|
}
|
|
545
608
|
};
|
|
546
609
|
}
|
|
@@ -558,7 +621,8 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
558
621
|
stderr: stderrText,
|
|
559
622
|
finalText,
|
|
560
623
|
parsedJsonSource,
|
|
561
|
-
status: proc.status
|
|
624
|
+
status: proc.status,
|
|
625
|
+
timeoutMs
|
|
562
626
|
})
|
|
563
627
|
};
|
|
564
628
|
} finally {
|
|
@@ -667,6 +731,7 @@ function createCodexExecAgentAdapter(config = {}, runner = createCodexExecJsonRu
|
|
|
667
731
|
"Write a proof_plan and capture_script that will verify the exact user-facing change.",
|
|
668
732
|
"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.",
|
|
669
733
|
"Use the recon-approved route and baseline context; make the plan name the concrete target, expected before state, expected after state, and stop condition.",
|
|
734
|
+
"Do not leave this authoring stage pending for external investigation. Keep any repo inspection brief, do not modify files, and return the JSON proof packet from the available state.",
|
|
670
735
|
"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.",
|
|
671
736
|
"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.",
|
|
672
737
|
"For interaction proof, return a structured evidence object with start route/state, terminal route/state, action, assertions, and matched UI text. Catch waitForURL or selector timeouts and record them as failed assertions instead of throwing before evidence is emitted.",
|
package/dist/adapters/codex.js
CHANGED
|
@@ -48,6 +48,8 @@ function compactRecord(input) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// src/codex-exec-agent.ts
|
|
51
|
+
var DEFAULT_CODEX_TIMEOUT_MS = 6e5;
|
|
52
|
+
var DEFAULT_PROOF_PACKET_AUTHOR_TIMEOUT_MS = 18e4;
|
|
51
53
|
var REFINED_INPUTS_SCHEMA = {
|
|
52
54
|
type: "object",
|
|
53
55
|
additionalProperties: false,
|
|
@@ -391,6 +393,46 @@ function parseJsonFromRunnerOutputs(outputs, schema) {
|
|
|
391
393
|
if (!combined.trim() || seen.has(combined)) return { parsed: null, source: "" };
|
|
392
394
|
return { parsed: parseJsonObject(combined, schema), source: "combined_output" };
|
|
393
395
|
}
|
|
396
|
+
function resolveCodexTimeoutMs(config, request) {
|
|
397
|
+
if (typeof config.codexTimeoutMs === "number" && Number.isFinite(config.codexTimeoutMs) && config.codexTimeoutMs > 0) {
|
|
398
|
+
return Number(config.codexTimeoutMs);
|
|
399
|
+
}
|
|
400
|
+
return request.purpose === "proof packet authoring" ? DEFAULT_PROOF_PACKET_AUTHOR_TIMEOUT_MS : DEFAULT_CODEX_TIMEOUT_MS;
|
|
401
|
+
}
|
|
402
|
+
function isCodexLifecycleEvent(value) {
|
|
403
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
404
|
+
const type = value.type;
|
|
405
|
+
return typeof type === "string" && (type.startsWith("thread.") || type.startsWith("turn.") || type.startsWith("exec.") || type.startsWith("agent.") || type.startsWith("token.") || type.startsWith("reasoning.") || type.startsWith("error."));
|
|
406
|
+
}
|
|
407
|
+
function analyzeCodexRunnerOutput(outputs) {
|
|
408
|
+
const eventTypes = /* @__PURE__ */ new Set();
|
|
409
|
+
let eventLineCount = 0;
|
|
410
|
+
let nonEventLineCount = 0;
|
|
411
|
+
const nonEventSamples = [];
|
|
412
|
+
for (const output of outputs) {
|
|
413
|
+
const lines = output.text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
414
|
+
for (const line of lines) {
|
|
415
|
+
try {
|
|
416
|
+
const parsed = JSON.parse(line);
|
|
417
|
+
if (isCodexLifecycleEvent(parsed)) {
|
|
418
|
+
eventLineCount += 1;
|
|
419
|
+
eventTypes.add(parsed.type);
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
} catch {
|
|
423
|
+
}
|
|
424
|
+
nonEventLineCount += 1;
|
|
425
|
+
if (nonEventSamples.length < 3) nonEventSamples.push(line.slice(0, 240));
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
eventLineCount,
|
|
430
|
+
eventTypes: Array.from(eventTypes),
|
|
431
|
+
nonEventLineCount,
|
|
432
|
+
nonEventSamples,
|
|
433
|
+
onlyLifecycleEvents: eventLineCount > 0 && nonEventLineCount === 0
|
|
434
|
+
};
|
|
435
|
+
}
|
|
394
436
|
function isHarnessVerificationOnlyBlocker(blocker) {
|
|
395
437
|
const text = blocker.toLowerCase();
|
|
396
438
|
return (text.includes("erofs") || text.includes("read-only file system")) && text.includes("node_modules") && (text.includes(".vite-temp") || text.includes("vite.config"));
|
|
@@ -414,21 +456,25 @@ function runnerMetrics(input) {
|
|
|
414
456
|
exit_status: input.status ?? null,
|
|
415
457
|
timed_out: input.timedOut || false,
|
|
416
458
|
error_code: input.errorCode,
|
|
459
|
+
codex_event_types: input.codexEventTypes && input.codexEventTypes.length ? input.codexEventTypes : void 0,
|
|
460
|
+
codex_event_line_count: input.codexEventLineCount,
|
|
461
|
+
codex_non_event_line_count: input.codexNonEventLineCount,
|
|
417
462
|
codex_command: input.config.codexCommand || "codex",
|
|
418
463
|
codex_model: input.config.codexModel,
|
|
419
464
|
codex_sandbox: input.config.codexSandbox || "workspace-write",
|
|
420
465
|
codex_full_auto: input.config.codexFullAuto !== false,
|
|
421
|
-
timeout_ms:
|
|
466
|
+
timeout_ms: input.timeoutMs ?? DEFAULT_CODEX_TIMEOUT_MS
|
|
422
467
|
});
|
|
423
468
|
}
|
|
424
469
|
function createCodexExecJsonRunner(config = {}) {
|
|
425
470
|
return (request) => {
|
|
426
471
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
427
472
|
const startedMs = Date.now();
|
|
473
|
+
const timeoutMs = resolveCodexTimeoutMs(config, request);
|
|
428
474
|
if (!request.workdir || !(0, import_node_fs.existsSync)(request.workdir)) {
|
|
429
475
|
return {
|
|
430
476
|
ok: false,
|
|
431
|
-
metrics: runnerMetrics({ request, config, startedAt, startedMs, errorCode: "workdir_missing" }),
|
|
477
|
+
metrics: runnerMetrics({ request, config, startedAt, startedMs, timeoutMs, errorCode: "workdir_missing" }),
|
|
432
478
|
blocker: {
|
|
433
479
|
code: "codex_workdir_missing",
|
|
434
480
|
message: `Codex workdir does not exist for ${request.purpose}.`,
|
|
@@ -463,7 +509,7 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
463
509
|
const proc = (0, import_node_child_process.spawnSync)(config.codexCommand || "codex", args, {
|
|
464
510
|
input: request.prompt,
|
|
465
511
|
encoding: "utf-8",
|
|
466
|
-
timeout:
|
|
512
|
+
timeout: timeoutMs,
|
|
467
513
|
maxBuffer: 10 * 1024 * 1024,
|
|
468
514
|
env
|
|
469
515
|
});
|
|
@@ -482,6 +528,7 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
482
528
|
stderr: proc.stderr || "",
|
|
483
529
|
status: proc.status,
|
|
484
530
|
timedOut,
|
|
531
|
+
timeoutMs,
|
|
485
532
|
errorCode: proc.error.code || "spawn_error"
|
|
486
533
|
}),
|
|
487
534
|
blocker: {
|
|
@@ -504,6 +551,7 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
504
551
|
stdout: proc.stdout || "",
|
|
505
552
|
stderr: proc.stderr || "",
|
|
506
553
|
status: proc.status,
|
|
554
|
+
timeoutMs,
|
|
507
555
|
errorCode: "nonzero_exit"
|
|
508
556
|
}),
|
|
509
557
|
blocker: {
|
|
@@ -516,12 +564,15 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
516
564
|
const finalText = (0, import_node_fs.existsSync)(lastMessagePath) ? (0, import_node_fs.readFileSync)(lastMessagePath, "utf-8") : String(proc.stdout || "");
|
|
517
565
|
const stdoutText = String(proc.stdout || "");
|
|
518
566
|
const stderrText = String(proc.stderr || "");
|
|
519
|
-
const
|
|
567
|
+
const runnerOutputs = [
|
|
520
568
|
{ source: (0, import_node_fs.existsSync)(lastMessagePath) ? "last_message" : "stdout", text: finalText },
|
|
521
569
|
{ source: "stdout", text: stdoutText },
|
|
522
570
|
{ source: "stderr", text: stderrText }
|
|
523
|
-
]
|
|
571
|
+
];
|
|
572
|
+
const { parsed, source: parsedJsonSource } = parseJsonFromRunnerOutputs(runnerOutputs, request.schema);
|
|
524
573
|
if (!parsed) {
|
|
574
|
+
const outputAnalysis = analyzeCodexRunnerOutput(runnerOutputs);
|
|
575
|
+
const errorCode = outputAnalysis.onlyLifecycleEvents ? "no_final_response" : "invalid_json";
|
|
525
576
|
return {
|
|
526
577
|
ok: false,
|
|
527
578
|
stdout: stdoutText,
|
|
@@ -535,12 +586,24 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
535
586
|
stderr: stderrText,
|
|
536
587
|
finalText,
|
|
537
588
|
status: proc.status,
|
|
538
|
-
|
|
589
|
+
timeoutMs,
|
|
590
|
+
errorCode,
|
|
591
|
+
codexEventTypes: outputAnalysis.eventTypes,
|
|
592
|
+
codexEventLineCount: outputAnalysis.eventLineCount,
|
|
593
|
+
codexNonEventLineCount: outputAnalysis.nonEventLineCount
|
|
539
594
|
}),
|
|
540
595
|
blocker: {
|
|
541
|
-
code: "codex_invalid_json",
|
|
542
|
-
message: `Codex completed ${request.purpose}, but did not return valid JSON.`,
|
|
543
|
-
details: {
|
|
596
|
+
code: outputAnalysis.onlyLifecycleEvents ? "codex_no_final_response" : "codex_invalid_json",
|
|
597
|
+
message: outputAnalysis.onlyLifecycleEvents ? `Codex emitted lifecycle events during ${request.purpose}, but did not produce a final JSON response.` : `Codex completed ${request.purpose}, but did not return valid JSON.`,
|
|
598
|
+
details: {
|
|
599
|
+
finalText,
|
|
600
|
+
stdout: stdoutText,
|
|
601
|
+
stderr: stderrText,
|
|
602
|
+
event_types: outputAnalysis.eventTypes,
|
|
603
|
+
event_line_count: outputAnalysis.eventLineCount,
|
|
604
|
+
non_event_line_count: outputAnalysis.nonEventLineCount,
|
|
605
|
+
non_event_samples: outputAnalysis.nonEventSamples
|
|
606
|
+
}
|
|
544
607
|
}
|
|
545
608
|
};
|
|
546
609
|
}
|
|
@@ -558,7 +621,8 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
558
621
|
stderr: stderrText,
|
|
559
622
|
finalText,
|
|
560
623
|
parsedJsonSource,
|
|
561
|
-
status: proc.status
|
|
624
|
+
status: proc.status,
|
|
625
|
+
timeoutMs
|
|
562
626
|
})
|
|
563
627
|
};
|
|
564
628
|
} finally {
|
|
@@ -667,6 +731,7 @@ function createCodexExecAgentAdapter(config = {}, runner = createCodexExecJsonRu
|
|
|
667
731
|
"Write a proof_plan and capture_script that will verify the exact user-facing change.",
|
|
668
732
|
"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.",
|
|
669
733
|
"Use the recon-approved route and baseline context; make the plan name the concrete target, expected before state, expected after state, and stop condition.",
|
|
734
|
+
"Do not leave this authoring stage pending for external investigation. Keep any repo inspection brief, do not modify files, and return the JSON proof packet from the available state.",
|
|
670
735
|
"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.",
|
|
671
736
|
"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.",
|
|
672
737
|
"For interaction proof, return a structured evidence object with start route/state, terminal route/state, action, assertions, and matched UI text. Catch waitForURL or selector timeouts and record them as failed assertions instead of throwing before evidence is emitted.",
|