Move the judge, the interrupt, trust and model resolution into their own modules

This commit is contained in:
2026-09-28 16:42:32 +02:00
parent 5e773f8460
commit b0afcfab57
12 changed files with 315 additions and 256 deletions
+31
View File
@@ -0,0 +1,31 @@
import subprocess
import sys
from loop_claude import human
from loop_claude.checkout import checkouts
from loop_claude.outcome import Failure, Stop
from loop_claude.transcript import human_turns, read
from loop_claude.trust import trust
TO = "answer the question above"
def interrupt(root, session_id, model, path, question, paths):
print(f"\n{question}", file=sys.stderr)
if stop := human.off_terminal(TO):
return stop
trust(paths.claude_json, checkouts(root))
entries = read(path)
if isinstance(entries, Failure):
return Stop(1, entries.reason)
before = human_turns(entries)
try:
subprocess.run(["claude", "--model", model, "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root)
except OSError as failure:
return Stop(1, f"could not start claude: {failure.strerror}")
entries = read(path)
if isinstance(entries, Failure):
return Stop(1, f"could not tell whether you typed anything: {entries.reason}")
if human_turns(entries) <= before:
return human.needed(TO, "the interrupt ended without you typing anything")
return None