@riddledc/riddle-proof 0.7.225 → 0.7.227

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/adapters/codex-exec-agent.cjs +893 -0
  2. package/dist/adapters/codex-exec-agent.d.cts +3 -0
  3. package/dist/adapters/codex-exec-agent.d.ts +3 -0
  4. package/dist/adapters/codex-exec-agent.js +13 -0
  5. package/dist/adapters/codex.cjs +893 -0
  6. package/dist/adapters/codex.d.cts +3 -0
  7. package/dist/adapters/codex.d.ts +3 -0
  8. package/dist/adapters/codex.js +13 -0
  9. package/dist/adapters/local-agent.cjs +893 -0
  10. package/dist/adapters/local-agent.d.cts +3 -0
  11. package/dist/adapters/local-agent.d.ts +3 -0
  12. package/dist/adapters/local-agent.js +13 -0
  13. package/dist/adapters/openclaw.cjs +213 -0
  14. package/dist/adapters/openclaw.d.cts +2 -0
  15. package/dist/adapters/openclaw.d.ts +2 -0
  16. package/dist/adapters/openclaw.js +17 -0
  17. package/dist/advanced/engine-harness.cjs +5701 -0
  18. package/dist/advanced/engine-harness.d.cts +2 -0
  19. package/dist/advanced/engine-harness.d.ts +2 -0
  20. package/dist/advanced/engine-harness.js +16 -0
  21. package/dist/advanced/index.cjs +6242 -0
  22. package/dist/advanced/index.d.cts +5 -0
  23. package/dist/advanced/index.d.ts +5 -0
  24. package/dist/advanced/index.js +23 -0
  25. package/dist/advanced/proof-run-core.cjs +1085 -0
  26. package/dist/advanced/proof-run-core.d.cts +1 -0
  27. package/dist/advanced/proof-run-core.d.ts +1 -0
  28. package/dist/advanced/proof-run-core.js +59 -0
  29. package/dist/advanced/proof-run-engine.cjs +2905 -0
  30. package/dist/advanced/proof-run-engine.d.cts +2 -0
  31. package/dist/advanced/proof-run-engine.d.ts +2 -0
  32. package/dist/advanced/proof-run-engine.js +10 -0
  33. package/dist/advanced/runner.cjs +833 -0
  34. package/dist/advanced/runner.d.cts +2 -0
  35. package/dist/advanced/runner.d.ts +2 -0
  36. package/dist/advanced/runner.js +12 -0
  37. package/dist/app-contract/index.cjs +24 -0
  38. package/dist/app-contract/index.d.cts +1 -0
  39. package/dist/app-contract/index.d.ts +1 -0
  40. package/dist/app-contract/index.js +2 -0
  41. package/dist/basic-gameplay.js +1 -0
  42. package/dist/checkpoint.js +1 -0
  43. package/dist/chunk-BHL4JSGM.js +1900 -0
  44. package/dist/chunk-BTN76IGW.js +115 -0
  45. package/dist/{chunk-TGHTM66Z.js → chunk-COERZX63.js} +10 -2
  46. package/dist/{chunk-4DRRIJDX.js → chunk-IWLQQ5S5.js} +27 -4
  47. package/dist/chunk-MLKGABMK.js +9 -0
  48. package/dist/chunk-OFSECTSC.js +0 -0
  49. package/dist/{chunk-GBVEQQIM.js → chunk-TJ63IE65.js} +36 -1
  50. package/dist/chunk-VZD5LH7U.js +4138 -0
  51. package/dist/cli/index.cjs +18 -0
  52. package/dist/cli/index.d.cts +2 -0
  53. package/dist/cli/index.d.ts +2 -0
  54. package/dist/cli/index.js +12 -0
  55. package/dist/cli.cjs +19 -2
  56. package/dist/cli.d.cts +1 -0
  57. package/dist/cli.d.ts +1 -0
  58. package/dist/cli.js +8 -4139
  59. package/dist/codex-exec-agent.d.cts +1 -1
  60. package/dist/codex-exec-agent.d.ts +1 -1
  61. package/dist/codex-exec-agent.js +1 -0
  62. package/dist/diagnostics.js +1 -0
  63. package/dist/engine-harness-CMACHP6A.d.ts +96 -0
  64. package/dist/engine-harness-LBfqbFSe.d.cts +96 -0
  65. package/dist/engine-harness.cjs +19 -2
  66. package/dist/engine-harness.d.cts +2 -79
  67. package/dist/engine-harness.d.ts +2 -79
  68. package/dist/engine-harness.js +3 -2
  69. package/dist/index.cjs +19 -2
  70. package/dist/index.d.cts +2 -2
  71. package/dist/index.d.ts +2 -2
  72. package/dist/index.js +4 -3
  73. package/dist/local-agent.d.cts +1 -1
  74. package/dist/local-agent.d.ts +1 -1
  75. package/dist/local-agent.js +1 -0
  76. package/dist/openclaw.js +8 -107
  77. package/dist/playability.js +1 -0
  78. package/dist/profile/index.cjs +9403 -0
  79. package/dist/profile/index.d.cts +2 -0
  80. package/dist/profile/index.d.ts +2 -0
  81. package/dist/profile/index.js +53 -0
  82. package/dist/profile.js +1 -0
  83. package/dist/proof-run-core-CE0jx7wL.d.cts +359 -0
  84. package/dist/proof-run-core-CE0jx7wL.d.ts +359 -0
  85. package/dist/proof-run-core.d.cts +1 -322
  86. package/dist/proof-run-core.d.ts +1 -322
  87. package/dist/proof-run-core.js +2 -1
  88. package/dist/proof-run-engine-CSSc0mNn.d.ts +764 -0
  89. package/dist/proof-run-engine-HSRpUeBi.d.cts +764 -0
  90. package/dist/proof-run-engine.cjs +4 -0
  91. package/dist/proof-run-engine.d.cts +2 -757
  92. package/dist/proof-run-engine.d.ts +2 -757
  93. package/dist/proof-run-engine.js +5 -1881
  94. package/dist/proof-session.js +1 -0
  95. package/dist/result.js +1 -0
  96. package/dist/riddle-client.js +1 -0
  97. package/dist/run-card.js +1 -0
  98. package/dist/runner-4LJ5z0D-.d.cts +29 -0
  99. package/dist/runner-BdQpOkZD.d.ts +29 -0
  100. package/dist/runner.d.cts +2 -22
  101. package/dist/runner.d.ts +2 -22
  102. package/dist/runner.js +3 -2
  103. package/dist/runtime/index.cjs +528 -0
  104. package/dist/runtime/index.d.cts +1 -0
  105. package/dist/runtime/index.d.ts +1 -0
  106. package/dist/runtime/index.js +37 -0
  107. package/dist/runtime/riddle-client.cjs +528 -0
  108. package/dist/runtime/riddle-client.d.cts +1 -0
  109. package/dist/runtime/riddle-client.d.ts +1 -0
  110. package/dist/runtime/riddle-client.js +37 -0
  111. package/dist/spec/checkpoint.cjs +807 -0
  112. package/dist/spec/checkpoint.d.cts +2 -0
  113. package/dist/spec/checkpoint.d.ts +2 -0
  114. package/dist/spec/checkpoint.js +34 -0
  115. package/dist/spec/index.cjs +1510 -0
  116. package/dist/spec/index.d.cts +5 -0
  117. package/dist/spec/index.d.ts +5 -0
  118. package/dist/spec/index.js +80 -0
  119. package/dist/spec/result.cjs +259 -0
  120. package/dist/spec/result.d.cts +2 -0
  121. package/dist/spec/result.d.ts +2 -0
  122. package/dist/spec/result.js +21 -0
  123. package/dist/spec/run-card.cjs +287 -0
  124. package/dist/spec/run-card.d.cts +2 -0
  125. package/dist/spec/run-card.d.ts +2 -0
  126. package/dist/spec/run-card.js +11 -0
  127. package/dist/spec/state.cjs +541 -0
  128. package/dist/spec/state.d.cts +2 -0
  129. package/dist/spec/state.d.ts +2 -0
  130. package/dist/spec/state.js +28 -0
  131. package/dist/spec/types.cjs +18 -0
  132. package/dist/spec/types.d.cts +1 -0
  133. package/dist/spec/types.d.ts +1 -0
  134. package/dist/spec/types.js +1 -0
  135. package/dist/state.js +1 -0
  136. package/package.json +95 -2
  137. package/runtime/lib/verify.py +53 -3
  138. package/runtime/pipelines/riddle-proof-setup.lobster +45 -41
  139. package/runtime/tests/recon_verify_smoke.py +41 -0
