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
+16 -5
View File
@@ -6,10 +6,18 @@ from loop_claude.cycle.judge import Finished, Interrupt, QuotedAnswer, Unfinishe
QUOTED_ANSWERS_PER_CYCLE = 3
@dataclasses.dataclass(frozen=True)
class TypedAnswer:
"""The human's answer to an interrupt, typed at loop-claude's terminal; stepped is whether the interrupt stepped the worker up."""
question: str
answer: str
stepped: bool
@dataclasses.dataclass(frozen=True)
class Working:
"""The worker runs, resumed with an answer quoted from README.md or the records when there is one."""
answered: QuotedAnswer | None = None
"""The worker runs, resumed with an answer quoted from README.md or the records, or typed by the human, when there is one."""
answered: QuotedAnswer | TypedAnswer | None = None
quoted_answers: int = 0
@@ -55,7 +63,8 @@ class Ruled:
@dataclasses.dataclass(frozen=True)
class HumanAnswered:
pass
"""typed is None where the human answered in the interrupt's claude session."""
typed: TypedAnswer | None = None
@dataclasses.dataclass(frozen=True)
@@ -78,8 +87,10 @@ def transition(state: State, event: Event) -> State:
return Interrupting(transcript_path, ruling, quoted_answers)
case Judging(transcript_path, _), Ruled(Finished() | Unfinished() as verdict):
return Closing(transcript_path, verdict)
# The human works in the interrupt's claude session, so the judge rules again on the transcript it leaves.
case Interrupting(transcript_path, _, quoted_answers), HumanAnswered():
case Interrupting(_, _, quoted_answers), HumanAnswered(TypedAnswer() as typed):
return Working(typed, quoted_answers)
# The human worked in the interrupt's claude session, so the judge rules again on the transcript it leaves.
case Interrupting(transcript_path, _, quoted_answers), HumanAnswered(None):
return Judging(transcript_path, quoted_answers)
case Closing(_, verdict), Archived():
return Ended(verdict)