mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
- Refactor gateway/platforms/qqbot.py into gateway/platforms/qqbot/ package: - adapter.py: core QQAdapter (unchanged logic, constants from shared module) - constants.py: shared constants (API URLs, timeouts, message types) - crypto.py: AES-256-GCM key generation and secret decryption - onboard.py: QR-code scan-to-configure API (create_bind_task, poll_bind_result) - utils.py: User-Agent builder, HTTP headers, config helpers - __init__.py: re-exports all public symbols for backward compatibility - Add interactive QR-code setup flow in hermes_cli/gateway.py: - Terminal QR rendering via qrcode package (graceful fallback to URL) - Auto-refresh on QR expiry (up to 3 times) - AES-256-GCM encrypted credential exchange - DM security policy selection (pairing/allowlist/open) - Update hermes_cli/setup.py to delegate to gateway's _setup_qqbot() - Add qrcode>=7.4 dependency to pyproject.toml and requirements.txt
74 lines
2.4 KiB
Python
74 lines
2.4 KiB
Python
"""QQBot package-level constants shared across adapter, onboard, and other modules."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# QQBot adapter version — bump on functional changes to the adapter package.
|
|
# ---------------------------------------------------------------------------
|
|
|
|
QQBOT_VERSION = "1.1.0"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# API endpoints
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# The portal domain is configurable via QQ_API_HOST for corporate proxies
|
|
# or test environments. Default: q.qq.com (production).
|
|
PORTAL_HOST = os.getenv("QQ_PORTAL_HOST", "q.qq.com")
|
|
|
|
API_BASE = "https://api.sgroup.qq.com"
|
|
TOKEN_URL = "https://bots.qq.com/app/getAppAccessToken"
|
|
GATEWAY_URL_PATH = "/gateway"
|
|
|
|
# QR-code onboard endpoints (on the portal host)
|
|
ONBOARD_CREATE_PATH = "/lite/create_bind_task"
|
|
ONBOARD_POLL_PATH = "/lite/poll_bind_result"
|
|
QR_URL_TEMPLATE = (
|
|
"https://q.qq.com/qqbot/openclaw/connect.html"
|
|
"?task_id={task_id}&_wv=2&source=hermes"
|
|
)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Timeouts & retry
|
|
# ---------------------------------------------------------------------------
|
|
|
|
DEFAULT_API_TIMEOUT = 30.0
|
|
FILE_UPLOAD_TIMEOUT = 120.0
|
|
CONNECT_TIMEOUT_SECONDS = 20.0
|
|
|
|
RECONNECT_BACKOFF = [2, 5, 10, 30, 60]
|
|
MAX_RECONNECT_ATTEMPTS = 100
|
|
RATE_LIMIT_DELAY = 60 # seconds
|
|
QUICK_DISCONNECT_THRESHOLD = 5.0 # seconds
|
|
MAX_QUICK_DISCONNECT_COUNT = 3
|
|
|
|
ONBOARD_POLL_INTERVAL = 2.0 # seconds between poll_bind_result calls
|
|
ONBOARD_API_TIMEOUT = 10.0
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Message limits
|
|
# ---------------------------------------------------------------------------
|
|
|
|
MAX_MESSAGE_LENGTH = 4000
|
|
DEDUP_WINDOW_SECONDS = 300
|
|
DEDUP_MAX_SIZE = 1000
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# QQ Bot message types
|
|
# ---------------------------------------------------------------------------
|
|
|
|
MSG_TYPE_TEXT = 0
|
|
MSG_TYPE_MARKDOWN = 2
|
|
MSG_TYPE_MEDIA = 7
|
|
MSG_TYPE_INPUT_NOTIFY = 6
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# QQ Bot file media types
|
|
# ---------------------------------------------------------------------------
|
|
|
|
MEDIA_TYPE_IMAGE = 1
|
|
MEDIA_TYPE_VIDEO = 2
|
|
MEDIA_TYPE_VOICE = 3
|
|
MEDIA_TYPE_FILE = 4
|