refactor(sms,google_chat): compact module docstrings (env tables kept)

This commit is contained in:
Teknium
2026-09-02 22:32:44 -07:00
parent 7f9a9b84a3
commit f58da7c156
2 changed files with 15 additions and 33 deletions
+7 -16
View File
@@ -1,22 +1,13 @@
"""User OAuth helper for the Google Chat gateway adapter.
Google Chat's ``media.upload`` rejects service-account auth, so for native file
attachments each user grants the bot ``chat.messages.create`` ONCE in their own
DM; the bot stores per-user refresh tokens and uploads *as the user*
(https://developers.google.com/chat/api/guides/auth/users).
Library: load_user_credentials(email=None), refresh_or_none(creds, email=None),
build_user_chat_service(creds), list_authorized_emails().
CLI (driven by ``/setup-files``): --check | --client-secret PATH | --auth-url |
--auth-code CODE | --revoke | --install-deps [--email EMAIL] (legacy single-user
mode when --email is omitted).
Token storage layout (all under ``${HERMES_HOME}``):
- Per-user tokens: ``google_chat_user_tokens/<sanitized_email>.json``
- Legacy single-user: ``google_chat_user_token.json``
- Per-user pending PKCE: ``google_chat_user_oauth_pending/<sanitized_email>.json``
- Legacy pending state: ``google_chat_user_oauth_pending.json``
- OAuth client secret: ``google_chat_user_client_secret.json``
attachments each user grants the bot ``chat.messages.create`` ONCE in their own DM;
the bot stores per-user refresh tokens and uploads *as the user*
(https://developers.google.com/chat/api/guides/auth/users). Library API for the
adapter plus a CLI driven by ``/setup-files`` (``--help``; ``--email`` omitted ==
legacy single-user mode). Files under ``${HERMES_HOME}``: ``google_chat_user_tokens/
<email>.json`` (per-user) / ``google_chat_user_token.json`` (legacy); pending PKCE state
in ``google_chat_user_oauth_pending[/<email>].json``; ``google_chat_user_client_secret.json``.
"""
from __future__ import annotations
+8 -17
View File
@@ -2,19 +2,11 @@
Outbound SMS via the Twilio REST API; inbound via an aiohttp webhook server.
Shares credentials with the optional telephony skill — same env vars:
- TWILIO_ACCOUNT_SID
- TWILIO_AUTH_TOKEN
- TWILIO_PHONE_NUMBER (E.164 from-number, e.g. +15551234567)
Gateway-specific env vars:
- SMS_WEBHOOK_PORT (default 8080)
- SMS_WEBHOOK_HOST (default 127.0.0.1)
- SMS_WEBHOOK_URL (public URL for Twilio signature validation — required)
- SMS_INSECURE_NO_SIGNATURE (true to disable signature validation — dev only)
- SMS_ALLOWED_USERS (comma-separated E.164 phone numbers)
- SMS_ALLOW_ALL_USERS (true/false)
- SMS_HOME_CHANNEL (phone number for cron delivery)
Env vars — shared with the telephony skill: TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN,
TWILIO_PHONE_NUMBER (E.164 from-number). Gateway-specific: SMS_WEBHOOK_PORT (8080),
SMS_WEBHOOK_HOST (127.0.0.1), SMS_WEBHOOK_URL (public URL for Twilio signature
validation — required), SMS_INSECURE_NO_SIGNATURE (true disables validation — dev only),
SMS_ALLOWED_USERS (comma-separated E.164), SMS_ALLOW_ALL_USERS, SMS_HOME_CHANNEL (cron).
"""
import asyncio
@@ -284,11 +276,10 @@ class SmsAdapter(BasePlatformAdapter):
return _twiml_response()
# -- Plugin registration -----------------------------------------------------
# TWILIO_* env→PlatformConfig seeding stays in core (gateway/config.py).
# -- Plugin registration (TWILIO_* env→PlatformConfig seeding stays in gateway/config.py)
# Standalone-send markdown stripping (looser than helpers.strip_markdown: no
# word-boundary guards on underscores, ``[a-z]*`` fence tags — kept for parity).
# Standalone-send markdown stripping: looser than helpers.strip_markdown (no
# word-boundary guards on underscores, ``[a-z]*`` fence tags) — kept for parity.
_SMS_MARKDOWN_SUBS = (
(re.compile(r"\*\*(.+?)\*\*", re.DOTALL), r"\1"),
(re.compile(r"\*(.+?)\*", re.DOTALL), r"\1"),