{
  "openapi": "3.1.0",
  "info": {
    "title": "mxr HTTP Bridge",
    "description": "Local-first email daemon HTTP/WebSocket surface. All routes (except /api/v1/health) require a bearer token from ~/.config/mxr/bridge-token.",
    "contact": {
      "name": "mxr",
      "url": "https://mxr.sh"
    },
    "license": {
      "name": "MIT OR Apache-2.0"
    },
    "version": "0.5.8"
  },
  "paths": {
    "/api/v1/admin/diagnostics": {
      "get": {
        "tags": [],
        "summary": "Diagnostics report",
        "operationId": "admin_diagnostics",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/admin/diagnostics/bug-report": {
      "get": {
        "tags": [],
        "summary": "Sanitized bug report",
        "operationId": "admin_bug_report",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/admin/events": {
      "get": {
        "tags": [],
        "summary": "Persisted daemon events",
        "operationId": "admin_events",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/admin/logs": {
      "get": {
        "tags": [],
        "summary": "Recent daemon logs",
        "operationId": "admin_logs",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/admin/ping": {
      "post": {
        "tags": [],
        "summary": "Bridge round-trip ping",
        "operationId": "admin_ping",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/admin/shutdown": {
      "post": {
        "tags": [],
        "summary": "Request daemon shutdown",
        "operationId": "admin_shutdown",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/admin/status": {
      "get": {
        "tags": [],
        "summary": "Daemon status snapshot",
        "operationId": "admin_status",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/desktop/shell": {
      "get": {
        "tags": [],
        "summary": "Desktop shell manifest",
        "operationId": "desktop_shell",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/docs": {
      "get": {
        "tags": [],
        "summary": "Swagger UI",
        "operationId": "swagger_ui",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/events": {
      "get": {
        "tags": [],
        "summary": "WebSocket daemon event stream",
        "operationId": "events_ws",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/health": {
      "get": {
        "tags": [],
        "summary": "Unauthenticated bridge liveness probe",
        "operationId": "health",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/actions/snooze": {
      "post": {
        "tags": [],
        "summary": "Snooze messages",
        "operationId": "action_snooze",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/actions/snooze/presets": {
      "get": {
        "tags": [],
        "summary": "List snooze presets",
        "operationId": "action_snooze_presets",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/actions/unsubscribe": {
      "post": {
        "tags": [],
        "summary": "Unsubscribe from list mail",
        "operationId": "action_unsubscribe",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/attachments/download": {
      "post": {
        "tags": [],
        "summary": "Download an attachment",
        "operationId": "attachment_download",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/attachments/open": {
      "post": {
        "tags": [],
        "summary": "Open an attachment",
        "operationId": "attachment_open",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/compose/session": {
      "post": {
        "tags": [],
        "summary": "Start compose session",
        "operationId": "compose_session_start",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/compose/session/attachment": {
      "post": {
        "tags": [],
        "summary": "Upload compose attachment",
        "operationId": "compose_session_attachment",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/compose/session/discard": {
      "post": {
        "tags": [],
        "summary": "Discard compose session",
        "operationId": "compose_session_discard",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/compose/session/refresh": {
      "post": {
        "tags": [],
        "summary": "Refresh compose session",
        "operationId": "compose_session_refresh",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/compose/session/restore": {
      "post": {
        "tags": [],
        "summary": "Restore compose session",
        "operationId": "compose_session_restore",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/compose/session/save": {
      "post": {
        "tags": [],
        "summary": "Save compose session",
        "operationId": "compose_session_save",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/compose/session/send": {
      "post": {
        "tags": [],
        "summary": "Send compose session",
        "operationId": "compose_session_send",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/compose/session/update": {
      "post": {
        "tags": [],
        "summary": "Update compose session",
        "operationId": "compose_session_update",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/count": {
      "get": {
        "tags": [],
        "summary": "Count matching messages",
        "operationId": "mail_count",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/drafts": {
      "get": {
        "tags": [],
        "summary": "List drafts",
        "operationId": "mail_drafts",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/labels/create": {
      "post": {
        "tags": [],
        "summary": "Create a label",
        "operationId": "label_create",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/labels/delete": {
      "post": {
        "tags": [],
        "summary": "Delete a label",
        "operationId": "label_delete",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/labels/rename": {
      "post": {
        "tags": [],
        "summary": "Rename a label",
        "operationId": "label_rename",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/mailbox": {
      "get": {
        "tags": [],
        "summary": "Mailbox view",
        "operationId": "mail_mailbox",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/mutations/archive": {
      "post": {
        "tags": [],
        "summary": "Archive messages",
        "operationId": "mutation_archive",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/mutations/labels": {
      "post": {
        "tags": [],
        "summary": "Add or remove labels",
        "operationId": "mutation_labels",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/mutations/move": {
      "post": {
        "tags": [],
        "summary": "Move messages to a label or folder",
        "operationId": "mutation_move",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/mutations/read": {
      "post": {
        "tags": [],
        "summary": "Mark messages read or unread",
        "operationId": "mutation_read",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/mutations/read-and-archive": {
      "post": {
        "tags": [],
        "summary": "Read and archive messages",
        "operationId": "mutation_read_archive",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/mutations/spam": {
      "post": {
        "tags": [],
        "summary": "Mark messages as spam",
        "operationId": "mutation_spam",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/mutations/star": {
      "post": {
        "tags": [],
        "summary": "Star or unstar messages",
        "operationId": "mutation_star",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/mutations/trash": {
      "post": {
        "tags": [],
        "summary": "Trash messages",
        "operationId": "mutation_trash",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/mutations/undo": {
      "post": {
        "tags": [],
        "summary": "Undo a recent mutation",
        "operationId": "mutation_undo",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/reminders": {
      "post": {
        "tags": [],
        "summary": "Schedule an auto-reminder",
        "operationId": "reminders_set",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/reminders/{message_id}": {
      "delete": {
        "tags": [],
        "summary": "Cancel an auto-reminder",
        "operationId": "reminders_cancel",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/reply-later": {
      "get": {
        "tags": [],
        "summary": "List reply-later messages",
        "operationId": "reply_later_list",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/reply-later/{message_id}": {
      "post": {
        "tags": [],
        "summary": "Set or clear reply-later",
        "operationId": "reply_later_set",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/scheduled-sends": {
      "post": {
        "tags": [],
        "summary": "Schedule a draft send",
        "operationId": "scheduled_sends_create",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/scheduled-sends/{draft_id}": {
      "delete": {
        "tags": [],
        "summary": "Cancel a scheduled send",
        "operationId": "scheduled_sends_cancel",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/screener/decisions": {
      "get": {
        "tags": [],
        "summary": "List screener decisions",
        "operationId": "screener_decisions_list",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      },
      "post": {
        "tags": [],
        "summary": "Set screener decision",
        "operationId": "screener_decisions_set",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      },
      "delete": {
        "tags": [],
        "summary": "Clear screener decision",
        "operationId": "screener_decisions_clear",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/screener/queue": {
      "get": {
        "tags": [],
        "summary": "List screener queue",
        "operationId": "screener_queue",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/search": {
      "get": {
        "tags": [],
        "summary": "Run a mail search",
        "operationId": "mail_search",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/sender": {
      "get": {
        "tags": [],
        "summary": "Sender profile",
        "operationId": "sender_profile",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/snippets": {
      "get": {
        "tags": [],
        "summary": "List snippets",
        "operationId": "snippets_list",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      },
      "post": {
        "tags": [],
        "summary": "Create or update a snippet",
        "operationId": "snippets_set",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/snippets/{name}": {
      "delete": {
        "tags": [],
        "summary": "Delete a snippet",
        "operationId": "snippets_delete",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/snoozed": {
      "get": {
        "tags": [],
        "summary": "List snoozed messages",
        "operationId": "mail_snoozed",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/snoozed/{message_id}/wake": {
      "post": {
        "tags": [],
        "summary": "Wake one snoozed message",
        "operationId": "mail_unsnooze_one",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/sync": {
      "post": {
        "tags": [],
        "summary": "Trigger sync",
        "operationId": "mail_sync",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/sync/status": {
      "get": {
        "tags": [],
        "summary": "Sync status",
        "operationId": "mail_sync_status",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/threads/draft-assist": {
      "post": {
        "tags": [],
        "summary": "Generate a draft body",
        "operationId": "draft_assist",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/threads/{thread_id}": {
      "get": {
        "tags": [],
        "summary": "Read a thread",
        "operationId": "mail_thread",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/threads/{thread_id}/export": {
      "get": {
        "tags": [],
        "summary": "Export a thread",
        "operationId": "mail_thread_export",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/mail/threads/{thread_id}/summarize": {
      "post": {
        "tags": [],
        "summary": "Summarize a thread",
        "operationId": "thread_summarize",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/openapi.json": {
      "get": {
        "tags": [],
        "summary": "OpenAPI 3.1 document",
        "operationId": "openapi_json",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/accounts": {
      "get": {
        "tags": [],
        "summary": "List runtime accounts",
        "operationId": "accounts_list",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/accounts/config": {
      "get": {
        "tags": [],
        "summary": "List configured accounts",
        "operationId": "accounts_config",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/accounts/default": {
      "post": {
        "tags": [],
        "summary": "Set default account",
        "operationId": "account_set_default",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/accounts/test": {
      "post": {
        "tags": [],
        "summary": "Test account connectivity",
        "operationId": "account_test",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/accounts/upsert": {
      "post": {
        "tags": [],
        "summary": "Create or update account",
        "operationId": "account_upsert",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/accounts/{account_id}/addresses": {
      "get": {
        "tags": [],
        "summary": "List account addresses",
        "operationId": "account_addresses_list",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      },
      "post": {
        "tags": [],
        "summary": "Add account address",
        "operationId": "account_addresses_add",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/accounts/{account_id}/addresses/primary": {
      "post": {
        "tags": [],
        "summary": "Set primary account address",
        "operationId": "account_addresses_primary",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/accounts/{account_id}/addresses/remove": {
      "post": {
        "tags": [],
        "summary": "Remove account address",
        "operationId": "account_addresses_remove",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/accounts/{key}": {
      "delete": {
        "tags": [],
        "summary": "Remove account",
        "operationId": "account_remove",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/accounts/{key}/disable": {
      "post": {
        "tags": [],
        "summary": "Disable account",
        "operationId": "account_disable",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/analytics/contact-asymmetry": {
      "get": {
        "tags": [],
        "summary": "Contact asymmetry",
        "operationId": "analytics_contact_asymmetry",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/analytics/contact-decay": {
      "get": {
        "tags": [],
        "summary": "Contact decay",
        "operationId": "analytics_contact_decay",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/analytics/largest-messages": {
      "get": {
        "tags": [],
        "summary": "Largest messages",
        "operationId": "analytics_largest_messages",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/analytics/rebuild": {
      "post": {
        "tags": [],
        "summary": "Rebuild analytics",
        "operationId": "analytics_rebuild",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/analytics/refresh-contacts": {
      "post": {
        "tags": [],
        "summary": "Refresh contacts",
        "operationId": "analytics_refresh_contacts",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/analytics/response-time": {
      "get": {
        "tags": [],
        "summary": "Response-time analytics",
        "operationId": "analytics_response_time",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/analytics/stale-threads": {
      "get": {
        "tags": [],
        "summary": "Stale threads",
        "operationId": "analytics_stale_threads",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/analytics/storage-breakdown": {
      "get": {
        "tags": [],
        "summary": "Storage breakdown",
        "operationId": "analytics_storage_breakdown",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/analytics/wrapped": {
      "get": {
        "tags": [],
        "summary": "Wrapped analytics",
        "operationId": "analytics_wrapped",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/auth/sessions/start": {
      "post": {
        "tags": [],
        "summary": "Start OAuth session",
        "operationId": "auth_session_start",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/auth/sessions/{session_id}": {
      "get": {
        "tags": [],
        "summary": "Get OAuth session",
        "operationId": "auth_session_get",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/auth/sessions/{session_id}/cancel": {
      "post": {
        "tags": [],
        "summary": "Cancel OAuth session",
        "operationId": "auth_session_cancel",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/auth/sessions/{session_id}/complete": {
      "post": {
        "tags": [],
        "summary": "Complete OAuth session",
        "operationId": "auth_session_complete",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/llm/config": {
      "get": {
        "tags": [],
        "summary": "Get LLM configuration",
        "operationId": "llm_config_get",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      },
      "post": {
        "tags": [],
        "summary": "Update LLM configuration",
        "operationId": "llm_config_update",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/llm/status": {
      "get": {
        "tags": [],
        "summary": "LLM provider status",
        "operationId": "llm_status",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/rules": {
      "get": {
        "tags": [],
        "summary": "List rules",
        "operationId": "rules_list",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/rules/delete": {
      "post": {
        "tags": [],
        "summary": "Delete rule",
        "operationId": "rule_delete",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/rules/detail": {
      "get": {
        "tags": [],
        "summary": "Rule detail",
        "operationId": "rule_detail",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/rules/dry-run": {
      "get": {
        "tags": [],
        "summary": "Dry-run rules",
        "operationId": "rule_dry_run",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/rules/form": {
      "get": {
        "tags": [],
        "summary": "Rule form payload",
        "operationId": "rule_form",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/rules/history": {
      "get": {
        "tags": [],
        "summary": "Rule history",
        "operationId": "rule_history",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/rules/upsert": {
      "post": {
        "tags": [],
        "summary": "Create or update rule",
        "operationId": "rule_upsert",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/rules/upsert-form": {
      "post": {
        "tags": [],
        "summary": "Create or update rule from form",
        "operationId": "rule_upsert_form",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/saved-searches": {
      "get": {
        "tags": [],
        "summary": "List saved searches",
        "operationId": "saved_searches_list",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/saved-searches/create": {
      "post": {
        "tags": [],
        "summary": "Create saved search",
        "operationId": "saved_searches_create",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/saved-searches/delete": {
      "post": {
        "tags": [],
        "summary": "Delete saved search",
        "operationId": "saved_searches_delete",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/saved-searches/run": {
      "post": {
        "tags": [],
        "summary": "Run saved search",
        "operationId": "saved_searches_run",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/semantic/enable": {
      "post": {
        "tags": [],
        "summary": "Enable semantic search",
        "operationId": "semantic_enable",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/semantic/profiles/install": {
      "post": {
        "tags": [],
        "summary": "Install semantic profile",
        "operationId": "semantic_profile_install",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/semantic/profiles/use": {
      "post": {
        "tags": [],
        "summary": "Use semantic profile",
        "operationId": "semantic_profile_use",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/semantic/reindex": {
      "post": {
        "tags": [],
        "summary": "Reindex semantic search",
        "operationId": "semantic_reindex",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/semantic/status": {
      "get": {
        "tags": [],
        "summary": "Semantic index status",
        "operationId": "semantic_status",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    },
    "/api/v1/platform/subscriptions": {
      "get": {
        "tags": [],
        "summary": "List subscriptions",
        "operationId": "subscriptions_list",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Missing or invalid bridge token"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AccountAddress": {
        "type": "object",
        "description": "One owned email address per account. Direction inference compares\n`messages.from_email` against this set to decide inbound vs outbound.",
        "required": [
          "account_id",
          "email",
          "is_primary"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "email": {
            "type": "string"
          },
          "is_primary": {
            "type": "boolean"
          }
        }
      },
      "AccountCapabilitiesData": {
        "type": "object",
        "required": [
          "labels",
          "server_search",
          "delta_sync",
          "push",
          "batch_operations",
          "native_thread_ids",
          "supports_send",
          "supports_local_drafts",
          "supports_server_drafts"
        ],
        "properties": {
          "batch_operations": {
            "type": "boolean"
          },
          "delta_sync": {
            "type": "boolean"
          },
          "labels": {
            "type": "boolean"
          },
          "native_thread_ids": {
            "type": "boolean"
          },
          "push": {
            "type": "boolean"
          },
          "server_search": {
            "type": "boolean"
          },
          "supports_local_drafts": {
            "type": "boolean"
          },
          "supports_send": {
            "type": "boolean"
          },
          "supports_server_drafts": {
            "type": "boolean"
          }
        }
      },
      "AccountConfigData": {
        "type": "object",
        "required": [
          "key",
          "name",
          "email",
          "is_default"
        ],
        "properties": {
          "email": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "is_default": {
            "type": "boolean"
          },
          "key": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "send": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/AccountSendConfigData"
              }
            ]
          },
          "sync": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/AccountSyncConfigData"
              }
            ]
          }
        }
      },
      "AccountEditModeData": {
        "type": "string",
        "enum": [
          "full",
          "runtime_only"
        ]
      },
      "AccountId": {
        "type": "string",
        "format": "uuid"
      },
      "AccountMutationResultData": {
        "type": "object",
        "required": [
          "account_id",
          "account_name",
          "succeeded",
          "skipped",
          "failed"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "account_name": {
            "type": "string"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "failed": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "skipped": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "succeeded": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "AccountOperationResult": {
        "type": "object",
        "required": [
          "ok",
          "summary"
        ],
        "properties": {
          "auth": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/AccountOperationStep"
              }
            ]
          },
          "device_code_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "device_code_user_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "ok": {
            "type": "boolean"
          },
          "save": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/AccountOperationStep"
              }
            ]
          },
          "send": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/AccountOperationStep"
              }
            ]
          },
          "summary": {
            "type": "string"
          },
          "sync": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/AccountOperationStep"
              }
            ]
          }
        }
      },
      "AccountOperationStep": {
        "type": "object",
        "required": [
          "ok",
          "detail"
        ],
        "properties": {
          "detail": {
            "type": "string"
          },
          "ok": {
            "type": "boolean"
          }
        }
      },
      "AccountSendConfigData": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "gmail"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "token_ref",
              "type"
            ],
            "properties": {
              "client_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "token_ref": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "outlook_personal"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "token_ref",
              "type"
            ],
            "properties": {
              "client_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "token_ref": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "outlook_work"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "host",
              "port",
              "username",
              "password_ref",
              "use_tls",
              "type"
            ],
            "properties": {
              "auth_required": {
                "type": "boolean"
              },
              "host": {
                "type": "string"
              },
              "password": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "password_ref": {
                "type": "string"
              },
              "port": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "type": {
                "type": "string",
                "enum": [
                  "smtp"
                ]
              },
              "use_tls": {
                "type": "boolean"
              },
              "username": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "description": "In-memory send provider for tests. Not for production use.",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "fake"
                ]
              }
            }
          }
        ]
      },
      "AccountSourceData": {
        "type": "string",
        "enum": [
          "runtime",
          "config",
          "both"
        ]
      },
      "AccountSummaryData": {
        "type": "object",
        "required": [
          "account_id",
          "name",
          "email",
          "provider_kind",
          "enabled",
          "is_default",
          "source",
          "editable"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "capabilities": {
            "$ref": "#/components/schemas/AccountCapabilitiesData"
          },
          "editable": {
            "$ref": "#/components/schemas/AccountEditModeData"
          },
          "email": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "is_default": {
            "type": "boolean"
          },
          "key": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "provider_kind": {
            "type": "string"
          },
          "send": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/AccountSendConfigData"
              }
            ]
          },
          "send_kind": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "$ref": "#/components/schemas/AccountSourceData"
          },
          "sync": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/AccountSyncConfigData"
              }
            ]
          },
          "sync_kind": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "AccountSyncConfigData": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "client_id",
              "token_ref",
              "type"
            ],
            "properties": {
              "client_id": {
                "type": "string"
              },
              "client_secret": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "credential_source": {
                "$ref": "#/components/schemas/GmailCredentialSourceData"
              },
              "token_ref": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "gmail"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "host",
              "port",
              "username",
              "password_ref",
              "use_tls",
              "type"
            ],
            "properties": {
              "auth_required": {
                "type": "boolean"
              },
              "host": {
                "type": "string"
              },
              "password": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "password_ref": {
                "type": "string"
              },
              "port": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "type": {
                "type": "string",
                "enum": [
                  "imap"
                ]
              },
              "use_tls": {
                "type": "boolean"
              },
              "username": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "token_ref",
              "type"
            ],
            "properties": {
              "client_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "token_ref": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "outlook_personal"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "token_ref",
              "type"
            ],
            "properties": {
              "client_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "token_ref": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "outlook_work"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "In-memory provider used for CLI smoke tests. Not for production use.",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "fake"
                ]
              }
            }
          }
        ]
      },
      "AccountSyncStatus": {
        "type": "object",
        "required": [
          "account_id",
          "account_name",
          "consecutive_failures",
          "sync_in_progress",
          "last_synced_count",
          "healthy"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "account_name": {
            "type": "string"
          },
          "backoff_until": {
            "type": [
              "string",
              "null"
            ]
          },
          "consecutive_failures": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "current_cursor_summary": {
            "type": [
              "string",
              "null"
            ]
          },
          "failure_class": {
            "type": [
              "string",
              "null"
            ]
          },
          "healthy": {
            "type": "boolean"
          },
          "last_attempt_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_success_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_synced_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "sync_in_progress": {
            "type": "boolean"
          }
        }
      },
      "Address": {
        "type": "object",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "AttachmentDisposition": {
        "type": "string",
        "enum": [
          "attachment",
          "inline",
          "unspecified"
        ]
      },
      "AttachmentFile": {
        "type": "object",
        "required": [
          "attachment_id",
          "filename",
          "path"
        ],
        "properties": {
          "attachment_id": {
            "$ref": "#/components/schemas/AttachmentId"
          },
          "filename": {
            "type": "string"
          },
          "path": {
            "type": "string"
          }
        }
      },
      "AttachmentId": {
        "type": "string",
        "format": "uuid"
      },
      "AttachmentMeta": {
        "type": "object",
        "required": [
          "id",
          "message_id",
          "filename",
          "mime_type",
          "size_bytes",
          "provider_id"
        ],
        "properties": {
          "content_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "content_location": {
            "type": [
              "string",
              "null"
            ]
          },
          "disposition": {
            "$ref": "#/components/schemas/AttachmentDisposition"
          },
          "filename": {
            "type": "string"
          },
          "id": {
            "$ref": "#/components/schemas/AttachmentId"
          },
          "local_path": {
            "type": [
              "string",
              "null"
            ]
          },
          "message_id": {
            "$ref": "#/components/schemas/MessageId"
          },
          "mime_type": {
            "type": "string"
          },
          "provider_id": {
            "type": "string"
          },
          "size_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "AuthFlowData": {
        "type": "string",
        "enum": [
          "auto",
          "installed",
          "device"
        ]
      },
      "AuthSessionData": {
        "type": "object",
        "required": [
          "session_id",
          "state",
          "flow",
          "account_key"
        ],
        "properties": {
          "account_key": {
            "type": "string"
          },
          "auth_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at_unix": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "flow": {
            "$ref": "#/components/schemas/AuthFlowData"
          },
          "message": {
            "type": [
              "string",
              "null"
            ]
          },
          "poll_interval_secs": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "session_id": {
            "$ref": "#/components/schemas/AuthSessionId"
          },
          "state": {
            "$ref": "#/components/schemas/AuthSessionStateData"
          },
          "user_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "verification_uri": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "AuthSessionId": {
        "type": "string"
      },
      "AuthSessionStateData": {
        "type": "string",
        "enum": [
          "starting",
          "waiting_for_user",
          "authorized",
          "failed",
          "cancelled"
        ]
      },
      "BodyFailure": {
        "type": "object",
        "required": [
          "message_id",
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message_id": {
            "$ref": "#/components/schemas/MessageId"
          }
        }
      },
      "BodyPartSource": {
        "type": "string",
        "enum": [
          "exact",
          "derived_from_plain",
          "derived_from_html",
          "best_effort_summary"
        ]
      },
      "CalendarMetadata": {
        "type": "object",
        "properties": {
          "method": {
            "type": [
              "string",
              "null"
            ]
          },
          "summary": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ContactAsymmetryRow": {
        "type": "object",
        "required": [
          "email",
          "total_inbound",
          "total_outbound",
          "asymmetry",
          "last_seen_at"
        ],
        "properties": {
          "asymmetry": {
            "type": "number",
            "format": "double",
            "description": "`|inbound - outbound| / max(inbound, outbound)` in `[0, 1]`. 0 means\nperfectly balanced; 1 means I never responded (or vice versa)."
          },
          "display_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": "string"
          },
          "last_seen_at": {
            "type": "string",
            "format": "date-time"
          },
          "total_inbound": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "total_outbound": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "ContactDecayRow": {
        "type": "object",
        "required": [
          "email",
          "last_inbound_at",
          "days_since_inbound"
        ],
        "properties": {
          "days_since_inbound": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "days_since_outbound": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "display_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": "string"
          },
          "last_inbound_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_outbound_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "DaemonEvent": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "account_id",
              "messages_synced",
              "event"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "event": {
                "type": "string",
                "enum": [
                  "SyncCompleted"
                ]
              },
              "messages_synced": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "account_id",
              "error",
              "event"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "error": {
                "type": "string"
              },
              "event": {
                "type": "string",
                "enum": [
                  "SyncError"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "envelopes",
              "event"
            ],
            "properties": {
              "envelopes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Envelope"
                }
              },
              "event": {
                "type": "string",
                "enum": [
                  "NewMessages"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "event"
            ],
            "properties": {
              "event": {
                "type": "string",
                "enum": [
                  "MessageUnsnoozed"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "description": "A pending auto-reminder fired because its window elapsed without\na reply being detected. Carries the original outbound message\nthe user wanted to be nudged about.",
            "required": [
              "sent_message_id",
              "event"
            ],
            "properties": {
              "event": {
                "type": "string",
                "enum": [
                  "ReminderTriggered"
                ]
              },
              "sent_message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "counts",
              "event"
            ],
            "properties": {
              "counts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/LabelCount"
                }
              },
              "event": {
                "type": "string",
                "enum": [
                  "LabelCountsUpdated"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "operation_id",
              "operation",
              "message",
              "event"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "event": {
                "type": "string",
                "enum": [
                  "OperationStarted"
                ]
              },
              "message": {
                "type": "string"
              },
              "operation": {
                "type": "string"
              },
              "operation_id": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "operation_id",
              "operation",
              "current",
              "message",
              "event"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "current": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "event": {
                "type": "string",
                "enum": [
                  "OperationProgress"
                ]
              },
              "message": {
                "type": "string"
              },
              "operation": {
                "type": "string"
              },
              "operation_id": {
                "type": "string"
              },
              "total": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "operation_id",
              "operation",
              "message",
              "event"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "event": {
                "type": "string",
                "enum": [
                  "OperationCompleted"
                ]
              },
              "message": {
                "type": "string"
              },
              "operation": {
                "type": "string"
              },
              "operation_id": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "operation_id",
              "operation",
              "error",
              "retryable",
              "event"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "error": {
                "type": "string"
              },
              "event": {
                "type": "string",
                "enum": [
                  "OperationFailed"
                ]
              },
              "operation": {
                "type": "string"
              },
              "operation_id": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "operation_id",
              "operation",
              "message",
              "event"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "event": {
                "type": "string",
                "enum": [
                  "OperationCancelled"
                ]
              },
              "message": {
                "type": "string"
              },
              "operation": {
                "type": "string"
              },
              "operation_id": {
                "type": "string"
              }
            }
          }
        ]
      },
      "DaemonHealthClass": {
        "type": "string",
        "enum": [
          "healthy",
          "degraded",
          "restart_required",
          "repair_required"
        ]
      },
      "DoctorDataStats": {
        "type": "object",
        "required": [
          "accounts",
          "labels",
          "messages",
          "unread_messages",
          "starred_messages",
          "messages_with_attachments",
          "message_labels",
          "bodies",
          "attachments",
          "drafts",
          "snoozed",
          "saved_searches",
          "rules",
          "rule_logs",
          "sync_log",
          "sync_runtime_statuses",
          "event_log",
          "semantic_profiles",
          "semantic_chunks",
          "semantic_embeddings"
        ],
        "properties": {
          "accounts": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "attachments": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "bodies": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "drafts": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "event_log": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "labels": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "message_labels": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "messages": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "messages_with_attachments": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "rule_logs": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "rules": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "saved_searches": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "semantic_chunks": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "semantic_embeddings": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "semantic_profiles": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "snoozed": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "starred_messages": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "sync_log": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "sync_runtime_statuses": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "unread_messages": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "DoctorFinding": {
        "type": "object",
        "description": "One actionable issue identified by `mxr doctor`. Combines a short\nhuman-readable message with optional shell commands the user can\nrun to remediate.",
        "required": [
          "category",
          "severity",
          "message"
        ],
        "properties": {
          "category": {
            "$ref": "#/components/schemas/DoctorFindingCategory"
          },
          "message": {
            "type": "string"
          },
          "remediation": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Shell-runnable suggestions the user can copy-paste. Empty when\nno automated remediation is available."
          },
          "severity": {
            "$ref": "#/components/schemas/DoctorFindingSeverity"
          }
        }
      },
      "DoctorFindingCategory": {
        "type": "string",
        "description": "Coarse category of a doctor finding. Lets clients group related\nissues without parsing free text.",
        "enum": [
          "generic",
          "sync",
          "o_auth",
          "network",
          "search_index",
          "semantic",
          "sqlite_lock",
          "storage",
          "daemon"
        ]
      },
      "DoctorFindingSeverity": {
        "type": "string",
        "description": "Severity of a doctor finding. Drives whether the CLI exits non-zero\n(`Error`) and how the TUI styles the entry.",
        "enum": [
          "info",
          "warning",
          "error"
        ]
      },
      "DoctorReport": {
        "type": "object",
        "required": [
          "healthy",
          "data_dir_exists",
          "database_exists",
          "index_exists",
          "socket_exists",
          "socket_reachable",
          "stale_socket",
          "daemon_running",
          "index_lock_held",
          "database_path",
          "database_size_bytes",
          "index_path",
          "index_size_bytes",
          "log_path",
          "log_size_bytes",
          "sync_statuses",
          "recent_sync_events",
          "recent_error_logs",
          "recommended_next_steps"
        ],
        "properties": {
          "daemon_build_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "daemon_pid": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "daemon_protocol_version": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "daemon_running": {
            "type": "boolean"
          },
          "daemon_version": {
            "type": [
              "string",
              "null"
            ]
          },
          "data_dir_exists": {
            "type": "boolean"
          },
          "data_stats": {
            "$ref": "#/components/schemas/DoctorDataStats"
          },
          "database_exists": {
            "type": "boolean"
          },
          "database_path": {
            "type": "string"
          },
          "database_size_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "findings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DoctorFinding"
            },
            "description": "Structured findings: per-issue category, severity, and\nshell-runnable remediation steps. Replaces the freeform\n`recommended_next_steps` for clients that want to reason about\nindividual problems (TUI, future agent integrations). The\nfreeform field is preserved for backwards-compatibility."
          },
          "health_class": {
            "$ref": "#/components/schemas/DaemonHealthClass"
          },
          "healthy": {
            "type": "boolean"
          },
          "index_exists": {
            "type": "boolean"
          },
          "index_lock_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "index_lock_held": {
            "type": "boolean"
          },
          "index_path": {
            "type": "string"
          },
          "index_size_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "last_successful_sync_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "lexical_index_freshness": {
            "$ref": "#/components/schemas/IndexFreshness"
          },
          "lexical_last_rebuilt_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "log_path": {
            "type": "string"
          },
          "log_size_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "recent_error_logs": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "recent_sync_events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventLogEntry"
            }
          },
          "recommended_next_steps": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "repair_required": {
            "type": "boolean"
          },
          "restart_required": {
            "type": "boolean"
          },
          "semantic_active_profile": {
            "type": [
              "string",
              "null"
            ]
          },
          "semantic_enabled": {
            "type": "boolean"
          },
          "semantic_index_freshness": {
            "$ref": "#/components/schemas/IndexFreshness"
          },
          "semantic_last_indexed_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "socket_exists": {
            "type": "boolean"
          },
          "socket_reachable": {
            "type": "boolean"
          },
          "stale_socket": {
            "type": "boolean"
          },
          "sync_statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountSyncStatus"
            }
          }
        }
      },
      "Draft": {
        "type": "object",
        "required": [
          "id",
          "account_id",
          "to",
          "cc",
          "bcc",
          "subject",
          "body_markdown",
          "attachments",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bcc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          },
          "body_markdown": {
            "type": "string"
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "$ref": "#/components/schemas/DraftId"
          },
          "reply_headers": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ReplyHeaders"
              }
            ]
          },
          "subject": {
            "type": "string"
          },
          "to": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DraftId": {
        "type": "string",
        "format": "uuid"
      },
      "Envelope": {
        "type": "object",
        "required": [
          "id",
          "account_id",
          "provider_id",
          "thread_id",
          "references",
          "from",
          "to",
          "cc",
          "bcc",
          "subject",
          "date",
          "flags",
          "snippet",
          "has_attachments",
          "size_bytes",
          "unsubscribe"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "bcc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "flags": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "from": {
            "$ref": "#/components/schemas/Address"
          },
          "has_attachments": {
            "type": "boolean"
          },
          "id": {
            "$ref": "#/components/schemas/MessageId"
          },
          "in_reply_to": {
            "type": [
              "string",
              "null"
            ]
          },
          "label_provider_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Provider-specific label IDs (e.g. \"INBOX\", \"SENT\", \"Label_123\").\nTransient: used during sync to populate the message_labels junction table."
          },
          "message_id_header": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider_id": {
            "type": "string",
            "description": "Provider-instance identity used for sync and mutations.\n\nStable for Gmail message IDs.\nFor IMAP, this is mailbox-scoped today and may change across moves/copies."
          },
          "references": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "size_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "snippet": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "thread_id": {
            "$ref": "#/components/schemas/ThreadId"
          },
          "to": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          },
          "unsubscribe": {
            "$ref": "#/components/schemas/UnsubscribeMethod"
          }
        }
      },
      "EventLogEntry": {
        "type": "object",
        "required": [
          "timestamp",
          "level",
          "category",
          "summary"
        ],
        "properties": {
          "account_id": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/AccountId"
              }
            ]
          },
          "category": {
            "type": "string"
          },
          "details": {
            "type": [
              "string",
              "null"
            ]
          },
          "level": {
            "type": "string"
          },
          "message_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "rule_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "summary": {
            "type": "string"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "ExportFormat": {
        "type": "string",
        "enum": [
          "Markdown",
          "Json",
          "Mbox",
          "LlmContext"
        ]
      },
      "ForwardContext": {
        "type": "object",
        "description": "Forward context returned by PrepareForward.",
        "required": [
          "account_id",
          "subject",
          "from",
          "forwarded_content"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "forwarded_content": {
            "type": "string"
          },
          "from": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          }
        }
      },
      "GmailCredentialSourceData": {
        "type": "string",
        "enum": [
          "bundled",
          "custom"
        ]
      },
      "HtmlImageAsset": {
        "type": "object",
        "required": [
          "source",
          "kind",
          "status"
        ],
        "properties": {
          "detail": {
            "type": [
              "string",
              "null"
            ]
          },
          "kind": {
            "$ref": "#/components/schemas/HtmlImageSourceKind"
          },
          "mime_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "path": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/HtmlImageAssetStatus"
          }
        }
      },
      "HtmlImageAssetStatus": {
        "type": "string",
        "enum": [
          "ready",
          "blocked",
          "missing",
          "unsupported",
          "failed"
        ]
      },
      "HtmlImageSourceKind": {
        "type": "string",
        "enum": [
          "cid",
          "data_uri",
          "remote",
          "content_location",
          "file"
        ]
      },
      "IndexFreshness": {
        "type": "string",
        "enum": [
          "unknown",
          "current",
          "stale",
          "disabled",
          "indexing",
          "error",
          "repair_required"
        ]
      },
      "IpcErrorKind": {
        "type": "string",
        "enum": [
          "invalid_request",
          "not_found",
          "auth",
          "policy",
          "provider",
          "rate_limited",
          "store",
          "unsupported",
          "internal"
        ]
      },
      "Label": {
        "type": "object",
        "required": [
          "id",
          "account_id",
          "name",
          "kind",
          "provider_id",
          "unread_count",
          "total_count"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "color": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "$ref": "#/components/schemas/LabelId"
          },
          "kind": {
            "$ref": "#/components/schemas/LabelKind"
          },
          "name": {
            "type": "string"
          },
          "provider_id": {
            "type": "string"
          },
          "total_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "unread_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "LabelCount": {
        "type": "object",
        "required": [
          "label_id",
          "unread_count",
          "total_count"
        ],
        "properties": {
          "label_id": {
            "$ref": "#/components/schemas/LabelId"
          },
          "total_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "unread_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "LabelId": {
        "type": "string",
        "format": "uuid"
      },
      "LabelKind": {
        "type": "string",
        "enum": [
          "System",
          "Folder",
          "User"
        ]
      },
      "LargestMessageRow": {
        "type": "object",
        "description": "Single message ranked by its envelope `size_bytes`. Powers\n`mxr storage --by message`: lets users find and act on the single\nbiggest emails (the 250 MB attachment from a courier service, the\nmassive zip a colleague sent in 2017) instead of just the bucket totals.",
        "required": [
          "message_id",
          "from_email",
          "subject",
          "size_bytes",
          "date"
        ],
        "properties": {
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "from_email": {
            "type": "string"
          },
          "message_id": {
            "$ref": "#/components/schemas/MessageId"
          },
          "size_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "subject": {
            "type": "string"
          }
        }
      },
      "LlmConfigData": {
        "type": "object",
        "required": [
          "enabled",
          "base_url",
          "model",
          "api_key_env",
          "context_window",
          "request_timeout_secs"
        ],
        "properties": {
          "api_key_env": {
            "type": "string"
          },
          "base_url": {
            "type": "string"
          },
          "context_window": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "enabled": {
            "type": "boolean"
          },
          "model": {
            "type": "string"
          },
          "request_timeout_secs": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "LlmStatusSnapshot": {
        "type": "object",
        "required": [
          "enabled",
          "provider",
          "model",
          "configured_model",
          "api_key_present",
          "context_window",
          "supports_streaming",
          "request_timeout_secs"
        ],
        "properties": {
          "api_key_env": {
            "type": [
              "string",
              "null"
            ]
          },
          "api_key_present": {
            "type": "boolean"
          },
          "base_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "configured_model": {
            "type": "string"
          },
          "context_window": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "enabled": {
            "type": "boolean"
          },
          "model": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "request_timeout_secs": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "supports_streaming": {
            "type": "boolean"
          }
        }
      },
      "MessageBody": {
        "type": "object",
        "required": [
          "message_id",
          "attachments",
          "fetched_at"
        ],
        "properties": {
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AttachmentMeta"
            }
          },
          "fetched_at": {
            "type": "string",
            "format": "date-time"
          },
          "message_id": {
            "$ref": "#/components/schemas/MessageId"
          },
          "metadata": {
            "$ref": "#/components/schemas/MessageMetadata"
          },
          "text_html": {
            "type": [
              "string",
              "null"
            ]
          },
          "text_plain": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "MessageId": {
        "type": "string",
        "format": "uuid"
      },
      "MessageMetadata": {
        "type": "object",
        "properties": {
          "auth_results": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "calendar": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/CalendarMetadata"
              }
            ]
          },
          "content_language": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "list_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "raw_headers": {
            "type": [
              "string",
              "null"
            ]
          },
          "text_html_source": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/BodyPartSource"
              }
            ]
          },
          "text_plain_format": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/TextPlainFormat"
              }
            ]
          },
          "text_plain_source": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/BodyPartSource"
              }
            ]
          }
        }
      },
      "MutationCommand": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "message_ids",
              "mutation"
            ],
            "properties": {
              "message_ids": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MessageId"
                }
              },
              "mutation": {
                "type": "string",
                "enum": [
                  "Archive"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_ids",
              "mutation"
            ],
            "properties": {
              "message_ids": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MessageId"
                }
              },
              "mutation": {
                "type": "string",
                "enum": [
                  "ReadAndArchive"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_ids",
              "mutation"
            ],
            "properties": {
              "message_ids": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MessageId"
                }
              },
              "mutation": {
                "type": "string",
                "enum": [
                  "Trash"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_ids",
              "mutation"
            ],
            "properties": {
              "message_ids": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MessageId"
                }
              },
              "mutation": {
                "type": "string",
                "enum": [
                  "Spam"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_ids",
              "starred",
              "mutation"
            ],
            "properties": {
              "message_ids": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MessageId"
                }
              },
              "mutation": {
                "type": "string",
                "enum": [
                  "Star"
                ]
              },
              "starred": {
                "type": "boolean"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_ids",
              "read",
              "mutation"
            ],
            "properties": {
              "message_ids": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MessageId"
                }
              },
              "mutation": {
                "type": "string",
                "enum": [
                  "SetRead"
                ]
              },
              "read": {
                "type": "boolean"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_ids",
              "add",
              "remove",
              "mutation"
            ],
            "properties": {
              "add": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "message_ids": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MessageId"
                }
              },
              "mutation": {
                "type": "string",
                "enum": [
                  "ModifyLabels"
                ]
              },
              "remove": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_ids",
              "target_label",
              "mutation"
            ],
            "properties": {
              "message_ids": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MessageId"
                }
              },
              "mutation": {
                "type": "string",
                "enum": [
                  "Move"
                ]
              },
              "target_label": {
                "type": "string"
              }
            }
          }
        ],
        "description": "Mutation commands for modifying messages."
      },
      "MutationResultData": {
        "type": "object",
        "required": [
          "requested",
          "succeeded",
          "skipped",
          "failed",
          "accounts"
        ],
        "properties": {
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountMutationResultData"
            }
          },
          "failed": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "mutation_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Set by undoable mutations (Archive / Trash / Spam / SetRead /\nReadAndArchive). Identifies a row in the daemon's\n`mutation_undo_log` that the client can reference via\n`Request::UndoMutation` for ~60s after the mutation lands.\n`None` for non-undoable mutations (Star, ModifyLabels, Move)."
          },
          "requested": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "skipped": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "succeeded": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "ReplyContext": {
        "type": "object",
        "description": "Reply context returned by PrepareReply.",
        "required": [
          "account_id",
          "in_reply_to",
          "references",
          "reply_to",
          "cc",
          "subject",
          "from",
          "thread_context"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "cc": {
            "type": "string"
          },
          "from": {
            "type": "string"
          },
          "in_reply_to": {
            "type": "string"
          },
          "references": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "reply_to": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "thread_context": {
            "type": "string"
          },
          "thread_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Provider-native thread hint (e.g. Gmail thread id). None for IMAP."
          }
        }
      },
      "ReplyHeaders": {
        "type": "object",
        "required": [
          "in_reply_to"
        ],
        "properties": {
          "in_reply_to": {
            "type": "string"
          },
          "references": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "thread_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Provider-native thread hint. Gmail uses this to keep replies in-thread;\nIMAP relies on the In-Reply-To/References headers and ignores it."
          }
        }
      },
      "Request": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "limit",
              "offset",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListEnvelopes"
                ]
              },
              "label_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/LabelId"
                  }
                ]
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "offset": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_ids",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListEnvelopesByIds"
                ]
              },
              "message_ids": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MessageId"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetEnvelope"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetBody"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "allow_remote",
              "cmd"
            ],
            "properties": {
              "allow_remote": {
                "type": "boolean"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "GetHtmlImageAssets"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "attachment_id",
              "cmd"
            ],
            "properties": {
              "attachment_id": {
                "$ref": "#/components/schemas/AttachmentId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "DownloadAttachment"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "attachment_id",
              "cmd"
            ],
            "properties": {
              "attachment_id": {
                "$ref": "#/components/schemas/AttachmentId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "OpenAttachment"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_ids",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListBodies"
                ]
              },
              "message_ids": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MessageId"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "thread_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetThread"
                ]
              },
              "thread_id": {
                "$ref": "#/components/schemas/ThreadId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListLabels"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "name",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "CreateLabel"
                ]
              },
              "color": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "name": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "name",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "DeleteLabel"
                ]
              },
              "name": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "old",
              "new",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "RenameLabel"
                ]
              },
              "new": {
                "type": "string"
              },
              "old": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListAccounts"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListAccountsConfig"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "account",
              "reauthorize",
              "cmd"
            ],
            "properties": {
              "account": {
                "$ref": "#/components/schemas/AccountConfigData"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "AuthorizeAccountConfig"
                ]
              },
              "reauthorize": {
                "type": "boolean"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "account",
              "reauthorize",
              "cmd"
            ],
            "properties": {
              "account": {
                "$ref": "#/components/schemas/AccountConfigData"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "StartAuthSession"
                ]
              },
              "flow": {
                "$ref": "#/components/schemas/AuthFlowData"
              },
              "reauthorize": {
                "type": "boolean"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "session_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetAuthSession"
                ]
              },
              "session_id": {
                "$ref": "#/components/schemas/AuthSessionId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "session_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "CancelAuthSession"
                ]
              },
              "session_id": {
                "$ref": "#/components/schemas/AuthSessionId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "session_id",
              "save_account",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "CompleteAuthSession"
                ]
              },
              "save_account": {
                "type": "boolean"
              },
              "session_id": {
                "$ref": "#/components/schemas/AuthSessionId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "account",
              "cmd"
            ],
            "properties": {
              "account": {
                "$ref": "#/components/schemas/AccountConfigData"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "UpsertAccountConfig"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "key",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "SetDefaultAccount"
                ]
              },
              "key": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "account",
              "cmd"
            ],
            "properties": {
              "account": {
                "$ref": "#/components/schemas/AccountConfigData"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "TestAccountConfig"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "key",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "DisableAccountConfig"
                ]
              },
              "key": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "key",
              "purge_local_data",
              "dry_run",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "RemoveAccountConfig"
                ]
              },
              "dry_run": {
                "type": "boolean"
              },
              "key": {
                "type": "string"
              },
              "purge_local_data": {
                "type": "boolean"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "account",
              "cmd"
            ],
            "properties": {
              "account": {
                "$ref": "#/components/schemas/AccountConfigData"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "RepairAccountConfig"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListRules"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rule",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetRule"
                ]
              },
              "rule": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rule",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetRuleForm"
                ]
              },
              "rule": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rule",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "UpsertRule"
                ]
              },
              "rule": {}
            }
          },
          {
            "type": "object",
            "required": [
              "name",
              "condition",
              "action",
              "priority",
              "enabled",
              "cmd"
            ],
            "properties": {
              "action": {
                "type": "string"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "UpsertRuleForm"
                ]
              },
              "condition": {
                "type": "string"
              },
              "enabled": {
                "type": "boolean"
              },
              "existing_rule": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "name": {
                "type": "string"
              },
              "priority": {
                "type": "integer",
                "format": "int32"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rule",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "DeleteRule"
                ]
              },
              "rule": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "all",
              "cmd"
            ],
            "properties": {
              "after": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "all": {
                "type": "boolean"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "DryRunRules"
                ]
              },
              "rule": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListSavedSearches"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "limit",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListSubscriptions"
                ]
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "group_by",
              "limit",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListStorageBreakdown"
                ]
              },
              "group_by": {
                "$ref": "#/components/schemas/StorageGroupBy"
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "limit",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListLargestMessages"
                ]
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "since_days": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "since_unix",
              "until_unix",
              "label",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "Wrapped"
                ]
              },
              "label": {
                "type": "string"
              },
              "since_unix": {
                "type": "integer",
                "format": "int64"
              },
              "until_unix": {
                "type": "integer",
                "format": "int64"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "perspective",
              "older_than_days",
              "within_days",
              "limit",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListStaleThreads"
                ]
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "older_than_days": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "perspective": {
                "$ref": "#/components/schemas/StaleBallInCourt"
              },
              "within_days": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "min_inbound",
              "limit",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListContactAsymmetry"
                ]
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "min_inbound": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "threshold_days",
              "max_lookback_days",
              "limit",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListContactDecay"
                ]
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "max_lookback_days": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "threshold_days": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "RefreshContacts"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "RebuildAnalytics"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "direction",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListResponseTime"
                ]
              },
              "counterparty": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "direction": {
                "$ref": "#/components/schemas/ResponseTimeDirection"
              },
              "since_days": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "account_id",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListAccountAddresses"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "account_id",
              "email",
              "primary",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "AddAccountAddress"
                ]
              },
              "email": {
                "type": "string"
              },
              "primary": {
                "type": "boolean"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "account_id",
              "email",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "RemoveAccountAddress"
                ]
              },
              "email": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "account_id",
              "email",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "SetPrimaryAccountAddress"
                ]
              },
              "email": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetLlmStatus"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetLlmConfig"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "config",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "UpdateLlmConfig"
                ]
              },
              "config": {
                "$ref": "#/components/schemas/LlmConfigData"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetSemanticStatus"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "enabled",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "EnableSemantic"
                ]
              },
              "enabled": {
                "type": "boolean"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "profile",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "InstallSemanticProfile"
                ]
              },
              "profile": {
                "$ref": "#/components/schemas/SemanticProfile"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "profile",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "UseSemanticProfile"
                ]
              },
              "profile": {
                "$ref": "#/components/schemas/SemanticProfile"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ReindexSemantic"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "name",
              "query",
              "search_mode",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "CreateSavedSearch"
                ]
              },
              "name": {
                "type": "string"
              },
              "query": {
                "type": "string"
              },
              "search_mode": {
                "$ref": "#/components/schemas/SearchMode"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "name",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "DeleteSavedSearch"
                ]
              },
              "name": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "name",
              "limit",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "RunSavedSearch"
                ]
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "name": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "limit",
              "cmd"
            ],
            "properties": {
              "category": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListEvents"
                ]
              },
              "level": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "limit",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetLogs"
                ]
              },
              "level": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetDoctorReport"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "verbose",
              "full_logs",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GenerateBugReport"
                ]
              },
              "full_logs": {
                "type": "boolean"
              },
              "since": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "verbose": {
                "type": "boolean"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "query",
              "limit",
              "explain",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "Search"
                ]
              },
              "explain": {
                "type": "boolean"
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "mode": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/SearchMode"
                  }
                ]
              },
              "offset": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "query": {
                "type": "string"
              },
              "sort": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/SortOrder"
                  }
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "account_id": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountId"
                  }
                ]
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "SyncNow"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "account_id",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "GetSyncStatus"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "flags",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "SetFlags"
                ]
              },
              "flags": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "query",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "Count"
                ]
              },
              "mode": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/SearchMode"
                  }
                ]
              },
              "query": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetHeaders"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "limit",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListRuleHistory"
                ]
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "rule": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          {
            "allOf": [
              {
                "$ref": "#/components/schemas/MutationCommand"
              },
              {
                "type": "object",
                "required": [
                  "cmd"
                ],
                "properties": {
                  "cmd": {
                    "type": "string",
                    "enum": [
                      "Mutation"
                    ]
                  }
                }
              }
            ]
          },
          {
            "type": "object",
            "description": "Reverse a recent undoable mutation by id. Available within ~60s of\nthe mutation landing; daemon refuses with an `Error` response\npast that window.",
            "required": [
              "mutation_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "UndoMutation"
                ]
              },
              "mutation_id": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "Unsubscribe"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "wake_at",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "Snooze"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              },
              "wake_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "Unsnooze"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListSnoozed"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Toggle the reply-later flag on a message. Local-only metadata —\nnever roundtrips to the provider. Setting a flag that is already\nset refreshes the timestamp, surfacing the message to the top of\nthe queue.",
            "required": [
              "message_id",
              "flag",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "SetReplyLater"
                ]
              },
              "flag": {
                "type": "boolean"
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "description": "List messages currently flagged for reply-later, ordered by most\nrecently flagged first.",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListReplyQueue"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Schedule a reminder for an outbound message: \"remind me if no\nreply by `remind_at`.\" Re-sending overwrites any prior reminder\non the same message.",
            "required": [
              "sent_message_id",
              "remind_at",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "SetAutoReminder"
                ]
              },
              "remind_at": {
                "type": "string",
                "format": "date-time"
              },
              "sent_message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "description": "Cancel a pending reminder.",
            "required": [
              "sent_message_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "CancelAutoReminder"
                ]
              },
              "sent_message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "description": "Schedule an existing draft to be sent at `send_at`. The flusher\nloop scans due rows on a 60-second cadence and runs them through\nthe same `send_stored_draft` pipeline that interactive sends use.",
            "required": [
              "draft_id",
              "send_at",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ScheduleSend"
                ]
              },
              "draft_id": {
                "$ref": "#/components/schemas/DraftId"
              },
              "send_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          {
            "type": "object",
            "description": "Cancel a pending scheduled send (the draft itself is preserved).",
            "required": [
              "draft_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "CancelScheduledSend"
                ]
              },
              "draft_id": {
                "$ref": "#/components/schemas/DraftId"
              }
            }
          },
          {
            "type": "object",
            "description": "List all snippets, alphabetically by name.",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListSnippets"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Create or update a snippet by name.",
            "required": [
              "name",
              "body",
              "vars",
              "cmd"
            ],
            "properties": {
              "body": {
                "type": "string"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "SetSnippet"
                ]
              },
              "name": {
                "type": "string"
              },
              "vars": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          {
            "type": "object",
            "description": "Delete a snippet by name. No-op if absent.",
            "required": [
              "name",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "DeleteSnippet"
                ]
              },
              "name": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "description": "Per-sender relationship aggregates: volume, response cadence,\nopen threads. Returns `None` (via `Ok`/`SenderProfileData` with\n`present=false`) if the contact is unknown.",
            "required": [
              "account_id",
              "email",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "GetSenderProfile"
                ]
              },
              "email": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "description": "List senders who've sent inbound messages but don't have a\nscreener decision yet.",
            "required": [
              "account_id",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListScreenerQueue"
                ]
              },
              "limit": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "description": "All screener decisions for an account.",
            "required": [
              "account_id",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ListScreenerDecisions"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Set or update the screener disposition for one sender.",
            "required": [
              "account_id",
              "sender_email",
              "disposition",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "SetScreenerDecision"
                ]
              },
              "disposition": {
                "$ref": "#/components/schemas/ScreenerDispositionData"
              },
              "route_label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "sender_email": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "description": "Clear an existing screener decision (returns the sender to\n\"no decision yet\" state).",
            "required": [
              "account_id",
              "sender_email",
              "cmd"
            ],
            "properties": {
              "account_id": {
                "$ref": "#/components/schemas/AccountId"
              },
              "cmd": {
                "type": "string",
                "enum": [
                  "ClearScreenerDecision"
                ]
              },
              "sender_email": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "description": "Generate a 2-3 sentence summary of a thread using the configured\nLLM. Returns `LlmDisabled` error when LLM is not configured.",
            "required": [
              "thread_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "SummarizeThread"
                ]
              },
              "thread_id": {
                "$ref": "#/components/schemas/ThreadId"
              }
            }
          },
          {
            "type": "object",
            "description": "Generate a draft reply grounded on the user's prior sent\nmessages and the current thread context. Caller is responsible\nfor opening the result in `$EDITOR` for review — the result is\nnever auto-sent.",
            "required": [
              "thread_id",
              "instruction",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "DraftAssist"
                ]
              },
              "instruction": {
                "type": "string"
              },
              "thread_id": {
                "$ref": "#/components/schemas/ThreadId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "reply_all",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "PrepareReply"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              },
              "reply_all": {
                "type": "boolean"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "PrepareForward"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "draft",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "SendDraft"
                ]
              },
              "draft": {
                "$ref": "#/components/schemas/Draft"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "draft",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "SaveDraft"
                ]
              },
              "draft": {
                "$ref": "#/components/schemas/Draft"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "draft_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "SendStoredDraft"
                ]
              },
              "draft_id": {
                "$ref": "#/components/schemas/DraftId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "draft_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "DeleteDraft"
                ]
              },
              "draft_id": {
                "$ref": "#/components/schemas/DraftId"
              }
            }
          },
          {
            "type": "object",
            "description": "Save draft to the mail server (e.g. Gmail Drafts folder).",
            "required": [
              "draft",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "SaveDraftToServer"
                ]
              },
              "draft": {
                "$ref": "#/components/schemas/Draft"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListDrafts"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "List drafts that look orphaned mid-send: status `'sending'` with\na stale `last_heartbeat_at` (or `status_updated_at` fallback)\nolder than 1h. Surfaces what the daemon-startup recovery loop\nwould also auto-reset.",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ListOrphanedDrafts"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Force-reset an orphaned `'sending'` draft back to `'draft'` so\nthe user can retry the send. Idempotent: already-`'draft'` rows\nreturn the no-op variant. `'sent'` rows refuse.",
            "required": [
              "draft_id",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ResetOrphanedDraft"
                ]
              },
              "draft_id": {
                "$ref": "#/components/schemas/DraftId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "thread_id",
              "format",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ExportThread"
                ]
              },
              "format": {
                "$ref": "#/components/schemas/ExportFormat"
              },
              "thread_id": {
                "$ref": "#/components/schemas/ThreadId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "query",
              "format",
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "ExportSearch"
                ]
              },
              "format": {
                "$ref": "#/components/schemas/ExportFormat"
              },
              "query": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "GetStatus"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "Ping"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "cmd"
            ],
            "properties": {
              "cmd": {
                "type": "string",
                "enum": [
                  "Shutdown"
                ]
              }
            }
          }
        ]
      },
      "Response": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "data",
              "status"
            ],
            "properties": {
              "data": {
                "$ref": "#/components/schemas/ResponseData"
              },
              "status": {
                "type": "string",
                "enum": [
                  "Ok"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message",
              "status"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "details": {},
              "kind": {
                "$ref": "#/components/schemas/IpcErrorKind"
              },
              "message": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean"
              },
              "status": {
                "type": "string",
                "enum": [
                  "Error"
                ]
              }
            }
          }
        ]
      },
      "ResponseData": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "envelopes",
              "kind"
            ],
            "properties": {
              "envelopes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Envelope"
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "Envelopes"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "envelope",
              "kind"
            ],
            "properties": {
              "envelope": {
                "$ref": "#/components/schemas/Envelope"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "Envelope"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "body",
              "kind"
            ],
            "properties": {
              "body": {
                "$ref": "#/components/schemas/MessageBody"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "Body"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "message_id",
              "assets",
              "kind"
            ],
            "properties": {
              "assets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/HtmlImageAsset"
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "HtmlImageAssets"
                ]
              },
              "message_id": {
                "$ref": "#/components/schemas/MessageId"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "file",
              "kind"
            ],
            "properties": {
              "file": {
                "$ref": "#/components/schemas/AttachmentFile"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "AttachmentFile"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "bodies",
              "kind"
            ],
            "properties": {
              "bodies": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MessageBody"
                }
              },
              "failures": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/BodyFailure"
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "Bodies"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "thread",
              "messages",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "Thread"
                ]
              },
              "messages": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Envelope"
                }
              },
              "thread": {
                "$ref": "#/components/schemas/Thread"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "labels",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "Labels"
                ]
              },
              "labels": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Label"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "label",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "Label"
                ]
              },
              "label": {
                "$ref": "#/components/schemas/Label"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "results",
              "kind"
            ],
            "properties": {
              "explain": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/SearchExplain"
                  }
                ]
              },
              "has_more": {
                "type": "boolean"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "SearchResults"
                ]
              },
              "next_offset": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "minimum": 0
              },
              "results": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SearchResultItem"
                }
              },
              "total": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "sync",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "SyncStatus"
                ]
              },
              "sync": {
                "$ref": "#/components/schemas/AccountSyncStatus"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "count",
              "kind"
            ],
            "properties": {
              "count": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "kind": {
                "type": "string",
                "enum": [
                  "Count"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "headers",
              "kind"
            ],
            "properties": {
              "headers": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": false,
                  "prefixItems": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "string"
                    }
                  ]
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "Headers"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "context",
              "kind"
            ],
            "properties": {
              "context": {
                "$ref": "#/components/schemas/ReplyContext"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "ReplyContext"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "context",
              "kind"
            ],
            "properties": {
              "context": {
                "$ref": "#/components/schemas/ForwardContext"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "ForwardContext"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "drafts",
              "kind"
            ],
            "properties": {
              "drafts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Draft"
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "Drafts"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "snoozed",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "SnoozedMessages"
                ]
              },
              "snoozed": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Snoozed"
                }
              }
            }
          },
          {
            "type": "object",
            "description": "List of messages currently flagged for reply-later.",
            "required": [
              "messages",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "ReplyQueue"
                ]
              },
              "messages": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "snippets",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "Snippets"
                ]
              },
              "snippets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SnippetData"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "snippet",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "SnippetData"
                ]
              },
              "snippet": {
                "$ref": "#/components/schemas/SnippetData"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "SenderProfile"
                ]
              },
              "profile": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/SenderProfileData"
                  }
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "entries",
              "kind"
            ],
            "properties": {
              "entries": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ScreenerQueueEntryData"
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "ScreenerQueue"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "decisions",
              "kind"
            ],
            "properties": {
              "decisions": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ScreenerDecisionData"
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "ScreenerDecisions"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "text",
              "model",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "ThreadSummary"
                ]
              },
              "model": {
                "type": "string"
              },
              "text": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "body",
              "model",
              "kind"
            ],
            "properties": {
              "body": {
                "type": "string"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "DraftSuggestion"
                ]
              },
              "model": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "content",
              "kind"
            ],
            "properties": {
              "content": {
                "type": "string"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "ExportResult"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "result",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "MutationResult"
                ]
              },
              "result": {
                "$ref": "#/components/schemas/MutationResultData"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rules",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "Rules"
                ]
              },
              "rules": {
                "type": "array",
                "items": {}
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rule",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "RuleData"
                ]
              },
              "rule": {}
            }
          },
          {
            "type": "object",
            "required": [
              "accounts",
              "kind"
            ],
            "properties": {
              "accounts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AccountSummaryData"
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "Accounts"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "accounts",
              "kind"
            ],
            "properties": {
              "accounts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AccountConfigData"
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "AccountsConfig"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "result",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "AccountOperation"
                ]
              },
              "result": {
                "$ref": "#/components/schemas/AccountOperationResult"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "session",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "AuthSession"
                ]
              },
              "session": {
                "$ref": "#/components/schemas/AuthSessionData"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "form",
              "kind"
            ],
            "properties": {
              "form": {
                "$ref": "#/components/schemas/RuleFormData"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "RuleFormData"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "results",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "RuleDryRun"
                ]
              },
              "results": {
                "type": "array",
                "items": {}
              }
            }
          },
          {
            "type": "object",
            "required": [
              "searches",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "SavedSearches"
                ]
              },
              "searches": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SavedSearch"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "subscriptions",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "Subscriptions"
                ]
              },
              "subscriptions": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SubscriptionSummary"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rows",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "StorageBreakdown"
                ]
              },
              "rows": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/StorageBucket"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rows",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "LargestMessages"
                ]
              },
              "rows": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/LargestMessageRow"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "summary",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "Wrapped"
                ]
              },
              "summary": {
                "$ref": "#/components/schemas/WrappedSummary"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rows",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "StaleThreads"
                ]
              },
              "rows": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/StaleThreadRow"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rows",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "ContactAsymmetry"
                ]
              },
              "rows": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ContactAsymmetryRow"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rows",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "ContactDecay"
                ]
              },
              "rows": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ContactDecayRow"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "rows",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "RefreshedContacts"
                ]
              },
              "rows": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "directions_reclassified",
              "list_ids_backfilled",
              "reply_pairs_resolved",
              "business_hours_backfilled",
              "contacts_rows",
              "kind"
            ],
            "properties": {
              "business_hours_backfilled": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "contacts_rows": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "directions_reclassified": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "kind": {
                "type": "string",
                "enum": [
                  "AnalyticsRebuildSummary"
                ]
              },
              "list_ids_backfilled": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "reply_pairs_resolved": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "summary",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "ResponseTime"
                ]
              },
              "summary": {
                "$ref": "#/components/schemas/ResponseTimeSummary"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "addresses",
              "kind"
            ],
            "properties": {
              "addresses": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AccountAddress"
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "AccountAddresses"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "snapshot",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "SemanticStatus"
                ]
              },
              "snapshot": {
                "$ref": "#/components/schemas/SemanticStatusSnapshot"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "snapshot",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "LlmStatus"
                ]
              },
              "snapshot": {
                "$ref": "#/components/schemas/LlmStatusSnapshot"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "config",
              "kind"
            ],
            "properties": {
              "config": {
                "$ref": "#/components/schemas/LlmConfigData"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "LlmConfig"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "search",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "SavedSearchData"
                ]
              },
              "search": {
                "$ref": "#/components/schemas/SavedSearch"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "entries",
              "kind"
            ],
            "properties": {
              "entries": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/EventLogEntry"
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "EventLogEntries"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "lines",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "LogLines"
                ]
              },
              "lines": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "report",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "DoctorReport"
                ]
              },
              "report": {
                "$ref": "#/components/schemas/DoctorReport"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "content",
              "kind"
            ],
            "properties": {
              "content": {
                "type": "string"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "BugReport"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "entries",
              "kind"
            ],
            "properties": {
              "entries": {
                "type": "array",
                "items": {}
              },
              "kind": {
                "type": "string",
                "enum": [
                  "RuleHistory"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "uptime_secs",
              "accounts",
              "total_messages",
              "kind"
            ],
            "properties": {
              "accounts": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "daemon_build_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "daemon_pid": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "minimum": 0
              },
              "daemon_version": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "kind": {
                "type": "string",
                "enum": [
                  "Status"
                ]
              },
              "protocol_version": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "repair_required": {
                "type": "boolean"
              },
              "semantic_runtime": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/SemanticRuntimeMetrics"
                  }
                ]
              },
              "sync_statuses": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AccountSyncStatus"
                }
              },
              "total_messages": {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              },
              "uptime_secs": {
                "type": "integer",
                "format": "int64",
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "Pong"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "Ack"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Returned by `Request::SendDraft` and `Request::SendStoredDraft` on\nsuccess. Carries the IDs minted during synthetic Sent ingestion so\ncallers can navigate to or reference the just-sent message without\nwaiting for the next sync.",
            "required": [
              "local_message_id",
              "rfc2822_message_id",
              "kind"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "SendReceipt"
                ]
              },
              "local_message_id": {
                "$ref": "#/components/schemas/MessageId"
              },
              "provider_message_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "rfc2822_message_id": {
                "type": "string"
              }
            }
          }
        ]
      },
      "ResponseTimeBucket": {
        "type": "object",
        "description": "A single bucket of the response-time histogram. `count` rows had a\nclock latency in `(prev_upper, upper_bound_seconds]`. The last\nbucket uses `u32::MAX` as `upper_bound_seconds` to mean \"no upper\nlimit\".",
        "required": [
          "upper_bound_seconds",
          "count"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "upper_bound_seconds": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "ResponseTimeDirection": {
        "type": "string",
        "enum": [
          "i_replied",
          "they_replied"
        ]
      },
      "ResponseTimeSummary": {
        "type": "object",
        "description": "Aggregate response-time summary for `mxr response-time`. p50/p90 in\nseconds; business-hours percentiles are `None` until the reconciler has\nbackfilled the relevant rows.",
        "required": [
          "direction",
          "sample_count",
          "clock_p50_seconds",
          "clock_p90_seconds"
        ],
        "properties": {
          "business_hours_p50_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "business_hours_p90_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "clock_p50_seconds": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "clock_p90_seconds": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "direction": {
            "$ref": "#/components/schemas/ResponseTimeDirection"
          },
          "histogram": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResponseTimeBucket"
            },
            "description": "Distribution of clock latencies (seconds) bucketed for the\nhistogram view in the TUI / future CLI surface. Ordered from\nshortest to longest by `upper_bound_seconds`. `#[serde(default)]`\nso older daemons returning the previous payload deserialize\ncleanly during a rolling upgrade."
          },
          "sample_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "RuleFormData": {
        "type": "object",
        "required": [
          "name",
          "condition",
          "action",
          "priority",
          "enabled"
        ],
        "properties": {
          "action": {
            "type": "string"
          },
          "condition": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "id": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "priority": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "SavedSearch": {
        "type": "object",
        "required": [
          "id",
          "name",
          "query",
          "sort",
          "position",
          "created_at"
        ],
        "properties": {
          "account_id": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/AccountId"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "icon": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "$ref": "#/components/schemas/SavedSearchId"
          },
          "name": {
            "type": "string"
          },
          "position": {
            "type": "integer",
            "format": "int32"
          },
          "query": {
            "type": "string"
          },
          "search_mode": {
            "$ref": "#/components/schemas/SearchMode"
          },
          "sort": {
            "$ref": "#/components/schemas/SortOrder"
          }
        }
      },
      "SavedSearchId": {
        "type": "string",
        "format": "uuid"
      },
      "ScreenerDecisionData": {
        "type": "object",
        "required": [
          "account_id",
          "sender_email",
          "disposition",
          "decided_at"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "decided_at": {
            "type": "string",
            "format": "date-time"
          },
          "disposition": {
            "$ref": "#/components/schemas/ScreenerDispositionData"
          },
          "route_label": {
            "type": [
              "string",
              "null"
            ]
          },
          "sender_email": {
            "type": "string"
          }
        }
      },
      "ScreenerDispositionData": {
        "type": "string",
        "enum": [
          "allow",
          "deny",
          "feed",
          "paper_trail",
          "unknown"
        ]
      },
      "ScreenerQueueEntryData": {
        "type": "object",
        "required": [
          "sender_email",
          "message_count",
          "latest_subject",
          "latest_at"
        ],
        "properties": {
          "display_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "latest_at": {
            "type": "string",
            "format": "date-time"
          },
          "latest_subject": {
            "type": "string"
          },
          "message_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "sender_email": {
            "type": "string"
          }
        }
      },
      "SearchExplain": {
        "type": "object",
        "required": [
          "requested_mode",
          "executed_mode",
          "lexical_window",
          "lexical_candidates",
          "dense_candidates",
          "final_results",
          "notes",
          "results"
        ],
        "properties": {
          "dense_candidates": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "dense_window": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "executed_mode": {
            "$ref": "#/components/schemas/SearchMode"
          },
          "final_results": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "lexical_candidates": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "lexical_window": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requested_mode": {
            "$ref": "#/components/schemas/SearchMode"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SearchExplainResult"
            }
          },
          "rrf_k": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "semantic_query": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "SearchExplainResult": {
        "type": "object",
        "required": [
          "rank",
          "message_id",
          "final_score"
        ],
        "properties": {
          "dense_rank": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "dense_score": {
            "type": [
              "number",
              "null"
            ],
            "format": "float"
          },
          "final_score": {
            "type": "number",
            "format": "float"
          },
          "lexical_rank": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "lexical_score": {
            "type": [
              "number",
              "null"
            ],
            "format": "float"
          },
          "message_id": {
            "$ref": "#/components/schemas/MessageId"
          },
          "rank": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "SearchMode": {
        "type": "string",
        "enum": [
          "lexical",
          "hybrid",
          "semantic"
        ]
      },
      "SearchResultItem": {
        "type": "object",
        "required": [
          "message_id",
          "account_id",
          "thread_id",
          "score",
          "mode"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "message_id": {
            "$ref": "#/components/schemas/MessageId"
          },
          "mode": {
            "$ref": "#/components/schemas/SearchMode"
          },
          "score": {
            "type": "number",
            "format": "float"
          },
          "thread_id": {
            "$ref": "#/components/schemas/ThreadId"
          }
        }
      },
      "SemanticProfile": {
        "type": "string",
        "enum": [
          "bge-small-en-v1.5",
          "multilingual-e5-small",
          "bge-m3"
        ]
      },
      "SemanticProfileId": {
        "type": "string",
        "format": "uuid"
      },
      "SemanticProfileRecord": {
        "type": "object",
        "required": [
          "id",
          "profile",
          "backend",
          "model_revision",
          "dimensions",
          "status",
          "progress_completed",
          "progress_total"
        ],
        "properties": {
          "activated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "backend": {
            "type": "string"
          },
          "dimensions": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "id": {
            "$ref": "#/components/schemas/SemanticProfileId"
          },
          "installed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_indexed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "model_revision": {
            "type": "string"
          },
          "profile": {
            "$ref": "#/components/schemas/SemanticProfile"
          },
          "progress_completed": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "progress_total": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "status": {
            "$ref": "#/components/schemas/SemanticProfileStatus"
          }
        }
      },
      "SemanticProfileStatus": {
        "type": "string",
        "enum": [
          "pending",
          "ready",
          "indexing",
          "error"
        ]
      },
      "SemanticRuntimeMetrics": {
        "type": "object",
        "properties": {
          "in_flight": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "last_embedding_prep_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "last_extract_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "last_ingest_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "last_queue_wait_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "queue_depth": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "SemanticStatusSnapshot": {
        "type": "object",
        "required": [
          "enabled",
          "active_profile",
          "profiles"
        ],
        "properties": {
          "active_profile": {
            "$ref": "#/components/schemas/SemanticProfile"
          },
          "enabled": {
            "type": "boolean"
          },
          "profiles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SemanticProfileRecord"
            }
          },
          "runtime": {
            "$ref": "#/components/schemas/SemanticRuntimeMetrics"
          }
        }
      },
      "SenderProfileData": {
        "type": "object",
        "required": [
          "account_id",
          "email",
          "first_seen_at",
          "last_seen_at",
          "total_inbound",
          "total_outbound",
          "replied_count",
          "is_list_sender",
          "open_thread_count"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "attachment_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "attachment_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "cadence_days_p50": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "display_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": "string"
          },
          "first_seen_at": {
            "type": "string",
            "format": "date-time"
          },
          "inbound_storage_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "is_list_sender": {
            "type": "boolean"
          },
          "last_inbound_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_outbound_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_seen_at": {
            "type": "string",
            "format": "date-time"
          },
          "list_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "open_thread_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "outbound_storage_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "replied_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "total_inbound": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "total_outbound": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "SnippetData": {
        "type": "object",
        "required": [
          "name",
          "body",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "body": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "name": {
            "type": "string"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "vars": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Snoozed": {
        "type": "object",
        "required": [
          "message_id",
          "account_id",
          "snoozed_at",
          "wake_at",
          "original_labels"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "message_id": {
            "$ref": "#/components/schemas/MessageId"
          },
          "original_labels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LabelId"
            }
          },
          "snoozed_at": {
            "type": "string",
            "format": "date-time"
          },
          "wake_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SortOrder": {
        "type": "string",
        "enum": [
          "DateDesc",
          "DateAsc",
          "Relevance"
        ]
      },
      "StaleBallInCourt": {
        "type": "string",
        "enum": [
          "mine",
          "theirs"
        ]
      },
      "StaleThreadRow": {
        "type": "object",
        "description": "Single row of `mxr stale` output: a thread whose latest message points\nat one party and has been silent past the threshold.",
        "required": [
          "thread_id",
          "latest_message_id",
          "latest_subject",
          "counterparty_email",
          "latest_date",
          "days_stale"
        ],
        "properties": {
          "counterparty_email": {
            "type": "string"
          },
          "days_stale": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "latest_date": {
            "type": "string",
            "format": "date-time"
          },
          "latest_message_id": {
            "$ref": "#/components/schemas/MessageId"
          },
          "latest_subject": {
            "type": "string"
          },
          "thread_id": {
            "$ref": "#/components/schemas/ThreadId"
          }
        }
      },
      "StorageBucket": {
        "type": "object",
        "description": "Single row of `mxr storage` output: how many bytes / how many items\nrolled up under a particular grouping key (sender, mimetype, label).",
        "required": [
          "key",
          "bytes",
          "count"
        ],
        "properties": {
          "bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "key": {
            "type": "string"
          }
        }
      },
      "StorageGroupBy": {
        "type": "string",
        "enum": [
          "mimetype",
          "sender",
          "label"
        ]
      },
      "SubscriptionSummary": {
        "type": "object",
        "required": [
          "account_id",
          "sender_email",
          "message_count",
          "latest_message_id",
          "latest_provider_id",
          "latest_thread_id",
          "latest_subject",
          "latest_snippet",
          "latest_date",
          "latest_flags",
          "latest_has_attachments",
          "latest_size_bytes",
          "unsubscribe"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "archived_unread_count": {
            "type": "integer",
            "format": "int32",
            "description": "Messages that landed in ARCHIVE without ever being read. Strong\n\"this is noise\" signal for the unsubscribe ranker.",
            "minimum": 0
          },
          "latest_date": {
            "type": "string",
            "format": "date-time"
          },
          "latest_flags": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "latest_has_attachments": {
            "type": "boolean"
          },
          "latest_message_id": {
            "$ref": "#/components/schemas/MessageId"
          },
          "latest_provider_id": {
            "type": "string"
          },
          "latest_size_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "latest_snippet": {
            "type": "string"
          },
          "latest_subject": {
            "type": "string"
          },
          "latest_thread_id": {
            "$ref": "#/components/schemas/ThreadId"
          },
          "message_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "opened_count": {
            "type": "integer",
            "format": "int32",
            "description": "Number of messages from this sender that have been marked READ.\nCombined with `message_count` gives the open-rate used by `unsub --rank`.",
            "minimum": 0
          },
          "replied_count": {
            "type": "integer",
            "format": "int32",
            "description": "Number of messages where I replied. Placeholder zero until Slice 9\nwires `reply_pairs`. Field exists so the JSON contract is stable.",
            "minimum": 0
          },
          "sender_email": {
            "type": "string"
          },
          "sender_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "unsubscribe": {
            "$ref": "#/components/schemas/UnsubscribeMethod"
          }
        }
      },
      "TextPlainFormat": {
        "oneOf": [
          {
            "type": "string",
            "enum": [
              "Fixed"
            ]
          },
          {
            "type": "object",
            "required": [
              "Flowed"
            ],
            "properties": {
              "Flowed": {
                "type": "object",
                "required": [
                  "delsp"
                ],
                "properties": {
                  "delsp": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        ]
      },
      "Thread": {
        "type": "object",
        "required": [
          "id",
          "account_id",
          "subject",
          "participants",
          "message_count",
          "unread_count",
          "latest_date",
          "snippet"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/AccountId"
          },
          "id": {
            "$ref": "#/components/schemas/ThreadId"
          },
          "latest_date": {
            "type": "string",
            "format": "date-time"
          },
          "message_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "participants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          },
          "snippet": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "unread_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "ThreadId": {
        "type": "string",
        "format": "uuid"
      },
      "UnsubscribeMethod": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "OneClick"
            ],
            "properties": {
              "OneClick": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string"
                  }
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "HttpLink"
            ],
            "properties": {
              "HttpLink": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string"
                  }
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "Mailto"
            ],
            "properties": {
              "Mailto": {
                "type": "object",
                "required": [
                  "address"
                ],
                "properties": {
                  "address": {
                    "type": "string"
                  },
                  "subject": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "BodyLink"
            ],
            "properties": {
              "BodyLink": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string"
                  }
                }
              }
            }
          },
          {
            "type": "string",
            "enum": [
              "None"
            ]
          }
        ]
      },
      "WrappedContactRank": {
        "type": "object",
        "required": [
          "email",
          "count"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "display_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": "string"
          }
        }
      },
      "WrappedLongestThread": {
        "type": "object",
        "required": [
          "thread_id",
          "subject",
          "message_count"
        ],
        "properties": {
          "message_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "subject": {
            "type": "string"
          },
          "thread_id": {
            "$ref": "#/components/schemas/ThreadId"
          }
        }
      },
      "WrappedMostGhosted": {
        "type": "object",
        "required": [
          "email",
          "inbound_count",
          "outbound_count"
        ],
        "properties": {
          "email": {
            "type": "string"
          },
          "inbound_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "outbound_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "WrappedNewsletters": {
        "type": "object",
        "required": [
          "unique_lists",
          "list_share_of_inbound_pct"
        ],
        "properties": {
          "list_share_of_inbound_pct": {
            "type": "number",
            "format": "double",
            "description": "0.0–100.0; share of inbound messages that came via a list_id."
          },
          "top_list": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WrappedTopList"
              }
            ]
          },
          "unique_lists": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "WrappedReplyDiscipline": {
        "type": "object",
        "required": [
          "sample_count",
          "clock_p50_seconds",
          "clock_p90_seconds"
        ],
        "properties": {
          "business_hours_p50_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "business_hours_p90_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "clock_p50_seconds": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "clock_p90_seconds": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "fastest": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WrappedReplyExtreme",
                "description": "Single fastest reply pair in the window."
              }
            ]
          },
          "sample_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "slowest": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WrappedReplyExtreme",
                "description": "Single slowest reply pair in the window. Capped at 30 days to\nexclude the pathological \"I replied 8 years later\" cases."
              }
            ]
          }
        }
      },
      "WrappedReplyExtreme": {
        "type": "object",
        "required": [
          "counterparty_email",
          "latency_seconds",
          "replied_at"
        ],
        "properties": {
          "counterparty_email": {
            "type": "string"
          },
          "latency_seconds": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "replied_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WrappedStorage": {
        "type": "object",
        "required": [
          "total_bytes"
        ],
        "properties": {
          "heaviest_message": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/LargestMessageRow"
              }
            ]
          },
          "top_mimetype": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WrappedStorageBucket"
              }
            ]
          },
          "total_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "WrappedStorageBucket": {
        "type": "object",
        "required": [
          "key",
          "bytes",
          "count"
        ],
        "properties": {
          "bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "key": {
            "type": "string"
          }
        }
      },
      "WrappedSummary": {
        "type": "object",
        "description": "Year-in-review summary returned by `mxr wrapped`. Combines volume,\ntime-pattern, contact, reply-discipline, storage, newsletter, and\nsuperlative sections so the CLI can render a single narrative panel.",
        "required": [
          "window_start",
          "window_end",
          "label",
          "volume",
          "time_patterns",
          "top_contacts",
          "storage",
          "newsletters",
          "superlatives"
        ],
        "properties": {
          "label": {
            "type": "string"
          },
          "newsletters": {
            "$ref": "#/components/schemas/WrappedNewsletters"
          },
          "reply_discipline": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WrappedReplyDiscipline"
              }
            ]
          },
          "storage": {
            "$ref": "#/components/schemas/WrappedStorage"
          },
          "superlatives": {
            "$ref": "#/components/schemas/WrappedSuperlatives"
          },
          "time_patterns": {
            "$ref": "#/components/schemas/WrappedTimePatterns"
          },
          "top_contacts": {
            "$ref": "#/components/schemas/WrappedTopContacts"
          },
          "volume": {
            "$ref": "#/components/schemas/WrappedVolume"
          },
          "window_end": {
            "type": "string",
            "format": "date-time"
          },
          "window_start": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WrappedSuperlatives": {
        "type": "object",
        "properties": {
          "longest_thread": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WrappedLongestThread"
              }
            ]
          },
          "most_ghosted": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WrappedMostGhosted"
              }
            ]
          }
        }
      },
      "WrappedTimePatterns": {
        "type": "object",
        "required": [
          "busiest_day_of_week_count",
          "busiest_hour_count",
          "busiest_date_count"
        ],
        "properties": {
          "busiest_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The single calendar day with the most activity, and its count."
          },
          "busiest_date_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "busiest_day_of_week": {
            "type": [
              "string",
              "null"
            ],
            "description": "Day name and message count for the busiest day-of-week (Mon–Sun)."
          },
          "busiest_day_of_week_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "busiest_hour_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "busiest_hour_utc": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Hour 0–23 (UTC) and message count for the busiest hour-of-day.",
            "minimum": 0
          },
          "day_of_week_distribution": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-day-of-week message counts. Index 0 = Monday … 6 = Sunday.\n`#[serde(default)]` keeps older daemons compatible."
          },
          "hour_distribution": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-hour message counts (UTC), indexed 0..=23. Powers the\nhour-of-day chart in the TUI Wrapped view.\n`#[serde(default)]` keeps older daemons compatible."
          }
        }
      },
      "WrappedTopContacts": {
        "type": "object",
        "required": [
          "most_emailed_to_me",
          "most_emailed_by_me",
          "most_asymmetric"
        ],
        "properties": {
          "most_asymmetric": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactAsymmetryRow"
            },
            "description": "Top 3 most-asymmetric counterparties (inbound-heavy)."
          },
          "most_emailed_by_me": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WrappedContactRank"
            },
            "description": "Top 5 recipients I emailed by outbound count."
          },
          "most_emailed_to_me": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WrappedContactRank"
            },
            "description": "Top 5 senders to me by inbound count."
          }
        }
      },
      "WrappedTopList": {
        "type": "object",
        "required": [
          "list_id",
          "message_count",
          "opened_count"
        ],
        "properties": {
          "list_id": {
            "type": "string"
          },
          "message_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "opened_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "WrappedVolume": {
        "type": "object",
        "required": [
          "inbound_count",
          "outbound_count",
          "thread_count"
        ],
        "properties": {
          "inbound_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "outbound_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "thread_count": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      }
    },
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "opaque",
        "description": "Token from `~/.config/mxr/bridge-token`. Send via `Authorization: Bearer <token>` header. WebSocket clients can also pass it via the `?token=<token>` query string or the `Sec-WebSocket-Protocol: bearer, <token>` subprotocol."
      }
    }
  },
  "security": [
    {
      "bearer": []
    }
  ]
}
