* Detects whether the log is in the Codex experimental JSONL event format. * Newer Codex CLI versions (e.g. 0.141+) emit a stream of JSON objects such as * `{"type":"thread.started",...}`, `{"type":"turn.completed",...}` and * `{"type":"item.completed","item":{"type":"agent_message",...}}` instea
(lines)
| 304 | * @returns {boolean} True if at least one Codex JSONL event line is present |
| 305 | */ |
| 306 | function isCodexJsonlFormat(lines) { |
| 307 | for (const line of lines) { |
| 308 | const trimmed = line.trim(); |
| 309 | if (!trimmed.startsWith("{")) continue; |
| 310 | let event; |
| 311 | try { |
| 312 | event = JSON.parse(trimmed); |
| 313 | } catch { |
| 314 | continue; |
| 315 | } |
| 316 | if (event && typeof event === "object" && typeof event.type === "string" && /^(thread|turn|item)\./.test(event.type)) { |
| 317 | return true; |
| 318 | } |
| 319 | } |
| 320 | return false; |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * Parse the Codex experimental JSONL event stream into the shared logEntries model. |
no test coverage detected