main
md 54 lines 2.84 KB
Rendered Raw
1 # plugins.py DOX
2
3 ## Purpose
4
5 - Own the `plugins.py` API endpoint.
6 - This module manages plugin actions and plugin settings through the core API.
7 - Keep this file-level DOX profile synchronized with `plugins.py` because this directory is intentionally flat.
8
9 ## Ownership
10
11 - `plugins.py` owns the runtime implementation.
12 - `plugins.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
13 - Classes:
14 - `Plugins` (`ApiHandler`)
15 - `async process(self, input: dict, request: Request) -> dict | Response`
16
17 ## Runtime Contracts
18
19 - HTTP handlers must derive from `helpers.api.ApiHandler`; WebSocket handlers must derive from `helpers.ws.WsHandler`.
20 - Update this file whenever request payloads, authentication or CSRF requirements, response shapes, route side effects, or WebSocket event contracts change.
21 - `Plugins` is an `ApiHandler`.
22 - `Plugins` defines `process(...)`.
23 - Toggle requests that try to disable an `always_enabled` plugin return HTTP
24 400 without changing plugin state.
25 - Observed side-effect areas: filesystem reads, filesystem writes, filesystem deletion, subprocess/runtime control, plugin state, settings/state persistence.
26 - Imported dependency areas include: `helpers`, `helpers.api`, `helpers.localization`, `json`, `os`, `subprocess`, `sys`.
27
28 ## Key Concepts
29
30 - Important called helpers/classes observed in the source: `Response`, `plugins.find_plugin_assets`, `plugins.get_plugin_meta`, `plugins.get_default_plugin_config`, `plugins.save_plugin_config`, `plugins.toggle_plugin`, `plugins.find_plugin_dir`, `files.get_abs_path`, `Localization.get.now_iso`, `plugins.determine_plugin_asset_path`, `self._get_config`, `self._get_toggle_status`, `self._list_configs`, `self._delete_config`, `self._delete_plugin`, `self._get_default_config`, `self._save_config`, `self._toggle_plugin`, `self._get_doc`, `self._run_execute_script`.
31 - Keep request/response, tool, or helper semantics documented here at the same time as source changes.
32
33 ## Work Guidance
34
35 - Preserve authentication, CSRF, loopback, and API-key checks unless the endpoint contract explicitly changes.
36 - Update frontend callers, plugin callers, and tests together when payload shape changes.
37 - Use `helpers.api.Response` for non-JSON responses, files, redirects, or status-specific replies.
38
39 ## Verification
40
41 - Run endpoint-specific or API/WebSocket tests for changed behavior; smoke-test browser callers when no focused test exists.
42 - Related tests observed by source search:
43 - `tests/test_a0_connector_computer_use_metadata.py`
44 - `tests/test_a0_connector_prompt_gating.py`
45 - `tests/test_browser_agent_regressions.py`
46 - `tests/test_chat_compaction.py`
47 - `tests/test_default_prompt_budget.py`
48 - `tests/test_document_query_plugin.py`
49 - `tests/test_error_retry_plugin.py`
50 - `tests/test_host_browser_connector.py`
51
52 ## Child DOX Index
53
54 No child DOX files.