Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(grok): parse chat_history.jsonl for the context-link reader

Xavi Guardiac214028dd3b7
diff --git a/src/core/__fixtures__/grok/chat_history.jsonl b/src/core/__fixtures__/grok/chat_history.jsonl
new file mode 100644
index 000000000..71ef447c4
--- /dev/null
+++ b/src/core/__fixtures__/grok/chat_history.jsonl
@@ -0,0 +1,25 @@
+{"type": "system", "content": "You are Grok 4.6 released by xAI. You are an interactive CLI tool that helps users with software engineering tasks. Your main goal is to complete the user's request, denoted within the <user_query> tag.\n\n<work_policy>\n- Keep every explicit …[truncated for the fixture]"}
+{"type": "user", "content": [{"type": "text", "text": "<user_info>\nOS Version: macos\nShell: /bin/zsh\nWorkspace Path: /home/user/Repositories/surfski-go\nToday's date: 2026-08-31\nNote: Prefer using relative paths over absolute paths as tool call args when possible.\n</user_info>\n\n<rules>\nThe rules …[truncated for the fixture]"}]}
+{"type": "user", "content": [{"type": "text", "text": "<system-reminder>\nThe following skills are available for use:\n\n- get-linked-context: Read the conversation/transcript, a recent summary, or the terminal output of another agent node (Claude, Codex or Gemini) you are linked to on the nodeter …[truncated for the fixture]"}], "synthetic_reason": "system_reminder"}
+{"type": "user", "content": [{"type": "text", "text": "<system-reminder>\nThe following skills are available for use:\n\n- get-linked-context: Read the conversation/transcript, a recent summary, or the terminal output of another agent node (Claude, Codex or Gemini) you are linked to on the nodeter …[truncated for the fixture]"}], "synthetic_reason": "system_reminder"}
+{"type": "user", "content": [{"type": "text", "text": "<user_query>\nLee BRIEF.md en este directorio (ruta absoluta: /home/user/Repositories/surfski-go/BRIEF.md) y ejecútalo entero. Es Spec Kit desde 0: specify init --here --force --non-interactive --integration grok --script sh, luego constitut …[truncated for the fixture]"}], "prompt_index": 0}
+{"type": "user", "content": [{"type": "text", "text": "<user_query>\nLee BRIEF.md en este directorio (ruta absoluta: /home/user/Repositories/surfski-go/BRIEF.md) y ejecútalo entero. Es Spec Kit desde 0: specify init --here --force --non-interactive --integration grok --script sh, luego constitut …[truncated for the fixture]"}], "prompt_index": 0}
+{"type": "reasoning", "id": "rs_48d3f4e0-e173-9179-8a66-855d722a86f4", "summary": [{"type": "summary_text", "text": "The user wants me to read BRIEF.md and execute it entirely. Let me start by reading the brief and understanding the project, then execute Spec Kit from scratch following the specified commands.\n"}], "encrypted_content": "XP+7xJDirbqZ9u/OhEq6hesBn/K/oFxCWgAfDzQlSaASylJoamA9py/huJ9BURw+RIGN9YP0jZ0Wt6Foqq6g0K2ylYL9JjIA2mU4GTWkHuu4qIwAiaufxVxPqStuzBZaJn4t/OjeE/w8mbmsgadCu3/RyGXESQKmLgWlMHlPwNmmYLrjYMElUY7phEborf/3CVmtZ4bievxmdI0KjQ3LRKdk2GqmyI/waKQY9u2nDQT7sxt0 …[truncated for the fixture]", "status": "completed"}
+{"type": "reasoning", "id": "rs_48d3f4e0-e173-9179-8a66-855d722a86f4", "summary": [{"type": "summary_text", "text": "The user wants me to read BRIEF.md and execute it entirely. Let me start by reading the brief and understanding the project, then execute Spec Kit from scratch following the specified commands.\n"}], "encrypted_content": "XP+7xJDirbqZ9u/OhEq6hesBn/K/oFxCWgAfDzQlSaASylJoamA9py/huJ9BURw+RIGN9YP0jZ0Wt6Foqq6g0K2ylYL9JjIA2mU4GTWkHuu4qIwAiaufxVxPqStuzBZaJn4t/OjeE/w8mbmsgadCu3/RyGXESQKmLgWlMHlPwNmmYLrjYMElUY7phEborf/3CVmtZ4bievxmdI0KjQ3LRKdk2GqmyI/waKQY9u2nDQT7sxt0 …[truncated for the fixture]", "status": "completed"}
+{"type": "assistant", "content": "Voy a leer el BRIEF y el estado del repo para ejecutar Spec Kit de punta a punta en main.", "tool_calls": [{"id": "call-00000000-0000-4000-8000-000000000000-0", "name": "read_file", "arguments": "{\"target_file\":\"/home/user/Repositories/surfski-go/BRIEF.md\"}"}, {"id": "call-00000000-0000-4000-8000-000000000000-1", "name": "list_dir", "arguments": "{\"target_directory\":\"/home/user/Repositories/surfski-go\"}"}, {"id": "call-00000000-0000-4000-8000-000000000000-2", "name": "read_file", "arguments": "{\"target_file\":\"/home/user/Repositories/surfski-go/CLAUDE.md\"}"}], "model_id": "grok-4.6-build", "model_fingerprint": "fp_08d0bc26c22b024e", "reasoning_effort": "xhigh"}
+{"type": "assistant", "content": "Voy a leer el BRIEF y el estado del repo para ejecutar Spec Kit de punta a punta en main.", "tool_calls": [{"id": "call-00000000-0000-4000-8000-000000000000-0", "name": "read_file", "arguments": "{\"target_file\":\"/home/user/Repositories/surfski-go/BRIEF.md\"}"}, {"id": "call-00000000-0000-4000-8000-000000000000-1", "name": "list_dir", "arguments": "{\"target_directory\":\"/home/user/Repositories/surfski-go\"}"}, {"id": "call-00000000-0000-4000-8000-000000000000-2", "name": "read_file", "arguments": "{\"target_file\":\"/home/user/Repositories/surfski-go/CLAUDE.md\"}"}], "model_id": "grok-4.6-build", "model_fingerprint": "fp_08d0bc26c22b024e", "reasoning_effort": "xhigh"}
+{"type":"assistant","content":"truncated line with no closing brace
+{"type": "tool_result", "tool_call_id": "call-00000000-0000-4000-8000-000000000000-0", "content": "1→# BRIEF — surfski-go (Spec Kit desde 0)\n\nEres un nodo de diseño/implementación. **No improvises un prototipo.** Arranca **GitHub Spec Kit desde cero** en ESTE directorio y deja el sistema especificado (constitution → specify → plan → task …[truncated for the fixture]"}
+{"type": "tool_result", "tool_call_id": "call-00000000-0000-4000-8000-000000000000-0", "content": "1→# BRIEF — surfski-go (Spec Kit desde 0)\n\nEres un nodo de diseño/implementación. **No improvises un prototipo.** Arranca **GitHub Spec Kit desde cero** en ESTE directorio y deja el sistema especificado (constitution → specify → plan → task …[truncated for the fixture]"}
+{"type": "tool_result", "tool_call_id": "call-00000000-0000-4000-8000-000000000000-2", "content": "Error: /home/user/Repositories/surfski-go/CLAUDE.md does not exist.\nNote: your current working directory is /home/user/Repositories/surfski-go"}
+{"type": "backend_tool_call", "kind": {"tool_type": "web_search", "action": {"type": "search", "query": "github spec-kit specify init grok integration constitution specify plan tasks", "sources": [{"type": "url", "url": "https://github.github.com/spec-kit/reference/core.html"}, {"type": "url", "url": "https://github.github.com/spec-kit/quickstart.html"}, {"type": "url", "url": "https://github.com/github/spec-kit/blob/main/templates/commands/constitution.md?plain=1"}, {"type": "url", "url": "https://github.com/github/spec-kit/blob/main/templates/commands/plan.md?plain=1"}, {"type": "url", "url": "https://github.com/github/spec-kit/blob/main/templates/plan-template.md?plain=1"}, {"type": "url", "url": "https://github.github.com/spec-kit/reference/overview.html"}, {"type": "url", "url": "https://github.github.io/spec-kit/"}, {"type": "url", "url": "https://github.com/github/spec-kit/blob/main/integrations/README.md"}]}, "id": "ws_69bad8ef-1a17-93f8-a971-e8d867afb5a3_call-00000000-0000-4000-8000-000000000000-4", "status": "completed"}}
+{"type": "backend_tool_call", "kind": {"tool_type": "web_search", "action": {"type": "search", "query": "github spec-kit specify init grok integration constitution specify plan tasks", "sources": [{"type": "url", "url": "https://github.github.com/spec-kit/reference/core.html"}, {"type": "url", "url": "https://github.github.com/spec-kit/quickstart.html"}, {"type": "url", "url": "https://github.com/github/spec-kit/blob/main/templates/commands/constitution.md?plain=1"}, {"type": "url", "url": "https://github.com/github/spec-kit/blob/main/templates/commands/plan.md?plain=1"}, {"type": "url", "url": "https://github.com/github/spec-kit/blob/main/templates/plan-template.md?plain=1"}, {"type": "url", "url": "https://github.github.com/spec-kit/reference/overview.html"}, {"type": "url", "url": "https://github.github.io/spec-kit/"}, {"type": "url", "url": "https://github.com/github/spec-kit/blob/main/integrations/README.md"}]}, "id": "ws_69bad8ef-1a17-93f8-a971-e8d867afb5a3_call-00000000-0000-4000-8000-000000000000-4", "status": "completed"}}
+{"type": "reasoning", "id": "tco_69bad8ef-1a17-93f8-a971-e8d867afb5a3_call-00000000-0000-4000-8000-000000000000-4", "summary": [], "encrypted_content": "tco_69bad8ef-1a17-93f8-a971-e8d867afb5a3_call-00000000-0000-4000-8000-000000000000-4_bgJX1/VyBMRIIvCxQyCSI16UHQJvaVJX657+uRjtUMHC0GdrDhE/ym6Coy8egERYP7UVoseRmJaMKDVe4ox6vIepevAKalSb0dqbG5ncO5HOsq9gZwr7B/sJfPse3ATPeQ6cHQkSxJ+tYTNrZruT6VQCQ1A …[truncated for the fixture]", "status": "completed"}
+{"type": "assistant", "content": "El BRIEF pide Spec Kit de cero en este directorio. Arranco el init y, en paralelo, reviso cómo encajan constitution → specify → plan → tasks.", "tool_calls": [{"id": "call-00000000-0000-4000-8000-000000000000-3", "name": "run_terminal_command", "arguments": "{\"command\":\"ls -la /home/user/Repositories/surfski-go && git status 2>/dev/null; which uvx; which specify; uvx --from git+https://github.com/github/spec-kit.git specify --help 2>&1 | head -80\",\"description\":\"Check repo state and spec-kit CL …[truncated for the fixture]"}], "model_id": "grok-4.6-build", "model_fingerprint": "fp_08d0bc26c22b024e", "reasoning_effort": "xhigh"}
+{"type": "assistant", "content": "Spec Kit está arrancado en **main** (sin ramas). Constitution → specify → plan → tasks están escritos, y el motor de los 6 oráculos está en verde.\n\n## Qué hay\n\n**Spec Kit** (`specify init --here --force --non-interactive --integration grok …[truncated for the fixture]", "model_id": "grok-4.6-build", "model_fingerprint": "fp_08d0bc26c22b024e", "reasoning_effort": "xhigh"}
+{"type": "assistant", "content": "Spec Kit está arrancado en **main** (sin ramas). Constitution → specify → plan → tasks están escritos, y el motor de los 6 oráculos está en verde.\n\n## Qué hay\n\n**Spec Kit** (`specify init --here --force --non-interactive --integration grok …[truncated for the fixture]", "model_id": "grok-4.6-build", "model_fingerprint": "fp_08d0bc26c22b024e", "reasoning_effort": "xhigh"}
+{"type": "user", "content": [{"type": "text", "text": "<user_query>\nen que directorio estas trabajando ? para ver los archivos ¿?\n</user_query>"}], "prompt_index": 1}
+{"type": "user", "content": [{"type": "text", "text": "<user_info>\nOS Version: macos\nShell: /bin/zsh\nWorkspace Path: /private/tmp/claude-502/-Users-xavi-1/00000000-0000-4000-8000-000000000000/scratchpad/grokcap\nToday's date: 2026-09-01\nNote: Prefer using relative paths over absolute paths as to …[truncated for the fixture]"}], "synthetic_reason": "compaction_meta"}
+{"type": "user", "content": [{"type": "text", "text": "\n\n<system-reminder>\nAs you answer the user's questions, you can use the following context (ordered from repo root to current directory - deeper files take precedence on conflicts):\n\n## From: /home/user/.claude/Claude.md\n# Global Claude Code …[truncated for the fixture]"}], "synthetic_reason": "project_instructions"}
+{"type": "user", "content": [{"type": "text", "text": "<system-reminder>\nBackground task \"call-00000000-0000-4000-8000-000000000000-3\" completed (exit code: 0).\nCommand: ls -la \"/home/user/Library/Application Support/node-terminal/\" 2>/dev/null; echo \"---\"; find /home/user -maxdepth 4 -iname \"* …[truncated for the fixture]"}], "synthetic_reason": "task_completed", "prompt_index": 1}
+{"type": "assistant", "content": "Estoy en **`/home/user/Repositories/surfski-go`**.\n\nAhí está el repo entero: `BRIEF.md`, `docs/`, `specs/001-surfski-verdict/`, `src/surfski_go/`, `profiles/llanca.json`, `tests/`.", "model_id": "grok-4.6-build", "model_fingerprint": "fp_08d0bc26c22b024e", "reasoning_effort": "xhigh"}
diff --git a/src/core/context-link-render.test.ts b/src/core/context-link-render.test.ts
new file mode 100644
index 000000000..3ca1a6844
--- /dev/null
+++ b/src/core/context-link-render.test.ts
@@ -0,0 +1,108 @@
+// Parser tests for the context-link transcript renderers.
+//
+// FIXTURE PROVENANCE — `__fixtures__/grok/chat_history.jsonl` is REAL. It was cut from a live grok
+// 1.0.13 session (576 messages, a logged-in account) on 2026-09-01: 21 lines chosen to cover all
+// eight line shapes that session contains, with home paths, usernames and session UUIDs redacted
+// and long text truncated. NO KEY WAS ALTERED and no line was authored by hand — except one
+// deliberately truncated JSON line, added to exercise the malformed-line counter.
+//
+// It is real for a reason this project paid for: in task03 the grok hook tests asserted against
+// payloads WE had written from grok's shipped docs, so they pinned our reading of the documentation
+// instead of the agent's behaviour, and a feature that was dead on every real payload stayed green
+// through TDD, an independent review and a QA sign-off. A fixture the agent produced cannot agree
+// with us out of politeness.
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'fs'
+import path from 'path'
+import { linesFromGrok, renderTranscriptLines } from './context-link-render'
+
+const buf = readFileSync(path.join(__dirname, '__fixtures__/grok/chat_history.jsonl'), 'utf8')
+
+describe('linesFromGrok over a real chat_history.jsonl', () => {
+ it('renders user prompts and assistant text in file order', () => {
+ const lines = linesFromGrok(buf)
+ expect(lines.length).toBeGreaterThan(0)
+ expect(lines.some((l) => l.startsWith('user: '))).toBe(true)
+ expect(lines.some((l) => l.startsWith('assistant: '))).toBe(true)
+ // Order is the file's own: the first rendered line comes from the first renderable record.
+ const firstRenderable = buf
+ .split('\n')
+ .filter((l) => l.trim())
+ .map((l) => {
+ try {
+ return JSON.parse(l) as { type?: string }
+ } catch {
+ return undefined
+ }
+ })
+ .find((o) => o && (o.type === 'user' || o.type === 'assistant' || o.type === 'system'))
+ expect(firstRenderable).toBeDefined()
+ expect(lines[0].startsWith(`${firstRenderable!.type === 'assistant' ? 'assistant' : firstRenderable!.type}: `)).toBe(
+ true
+ )
+ })
+
+ it('reads `content` in BOTH shapes: a bare string and an array of parts carrying `.text`', () => {
+ const arrayLine = buf
+ .split('\n')
+ .filter((l) => l.trim())
+ .map((l) => {
+ try {
+ return JSON.parse(l) as { type?: string; content?: unknown }
+ } catch {
+ return undefined
+ }
+ })
+ .find((o) => o && Array.isArray(o.content))
+ expect(arrayLine, 'the fixture must contain an array-content line or this test proves nothing').toBeDefined()
+ const text = (arrayLine!.content as { text?: string }[])[0].text!.slice(0, 24)
+ expect(linesFromGrok(buf).some((l) => l.includes(text))).toBe(true)
+ })
+
+ it('never attributes harness-injected text to the human', () => {
+ // grok files these under `type: 'user'` and marks them with `synthetic_reason`. Measured
+ // vocabulary across every local session: system_reminder, compaction_meta,
+ // project_instructions, task_completed — 60 lines, all of them `user`, none of them typed by
+ // a person. This reader feeds context-link and transfer, so "the other agent's user said X"
+ // has to mean a human said X.
+ const lines = linesFromGrok(buf)
+ expect(lines.some((l) => l.startsWith('user: <system-reminder>'))).toBe(false)
+ expect(lines.some((l) => l.includes('<system-reminder>') && l.startsWith('user: '))).toBe(false)
+ })
+
+ it('labels each injected line with its own reason, including one it has never seen', () => {
+ const lines = linesFromGrok(buf)
+ for (const reason of ['system_reminder', 'compaction_meta', 'project_instructions', 'task_completed']) {
+ expect(lines.some((l) => l.startsWith(`${reason}: `)), `no line rendered for ${reason}`).toBe(true)
+ }
+ // The rule is "carries synthetic_reason ⇒ not the human", not a table of the four values we
+ // happened to observe: an unmeasured future reason must still not land on `user`.
+ const future = JSON.stringify({ type: 'user', content: 'x', synthetic_reason: 'not_yet_invented' })
+ expect(linesFromGrok(future)).toEqual(['not_yet_invented: x'])
+ })
+
+ it('renders tool calls and tool results, distinctly from prose', () => {
+ const lines = linesFromGrok(buf)
+ expect(lines.some((l) => l.startsWith(' $ '))).toBe(true)
+ expect(lines.some((l) => l.startsWith(' = '))).toBe(true)
+ })
+
+ it('renders a backend tool call (web search) by its query', () => {
+ expect(linesFromGrok(buf).some((l) => l.startsWith(' $ web_search'))).toBe(true)
+ })
+
+ it('never emits the encrypted reasoning payload', () => {
+ expect(buf).toContain('encrypted_content')
+ expect(linesFromGrok(buf).join('\n')).not.toContain('encrypted_content')
+ })
+
+ it('counts malformed lines instead of dropping them silently', () => {
+ expect(linesFromGrok.skipped(buf)).toBe(1)
+ // A malformed line must not cost the lines around it.
+ expect(linesFromGrok(buf).length).toBeGreaterThan(5)
+ })
+
+ it('is routed by agent id, with no call-site comparison', () => {
+ expect(renderTranscriptLines('grok', buf)).toEqual(linesFromGrok(buf))
+ })
+})
diff --git a/src/core/context-link-render.ts b/src/core/context-link-render.ts
index 81d8c9203..0e137d15c 100644
--- a/src/core/context-link-render.ts
+++ b/src/core/context-link-render.ts
@@ -199,9 +199,117 @@ export function linesFromOpencodeExport(raw: string): string[] | null {
return res
}
+/**
+ * One whole grok `chat_history.jsonl`. Pure: a buffer in, display strings out.
+ *
+ * MEASURED against two real sessions (576 and 372 messages, grok 1.0.13, 2026-09-01), which is
+ * where every mapping below comes from. Eight line shapes exist and each `type` is handled:
+ *
+ * `user` prompt text when typed (`prompt_index`); a harness injection when it
+ * carries `synthetic_reason` — labelled with that reason, never as the human
+ * `assistant` prose, plus `tool_calls[]` of `{id, name, arguments}`
+ * `tool_result` the output of one call, tied back by `tool_call_id`
+ * `backend_tool_call` a server-side tool (web search); its detail lives under `kind`
+ * `system` a bare system message
+ * `reasoning` model reasoning — SKIPPED, see below
+ *
+ * `reasoning` is skipped, and the distinction matters: its `encrypted_content` is NOT READABLE, so
+ * nothing here attempts to read it — a read we cannot perform is never reported as absence. Note
+ * that its sibling `summary[].text` IS plaintext and readable (138 of 156 lines in the measured
+ * session carry one); it is skipped anyway, because every other parser in this file omits model
+ * reasoning too (claude's renders `text` and `tool_use` only). Surfacing it is a product decision
+ * about what one agent may read of another's thinking, not a parsing gap — so it is recorded here
+ * rather than silently taken.
+ *
+ * A malformed line is skipped but NOT in silence: `linesFromGrok.skipped(buf)` counts them, so a
+ * caller can say "3 lines were unreadable" instead of quietly rendering a shorter transcript.
+ */
+interface GrokChatLine {
+ type?: string
+ content?: unknown
+ tool_calls?: { id?: string; name?: string; arguments?: unknown }[]
+ tool_call_id?: string
+ synthetic_reason?: string
+ kind?: { tool_type?: string; action?: { type?: string; query?: string } }
+}
+
+function grokParse(buf: string): { lines: GrokChatLine[]; skipped: number } {
+ const lines: GrokChatLine[] = []
+ let skipped = 0
+ for (const raw of buf.split('\n')) {
+ const t = raw.trim()
+ if (!t) continue
+ const o = parseJson(t) as GrokChatLine | undefined
+ if (!o || typeof o !== 'object') {
+ skipped++
+ continue
+ }
+ lines.push(o)
+ }
+ return { lines, skipped }
+}
+
+export function linesFromGrok(buf: string): string[] {
+ const res: string[] = []
+ for (const o of grokParse(buf).lines) {
+ switch (o.type) {
+ case 'user':
+ case 'system': {
+ const t = flatText(o.content)
+ if (!t) break
+ // A `user` line carrying `synthetic_reason` was injected by the harness, not typed by a
+ // person: grok files skill reminders, project instructions, compaction notes and subagent
+ // completions under the user role and marks them only with this field. Measured across
+ // every local session: 60 such lines, all `type: 'user'`, vocabulary `system_reminder`,
+ // `compaction_meta`, `project_instructions`, `task_completed`.
+ //
+ // They are LABELLED, not dropped, and the rule is the field's PRESENCE rather than a table
+ // of those four values — so a reason nobody has measured yet is still never attributed to
+ // the human. Dropping them was the other candidate and it loses real events (a subagent
+ // finished; the conversation was compacted) that explain what the agent did next. This
+ // reader feeds context-link and transfer, where "their user said X" must mean a human
+ // said X.
+ const injected = typeof o.synthetic_reason === 'string' ? o.synthetic_reason.trim() : ''
+ res.push(`${injected || o.type}: ${t}`)
+ break
+ }
+ case 'assistant': {
+ const t = flatText(o.content)
+ if (t) res.push(`assistant: ${t}`)
+ for (const c of o.tool_calls ?? []) {
+ const a = typeof c.arguments === 'string' ? c.arguments : JSON.stringify(c.arguments ?? '')
+ res.push(` $ ${c.name || 'tool'} ${String(a).slice(0, TOOL_ARG_MAX)}`.trimEnd())
+ }
+ break
+ }
+ case 'tool_result': {
+ const s = flatText(o.content).split('\n').slice(0, 3).join(' ').slice(0, TOOL_RESULT_MAX)
+ if (s) res.push(` = ${s}`)
+ break
+ }
+ case 'backend_tool_call': {
+ // Server-side tool: no arguments field, the query hangs off `kind.action`.
+ const name = o.kind?.tool_type || 'backend_tool'
+ const q = o.kind?.action?.query
+ res.push(` $ ${name}${typeof q === 'string' ? ` ${q.slice(0, TOOL_ARG_MAX)}` : ''}`)
+ break
+ }
+ // `reasoning` and any future type fall through deliberately: an unknown shape renders
+ // nothing rather than a guessed role.
+ default:
+ break
+ }
+ }
+ return res
+}
+
+/** How many lines of this buffer could not be parsed. Skipped, but never in silence. */
+linesFromGrok.skipped = (buf: string): number => grokParse(buf).skipped
+
/** Parse a whole transcript buffer with the parser its agent's format needs. */
export function renderTranscriptLines(agent: string | undefined, buf: string): string[] {
if (agent === 'gemini') return linesFromGemini(buf)
+ if (agent === 'grok') return linesFromGrok(buf)
const parse = agent === 'codex' ? linesFromCodex : linesFromClaude
const lines: string[] = []
for (const raw of buf.split('\n')) {