A single image destined for a vision request. `raw` is None when the image is unreadable or exceeds `_MAX_IMAGE_BYTES`, or when the target backend has no vision support — in every such case the renderers emit a text reference instead of pixels, so the image still becomes a graph nod
| 900 | |
| 901 | @dataclass |
| 902 | class _ImageRef: |
| 903 | """A single image destined for a vision request. |
| 904 | |
| 905 | `raw` is None when the image is unreadable or exceeds `_MAX_IMAGE_BYTES`, or |
| 906 | when the target backend has no vision support — in every such case the |
| 907 | renderers emit a text reference instead of pixels, so the image still |
| 908 | becomes a graph node. |
| 909 | """ |
| 910 | |
| 911 | path: Path # absolute path (claude-cli reads it via the Read tool) |
| 912 | rel: str # path relative to the corpus root (the node's source_file) |
| 913 | media_type: str # e.g. "image/png" |
| 914 | raw: bytes | None |
| 915 | |
| 916 | @property |
| 917 | def b64(self) -> str: |
| 918 | return base64.standard_b64encode(self.raw).decode("ascii") if self.raw else "" |
| 919 | |
| 920 | @property |
| 921 | def bedrock_format(self) -> str: |
| 922 | # Converse wants a bare format token, not a media type. |
| 923 | return self.media_type.split("/", 1)[-1] |
| 924 | |
| 925 | |
| 926 | def _is_vision_image(path: Path) -> bool: |