All checks were successful
plugin-tests / test (push) Successful in 8s
Closes Phase 2.A. STT now lives entirely in the plugin via the new public-API
method `api.register_audio_attachment_processor` added to the loader hook
(Rule 1 — extended API, no forced-internal). The fork patch stays minimal
(streaming.py gains a small loop that calls registered processors; loader
adds the 1 new method).
Plugin additions:
routes/transcribe.py POST /api/transcribe + audio_attachment_processor
- _external_stt_transcribe: multipart POST to STT endpoint
- _handle_transcribe: one-shot transcription route
- _transcribe_audio_attachments: voice-message processor
- _parse_multipart_file: stdlib email-based multipart
(Python 3.13 dropped cgi per PEP 594)
tests/unit/test_transcribe.py 8 tests (register, processor, route, multipart parser)
tests/evals/test_features.py + 1 eval (audio processor signature contract)
Config (read at call time, never persisted):
HERMES_WEBUI_STT_URL external STT endpoint (OpenAI or WhisperX shape)
HERMES_WEBUI_STT_KEY optional bearer token
CONNECTION-MAP regenerated: 9 public-API · 0 forced-internal · 1 frontend.
20/20 tests PASS.
Loader API extended in hermes-webui (next commit there) — 7th method:
register_audio_attachment_processor. Streaming.py gets a small loop that
calls registered processors before _build_native_multimodal_message.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
65 lines
2.7 KiB
Python
65 lines
2.7 KiB
Python
"""svrnty-hermes-webui-plugin — entry point.
|
|
|
|
Called by hermes-webui's plugin loader at startup (after the env var
|
|
HERMES_WEBUI_PYTHON_PLUGIN points the loader at this module).
|
|
|
|
The loader passes a single `api` argument exposing 6 methods (see CLAUDE.md +
|
|
protocol PRD §5.1). This module's job is to wire every route + static dir +
|
|
asset injection that defines the Svrnty surface on hermes-webui.
|
|
|
|
Keep this file thin. Route logic lives in `routes/<feature>.py`. Static lives
|
|
in `static/`. The map of every upstream dependency is in CONNECTION-MAP.md
|
|
(AST-generated by scripts/ast-connection-map.py).
|
|
"""
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Static + asset URL prefix (per protocol §12, decision Q5: /plugins/svrnty/<asset>)
|
|
STATIC_PREFIX = "svrnty"
|
|
STATIC_DIR = Path(__file__).resolve().parent / "static"
|
|
|
|
|
|
def register(api):
|
|
"""Wire every Svrnty modification to hermes-webui.
|
|
|
|
`api` is the loader-provided extension surface (6 methods). Treat it as the
|
|
ONLY public contract. Touching anything else in hermes-webui requires a
|
|
`CONNECTION-MAP.md` forced-internal entry with justification.
|
|
"""
|
|
log = api.logger("svrnty.plugin")
|
|
log.info("svrnty-hermes-webui-plugin: registering")
|
|
|
|
# Brand skin: serve static dir + inject CSS/JS into every page load.
|
|
if STATIC_DIR.exists():
|
|
api.register_static(STATIC_PREFIX, str(STATIC_DIR))
|
|
api.inject_stylesheet(f"/plugins/{STATIC_PREFIX}/app.css")
|
|
api.inject_script(f"/plugins/{STATIC_PREFIX}/app.js")
|
|
log.info("static + assets wired at /plugins/%s/", STATIC_PREFIX)
|
|
|
|
# Routes — each feature lives in its own module under routes/.
|
|
# Phase 2 will populate these. Import-and-register pattern; failures are
|
|
# logged but don't take down the rest of the plugin.
|
|
for route_module in _phase2_routes():
|
|
try:
|
|
mod = __import__(f"routes.{route_module}", fromlist=["register"])
|
|
mod.register(api)
|
|
log.info("route module loaded: %s", route_module)
|
|
except ImportError as e:
|
|
log.warning("route module %s not yet implemented (Phase 2): %s", route_module, e)
|
|
except Exception as e:
|
|
log.error("route module %s failed to register: %s", route_module, e)
|
|
|
|
log.info("svrnty-hermes-webui-plugin: registration complete")
|
|
|
|
|
|
def _phase2_routes():
|
|
"""Routes to attempt loading. Returns module names under routes/.
|
|
|
|
Phase 2 migrates the existing fork commits into these modules. Until then,
|
|
ImportError is logged + swallowed so the plugin loads cleanly.
|
|
"""
|
|
return [
|
|
"transcribe", # P2.A — STT + voice-message audio processor ✓
|
|
"vault_status", # P2.B — vault connections status ✓
|
|
]
|