@@ -0,0 +1,893 @@
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/adapters/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
+
45
+ // src/result.ts
46
+ function compactRecord(input) {
47
+ return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
48
+ }
49
+
50
+ // src/codex-exec-agent.ts
51
+ var REFINED_INPUTS_SCHEMA = {
52
+ type: "object",
53
+ additionalProperties: false,
54
+ required: ["server_path", "wait_for_selector", "reference"],
55
+ properties: {
56
+ server_path: { type: ["string", "null"] },
57
+ wait_for_selector: { type: ["string", "null"] },
58
+ reference: { enum: ["before", "prod", "both", null] }
59
+ }
60
+ };
61
+ var BASELINE_UNDERSTANDING_SCHEMA = {
62
+ type: "object",
63
+ additionalProperties: false,
64
+ required: [
65
+ "reference",
66
+ "target_route",
67
+ "before_evidence_url",
68
+ "visible_before_state",
69
+ "relevant_elements",
70
+ "requested_change",
71
+ "proof_focus",
72
+ "stop_condition",
73
+ "quality_risks"
74
+ ],
75
+ properties: {
76
+ reference: { type: "string", enum: ["before", "prod", "both", "unknown"] },
77
+ target_route: { type: "string" },
78
+ before_evidence_url: { type: "string" },
79
+ visible_before_state: { type: "string" },
80
+ relevant_elements: { type: "array", items: { type: "string" } },
81
+ requested_change: { type: "string" },
82
+ proof_focus: { type: "string" },
83
+ stop_condition: { type: "string" },
84
+ quality_risks: { type: "array", items: { type: "string" } }
85
+ }
86
+ };
87
+ var RECON_SCHEMA = {
88
+ type: "object",
89
+ additionalProperties: false,
90
+ required: [
91
+ "decision",
92
+ "summary",
93
+ "baseline_understanding",
94
+ "continue_with_stage",
95
+ "escalation_target",
96
+ "refined_inputs",
97
+ "reasons",
98
+ "source"
99
+ ],
100
+ properties: {
101
+ decision: { type: "string", enum: ["retry_recon", "ready_for_author", "recon_stuck"] },
102
+ summary: { type: "string" },
103
+ baseline_understanding: BASELINE_UNDERSTANDING_SCHEMA,
104
+ continue_with_stage: { type: "string", enum: ["recon", "author"] },
105
+ escalation_target: { type: "string", enum: ["agent", "human"] },
106
+ refined_inputs: REFINED_INPUTS_SCHEMA,
107
+ reasons: { type: "array", items: { type: "string" } },
108
+ source: { type: "string", enum: ["supervising_agent"] }
109
+ }
110
+ };
111
+ var AUTHOR_SCHEMA = {
112
+ type: "object",
113
+ additionalProperties: false,
114
+ required: [
115
+ "proof_plan",
116
+ "capture_script",
117
+ "baseline_understanding_used",
118
+ "refined_inputs",
119
+ "rationale",
120
+ "confidence",
121
+ "summary"
122
+ ],
123
+ properties: {
124
+ proof_plan: { type: "string" },
125
+ capture_script: { type: "string" },
126
+ baseline_understanding_used: BASELINE_UNDERSTANDING_SCHEMA,
127
+ refined_inputs: REFINED_INPUTS_SCHEMA,
128
+ rationale: { type: "array", items: { type: "string" } },
129
+ confidence: { type: "string", enum: ["low", "medium", "high"] },
130
+ summary: { type: "string" }
131
+ }
132
+ };
133
+ var IMPLEMENT_SCHEMA = {
134
+ type: "object",
135
+ additionalProperties: false,
136
+ required: ["summary", "implementation_notes", "changed_files", "tests_run", "blockers"],
137
+ properties: {
138
+ summary: { type: "string" },
139
+ implementation_notes: { type: "string" },
140
+ changed_files: { type: "array", items: { type: "string" } },
141
+ tests_run: { type: "array", items: { type: "string" } },
142
+ blockers: { type: "array", items: { type: "string" } }
143
+ }
144
+ };
145
+ var PROOF_SCHEMA = {
146
+ type: "object",
147
+ additionalProperties: false,
148
+ required: [
149
+ "decision",
150
+ "summary",
151
+ "recommended_stage",
152
+ "continue_with_stage",
153
+ "escalation_target",
154
+ "reasons",
155
+ "source"
156
+ ],
157
+ properties: {
158
+ decision: {
159
+ type: "string",
160
+ enum: [
161
+ "ready_to_ship",
162
+ "needs_richer_proof",
163
+ "revise_capture",
164
+ "needs_recon",
165
+ "needs_implementation"
166
+ ]
167
+ },
168
+ summary: { type: "string" },
169
+ recommended_stage: { type: "string", enum: ["ship", "author", "implement", "recon", "verify"] },
170
+ continue_with_stage: { type: "string", enum: ["ship", "author", "implement", "recon", "verify"] },
171
+ escalation_target: { type: "string", enum: ["agent", "human"] },
172
+ reasons: { type: "array", items: { type: "string" } },
173
+ source: { type: "string", enum: ["supervising_agent"] }
174
+ }
175
+ };
176
+ var PROMPT_STRING_LIMIT = 1e3;
177
+ var PROMPT_ARRAY_LIMIT = 8;
178
+ var PROMPT_OBJECT_KEY_LIMIT = 50;
179
+ var PROMPT_BLOCK_LIMIT = 16e3;
180
+ var PROMPT_TOTAL_LIMIT = 58e3;
181
+ var PROMPT_KEY_PRIORITY = [
182
+ "ok",
183
+ "status",
184
+ "stage",
185
+ "checkpoint",
186
+ "summary",
187
+ "state_path",
188
+ "repo",
189
+ "branch",
190
+ "change_request",
191
+ "context",
192
+ "success_criteria",
193
+ "verification_mode",
194
+ "reference",
195
+ "server_path",
196
+ "wait_for_selector",
197
+ "before_cdn",
198
+ "prod_cdn",
199
+ "after_cdn",
200
+ "before_baseline",
201
+ "prod_baseline",
202
+ "route_hints",
203
+ "route_candidates",
204
+ "keyword_hits",
205
+ "observations",
206
+ "latest_attempt",
207
+ "attempt_history",
208
+ "current_plan",
209
+ "plan_history",
210
+ "decision_history",
211
+ "refined_inputs",
212
+ "recon_assessment",
213
+ "baseline_understanding",
214
+ "supervisor_author_packet",
215
+ "proof_plan",
216
+ "capture_script",
217
+ "implementation_status",
218
+ "implementation_summary",
219
+ "implementation_notes",
220
+ "changed_files",
221
+ "verify_status",
222
+ "verify_summary",
223
+ "proof_assessment",
224
+ "proof_assessment_request",
225
+ "semantic_context",
226
+ "visual_delta",
227
+ "proof_evidence_present",
228
+ "proof_evidence_sample",
229
+ "artifacts",
230
+ "assertions",
231
+ "checkpointContract",
232
+ "shipGate",
233
+ "last_error",
234
+ "errors",
235
+ "runtime_events",
236
+ "events"
237
+ ];
238
+ var PROMPT_PRIORITY_INDEX = new Map(PROMPT_KEY_PRIORITY.map((key, index) => [key, index]));
239
+ function truncatePromptString(value, limit = PROMPT_STRING_LIMIT) {
240
+ if (value.length <= limit) return value;
241
+ return `${value.slice(0, limit)}
242
+ ...[truncated ${value.length - limit} chars]`;
243
+ }
244
+ function compactPromptValue(value, depth = 0, key = "") {
245
+ if (value === null || typeof value === "boolean" || typeof value === "number") return value;
246
+ if (typeof value === "string") {
247
+ const lowerKey = key.toLowerCase();
248
+ const looksLikeUrl = /^https?:\/\//.test(value);
249
+ if (!looksLikeUrl && (lowerKey.includes("base64") || lowerKey.includes("data_url") || lowerKey.includes("screenshot_blob"))) {
250
+ return `[omitted ${value.length} chars from ${key || "large artifact"}]`;
251
+ }
252
+ const limit = looksLikeUrl ? 1e3 : depth <= 1 ? PROMPT_STRING_LIMIT : 900;
253
+ return truncatePromptString(value, limit);
254
+ }
255
+ if (Array.isArray(value)) {
256
+ const lowerKey = key.toLowerCase();
257
+ const items = lowerKey.includes("event") || lowerKey.includes("histor") || lowerKey.includes("retry") ? value.slice(-PROMPT_ARRAY_LIMIT) : value.slice(0, PROMPT_ARRAY_LIMIT);
258
+ const compacted = items.map((item) => compactPromptValue(item, depth + 1, key));
259
+ if (value.length > items.length) {
260
+ const omitted = value.length - items.length;
261
+ return lowerKey.includes("event") || lowerKey.includes("histor") || lowerKey.includes("retry") ? [{ omittedEarlierItems: omitted }, ...compacted] : [...compacted, { omittedItems: omitted }];
262
+ }
263
+ return compacted;
264
+ }
265
+ if (!value || typeof value !== "object") return String(value);
266
+ const entries = Object.entries(value).sort(([left], [right]) => {
267
+ const leftPriority = PROMPT_PRIORITY_INDEX.get(left) ?? 1e3;
268
+ const rightPriority = PROMPT_PRIORITY_INDEX.get(right) ?? 1e3;
269
+ if (leftPriority !== rightPriority) return leftPriority - rightPriority;
270
+ return left.localeCompare(right);
271
+ });
272
+ const result = {};
273
+ for (const [entryKey, entryValue] of entries.slice(0, PROMPT_OBJECT_KEY_LIMIT)) {
274
+ result[entryKey] = compactPromptValue(entryValue, depth + 1, entryKey);
275
+ }
276
+ if (entries.length > PROMPT_OBJECT_KEY_LIMIT) {
277
+ result.__omitted_keys = entries.length - PROMPT_OBJECT_KEY_LIMIT;
278
+ }
279
+ return result;
280
+ }
281
+ function jsonBlock(label, value) {
282
+ let json = JSON.stringify(compactPromptValue(value), null, 2);
283
+ if (json.length > PROMPT_BLOCK_LIMIT) {
284
+ json = `${json.slice(0, PROMPT_BLOCK_LIMIT)}
285
+ ...[truncated ${json.length - PROMPT_BLOCK_LIMIT} chars from compacted ${label}]`;
286
+ }
287
+ return `${label}:
288
+ ${json}`;
289
+ }
290
+ function resolveWorkdir(context, fallback = "/tmp") {
291
+ const after = typeof context.fullRiddleState?.after_worktree === "string" ? context.fullRiddleState.after_worktree.trim() : "";
292
+ return after || fallback;
293
+ }
294
+ function basePrompt(context, role) {
295
+ const prompt = [
296
+ role,
297
+ "",
298
+ "You are the supervising Codex worker inside the Riddle Proof harness.",
299
+ "Return only JSON matching the provided output schema.",
300
+ "Do not ask the human to manually continue. If blocked, encode the blocker in the JSON fields allowed by the schema.",
301
+ "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.",
302
+ "",
303
+ jsonBlock("Original request", context.request),
304
+ jsonBlock("Riddle checkpoint result", context.engineResult),
305
+ jsonBlock("Full riddle state", context.fullRiddleState || {})
306
+ ].join("\n");
307
+ if (prompt.length <= PROMPT_TOTAL_LIMIT) return prompt;
308
+ return `${prompt.slice(0, PROMPT_TOTAL_LIMIT).trimEnd()}
309
+ ...[truncated ${prompt.length - PROMPT_TOTAL_LIMIT} chars from total prompt]`;
310
+ }
311
+ function schemaRequiredKeys(schema) {
312
+ const required = schema?.required;
313
+ return Array.isArray(required) ? required.filter((key) => typeof key === "string" && key.length > 0) : [];
314
+ }
315
+ function isSchemaShapedObject(value, schema) {
316
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
317
+ const required = schemaRequiredKeys(schema);
318
+ return required.every((key) => Object.prototype.hasOwnProperty.call(value, key));
319
+ }
320
+ function parseJsonCandidate(raw, schema) {
321
+ try {
322
+ const parsed = JSON.parse(raw);
323
+ return isSchemaShapedObject(parsed, schema) ? parsed : null;
324
+ } catch {
325
+ return null;
326
+ }
327
+ }
328
+ function extractJsonObjectCandidates(raw) {
329
+ const candidates = [];
330
+ let depth = 0;
331
+ let start = -1;
332
+ let inString = false;
333
+ let escaped = false;
334
+ for (let index = 0; index < raw.length; index += 1) {
335
+ const char = raw[index];
336
+ if (inString) {
337
+ if (escaped) {
338
+ escaped = false;
339
+ } else if (char === "\\") {
340
+ escaped = true;
341
+ } else if (char === '"') {
342
+ inString = false;
343
+ }
344
+ continue;
345
+ }
346
+ if (char === '"') {
347
+ inString = true;
348
+ continue;
349
+ }
350
+ if (char === "{") {
351
+ if (depth === 0) start = index;
352
+ depth += 1;
353
+ continue;
354
+ }
355
+ if (char === "}" && depth > 0) {
356
+ depth -= 1;
357
+ if (depth === 0 && start >= 0) {
358
+ candidates.push(raw.slice(start, index + 1));
359
+ start = -1;
360
+ }
361
+ }
362
+ }
363
+ return candidates;
364
+ }
365
+ function parseJsonObject(raw, schema) {
366
+ const trimmed = raw.trim();
367
+ if (!trimmed) return null;
368
+ const whole = parseJsonCandidate(trimmed, schema);
369
+ if (whole) return whole;
370
+ const lines = trimmed.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
371
+ for (let index = lines.length - 1; index >= 0; index -= 1) {
372
+ const parsed = parseJsonCandidate(lines[index], schema);
373
+ if (parsed) return parsed;
374
+ }
375
+ const candidates = extractJsonObjectCandidates(trimmed);
376
+ for (let index = candidates.length - 1; index >= 0; index -= 1) {
377
+ const parsed = parseJsonCandidate(candidates[index], schema);
378
+ if (parsed) return parsed;
379
+ }
380
+ return null;
381
+ }
382
+ function isHarnessVerificationOnlyBlocker(blocker) {
383
+ const text = blocker.toLowerCase();
384
+ return (text.includes("erofs") || text.includes("read-only file system")) && text.includes("node_modules") && (text.includes(".vite-temp") || text.includes("vite.config"));
385
+ }
386
+ function runnerMetrics(input) {
387
+ const schemaText = JSON.stringify(input.request.schema);
388
+ const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
389
+ return compactRecord({
390
+ purpose: input.request.purpose,
391
+ workdir: input.request.workdir,
392
+ started_at: input.startedAt,
393
+ finished_at: finishedAt,
394
+ duration_ms: Date.now() - input.startedMs,
395
+ prompt_chars: input.request.prompt.length,
396
+ prompt_lines: input.request.prompt.split(/\r?\n/).length,
397
+ schema_chars: schemaText.length,
398
+ stdout_chars: (input.stdout || "").length,
399
+ stderr_chars: (input.stderr || "").length,
400
+ final_message_chars: (input.finalText || "").length,
401
+ exit_status: input.status ?? null,
402
+ timed_out: input.timedOut || false,
403
+ error_code: input.errorCode,
404
+ codex_command: input.config.codexCommand || "codex",
405
+ codex_model: input.config.codexModel,
406
+ codex_sandbox: input.config.codexSandbox || "workspace-write",
407
+ codex_full_auto: input.config.codexFullAuto !== false,
408
+ timeout_ms: Number(input.config.codexTimeoutMs || 6e5)
409
+ });
410
+ }
411
+ function createCodexExecJsonRunner(config = {}) {
412
+ return (request) => {
413
+ const startedAt = (/* @__PURE__ */ new Date()).toISOString();
414
+ const startedMs = Date.now();
415
+ if (!request.workdir || !(0, import_node_fs.existsSync)(request.workdir)) {
416
+ return {
417
+ ok: false,
418
+ metrics: runnerMetrics({ request, config, startedAt, startedMs, errorCode: "workdir_missing" }),
419
+ blocker: {
420
+ code: "codex_workdir_missing",
421
+ message: `Codex workdir does not exist for ${request.purpose}.`,
422
+ details: { workdir: request.workdir }
423
+ }
424
+ };
425
+ }
426
+ const tmpDir = (0, import_node_fs.mkdtempSync)(import_node_path.default.join(import_node_os.default.tmpdir(), "riddle-proof-codex-"));
427
+ const schemaPath = import_node_path.default.join(tmpDir, "schema.json");
428
+ const lastMessagePath = import_node_path.default.join(tmpDir, "last-message.json");
429
+ (0, import_node_fs.writeFileSync)(schemaPath, JSON.stringify(request.schema, null, 2));
430
+ const args = [
431
+ "exec",
432
+ "--json",
433
+ "--output-schema",
434
+ schemaPath,
435
+ "--output-last-message",
436
+ lastMessagePath,
437
+ "--cd",
438
+ request.workdir,
439
+ "--sandbox",
440
+ config.codexSandbox || "workspace-write",
441
+ "--skip-git-repo-check"
442
+ ];
443
+ if (config.codexFullAuto !== false) args.push("--full-auto");
444
+ if (config.codexModel) args.push("-m", config.codexModel);
445
+ args.push("-");
446
+ const env = { ...process.env };
447
+ if (config.codexHome) env.CODEX_HOME = config.codexHome;
448
+ delete env.OPENAI_API_KEY;
449
+ try {
450
+ const proc = (0, import_node_child_process.spawnSync)(config.codexCommand || "codex", args, {
451
+ input: request.prompt,
452
+ encoding: "utf-8",
453
+ timeout: Number(config.codexTimeoutMs || 6e5),
454
+ maxBuffer: 10 * 1024 * 1024,
455
+ env
456
+ });
457
+ if (proc.error) {
458
+ const timedOut = proc.error.code === "ETIMEDOUT";
459
+ return {
460
+ ok: false,
461
+ stdout: proc.stdout || "",
462
+ stderr: proc.stderr || "",
463
+ metrics: runnerMetrics({
464
+ request,
465
+ config,
466
+ startedAt,
467
+ startedMs,
468
+ stdout: proc.stdout || "",
469
+ stderr: proc.stderr || "",
470
+ status: proc.status,
471
+ timedOut,
472
+ errorCode: proc.error.code || "spawn_error"
473
+ }),
474
+ blocker: {
475
+ code: timedOut ? "codex_timeout" : "codex_exec_error",
476
+ message: timedOut ? `Codex timed out during ${request.purpose}.` : `Codex failed to start or complete ${request.purpose}.`,
477
+ details: { error: proc.error.message }
478
+ }
479
+ };
480
+ }
481
+ if (proc.status !== 0) {
482
+ return {
483
+ ok: false,
484
+ stdout: proc.stdout || "",
485
+ stderr: proc.stderr || "",
486
+ metrics: runnerMetrics({
487
+ request,
488
+ config,
489
+ startedAt,
490
+ startedMs,
491
+ stdout: proc.stdout || "",
492
+ stderr: proc.stderr || "",
493
+ status: proc.status,
494
+ errorCode: "nonzero_exit"
495
+ }),
496
+ blocker: {
497
+ code: "codex_nonzero_exit",
498
+ message: `Codex exited with status ${proc.status} during ${request.purpose}.`,
499
+ details: { stdout: proc.stdout || "", stderr: proc.stderr || "" }
500
+ }
501
+ };
502
+ }
503
+ const finalText = (0, import_node_fs.existsSync)(lastMessagePath) ? (0, import_node_fs.readFileSync)(lastMessagePath, "utf-8") : String(proc.stdout || "");
504
+ const parsed = parseJsonObject(finalText, request.schema);
505
+ if (!parsed) {
506
+ return {
507
+ ok: false,
508
+ stdout: proc.stdout || "",
509
+ stderr: proc.stderr || "",
510
+ metrics: runnerMetrics({
511
+ request,
512
+ config,
513
+ startedAt,
514
+ startedMs,
515
+ stdout: proc.stdout || "",
516
+ stderr: proc.stderr || "",
517
+ finalText,
518
+ status: proc.status,
519
+ errorCode: "invalid_json"
520
+ }),
521
+ blocker: {
522
+ code: "codex_invalid_json",
523
+ message: `Codex completed ${request.purpose}, but did not return valid JSON.`,
524
+ details: { finalText, stdout: proc.stdout || "", stderr: proc.stderr || "" }
525
+ }
526
+ };
527
+ }
528
+ return {
529
+ ok: true,
530
+ json: parsed,
531
+ stdout: proc.stdout || "",
532
+ stderr: proc.stderr || "",
533
+ metrics: runnerMetrics({
534
+ request,
535
+ config,
536
+ startedAt,
537
+ startedMs,
538
+ stdout: proc.stdout || "",
539
+ stderr: proc.stderr || "",
540
+ finalText,
541
+ status: proc.status
542
+ })
543
+ };
544
+ } finally {
545
+ (0, import_node_fs.rmSync)(tmpDir, { recursive: true, force: true });
546
+ }
547
+ };
548
+ }
549
+ async function callRunner(runner, request) {
550
+ return runner(request);
551
+ }
552
+ function payloadOrBlocker(raw, checkpoint) {
553
+ if (!raw.ok || !raw.json) {
554
+ const blocker = raw.blocker || {
555
+ code: "codex_runner_failed",
556
+ message: "Codex runner failed without a detailed blocker.",
557
+ details: { stdout: raw.stdout || "", stderr: raw.stderr || "" }
558
+ };
559
+ return {
560
+ ok: false,
561
+ blocker: {
562
+ ...blocker,
563
+ checkpoint,
564
+ details: {
565
+ ...blocker.details || {},
566
+ runner_metrics: raw.metrics || null
567
+ }
568
+ }
569
+ };
570
+ }
571
+ return {
572
+ ok: true,
573
+ payload: raw.json,
574
+ summary: typeof raw.json.summary === "string" ? raw.json.summary : void 0,
575
+ details: compactRecord({
576
+ runner_metrics: raw.metrics || null
577
+ })
578
+ };
579
+ }
580
+ function stringArray(value) {
581
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
582
+ }
583
+ function parseGitStatusPaths(status) {
584
+ return status.split(/\r?\n/).map((line) => line.trimEnd()).filter(Boolean).map((line) => {
585
+ let item = line.length > 3 ? line.slice(3) : line;
586
+ if (item.includes(" -> ")) item = item.split(" -> ").pop() || item;
587
+ return item.trim();
588
+ }).filter(Boolean);
589
+ }
590
+ function isToolNoisePath(filePath) {
591
+ return filePath === ".codex" || filePath.startsWith(".codex/") || filePath === ".oc-smoke" || filePath.startsWith(".oc-smoke/");
592
+ }
593
+ function hasGitDiff(workdir) {
594
+ try {
595
+ const status = git(["status", "--porcelain"], workdir);
596
+ return parseGitStatusPaths(status).some((filePath) => !isToolNoisePath(filePath));
597
+ } catch {
598
+ return false;
599
+ }
600
+ }
601
+ function buildImplementationPrompt(context, extraLines = []) {
602
+ return [
603
+ basePrompt(context, "Implement the requested code change in the after worktree."),
604
+ "Make the code changes directly in this repository.",
605
+ "Use the recon-approved baseline understanding in the state to decide exactly what prior UI/state is being changed.",
606
+ "Run focused checks when practical.",
607
+ "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.",
608
+ "Leave a real git diff in the after worktree. Do not commit or push.",
609
+ "Before you return success, run git status --short and git diff --name-only in this repository and verify they show the intended change.",
610
+ "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.",
611
+ "changed_files should match the real git diff as closely as practical.",
612
+ "Return changed_files, implementation_notes, tests_run, and blockers if any.",
613
+ "Use empty arrays for tests_run or blockers when none apply.",
614
+ ...extraLines
615
+ ].join("\n");
616
+ }
617
+ function createCodexExecAgentAdapter(config = {}, runner = createCodexExecJsonRunner(config)) {
618
+ return {
619
+ async assessRecon(context) {
620
+ const raw = await callRunner(runner, {
621
+ purpose: "recon assessment",
622
+ workdir: resolveWorkdir(context),
623
+ schema: RECON_SCHEMA,
624
+ prompt: [
625
+ basePrompt(context, "Judge the latest recon packet."),
626
+ "Decide whether recon should retry, continue to author, or escalate to the human.",
627
+ "This is the first intelligent before-evidence gate. It runs before proof authoring and before any code edits.",
628
+ "Prefer ready_for_author only when the baseline evidence is trustworthy for the requested change.",
629
+ "Do not approve recon just because telemetry_ready is true or a screenshot URL exists.",
630
+ "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.",
631
+ "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.",
632
+ "If you cannot write a specific baseline_understanding from the current evidence, choose retry_recon or recon_stuck; do not choose ready_for_author.",
633
+ "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.",
634
+ "Your summary must say what is visibly present in the approved baseline or why the current baseline is not good enough.",
635
+ "Always include refined_inputs; use null values for server_path, wait_for_selector, or reference when no refinement is needed."
636
+ ].join("\n")
637
+ });
638
+ return payloadOrBlocker(raw, context.checkpoint);
639
+ },
640
+ async authorProofPacket(context) {
641
+ const raw = await callRunner(runner, {
642
+ purpose: "proof packet authoring",
643
+ workdir: resolveWorkdir(context),
644
+ schema: AUTHOR_SCHEMA,
645
+ prompt: [
646
+ basePrompt(context, "Author the proof packet."),
647
+ "Write a proof_plan and capture_script that will verify the exact user-facing change.",
648
+ "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.",
649
+ "Use the recon-approved route and baseline context; make the plan name the concrete target, expected before state, expected after state, and stop condition.",
650
+ "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.",
651
+ "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.",
652
+ "For structured proof, collect meaningful measurements inside page.evaluate, assign them to an evidence variable, and return that object from capture_script. Screenshots are optional supporting context for data/audio/log/metric/custom modes.",
653
+ "Do not assign globalThis.__riddleProofEvidence, window.__riddleProofEvidence, or self.__riddleProofEvidence in the worker context. Avoid global evidence assignment unless it is inside page.evaluate for compatibility with older packets.",
654
+ "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.",
655
+ "When page.evaluate needs data from the outer Playwright script, pass exactly one serializable argument object; do not pass multiple positional arguments.",
656
+ "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.",
657
+ "For audio/data/metric proof, return the same evidence object: const evidence = await page.evaluate(async () => ({ /* browser measurements */ })); Then assert evidence fields before saving screenshots and return evidence from capture_script.",
658
+ "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.",
659
+ "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.",
660
+ "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.",
661
+ "Include a short matchedSnippet or normalizedTextSample when proofing copy so assertion mismatches are diagnosable.",
662
+ "For visual/UI proof, include saveScreenshot('after-proof') exactly once.",
663
+ "Avoid generic proof language. The packet should be specific enough that verify can tell whether the requested change actually happened.",
664
+ "Echo the baseline understanding you used in baseline_understanding_used so later stages can detect drift.",
665
+ "Use refined_inputs for server_path, wait_for_selector, or reference when useful; use null values when no refinement is needed."
666
+ ].join("\n")
667
+ });
668
+ return payloadOrBlocker(raw, context.checkpoint);
669
+ },
670
+ async implementChange(context) {
671
+ if (!context.workdir || !(0, import_node_fs.existsSync)(context.workdir)) {
672
+ return {
673
+ ok: false,
674
+ blocker: {
675
+ code: "implementation_workdir_missing",
676
+ checkpoint: context.checkpoint,
677
+ message: "The Riddle Proof state does not include an after worktree that exists on disk.",
678
+ details: { workdir: context.workdir || null }
679
+ }
680
+ };
681
+ }
682
+ const workdir = context.workdir;
683
+ const attemptSummaries = [];
684
+ const runImplementationAttempt = async (purpose, extraLines = []) => {
685
+ const raw = await callRunner(runner, {
686
+ purpose,
687
+ workdir,
688
+ schema: IMPLEMENT_SCHEMA,
689
+ prompt: buildImplementationPrompt(context, extraLines)
690
+ });
691
+ if (!raw.ok || !raw.json) {
692
+ return {
693
+ ok: false,
694
+ payload: payloadOrBlocker(raw, context.checkpoint)
695
+ };
696
+ }
697
+ const changedFiles = stringArray(raw.json.changed_files);
698
+ const blockers = stringArray(raw.json.blockers);
699
+ const testsRun = stringArray(raw.json.tests_run);
700
+ const softVerificationBlockers = changedFiles.length ? blockers.filter(isHarnessVerificationOnlyBlocker) : [];
701
+ const hardBlockers = blockers.filter((item) => !softVerificationBlockers.includes(item));
702
+ const implementationNotesRaw = typeof raw.json.implementation_notes === "string" ? raw.json.implementation_notes : "";
703
+ const summary = typeof raw.json.summary === "string" ? raw.json.summary : "";
704
+ const implementationNotes = [
705
+ implementationNotesRaw,
706
+ ...softVerificationBlockers.map((item) => `Harness verification note: ${item}`)
707
+ ].filter(Boolean).join("\n");
708
+ const agentDetails = {
709
+ agent_purpose: purpose,
710
+ agent_summary: summary,
711
+ agent_changed_files: changedFiles,
712
+ agent_tests_run: testsRun,
713
+ agent_blockers: blockers,
714
+ runner_metrics: raw.metrics || null
715
+ };
716
+ attemptSummaries.push({
717
+ purpose,
718
+ summary,
719
+ changed_files: changedFiles,
720
+ tests_run: testsRun,
721
+ blockers,
722
+ runner_metrics: raw.metrics || null
723
+ });
724
+ if (hardBlockers.length) {
725
+ return {
726
+ ok: false,
727
+ payload: {
728
+ ok: false,
729
+ blocker: {
730
+ code: "codex_implementation_blocked",
731
+ checkpoint: context.checkpoint,
732
+ message: summary || "Codex reported implementation blockers.",
733
+ details: {
734
+ blockers: hardBlockers,
735
+ changedFiles,
736
+ testsRun,
737
+ implementationNotes: implementationNotesRaw,
738
+ ...agentDetails
739
+ }
740
+ }
741
+ }
742
+ };
743
+ }
744
+ return {
745
+ ok: true,
746
+ summary,
747
+ changedFiles,
748
+ testsRun,
749
+ implementationNotes,
750
+ implementationNotesRaw,
751
+ softVerificationBlockers,
752
+ hardBlockers,
753
+ agentDetails
754
+ };
755
+ };
756
+ let attempt = await runImplementationAttempt("implementation");
757
+ if (!attempt.ok) return attempt.payload;
758
+ let diffDetected = hasGitDiff(workdir);
759
+ if (!diffDetected) {
760
+ attempt = await runImplementationAttempt("implementation retry", [
761
+ "The previous implementation attempt returned without a detectable git diff in this repository.",
762
+ `Previous summary: ${attempt.summary || "(none)"}`,
763
+ `Previous changed_files: ${JSON.stringify(attempt.changedFiles)}`,
764
+ "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."
765
+ ]);
766
+ if (!attempt.ok) return attempt.payload;
767
+ diffDetected = hasGitDiff(workdir);
768
+ }
769
+ return {
770
+ ok: true,
771
+ summary: attempt.summary || void 0,
772
+ implementationNotes: attempt.implementationNotes || void 0,
773
+ changedFiles: attempt.changedFiles,
774
+ testsRun: attempt.testsRun,
775
+ details: {
776
+ ...attempt.agentDetails,
777
+ implementation_notes: attempt.implementationNotes || attempt.implementationNotesRaw || "",
778
+ soft_verification_blockers: attempt.softVerificationBlockers,
779
+ hard_blocker_count: attempt.hardBlockers.length,
780
+ retry_attempted: attemptSummaries.length > 1,
781
+ attempt_count: attemptSummaries.length,
782
+ attempt_summaries: attemptSummaries,
783
+ post_agent_diff_detected: diffDetected
784
+ }
785
+ };
786
+ },
787
+ async assessProof(context) {
788
+ const raw = await callRunner(runner, {
789
+ purpose: "proof assessment",
790
+ workdir: resolveWorkdir(context),
791
+ schema: PROOF_SCHEMA,
792
+ prompt: [
793
+ basePrompt(context, "Judge the proof bundle."),
794
+ "Decide whether the evidence is ready_to_ship or which internal stage should run next.",
795
+ "Only use ready_to_ship when the before/prod and after evidence actually prove the requested change.",
796
+ "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.",
797
+ "Use semantic_context.route, headings, buttons, and text anchors to ground route/content judgment before calling screenshot evidence wrong-route or unrelated.",
798
+ "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.",
799
+ "For visual/UI proof, screenshots and route/page-state quality still matter, but capture success alone is not proof.",
800
+ "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.",
801
+ "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.",
802
+ "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.",
803
+ "Do not ship if the baseline is blank, shell-only, generic, or unrelated to the requested feature.",
804
+ "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."
805
+ ].join("\n")
806
+ });
807
+ return payloadOrBlocker(raw, context.checkpoint);
808
+ }
809
+ };
810
+ }
811
+ function git(args, workdir) {
812
+ return (0, import_node_child_process.execFileSync)("git", args, {
813
+ cwd: workdir,
814
+ encoding: "utf-8",
815
+ timeout: 1e4
816
+ });
817
+ }
818
+ async function runCodexExecAgentDoctor(config = {}, runner = createCodexExecJsonRunner(config)) {
819
+ const workdir = (0, import_node_fs.mkdtempSync)(import_node_path.default.join(import_node_os.default.tmpdir(), "riddle-proof-codex-doctor-"));
820
+ const targetPath = import_node_path.default.join(workdir, "target.txt");
821
+ (0, import_node_fs.writeFileSync)(targetPath, "color=red\n");
822
+ try {
823
+ git(["init", "-b", "main"], workdir);
824
+ git(["config", "user.email", "doctor@example.com"], workdir);
825
+ git(["config", "user.name", "Riddle Proof Doctor"], workdir);
826
+ git(["add", "target.txt"], workdir);
827
+ git(["commit", "-m", "initial doctor fixture"], workdir);
828
+ } catch (error) {
829
+ return {
830
+ ok: false,
831
+ status: "blocked",
832
+ blocker: {
833
+ code: "doctor_git_setup_failed",
834
+ message: "Could not create the temporary doctor git fixture.",
835
+ details: { error: error instanceof Error ? error.message : String(error), workdir }
836
+ }
837
+ };
838
+ }
839
+ const raw = await callRunner(runner, {
840
+ purpose: "codex exec doctor implementation",
841
+ workdir,
842
+ schema: IMPLEMENT_SCHEMA,
843
+ prompt: [
844
+ "You are running a Riddle Proof Codex exec doctor check.",
845
+ "In this temporary git repository, edit target.txt so it says exactly: color=blue",
846
+ "Do not commit. Leave a git diff.",
847
+ "Return JSON matching the schema with changed_files containing target.txt.",
848
+ "Use empty arrays for tests_run and blockers."
849
+ ].join("\n")
850
+ });
851
+ if (!raw.ok || !raw.json) {
852
+ return {
853
+ ok: false,
854
+ status: "blocked",
855
+ blocker: {
856
+ ...raw.blocker || {
857
+ code: "doctor_codex_failed",
858
+ message: "Codex doctor runner failed.",
859
+ details: { stdout: raw.stdout || "", stderr: raw.stderr || "" }
860
+ },
861
+ details: {
862
+ ...raw.blocker?.details || {},
863
+ workdir
864
+ }
865
+ }
866
+ };
867
+ }
868
+ const content = (0, import_node_fs.readFileSync)(targetPath, "utf-8");
869
+ const status = git(["status", "--porcelain"], workdir);
870
+ const changedFiles = stringArray(raw.json.changed_files);
871
+ const ok = content.trim() === "color=blue" && status.includes("target.txt");
872
+ return {
873
+ ok,
874
+ status: ok ? "passed" : "blocked",
875
+ workdir,
876
+ changedFiles,
877
+ implementationSummary: raw.json.summary || null,
878
+ implementationNotes: raw.json.implementation_notes || null,
879
+ gitStatus: status,
880
+ targetContent: content,
881
+ blocker: ok ? null : {
882
+ code: "doctor_diff_missing_or_wrong",
883
+ message: "Codex doctor completed, but target.txt was not changed to color=blue with a git diff.",
884
+ details: { workdir, changedFiles, gitStatus: status, targetContent: content }
885
+ }
886
+ };
887
+ }
888
+ // Annotate the CommonJS export names for ESM import in node:
889
+ 0 && (module.exports = {
890
+ createLocalAgentAdapter,
891
+ createLocalAgentJsonRunner,
892
+ runLocalAgentDoctor
893
+ });