| 1 | # tunnel.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `tunnel.py` API endpoint. |
| 6 | - This module manages tunnel provider status, start, and stop actions. |
| 7 | - Keep this file-level DOX profile synchronized with `tunnel.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `tunnel.py` owns the runtime implementation. |
| 12 | - `tunnel.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Classes: |
| 14 | - `Tunnel` (`ApiHandler`) |
| 15 | - `async process(self, input: dict, request: Request) -> dict | Response` |
| 16 | - Top-level functions: |
| 17 | - `async process(input: dict) -> dict | Response` |
| 18 | - `stop()` |
| 19 | |
| 20 | ## Runtime Contracts |
| 21 | |
| 22 | - HTTP handlers must derive from `helpers.api.ApiHandler`; WebSocket handlers must derive from `helpers.ws.WsHandler`. |
| 23 | - Update this file whenever request payloads, authentication or CSRF requirements, response shapes, route side effects, or WebSocket event contracts change. |
| 24 | - `Tunnel` is an `ApiHandler`. |
| 25 | - `Tunnel` defines `process(...)`. |
| 26 | - Observed side-effect areas: tunnel state. |
| 27 | - Imported dependency areas include: `helpers`, `helpers.api`, `helpers.tunnel_manager`. |
| 28 | |
| 29 | ## Key Concepts |
| 30 | |
| 31 | - Important called helpers/classes observed in the source: `TunnelManager.get_instance`, `tunnel_manager.stop_tunnel`, `runtime.get_web_ui_port`, `tunnel_manager.start_tunnel`, `tunnel_manager.get_last_error`, `process`, `tunnel_manager.get_notifications`, `stop`, `tunnel_manager.get_tunnel_url`. |
| 32 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 33 | |
| 34 | ## Work Guidance |
| 35 | |
| 36 | - Preserve authentication, CSRF, loopback, and API-key checks unless the endpoint contract explicitly changes. |
| 37 | - Update frontend callers, plugin callers, and tests together when payload shape changes. |
| 38 | - Use `helpers.api.Response` for non-JSON responses, files, redirects, or status-specific replies. |
| 39 | |
| 40 | ## Verification |
| 41 | |
| 42 | - Run endpoint-specific or API/WebSocket tests for changed behavior; smoke-test browser callers when no focused test exists. |
| 43 | - Related tests observed by source search: |
| 44 | - `tests/test_tunnel_remote_link.py` |
| 45 | |
| 46 | ## Child DOX Index |
| 47 | |
| 48 | No child DOX files. |