Answer architecture round 1: 0 🔴, 2 🟡; keep stepped_from through the typed answer, name the events HumanTyped and HumanTalked, parse the answer from the prompt's start, and say why the judge decides release_ready
This commit is contained in:
@@ -16,22 +16,20 @@ TALK = "/talk"
|
||||
ASK_ANSWER = f"Answer ({TALK} opens claude, Enter stops the loop): "
|
||||
|
||||
|
||||
def interrupt(root: str, session_id: uuid.UUID, worker: Rung, path: str, question: str, release_ready: bool, paths: Paths, env: dict[str, str], effects: Effects) -> Stop | str | None:
|
||||
"""Puts question to the human on loop-claude's terminal and returns the answer they typed. Typing TALK instead opens the worker's session in claude on the terminal, and so does a release ready to cut, at once, since only the human may cut it; None is returned once they typed there."""
|
||||
def put_question(question: str, effects: Effects) -> Stop | None:
|
||||
"""Prints question for the human; a Stop where loop-claude is off a terminal, so no one can answer it."""
|
||||
print(f"\n{question}", file=sys.stderr)
|
||||
if stop := needs_terminal(ANSWER_QUESTION, effects.on_terminal()):
|
||||
return stop
|
||||
if not release_ready:
|
||||
try:
|
||||
answer = effects.input(ASK_ANSWER).strip()
|
||||
except EOFError:
|
||||
print(file=sys.stderr)
|
||||
return needs_human(ANSWER_QUESTION, "the input ended")
|
||||
if not answer:
|
||||
return needs_human(ANSWER_QUESTION, "nothing was typed")
|
||||
if answer != TALK:
|
||||
return answer
|
||||
return talk(root, session_id, worker, path, paths, env, effects)
|
||||
return needs_terminal(ANSWER_QUESTION, effects.on_terminal())
|
||||
|
||||
|
||||
def read_answer(effects: Effects) -> str | Stop:
|
||||
"""The line the human types at loop-claude's terminal, stripped: their answer, or TALK where they ask for claude's session; a Stop where they type nothing or the input ends."""
|
||||
try:
|
||||
answer = effects.input(ASK_ANSWER).strip()
|
||||
except EOFError:
|
||||
print(file=sys.stderr)
|
||||
return needs_human(ANSWER_QUESTION, "the input ended")
|
||||
return answer or needs_human(ANSWER_QUESTION, "nothing was typed")
|
||||
|
||||
|
||||
def talk(root: str, session_id: uuid.UUID, worker: Rung, path: str, paths: Paths, env: dict[str, str], effects: Effects) -> Stop | None:
|
||||
|
||||
Reference in New Issue
Block a user