modes.py 983 B

123456789101112131415161718
  1. """ACP's edit modes, one table for the in-process server and the gateway path.
  2. mode id -> (edit approval policy, display name, description). On the gateway path the policy is the
  3. session's own on the owner (``session.mutate edit_policy``), enforced where the edit runs
  4. (``gateway/session_local_editor.py``); sensitive paths always ask.
  5. """
  6. DEFAULT_MODE = "default"
  7. DEFAULT_EDIT_APPROVAL_POLICY = "ask"
  8. EDIT_APPROVAL_POLICY_CONFIG_ID = "edit_approval_policy"
  9. MODES: dict[str, tuple[str, str, str]] = {
  10. "default": ("ask", "Default", "Ask before edits."),
  11. "accept_edits": ("workspace_session", "Accept Edits",
  12. "Auto-allow workspace and temp-dir edits; still asks for sensitive paths."),
  13. "dont_ask": ("session", "Don't Ask", "Auto-allow file edits for this session except sensitive paths."),
  14. }
  15. MODE_TO_EDIT_APPROVAL_POLICY = {mode: spec[0] for mode, spec in MODES.items()}
  16. EDIT_APPROVAL_POLICY_TO_MODE = {spec[0]: mode for mode, spec in MODES.items()}