Expand description
Claude-compatible agent runner.
Handles Claude, Kimi, and MiniMax agents. All three use the same
claude binary (or a shell wrapper that sets ANTHROPIC_BASE_URL).
§CLI invocation
claude -p --model {model} \
--permission-mode bypassPermissions \
--output-format stream-json \
--disallowedTools '...' \
--append-system-prompt "{sys_file}" \
< "{msg_file}"§Output format (--output-format stream-json)
NDJSON event stream; the final event is always "type": "result":
{"type":"system","subtype":"init",...}
{"type":"assistant","message":{...}}
{"type":"tool_use","tool":{...}}
{"type":"tool_result","result":{...}}
{"type":"result","subtype":"success","is_error":false,"duration_ms":2006,"result":"...","usage":{"input_tokens":10,"output_tokens":78},"modelUsage":{...}}Backward compatible with --output-format json (single JSON blob) — the
parser finds the last "type":"result" line whether it is NDJSON or a
pretty-printed single object.
§Kimi/MiniMax wrappers
Both are shell scripts that exec the claude binary with custom env:
exec env ANTHROPIC_BASE_URL=... ANTHROPIC_API_KEY=... claude "$@"§Known error patterns
is_error: truewith various message strings- “credit balance too low” — billing/auth
- “overloaded” — capacity / rate limit (HTTP 529)
- “rate limit” / “429” — standard rate limiting
- “context_length_exceeded” — context overflow
Structs§
- Claude
Runner - Runner for Claude-compatible agents (Claude, Kimi, MiniMax).
Functions§
- collect_
assistant_ messages_ text - Concatenate text content from all
type:assistantNDJSON messages in the stream. Used as a fallback when thetype:resultenvelope text does not contain valid AgentResponse JSON but an earlier assistant turn might have emitted it. - find_
claude_ result - Extract a structured
AgentResultfrom Claude/Kimi/MiniMax NDJSON output. - review_
session_ exited_ mid_ thought - True when the stream has no result envelope and ended on a thinking block or a tool call, so the model never produced a finished review decision
- strip_
tty_ control_ lines - Drop
scripttty junk: show-cursor (ESC[?25h) and^D/backspace redraw lines