Files
Athena-Deck/basalt_serve.py
T
Mikei386 c0bc5d3a1b Integrate Basalt telemetry and shared GPU speech runtimes
Publish the reviewed accumulated runtime, scheduler, profile, UI, native recipes and historical maintenance evidence. Includes Qwen GPU ASR correction and shared Anna/atelier ownership. Validated with 784 local tests, Python/JSON parsing and eight JavaScript syntax checks. Live GPU acceptance and full fresh-host restore limits remain documented.
2026-11-03 21:16:41 +01:00

35 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""Run pinned upstream Basalt unchanged, adding authenticated numeric telemetry."""
import argparse,sys
from pathlib import Path
from basalt_telemetry import Counters,CountedHistory,snapshot
def install(service_module,handler_module):
original_service=service_module.Service;original_handler=handler_module.make_handler
class DeckService(original_service):
def __init__(self,*args,**kwargs):
super().__init__(*args,**kwargs)
self.deck_counters=Counters();self.history=CountedHistory(self.history,self)
def handler(svc):
base=original_handler(svc)
class Handler(base):
def do_GET(self):
if self.path.split('?',1)[0].rstrip('/')=='/telemetry':
if self._authorized():self._json(200,snapshot(svc))
return
return super().do_GET()
return Handler
service_module.Service=DeckService;handler_module.make_handler=handler
def main():
parser=argparse.ArgumentParser(add_help=False);parser.add_argument('--deck-source',type=Path,required=True);args,remaining=parser.parse_known_args()
source=args.deck_source
if not source.is_absolute() or {'vpn','vpn.auth','OpenVPN-KIT','GluetunVPN'}&set(source.parts) or not (source/'serve/server.py').is_file():parser.error('Registered absolute Basalt source required')
sys.path.insert(0,str(source))
from serve import service,handler
install(service,handler)
from serve.server import main as upstream_main
sys.argv=[str(source/'serve/server.py'),*remaining]
return upstream_main()
if __name__=='__main__':raise SystemExit(main())