FastAPI backend (port 8522):
- Session lifecycle: POST /session/start, DELETE /session/{id}/end, GET /session/{id}
- SSE stream: GET /session/{id}/stream — per-subscriber asyncio.Queue fan-out, 15s heartbeat
- History: GET /session/{id}/history with min_confidence + limit filters
- Audio: WS /session/{id}/audio — binary PCM ingestion stub (real inference in v0.2.x)
- Export: GET /session/{id}/export — downloadable JSON session log
- ContextClassifier background task per session (CF_VOICE_MOCK=1 in dev)
- ToneEvent SSE wire format per cf-core#40 (locked field names)
- Tier gate: CFG-LNNT- prefix check, 402 for paid features
Vue 3 frontend (port 8521, Vite + UnoCSS + Pinia):
- NowPanel: affect-aware border tint, subtext, prosody flags, shift indicator
- HistoryStrip: horizontal scroll, last 8 events with affect color
- ComposeBar: start/stop session, SSE connection lifecycle
- useToneStream: EventSource composable
- useAudioCapture: AudioWorklet → Int16 PCM → WebSocket (v0.1.x stub)
- audio-processor.js: 100ms chunk accumulator in AudioWorklet thread
- Respects prefers-reduced-motion globally
26 tests passing, manage.sh, Dockerfile, compose.yml included.
31 lines
1 KiB
Python
31 lines
1 KiB
Python
# app/tiers.py — tier gate checks
|
|
#
|
|
# Free tier: local inference only, no license key required.
|
|
# Paid tier: cloud STT/TTS fallback, session pinning (v1.0).
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
BYOK_UNLOCKABLE = ["cloud_stt", "cloud_tts", "session_pinning"]
|
|
|
|
|
|
def is_paid(license_key: str | None = None) -> bool:
|
|
"""Return True if the request has a valid Paid+ license key."""
|
|
key = license_key or os.environ.get("LINNET_LICENSE_KEY", "")
|
|
# Paid keys start with CFG-LNNT- (format: CFG-LNNT-XXXX-XXXX-XXXX)
|
|
return bool(key) and key.upper().startswith("CFG-LNNT-")
|
|
|
|
|
|
def require_free() -> None:
|
|
"""No-op. All users get Free tier features."""
|
|
|
|
|
|
def require_paid(license_key: str | None = None) -> None:
|
|
"""Raise if caller doesn't have a Paid license."""
|
|
if not is_paid(license_key):
|
|
from fastapi import HTTPException
|
|
raise HTTPException(
|
|
status_code=402,
|
|
detail="This feature requires a Linnet Paid license. "
|
|
"Get one at circuitforge.tech.",
|
|
)
|