| 1 | # api_terminate_chat.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `api_terminate_chat.py` API endpoint. |
| 6 | - This module terminates an API-created chat context. |
| 7 | - Keep this file-level DOX profile synchronized with `api_terminate_chat.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `api_terminate_chat.py` owns the runtime implementation. |
| 12 | - `api_terminate_chat.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Classes: |
| 14 | - `ApiTerminateChat` (`ApiHandler`) |
| 15 | - `requires_auth(cls) -> bool` |
| 16 | - `requires_csrf(cls) -> bool` |
| 17 | - `requires_api_key(cls) -> bool` |
| 18 | - `get_methods(cls) -> list[str]` |
| 19 | - `async process(self, input: dict, request: Request) -> dict | Response` |
| 20 | |
| 21 | ## Runtime Contracts |
| 22 | |
| 23 | - HTTP handlers must derive from `helpers.api.ApiHandler`; WebSocket handlers must derive from `helpers.ws.WsHandler`. |
| 24 | - Update this file whenever request payloads, authentication or CSRF requirements, response shapes, route side effects, or WebSocket event contracts change. |
| 25 | - `ApiTerminateChat` is an `ApiHandler`. |
| 26 | - `ApiTerminateChat` defines `process(...)`. |
| 27 | - `ApiTerminateChat` defines `get_methods(...)`. |
| 28 | - `ApiTerminateChat` defines `requires_auth(...)`. |
| 29 | - `ApiTerminateChat` defines `requires_csrf(...)`. |
| 30 | - `ApiTerminateChat` defines `requires_api_key(...)`. |
| 31 | - Observed side-effect areas: filesystem writes, filesystem deletion, settings/state persistence. |
| 32 | - Imported dependency areas include: `agent`, `helpers.api`, `helpers.persist_chat`, `helpers.print_style`, `json`. |
| 33 | |
| 34 | ## Key Concepts |
| 35 | |
| 36 | - Important called helpers/classes observed in the source: `AgentContext.use`, `AgentContext.remove`, `remove_chat`, `Response`, `PrintStyle.error`, `PrintStyle`, `json.dumps`. |
| 37 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 38 | |
| 39 | ## Work Guidance |
| 40 | |
| 41 | - Preserve authentication, CSRF, loopback, and API-key checks unless the endpoint contract explicitly changes. |
| 42 | - Update frontend callers, plugin callers, and tests together when payload shape changes. |
| 43 | - Use `helpers.api.Response` for non-JSON responses, files, redirects, or status-specific replies. |
| 44 | |
| 45 | ## Verification |
| 46 | |
| 47 | - Run endpoint-specific or API/WebSocket tests for changed behavior; smoke-test browser callers when no focused test exists. |
| 48 | - No direct test reference was found by name search; choose the nearest behavioral test or perform a focused smoke check. |
| 49 | |
| 50 | ## Child DOX Index |
| 51 | |
| 52 | No child DOX files. |