| 1 | # ephemeral_images.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `ephemeral_images.py` helper module. |
| 6 | - This module stores temporary image payloads by reference for safe short-lived access. |
| 7 | - Keep this file-level DOX profile synchronized with `ephemeral_images.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `ephemeral_images.py` owns the runtime implementation. |
| 12 | - `ephemeral_images.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Classes: |
| 14 | - `EphemeralImage` (no explicit base class) |
| 15 | - `data_url(self) -> str` |
| 16 | - `display_name(self) -> str` |
| 17 | - Top-level functions: |
| 18 | - `put_image_bytes(context_id: str, mime: str, payload: bytes, name: str=..., ttl_seconds: float=...) -> str` |
| 19 | - `put_image(context_id: str, mime: str, data: str, name: str=..., ttl_seconds: float=...) -> str` |
| 20 | - `is_ref(value: object) -> bool` |
| 21 | - `display_ref(ref: str) -> str` |
| 22 | - `get_image(ref: str, context_id: str=...) -> EphemeralImage | None` |
| 23 | - `consume_image(ref: str, context_id: str=...) -> EphemeralImage | None` |
| 24 | - `delete_image(ref: str) -> None` |
| 25 | - `clear_context(context_id: str) -> None` |
| 26 | - `_resolve_image(ref: str, context_id: str=..., consume: bool) -> EphemeralImage | None` |
| 27 | - `_compact_base64(data: str) -> str` |
| 28 | - `_normalize_mime(mime: str) -> str` |
| 29 | - `_prune_expired_locked(now: float | None=...) -> None` |
| 30 | - Notable constants/configuration names: `REF_PREFIX`, `DEFAULT_TTL_SECONDS`. |
| 31 | |
| 32 | ## Runtime Contracts |
| 33 | |
| 34 | - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together. |
| 35 | - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change. |
| 36 | - Observed side-effect areas: filesystem deletion. |
| 37 | - Imported dependency areas include: `__future__`, `base64`, `dataclasses`, `threading`, `time`, `uuid`. |
| 38 | |
| 39 | ## Key Concepts |
| 40 | |
| 41 | - Important called helpers/classes observed in the source: `dataclass`, `threading.RLock`, `base64.b64encode.decode`, `put_image`, `_compact_base64`, `base64.b64decode`, `_normalize_mime`, `time.time`, `EphemeralImage`, `str.strip.startswith`, `str.strip`, `_resolve_image`, `join`, `str.strip.lower`, `ValueError`, `_prune_expired_locked`, `is_ref`, `_store.pop`, `value.startswith`, `display_ref`. |
| 42 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 43 | |
| 44 | ## Work Guidance |
| 45 | |
| 46 | - Preserve public helper APIs used by core code and plugins unless every caller is updated. |
| 47 | - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded. |
| 48 | - Prefer adding cohesive helper functions here only when behavior is reused across modules. |
| 49 | |
| 50 | ## Verification |
| 51 | |
| 52 | - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers. |
| 53 | - Related tests observed by source search: |
| 54 | - `tests/test_browser_agent_regressions.py` |
| 55 | |
| 56 | ## Child DOX Index |
| 57 | |
| 58 | No child DOX files. |