Answer the first round: one clock read, the limit's message and time zone on stderr, plainer help and comments
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from loop_claude.claude_code.entries import assistant_parts, ends_stream, hit_limit, parse_entry, rejected_until
|
||||
from loop_claude.claude_code.entries import assistant_parts, ends_stream, hit_limit, limit_said, parse_entry, rejected_until
|
||||
from loop_claude.claude_code.session import Session
|
||||
from loop_claude.claude_code.transcript import part_line
|
||||
from loop_claude.effects import Effects
|
||||
@@ -12,20 +12,22 @@ def run_worker(root: str, args: list[str], effects: Effects) -> Failure | Limite
|
||||
proc = effects.stream_claude(args, root)
|
||||
except OSError as failure:
|
||||
return Failure(f"could not start claude: {failure.strerror}")
|
||||
done = limited = False
|
||||
done = False
|
||||
limit: str | None = None
|
||||
resets: list[int] = []
|
||||
for raw in proc.lines():
|
||||
event = parse_entry(raw) or {}
|
||||
done = done or ends_stream(event)
|
||||
limited = limited or hit_limit(event)
|
||||
if hit_limit(event):
|
||||
limit = limit_said(event)
|
||||
if (resets_at := rejected_until(event)) is not None:
|
||||
resets.append(resets_at)
|
||||
for part in assistant_parts(event):
|
||||
if line := part_line(part, PRINTED_TOOL_INPUT):
|
||||
print(line, flush=True)
|
||||
code = proc.wait()
|
||||
if limited:
|
||||
return Limited(max(resets, default=None))
|
||||
if limit is not None:
|
||||
return Limited(max(resets, default=None), limit)
|
||||
if code < 0:
|
||||
return Failure(f"claude killed by signal {-code}")
|
||||
if code:
|
||||
|
||||
Reference in New Issue
Block a user