Keep loop-claude's rendering out of the adapter and Claude Code's locations in it
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import subprocess
|
||||
|
||||
from loop_claude.claude_code import assistant_parts, ends_stream, parse
|
||||
from loop_claude.outcome import Failure
|
||||
from loop_claude.claude_code import ends_stream, parse, parts, said
|
||||
from loop_claude.transcript import said
|
||||
|
||||
|
||||
def run_worker(root, args):
|
||||
@@ -13,12 +14,10 @@ def run_worker(root, args):
|
||||
done = False
|
||||
for raw in proc.stdout:
|
||||
event = parse(raw) or {}
|
||||
if ends_stream(event):
|
||||
done = True
|
||||
elif event.get("type") == "assistant":
|
||||
for part in parts(event):
|
||||
if line := said(part, 160):
|
||||
print(line, flush=True)
|
||||
done = done or ends_stream(event)
|
||||
for part in assistant_parts(event):
|
||||
if line := said(part, 160):
|
||||
print(line, flush=True)
|
||||
code = proc.wait()
|
||||
if code < 0:
|
||||
return Failure(f"claude killed by signal {-code}")
|
||||
|
||||
Reference in New Issue
Block a user