ClaudeCliBackend.parse_result_envelope()

Parse the {is_error, result} JSON envelope from claude -p --output-format json.

Usage

Source

ClaudeCliBackend.parse_result_envelope(
    stdout,
    *,
    argv,
    stderr,
)

Parameters

stdout: bytes

Raw stdout bytes holding the JSON envelope.

argv: list[str]

The argv that produced the output, recorded on the raised error.

stderr: bytes
Raw stderr bytes, recorded on the raised error.

Returns

str
The envelope’s result string.

Raises

subprocess.CalledProcessError
If the envelope’s is_error flag is set.