17 Commits

Author SHA1 Message Date
itsrubberduck
d70fffdd68 refactor(tools): forward the airport endpoints to the backend
/api/service/tools/* was a second implementation of the OSM geocoding and taxi
routing the Python backend already owns — its own Overpass client, alias
matching and scoring. It drifted: it still asked Overpass for `out center tags`,
so a runway resolved to the middle of the strip rather than a threshold, which
is the runway-endpoint bug the backend fixed. Teaching the copy about runway
endpoints would mean maintaining the geometry twice, so the copy goes instead.

Forwarding exposes origin_runway_point / dest_runway_point and
include_connectors, and inherits the backend's Overpass cache and its radius
fallback for aerodromes with no generated OSM area (EDDM), which the copy
answered with an empty feature list. Failures now carry an HTTP status as well
as the error code in the body; the old copy answered every error with 200.

The frequencies call sites needed real types: airportGeocode.ts sat under
server/api with no default export, so Nitro registered it as a route whose
return type collapsed to any and poisoned the whole API type map. The typecheck
was green because of it, not despite it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 11:30:52 +02:00
leubeem
7367f7cdb7 feat(server): per-user AI usage tracking, cost alerting, and endpoint hardening
Usage tracking:
- new UsageEvent collection records every STT/TTS/LLM call per user with
  provider, model, volume (audio seconds, characters, tokens) and an
  estimated USD cost; self-hosted providers (Speaches/Piper) and cache
  hits record at $0
- pricing table for whisper-1, tts-1, gpt-5-nano & co. in server/utils/usage.ts
- weekly KPI mail gains an "AI-Nutzung & Kosten" section: weekly and
  rolling 30-day cost, per-kind breakdown, top 5 users by cost
- quota alert mail when rolling 30-day cost exceeds USAGE_ALERT_USD
  (default $5), at most once per calendar month (UsageAlertDelivery)

Hardening:
- /api/atc/say now requires an authenticated session (middleware
  exemption removed); useFlightLabAudio sends the bearer token
- /api/service/tools/latency requires auth (was a public LLM endpoint)
- per-user rate limits: PTT 20/min, say 60/min, latency 5/min
- cron endpoints (waitlist-drip, weekly-kpi-report) require a shared
  secret via ?secret= or x-cron-secret (CRON_SECRET, falls back to
  KPI_CRON_SECRET); allowed with a warning while unset so existing
  deployments keep working
- PTT records the actual transcribed audio duration for billing accuracy

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 23:17:03 +02:00
itsrubberduck
de02dc4f9e typescript 2026-02-17 18:19:55 +01:00
itsrubberduck
a5272149c6 add todo for najan 2025-10-19 21:03:52 +02:00
Remi
1dd78b95b1 Add bidirectional airport geocode and name-aware taxi routing 2025-10-19 19:17:18 +02:00
Remi
0febe45862 Remove explicit type hints from airport geocode lookup 2025-10-19 19:07:23 +02:00
Remi
ef603bda13 Infer airport geocode types from query text 2025-10-19 19:00:32 +02:00
Remi
f4beba1b25 Add airport geocode endpoint 2025-10-19 18:56:48 +02:00
Remi
20341aa06b Refine taxiway collapse and radius default 2025-10-18 21:47:54 +02:00
Remi
0c3605bc6c Adjust taxi route collapse rules 2025-10-18 21:47:54 +02:00
Remi
d753f0380a Preserve raw taxi route names 2025-10-18 21:47:53 +02:00
itsrubberduck
966ed6340f improve latency time 2025-09-20 16:21:59 +02:00
najajan
f43230ee30 get route 2025-09-20 15:55:25 +02:00
najajan
0b50e003d5 first try with graph 2025-09-20 15:47:22 +02:00
najajan
6fe19c0ccb fix taxiroute nearest taxiway 2025-09-20 15:41:03 +02:00
itsrubberduck
c39cbc2f3c document call example for taxiroute 2025-09-20 12:41:33 +02:00
itsrubberduck
2eae4e3aa6 add taxi route endpoint 2025-09-20 11:56:17 +02:00