Repository navigation
What's Changed in HostSpark v0.4.5
A major architectural decoupling and feature release introducing a centralized Single-Source-of-Truth (SSOT) architecture for operational constants and AI prompts, full-spectrum multimodal attachment handling (audio, voice notes, video, documents, and images) with safe extension validation and MIME auto-extension derivation, and seamless backward compatibility.
🧱 Architectural Decoupling: SSOT Constants & Centralized Prompts
src/hostspark/constants.py:- Eliminated scattered magic numbers across all modules.
- Centralized network & process timeouts (
DEFAULT_SUBPROCESS_TIMEOUT_SECONDS,PTY_COMMAND_TIMEOUT_SECONDS,SSRF_MEDIA_DOWNLOAD_TIMEOUT_SECONDS). - Centralized circuit-breaker thresholds (
DEFAULT_CIRCUIT_BREAKER_MAX_FAILURES = 3). - Unified message & prompt length limits (
MAX_MESSAGE_CHUNK_CHARS,LONG_MESSAGE_FILE_THRESHOLD_CHARS,SCHEDULE_MAX_ORIGINAL_PROMPT_CHARS,SCHEDULE_MAX_EXPANSION_PROMPT_CHARS). - Consolidated safe extension sets (
AUDIO_EXTENSIONS,VIDEO_EXTENSIONS,IMAGE_EXTENSIONS,DOC_EXTENSIONS,SAFE_EXTENSIONS).
src/hostspark/prompts.py:- Centralized all system prompts, multimodal analysis constraints, and dynamic prompt builders into one clean module.
- Dedicated builders:
build_attachment_prompt(),build_learn_prompt(),compose_followup_prompt(),compose_agy_prompt(), andbuild_prompt_expansion_request(). - Zero hardcoded prompt strings in message dispatchers, scheduler handlers, or query callbacks.
🎙️ Full-Spectrum Multimodal Attachments & Audio/Video Ingestion
- Audio & Voice Note Handling:
- Telegram Voice notes (
.ogg) and Audio uploads (.m4a,.mp3,.wav,.ogg,.flac,.aac) are natively received and stored in per-chatuploads/directories. - MIME-based Auto-Extension: Audio files uploaded without file extensions dynamically derive their correct suffix based on Telegram MIME types instead of being forced into
.m4a.
- Telegram Voice notes (
- Video & Document Ingestion:
- Direct upload support for videos (
.mp4,.mov,.mkv) and documents (.pdf,.txt,.py,.json,.csv,.md, etc.).
- Direct upload support for videos (
- Strict Safe Whitelisting:
- Any uploaded file whose extension is not in
SAFE_EXTENSIONSis safely rejected with an informative list of supported formats, preventing arbitrary or hazardous file staging.
- Any uploaded file whose extension is not in
- Native Gemini Multimodal Guidance:
- Dispatches attachments to AGY with explicit multimodal prompts guiding Gemini's native visual, video, and audio speech recognition (ASR) capabilities without running heavy local transcription models.
🔄 Backward Compatibility & Clean Linter Re-exports
- Preserved full backward compatibility for legacy imports from
hostspark.core.prompt,hostspark.telegram.media, andhostspark.storage.schedule_store. - Declared explicit
__all__lists in re-exporting modules, guaranteeing zero unused-import (F401) warnings in static analysis tools (pyflakes,flake8).
🛠️ Circuit-Breaker UI & Schedule Handler Synchronization
- Replaced hardcoded thresholds in
scheduler/handlers.pywithDEFAULT_CIRCUIT_BREAKER_MAX_FAILURES. /schedule_listand/schedule_shownow automatically reflect the true circuit-breaker state without desynchronization risks.
📦 Installation & Observability Enhancements
install.sh:- Replaced silent error swallowing (
|| true) with proactive detection and actionable warnings for system-leveledge-ttsandpillowinstallations. - Added documentation explaining why system Python is targeted for AGY standalone binary execution.
- Replaced silent error swallowing (
📖 Documentation Updates
- Updated
README.mdandREADME.zh-TW.md:- Added architectural decoupling and unified constants in Key Features.
- Added
/tokens,/compact, and/learncommands to the Telegram command reference table. - Expanded multimedia tool prerequisites and automatic installer details.
🧪 Test Suite & Health Metrics
- Expanded test suite to 140 unit and integration tests (100% passing, 0 regressions):
- 125 baseline tests.
- +2 media resolver & multimodal path detection tests (
test_media_resolver.py). - +7 prompts & constants integrity tests (
test_prompts.py). - +6 attachment handling & safe extension tests (
test_attachments.py).
- Full static analysis: 0 errors/warnings on
pyflakes.
📦 Upgrade Notes
To upgrade an existing HostSpark installation to v0.4.5:
git pull origin main
sudo systemctl restart agy-telegram.service