Answer an interrupt on loop-claude's terminal and resume the worker headless with the answer

This commit is contained in:
2026-10-17 23:04:28 +02:00
parent eddc5bec95
commit 831b9c63b6
17 changed files with 304 additions and 117 deletions
+5 -2
View File
@@ -1,4 +1,5 @@
import json
import typing
from claude_code.entries import assistant_parts, human_text, loop_text, parse_entry, part_text, tool_call
from failure import Failure
@@ -24,14 +25,16 @@ def human_turns(entries: list[dict]) -> int:
return sum(1 for entry in entries if human_text(entry) is not None)
def render(entries: list[dict]) -> str:
def render(entries: list[dict], typed_answer: typing.Callable[[str], str | None]) -> str:
"""The transcript as the judge reads it. typed_answer finds an answer the human typed in a -p prompt of loop-claude's, which reads as the human's, like one typed in claude."""
lines = []
for entry in entries:
lines += [line for part in assistant_parts(entry) if (line := part_line(part, JUDGED_TOOL_INPUT))]
if (text := human_text(entry)) is not None:
lines.append("[human] " + text)
elif (text := loop_text(entry)) is not None:
lines.append("[loop] " + text)
typed = typed_answer(text)
lines.append("[loop] " + text if typed is None else "[human] " + typed)
return "\n\n".join(lines)