| 1 | # images.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `images.py` helper module. |
| 6 | - This module resolves, compresses, and serializes image references for model inputs. |
| 7 | - Keep this file-level DOX profile synchronized with `images.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `images.py` owns the runtime implementation. |
| 12 | - `images.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Top-level functions: |
| 14 | - `prepare_content(content: Any) -> Any` |
| 15 | - `is_local_ref(url: str) -> bool` |
| 16 | - `to_data_url(url: str) -> str` |
| 17 | - `resolve_ref(url: str) -> Path` |
| 18 | - `compress_image(image_data: bytes, max_pixels: int=..., quality: int=...) -> bytes`: Compress an image by scaling it down and converting to JPEG with quality settings. |
| 19 | |
| 20 | ## Runtime Contracts |
| 21 | |
| 22 | - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together. |
| 23 | - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change. |
| 24 | - Observed side-effect areas: filesystem reads, network calls, settings/state persistence. |
| 25 | - Imported dependency areas include: `PIL`, `base64`, `io`, `math`, `mimetypes`, `pathlib`, `typing`, `urllib.parse`. |
| 26 | |
| 27 | ## Key Concepts |
| 28 | |
| 29 | - Important called helpers/classes observed in the source: `url.lower`, `lowered.startswith`, `resolve_ref`, `base64.b64encode.decode`, `Path.expanduser`, `raw_path.startswith`, `FileNotFoundError`, `io.BytesIO`, `img.save`, `output.getvalue`, `prepare_content`, `url.startswith`, `mimetypes.guess_type`, `ValueError`, `url.lower.startswith`, `unquote`, `seen.add`, `math.sqrt`, `img.resize`, `img.convert`. |
| 30 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 31 | |
| 32 | ## Work Guidance |
| 33 | |
| 34 | - Preserve public helper APIs used by core code and plugins unless every caller is updated. |
| 35 | - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded. |
| 36 | - Prefer adding cohesive helper functions here only when behavior is reused across modules. |
| 37 | |
| 38 | ## Verification |
| 39 | |
| 40 | - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers. |
| 41 | - Related tests observed by source search: |
| 42 | - `tests/test_browser_agent_regressions.py` |
| 43 | - `tests/test_image_get_security.py` |
| 44 | - `tests/test_vision_load_image_refs.py` |
| 45 | |
| 46 | ## Child DOX Index |
| 47 | |
| 48 | No child DOX files. |