diff --git a/.gitignore b/.gitignore
index a42d944..9fa4cde 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,9 @@ temp.txt
scratch/
.venv/
venv/
+
+# Cleanup rules
+debug.json
+ag-debug.json
+dump.json
+test-*.js
diff --git a/LIESMICH.md b/LIESMICH.md
new file mode 100644
index 0000000..70c9c61
--- /dev/null
+++ b/LIESMICH.md
@@ -0,0 +1,279 @@
+
+
+
+
+TokenWatch
+Selbstgehosteter API-Quota- & Limit-Tracker mit Live-Dashboard, 7-Tage-Verlaufsdiagramm und ntfy-Benachrichtigungen.
+
+
+ 🇬🇧 English · 🇩🇪 Deutsch
+
+
+---
+
+## Überblick
+
+**TokenWatch** ist eine selbstgehostete Webanwendung zur zentralen Überwachung von KI-API-Kontingenten und Rate-Limit-Fenstern über mehrere Anbieter hinweg. Die Anwendung fragt externe Provider-APIs ab, empfängt Webhook-Updates eines lokalen Antigravity-Language-Server-Sync-Skripts, speichert Verlaufsdaten in PostgreSQL, stellt interaktive 7-Tage-Verläufe grafisch dar und verschickt automatische Push-Warnungen über **ntfy**, sobald konfigurierte Schwellenwerte überschritten werden.
+
+### Architektur
+
+```text
++-----------------------------------+ POST /api/webhook/antigravity
+| Windows-Host (Antigravity IDE) | -------------------------------------+
+| Push-AntigravityQuota.ps1 | |
+| -> tokenwatch-sync.js | v
++-----------------------------------+ +------------------------------+
+ | TokenWatch-Server (Express) |
++-----------------------------------+ REST-API (30-Min- | Port 3000 |
+| Externe APIs | Cron + Live-Abruf) | - Statische UI (public/) |
+| - POE (current_balance) | <-------------------> | - /api/quotas |
+| - MiniMax (coding_plan/remains) | | - /api/history |
++-----------------------------------+ +--------------+---------------+
+ |
+ +----------------------------+----------------------------+
+ v v
+ +------------------------------+ +------------------------------+
+ | PostgreSQL-Datenbank | | ntfy-Server |
+ | - quotas (Verlauf) | | Schwellenwert-Warnungen |
+ | - antigravity_latest (JSONB) | +------------------------------+
+ +------------------------------+
+```
+
+---
+
+## Funktionen
+
+- **Multi-Provider-Quota-Tracking**:
+ - **POE**: Überwacht den aktuellen Punktestand im Verhältnis zum Limit von `2.500.000`, täglichem Refresh (`75.000`), verfallenden Punkten, Tagen bis zum Cap, dem heutigen Tagesverbrauch (berechnet gegen den ersten UTC-Snapshot des Tages) sowie einem Live-Countdown bis 00:00 Uhr UTC.
+ - **MiniMax**: Überwacht `MiniMax (5h)` und `MiniMax (Weekly)` in Prozent (`model_name === 'general'`) inklusive Live-Reset-Countdowns.
+ - **Antigravity (AG)**: Überwacht 5 separate Kontingente per Webhook-Push (`AG Gemini (5h)`, `AG Gemini (Weekly)`, `AG Claude (5h)`, `AG Claude (Weekly)`, `AG Gemini 4 Argon (Weekly)`) inklusive individueller Reset-Zeitstempel (`Heute`, `Morgen` oder Wochentag + Countdown).
+- **Persistenter Antigravity-Status**: Eingehende Webhook-Daten werden in der PostgreSQL-Tabelle `antigravity_latest` (`JSONB`) gespeichert und beim Serverstart automatisch wiederhergestellt.
+- **Automatisierte Cron-Snapshots & ntfy-Alerts**: Alle 30 Minuten (`*/30 * * * *`) ruft `node-cron` alle Quotas ab, speichert sie in PostgreSQL und sendet bei Überschreitung von `ALERT_THRESHOLD_PERCENT` (Standard: `80`) eine `ntfy`-Meldung (`Title: TokenWatch Alert`, `Tags: warning,robot`).
+- **7-Tage-Verlaufsdiagramm**: Interaktives Chart.js-Liniendiagramm, das Datenpunkte in 5-Minuten-Intervallen für `AG Gemini (5h)`, `AG Claude (5h)`, `POE` und `MiniMax (5h)` gruppiert.
+- **6 wählbare Fortschrittsbalken-Themes**: Live-Wechsel zwischen `Standard`, `Pac-Man`, `Battery`, `Nyan Cat`, `Matrix` und `Lava` (passt auch die Chart.js-Farben dynamisch an).
+- **Konfetti-Effekt bei 100 %**: Löst bei Erreichen von `100 %` eine `canvas-confetti`-Animation aus und zeigt bei Nicht-POE-Providern `LIMIT REACHED!` an.
+- **Lokale Antigravity-Sync- & Debug-Werkzeuge**: Enthält `tokenwatch-sync.js`, `Push-AntigravityQuota.ps1` (für die Windows-Aufgabenplanung) sowie das plattformübergreifende Debug-Skript `fetch-quota.js` zum Auslesen der Rohantwort des lokalen Language Servers.
+
+---
+
+## Funktionsweise & Tech-Stack
+
+### Interner Ablauf
+
+1. **Serverstart (`src/server.ts`)**: Startet Express auf `0.0.0.0:3000`, liefert statische Dateien aus `public/` aus, initialisiert die PostgreSQL-Tabellen (`quotas` und `antigravity_latest`) über `initDb()` und lädt gespeicherte Antigravity-Werte über `initAntigravityFromDb()`.
+2. **Quota-Abruf (`src/services/providers.ts`)**:
+ - `fetchPoeQuota()` fragt `https://api.poe.com/usage/current_balance` ab.
+ - `fetchMinimaxQuota()` fragt `https://api.minimax.io/v1/api/openplatform/coding_plan/remains` ab.
+ - `fetchAntigravityQuota()` liest den In-Memory-`antigravityCache`, der über `POST /api/webhook/antigravity` aktualisiert oder beim Start aus PostgreSQL geladen wird.
+3. **Alert-Logik (`src/cron.ts` & `src/services/ntfy.ts`)**:
+ - Bei **POE** (hier steht `percentage` für das *verbleibende* Kontingent) wird gewarnt, wenn `percentage <= (100 - ALERT_THRESHOLD_PERCENT)` (Standard: `<= 20 %` verbleibend).
+ - Bei **MiniMax** und **Antigravity** (hier steht `percentage` für das *verbrauchte* Kontingent) wird gewarnt, wenn `percentage >= ALERT_THRESHOLD_PERCENT` (Standard: `>= 80 %` verbraucht).
+4. **Lokaler Antigravity-Sync (`tokenwatch-sync.js`)**: Sucht laufende `language_server*`-Prozesse über PowerShell (`Get-CimInstance Win32_Process`), liest `--csrf_token` und `--extension_server_port` aus, ermittelt offene Loopback-Ports (`Get-NetTCPConnection` mit `netstat -ano` als Fallback), ruft `POST /exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary` auf und sendet die extrahierten Werte an `/api/webhook/antigravity`.
+
+### Tech-Stack & Ports
+
+| Komponente | Technologie / Version | Details |
+| :--- | :--- | :--- |
+| Laufzeitumgebung | Node.js 24 (`node:24-alpine`) | CommonJS-TypeScript-Build (`tsc` -> `dist/`) |
+| Backend | Express `^5.2.1`, TypeScript `^7.0.2` | REST-API + Auslieferung statischer Dateien |
+| Scheduler | `node-cron` `^4.6.0` | Läuft alle 30 Minuten (`*/30 * * * *`) |
+| HTTP-Client | `axios` `^1.20.0` | Provider-API-Abfragen & ntfy-Alerts |
+| Datenbank | PostgreSQL (`postgres:15-alpine`, `pg` `^8.23.0`) | Tabellen: `quotas`, `antigravity_latest` |
+| Frontend | Natives HTML/CSS/JS, Chart.js, `canvas-confetti` | Ausgeliefert aus `public/` |
+| Standard-Port | `3000` (Container) / `3500` (Jannik-Cloud-Host-Bind) | Konfigurierbar über `PORT` |
+
+---
+
+## Voraussetzungen & Installation
+
+### Voraussetzungen
+
+- **Lokale Entwicklung**: Node.js (v20+ / v24 empfohlen), npm und eine laufende PostgreSQL-Instanz.
+- **Docker-Deployment**: Docker und Docker Compose.
+- **Antigravity-Sync (optional)**: Windows-Rechner mit laufender Antigravity IDE, Node.js und PowerShell.
+
+### Lokale Installation
+
+1. Repository klonen:
+ ```bash
+ git clone https://git.orfel.de/Jannik/TokenWatch.git
+ cd TokenWatch
+ ```
+
+2. Abhängigkeiten installieren:
+ ```bash
+ npm install
+ ```
+
+3. Umgebungsdatei aus `.env.example` erstellen:
+ ```bash
+ cp .env.example .env
+ ```
+ Danach PostgreSQL-Zugangsdaten, `NTFY_URL` und API-Keys in `.env` eintragen.
+
+4. Im Entwicklungsmodus (`tsx`) starten oder für Produktion bauen:
+ ```bash
+ # Entwicklung
+ npm run dev
+
+ # Produktions-Build & Start
+ npm run build
+ npm start
+ ```
+
+### Docker-Compose-Setup
+
+TokenWatch gemeinsam mit PostgreSQL (`postgres:15-alpine`) starten:
+
+```bash
+cp .env.example .env
+# .env mit Zugangsdaten und API-Keys ausfüllen
+docker compose up -d
+```
+
+Das Dashboard ist anschließend unter `http://localhost:3000` erreichbar.
+
+### Jannik-Cloud-Produktivdeployment
+
+Eine fertige Deployment-Vorlage liegt in [`deployment-template/`](deployment-template/README.md):
+
+1. Den Inhalt von `deployment-template/` in das Verzeichnis `services/tokenwatch/` im `Jannik-Cloud`-Repository kopieren.
+2. In `services/tokenwatch/` das Skript `bash generate-env.sh` ausführen, um zufällige PostgreSQL-Zugangsdaten zu generieren und optional `.env` nach `.env.age` zu verschlüsseln (über `keys/age-public-key.txt`).
+3. Bei Bedarf Provider-API-Keys (`POE_API_KEY`, `MINIMAX_API_KEY` usw.) ergänzen.
+4. `tokenwatch.caddy` konfiguriert den Reverse-Proxy für `tw.orfel.de`, `token.orfel.de` und `tokenwatch.orfel.de` auf `tokenwatch:3000`; `docker-compose.yml` bindet `127.0.0.1:3500:3000` im externen Netzwerk `jannik-cloud-net`.
+5. Hinweis: `.github/workflows/docker.yml` enthält zudem einen GitHub-Actions-Workflow, der bei Pushes auf `main` oder `master` ein Image nach `ghcr.io//:latest` baut und pusht.
+
+---
+
+## Konfiguration
+
+### Umgebungsvariablen (`.env.example`)
+
+| Variable | Beschreibung | Standard / Beispiel |
+| :--- | :--- | :--- |
+| `PORT` | HTTP-Server-Port | `3000` |
+| `DB_USER` | PostgreSQL-Benutzername | `postgres` |
+| `DB_HOST` | PostgreSQL-Hostname | `postgres` |
+| `DB_NAME` | Name der PostgreSQL-Datenbank | `tokenwatch` |
+| `DB_PASSWORD` | PostgreSQL-Passwort | `your_db_password` |
+| `DB_PORT` | PostgreSQL-Port | `5432` |
+| `NTFY_URL` | ntfy-Topic-URL für Schwellenwert-Alerts | `https://ntfy.orfel.de/Token-Watch` (Fallback in `ntfy.ts`: `https://ntfy.orfel.de/tokenwatch_dummy`) |
+| `ALERT_THRESHOLD_PERCENT` | Schwellenwert in Prozent (`>=` verbraucht bzw. `<= 100 - N` verbleibend bei POE) | `80` |
+| `POE_API_KEY` | Bearer-Token für `api.poe.com/usage/current_balance` | — |
+| `MINIMAX_API_KEY` | Bearer-Token für `api.minimax.io/v1/api/openplatform/coding_plan/remains` | — |
+| `ANTIGRAVITY_API_KEY` | Optionaler Platzhalter in `.env.example` / Compose | — |
+| `ANTIGRAVITY_ENDPOINT` | Optionaler Platzhalter in `.env.example` / Compose | `https://api.antigravity.google/v1/quota` |
+
+### Docker-Volumes
+
+- `pgdata:/var/lib/postgresql/data` — Persistiert in `docker-compose.yml` den Verlauf in `quotas` sowie den Zustand in `antigravity_latest`.
+
+---
+
+## Nutzung
+
+### Web-Dashboard
+
+Öffne `http://localhost:3000` (bzw. deine konfigurierte Domain), um:
+- Aktuelle Fortschrittsbalken, Reset-Zeiten (`Heute`/`Morgen`/Wochentag) und Countdowns für POE, Antigravity und MiniMax anzuzeigen.
+- Über das Dropdown **Progress Bar Style** zwischen 6 Designs zu wechseln:
+ 1. `Standard`
+ 2. `Pac-Man`
+ 3. `Battery`
+ 4. `Nyan Cat`
+ 5. `Matrix`
+ 6. `Lava`
+- Den 7-Tage-Verlauf im Chart.js-Bereich **History** zu verfolgen.
+
+### API-Endpunkte
+
+| Methode | Endpunkt | Beschreibung |
+| :--- | :--- | :--- |
+| `GET` | `/api/quotas` | Liefert die aktuellen Quota-Objekte aller Provider inklusive `meta.todayUsed` für POE. |
+| `GET` | `/api/history` | Liefert die letzten 7 Tage aus der PostgreSQL-Tabelle `quotas` in chronologischer Reihenfolge. |
+| `POST` | `/api/webhook/antigravity` | Aktualisiert die 5 Antigravity-Einträge im Speicher und persistiert sie in `antigravity_latest`. |
+
+Beispiel-Payload für `POST /api/webhook/antigravity`:
+
+```json
+{
+ "gemini_5h_remaining": 85,
+ "gemini_weekly_remaining": 90,
+ "claude_5h_remaining": 100,
+ "claude_weekly_remaining": 75,
+ "gemini_argon_weekly_remaining": 100,
+ "gemini_5h_reset": "2026-01-01T15:00:00Z",
+ "gemini_weekly_reset": "2026-01-07T00:00:00Z",
+ "claude_5h_reset": null,
+ "claude_weekly_reset": null,
+ "gemini_argon_weekly_reset": null
+}
+```
+
+### Lokaler Antigravity-Sync (Windows)
+
+1. Stelle sicher, dass `url` in `tokenwatch-sync.js` auf deine TokenWatch-Instanz zeigt (Standard: `https://tokenwatch.orfel.de/api/webhook/antigravity`).
+2. Manuell ausführen:
+ ```powershell
+ .\Push-AntigravityQuota.ps1
+ ```
+ Oder direkt per Node:
+ ```bash
+ node tokenwatch-sync.js
+ ```
+3. **Automatisierung über Windows-Aufgabenplanung**:
+ - Trigger: Alle 30 Minuten
+ - Aktion: Programm starten
+ - Programm: `powershell`
+ - Argumente: `-ExecutionPolicy Bypass -File "C:\GitHub\TokenWatch\Push-AntigravityQuota.ps1"`
+4. **Rohdaten des Language Servers debuggen**:
+ ```bash
+ node fetch-quota.js
+ ```
+ Fragt `/exa.language_server_pb.LanguageServerService/GetUserStatus` beim lokalen Language Server ab (unterstützt Windows, macOS und Linux) und gibt die vollständige JSON-Antwort aus.
+
+---
+
+## Projektstruktur
+
+```text
+TokenWatch/
+├── .github/
+│ └── workflows/
+│ └── docker.yml # GitHub-Actions-Workflow zum Bauen/Pushen nach ghcr.io
+├── deployment-template/
+│ ├── README.md # Deployment-Anleitung für Jannik-Cloud
+│ ├── docker-compose.yml # Produktives Compose mit jannik-cloud-net
+│ ├── generate-env.sh # Erzeugt DB-Passwörter & optional .env.age
+│ ├── service.enabled # Aktivierungsdatei für Jannik-Cloud
+│ └── tokenwatch.caddy # Caddy-Reverse-Proxy-Konfiguration
+├── public/
+│ ├── logos/ # Provider-.ico-Dateien
+│ ├── app.js # Frontend-Logik, Countdowns, Chart.js & Themes
+│ ├── favicon.png # TokenWatch-Logo & Favicon
+│ ├── index.html # Dashboard-HTML
+│ ├── logo-*.png / .ico / .svg # Provider-Icons (POE, Gemini, Claude, MiniMax, AG)
+│ └── style.css # Dark-UI & 6 Fortschrittsbalken-Themes
+├── src/
+│ ├── services/
+│ │ ├── db.ts # PostgreSQL-Pool, Tabellen-Init, Verlauf & AG-Persistenz
+│ │ ├── ntfy.ts # ntfy-Benachrichtigungen
+│ │ └── providers.ts # POE-, MiniMax- & Antigravity-Provider-Logik
+│ ├── cron.ts # 30-Minuten-Cron-Job & Schwellenwert-Prüfung
+│ └── server.ts # Express-App & REST-API-Endpunkte
+├── .env.example # Beispiel-Umgebungsvariablen
+├── Dockerfile # Node-24-Alpine-Container mit TypeScript-Build
+├── docker-compose.yml # Lokales/Standalone-Compose mit PostgreSQL 15
+├── fetch-quota.js # Plattformübergreifendes Debug-Skript für Language Server
+├── language-server-process-utils.js# Prozesssuche & CLI-Argument-Extraktion
+├── package.json # Abhängigkeiten und npm-Skripte
+├── Push-AntigravityQuota.ps1 # PowerShell-Wrapper für Windows-Aufgabenplanung
+├── tokenwatch-sync.js # Lokaler Antigravity-Language-Server -> Webhook-Sync
+└── tsconfig.json # TypeScript-Konfiguration
+```
+
+---
+
+## Lizenz
+
+Lizenziert unter der **ISC**-Lizenz (gemäß [`package.json`](package.json)).
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..dab601b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,279 @@
+
+
+
+
+TokenWatch
+Self-hosted API quota & token limit tracker with live dashboard, 7-day history charts, and ntfy alerts.
+
+
+ 🇬🇧 English · 🇩🇪 Deutsch
+
+
+---
+
+## Overview
+
+**TokenWatch** is a self-hosted web application for monitoring AI API quotas and rate-limit windows across multiple providers in one dark-themed dashboard. It polls external provider APIs, accepts webhook pushes from a local Antigravity Language Server sync script, stores historical usage snapshots in PostgreSQL, displays interactive 7-day charts, and sends automated push alerts via **ntfy** when usage thresholds are reached.
+
+### Architecture
+
+```text
++-----------------------------------+ POST /api/webhook/antigravity
+| Windows Host (Antigravity IDE) | -------------------------------------+
+| Push-AntigravityQuota.ps1 | |
+| -> tokenwatch-sync.js | v
++-----------------------------------+ +------------------------------+
+ | TokenWatch Server (Express) |
++-----------------------------------+ REST API (30 min | Port 3000 |
+| External APIs | cron + live fetch) | - Static UI (public/) |
+| - POE (current_balance) | <-------------------> | - /api/quotas |
+| - MiniMax (coding_plan/remains) | | - /api/history |
++-----------------------------------+ +--------------+---------------+
+ |
+ +----------------------------+----------------------------+
+ v v
+ +------------------------------+ +------------------------------+
+ | PostgreSQL Database | | ntfy Server |
+ | - quotas (history) | | Alert threshold notifications|
+ | - antigravity_latest (JSONB) | +------------------------------+
+ +------------------------------+
+```
+
+---
+
+## Features
+
+- **Multi-Provider Quota Tracking**:
+ - **POE**: Tracks remaining point balance against a `2,500,000` cap, daily refresh (`75,000`), expiring points, days until cap, points used today (calculated against the first UTC snapshot of the day), and a live UTC midnight refresh countdown.
+ - **MiniMax**: Tracks `MiniMax (5h)` and `MiniMax (Weekly)` usage percentages (`model_name === 'general'`) with live reset countdowns.
+ - **Antigravity (AG)**: Tracks 5 separate quota buckets via webhook push (`AG Gemini (5h)`, `AG Gemini (Weekly)`, `AG Claude (5h)`, `AG Claude (Weekly)`, `AG Gemini 4 Argon (Weekly)`), including individual reset timestamps (`Heute`, `Morgen`, or weekday + countdown).
+- **Persistent Antigravity State**: Incoming Antigravity webhook payloads are saved into the `antigravity_latest` PostgreSQL table (`JSONB`) and automatically restored on server startup.
+- **Automated Cron Snapshots & ntfy Alerts**: Every 30 minutes (`*/30 * * * *`), `node-cron` fetches all quotas, records them in PostgreSQL, and sends an `ntfy` notification (`Title: TokenWatch Alert`, `Tags: warning,robot`) when the configured threshold (`ALERT_THRESHOLD_PERCENT`, default `80`) is crossed.
+- **7-Day History Chart**: Interactive Chart.js line chart grouping snapshots into 5-minute intervals for `AG Gemini (5h)`, `AG Claude (5h)`, `POE`, and `MiniMax (5h)`.
+- **6 Selectable Progress Bar Themes**: Switch live between `Standard`, `Pac-Man`, `Battery`, `Nyan Cat`, `Matrix`, and `Lava` themes (also dynamically updates Chart.js dataset colors).
+- **Confetti Milestone**: Triggers a `canvas-confetti` celebration and displays `LIMIT REACHED!` (for non-POE providers) when a quota reaches `100%`.
+- **Windows Antigravity Sync & Debug Tools**: Includes `tokenwatch-sync.js`, `Push-AntigravityQuota.ps1` (Task Scheduler-ready), and cross-platform `fetch-quota.js` for inspecting raw local Language Server quota responses.
+
+---
+
+## How It Works & Tech Stack
+
+### Internal Workflow
+
+1. **Server Startup (`src/server.ts`)**: Initializes Express on `0.0.0.0:3000`, serves static assets from `public/`, initializes the PostgreSQL tables (`quotas` and `antigravity_latest`) via `initDb()`, and restores cached Antigravity quotas via `initAntigravityFromDb()`.
+2. **Quota Polling (`src/services/providers.ts`)**:
+ - `fetchPoeQuota()` queries `https://api.poe.com/usage/current_balance`.
+ - `fetchMinimaxQuota()` queries `https://api.minimax.io/v1/api/openplatform/coding_plan/remains`.
+ - `fetchAntigravityQuota()` reads the in-memory `antigravityCache` populated by `POST /api/webhook/antigravity` or restored from PostgreSQL.
+3. **Alerting Logic (`src/cron.ts` & `src/services/ntfy.ts`)**:
+ - For **POE** (where `percentage` represents *remaining* quota), an alert is triggered when `percentage <= (100 - ALERT_THRESHOLD_PERCENT)` (default `<= 20%` remaining).
+ - For **MiniMax** and **Antigravity** (where `percentage` represents *used* quota), an alert is triggered when `percentage >= ALERT_THRESHOLD_PERCENT` (default `>= 80%` used).
+4. **Local Antigravity Sync (`tokenwatch-sync.js`)**: Discovers running `language_server*` processes via PowerShell (`Get-CimInstance Win32_Process`), extracts `--csrf_token` and `--extension_server_port`, scans localhost listening ports (`Get-NetTCPConnection` with `netstat -ano` fallback), calls `POST /exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary`, and forwards the parsed buckets to `/api/webhook/antigravity`.
+
+### Tech Stack & Ports
+
+| Component | Technology / Version | Details |
+| :--- | :--- | :--- |
+| Runtime | Node.js 24 (`node:24-alpine`) | CommonJS TypeScript build (`tsc` -> `dist/`) |
+| Backend | Express `^5.2.1`, TypeScript `^7.0.2` | REST API + static file server |
+| Scheduler | `node-cron` `^4.6.0` | Runs every 30 minutes (`*/30 * * * *`) |
+| HTTP Client | `axios` `^1.20.0` | Provider API calls & ntfy alerts |
+| Database | PostgreSQL (`postgres:15-alpine`, `pg` `^8.23.0`) | Tables: `quotas`, `antigravity_latest` |
+| Frontend | Vanilla HTML/CSS/JS, Chart.js, `canvas-confetti` | Served from `public/` |
+| Default Port | `3000` (Container) / `3500` (Jannik-Cloud host bind) | Configurable via `PORT` |
+
+---
+
+## Prerequisites & Installation
+
+### Prerequisites
+
+- **Local Development**: Node.js (v20+ / v24 recommended), npm, and a running PostgreSQL instance.
+- **Docker Deployment**: Docker and Docker Compose.
+- **Antigravity Local Sync (Optional)**: Windows host with Antigravity IDE running, Node.js, and PowerShell.
+
+### Local Installation
+
+1. Clone the repository:
+ ```bash
+ git clone https://git.orfel.de/Jannik/TokenWatch.git
+ cd TokenWatch
+ ```
+
+2. Install dependencies:
+ ```bash
+ npm install
+ ```
+
+3. Create your environment file from `.env.example`:
+ ```bash
+ cp .env.example .env
+ ```
+ Edit `.env` with your PostgreSQL credentials, `NTFY_URL`, and API keys.
+
+4. Run in development mode (using `tsx`) or build for production:
+ ```bash
+ # Development
+ npm run dev
+
+ # Production build & start
+ npm run build
+ npm start
+ ```
+
+### Docker Compose Setup
+
+Start TokenWatch together with PostgreSQL (`postgres:15-alpine`):
+
+```bash
+cp .env.example .env
+# Edit .env with your credentials and API keys
+docker compose up -d
+```
+
+The dashboard will be available at `http://localhost:3000`.
+
+### Jannik-Cloud Production Deployment
+
+A ready-to-use deployment template is provided in [`deployment-template/`](deployment-template/README.md):
+
+1. Copy the contents of `deployment-template/` into `services/tokenwatch/` in your `Jannik-Cloud` repository.
+2. Run `bash generate-env.sh` inside `services/tokenwatch/` to generate random PostgreSQL credentials and optionally encrypt `.env` to `.env.age` (using `keys/age-public-key.txt`).
+3. Add your provider API keys (`POE_API_KEY`, `MINIMAX_API_KEY`, etc.) as needed.
+4. The included `tokenwatch.caddy` configures reverse proxying for `tw.orfel.de`, `token.orfel.de`, and `tokenwatch.orfel.de` to `tokenwatch:3000`, while `docker-compose.yml` binds `127.0.0.1:3500:3000` on the external `jannik-cloud-net` network.
+5. Note: `.github/workflows/docker.yml` also defines a GitHub Actions workflow that builds and pushes `ghcr.io//:latest` on pushes to `main` or `master`.
+
+---
+
+## Configuration
+
+### Environment Variables (`.env.example`)
+
+| Variable | Description | Default / Example |
+| :--- | :--- | :--- |
+| `PORT` | HTTP server port | `3000` |
+| `DB_USER` | PostgreSQL username | `postgres` |
+| `DB_HOST` | PostgreSQL hostname | `postgres` |
+| `DB_NAME` | PostgreSQL database name | `tokenwatch` |
+| `DB_PASSWORD` | PostgreSQL password | `your_db_password` |
+| `DB_PORT` | PostgreSQL port | `5432` |
+| `NTFY_URL` | ntfy topic URL for threshold alerts | `https://ntfy.orfel.de/Token-Watch` (fallback in `ntfy.ts`: `https://ntfy.orfel.de/tokenwatch_dummy`) |
+| `ALERT_THRESHOLD_PERCENT` | Alert threshold percentage (`>=` used, or `<= 100 - N` remaining for POE) | `80` |
+| `POE_API_KEY` | Bearer token for `api.poe.com/usage/current_balance` | — |
+| `MINIMAX_API_KEY` | Bearer token for `api.minimax.io/v1/api/openplatform/coding_plan/remains` | — |
+| `ANTIGRAVITY_API_KEY` | Optional Antigravity key placeholder in `.env.example` / Compose | — |
+| `ANTIGRAVITY_ENDPOINT` | Optional Antigravity endpoint placeholder in `.env.example` / Compose | `https://api.antigravity.google/v1/quota` |
+
+### Docker Volumes
+
+- `pgdata:/var/lib/postgresql/data` — Persists PostgreSQL `quotas` history and `antigravity_latest` state in `docker-compose.yml`.
+
+---
+
+## Usage
+
+### Web Dashboard
+
+Open `http://localhost:3000` (or your configured reverse-proxy domain) to:
+- View real-time quota progress bars, reset times (`Heute`/`Morgen`/weekday), and countdowns for POE, Antigravity, and MiniMax.
+- Switch the **Progress Bar Style** dropdown between:
+ 1. `Standard`
+ 2. `Pac-Man`
+ 3. `Battery`
+ 4. `Nyan Cat`
+ 5. `Matrix`
+ 6. `Lava`
+- Inspect the 7-day usage trend in the **History** Chart.js graph.
+
+### API Endpoints
+
+| Method | Endpoint | Description |
+| :--- | :--- | :--- |
+| `GET` | `/api/quotas` | Returns current quota objects for all providers, enriched with `meta.todayUsed` for POE. |
+| `GET` | `/api/history` | Returns the last 7 days of rows from the `quotas` PostgreSQL table ordered chronologically. |
+| `POST` | `/api/webhook/antigravity` | Updates the 5 Antigravity quota entries and persists them to `antigravity_latest`. |
+
+Example webhook payload accepted by `POST /api/webhook/antigravity`:
+
+```json
+{
+ "gemini_5h_remaining": 85,
+ "gemini_weekly_remaining": 90,
+ "claude_5h_remaining": 100,
+ "claude_weekly_remaining": 75,
+ "gemini_argon_weekly_remaining": 100,
+ "gemini_5h_reset": "2026-01-01T15:00:00Z",
+ "gemini_weekly_reset": "2026-01-07T00:00:00Z",
+ "claude_5h_reset": null,
+ "claude_weekly_reset": null,
+ "gemini_argon_weekly_reset": null
+}
+```
+
+### Antigravity Local Sync (Windows)
+
+1. Verify `url` in `tokenwatch-sync.js` points to your TokenWatch instance (default: `https://tokenwatch.orfel.de/api/webhook/antigravity`).
+2. Run manually:
+ ```powershell
+ .\Push-AntigravityQuota.ps1
+ ```
+ Or directly:
+ ```bash
+ node tokenwatch-sync.js
+ ```
+3. **Windows Task Scheduler Automation**:
+ - Trigger: Every 30 minutes
+ - Action: Start a program
+ - Program: `powershell`
+ - Arguments: `-ExecutionPolicy Bypass -File "C:\GitHub\TokenWatch\Push-AntigravityQuota.ps1"`
+4. **Debugging Raw Language Server Quotas**:
+ ```bash
+ node fetch-quota.js
+ ```
+ Queries `/exa.language_server_pb.LanguageServerService/GetUserStatus` on the local Language Server (supports Windows, macOS, and Linux) and prints the complete JSON response.
+
+---
+
+## Project Structure
+
+```text
+TokenWatch/
+├── .github/
+│ └── workflows/
+│ └── docker.yml # GitHub Actions Docker build & push to ghcr.io
+├── deployment-template/
+│ ├── README.md # Jannik-Cloud deployment guide
+│ ├── docker-compose.yml # Production Compose using jannik-cloud-net
+│ ├── generate-env.sh # Generates DB credentials & optional age encryption
+│ ├── service.enabled # Jannik-Cloud service activation marker
+│ └── tokenwatch.caddy # Caddy reverse proxy config
+├── public/
+│ ├── logos/ # Provider .ico assets
+│ ├── app.js # Frontend fetching, countdowns, Chart.js & theme switcher
+│ ├── favicon.png # TokenWatch logo & favicon
+│ ├── index.html # Dashboard HTML
+│ ├── logo-*.png / .ico / .svg # Provider icons (POE, Gemini, Claude, MiniMax, AG)
+│ └── style.css # Dark UI & 6 progress bar theme styles
+├── src/
+│ ├── services/
+│ │ ├── db.ts # PostgreSQL pool, schema init, history & AG persistence
+│ │ ├── ntfy.ts # ntfy alert sender
+│ │ └── providers.ts # POE, MiniMax & Antigravity quota handlers
+│ ├── cron.ts # 30-minute quota logger & threshold alert job
+│ └── server.ts # Express app & REST API endpoints
+├── .env.example # Example environment configuration
+├── Dockerfile # Node 24 Alpine TypeScript build container
+├── docker-compose.yml # Local/standalone Compose with PostgreSQL 15
+├── fetch-quota.js # Cross-platform Language Server quota debug script
+├── language-server-process-utils.js# Process discovery & CLI arg extraction helpers
+├── package.json # Dependencies and npm scripts
+├── Push-AntigravityQuota.ps1 # Windows Task Scheduler wrapper script
+├── tokenwatch-sync.js # Local Antigravity Language Server -> webhook sync
+└── tsconfig.json # TypeScript compiler configuration
+```
+
+---
+
+## License
+
+Licensed under the **ISC** license (as specified in [`package.json`](package.json)).
diff --git a/ag-debug.json b/ag-debug.json
deleted file mode 100644
index 04206ce..0000000
--- a/ag-debug.json
+++ /dev/null
@@ -1,49 +0,0 @@
-{
- "response": {
- "groups": [
- {
- "displayName": "Gemini Models",
- "description": "Models within this group: Gemini Flash, Gemini Pro",
- "buckets": [
- {
- "bucketId": "gemini-weekly",
- "displayName": "Weekly Limit Remaining",
- "description": "You have used some of your weekly limit, it will fully refresh in 12 hours, 30 minutes.",
- "window": "weekly",
- "remainingFraction": 0.21547645,
- "resetTime": "2026-08-29T09:20:06Z"
- },
- {
- "bucketId": "gemini-5h",
- "displayName": "Five Hour Limit Remaining",
- "description": "You have used some of your 5-hour limit, it will fully refresh in 2 hours, 21 minutes.",
- "window": "5h",
- "remainingFraction": 0.5744839,
- "resetTime": "2026-08-28T23:11:19Z"
- }
- ]
- },
- {
- "displayName": "Claude and GPT models",
- "description": "Models within this group: Claude Opus, Claude Sonnet, GPT-OSS",
- "buckets": [
- {
- "bucketId": "3p-weekly",
- "displayName": "Weekly Limit Remaining",
- "window": "weekly",
- "remainingFraction": 1,
- "resetTime": "2026-09-04T20:49:50Z"
- },
- {
- "bucketId": "3p-5h",
- "displayName": "Five Hour Limit Remaining",
- "window": "5h",
- "remainingFraction": 1,
- "resetTime": "2026-08-29T01:49:50Z"
- }
- ]
- }
- ],
- "description": "Within each group, models share a weekly limit and a 5-hour limit. Quota is consumed proportionally to the cost of the tokens. Thus, limits will last longer with shorter tasks or using more cost-effective models. The 5-hour limit smooths out aggregate demand to fairly distribute global capacity across all users, while your weekly limit is tied directly to your individual tier."
- }
-}
\ No newline at end of file
diff --git a/debug.json b/debug.json
deleted file mode 100644
index dc66046..0000000
--- a/debug.json
+++ /dev/null
@@ -1,934 +0,0 @@
-{
- "userStatus": {
- "disableTelemetry": true,
- "name": "Jannik Müller",
- "email": "jannik.mueller.jannik@googlemail.com",
- "planStatus": {
- "planInfo": {
- "teamsTier": "TEAMS_TIER_PRO",
- "planName": "Pro",
- "hasAutocompleteFastMode": true,
- "allowStickyPremiumModels": true,
- "allowPremiumCommandModels": true,
- "hasTabToJump": true,
- "maxNumPremiumChatMessages": "-1",
- "maxNumChatInputTokens": "16384",
- "maxCustomChatInstructionCharacters": "600",
- "maxNumPinnedContextItems": "-1",
- "maxLocalIndexSize": "-1",
- "monthlyPromptCredits": 50000,
- "monthlyFlowCredits": 150000,
- "monthlyFlexCreditPurchaseAmount": 25000,
- "canBuyMoreCredits": true,
- "cascadeWebSearchEnabled": true,
- "canCustomizeAppIcon": true,
- "cascadeCanAutoRunCommands": true,
- "canGenerateCommitMessages": true,
- "knowledgeBaseEnabled": true,
- "defaultTeamConfig": {
- "allowMcpServers": true,
- "allowAutoRunCommands": true,
- "allowBrowserExperimentalFeatures": true
- },
- "canAllowCascadeInBackground": true,
- "browserEnabled": true
- },
- "availablePromptCredits": 500,
- "availableFlowCredits": 100
- },
- "cascadeModelConfigData": {
- "clientModelConfigs": [
- {
- "label": "Gemini 3.6 Flash (High)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M71"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 0.7300267,
- "resetTime": "2026-08-28T18:11:19Z"
- },
- "tagTitle": "Fast",
- "tagDescription": "Limited time",
- "supportedMimeTypes": {
- "application/json": true,
- "application/pdf": true,
- "application/rtf": true,
- "application/x-ipynb+json": true,
- "application/x-javascript": true,
- "application/x-python-code": true,
- "application/x-typescript": true,
- "audio/aac": true,
- "audio/flac": true,
- "audio/l16": true,
- "audio/m4a": true,
- "audio/mp3": true,
- "audio/mp4": true,
- "audio/mpeg": true,
- "audio/ogg": true,
- "audio/opus": true,
- "audio/vnd.wave": true,
- "audio/wav": true,
- "audio/wave": true,
- "audio/webm": true,
- "audio/webm;codecs=opus": true,
- "audio/x-wav": true,
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "text/css": true,
- "text/csv": true,
- "text/html": true,
- "text/javascript": true,
- "text/markdown": true,
- "text/plain": true,
- "text/rtf": true,
- "text/x-python": true,
- "text/x-python-script": true,
- "text/x-typescript": true,
- "text/xml": true,
- "video/audio/s16le": true,
- "video/audio/wav": true,
- "video/jpeg2000": true,
- "video/mp4": true,
- "video/text/timestamp": true,
- "video/videoframe/jpeg2000": true,
- "video/webm": true
- },
- "modelId": "gemini-3.6-flash-high"
- },
- {
- "label": "Gemini 3.6 Flash (Medium)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M72"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 0.7300267,
- "resetTime": "2026-08-28T18:11:19Z"
- },
- "tagTitle": "Fast",
- "tagDescription": "Limited time",
- "supportedMimeTypes": {
- "application/json": true,
- "application/pdf": true,
- "application/rtf": true,
- "application/x-ipynb+json": true,
- "application/x-javascript": true,
- "application/x-python-code": true,
- "application/x-typescript": true,
- "audio/aac": true,
- "audio/flac": true,
- "audio/l16": true,
- "audio/m4a": true,
- "audio/mp3": true,
- "audio/mp4": true,
- "audio/mpeg": true,
- "audio/ogg": true,
- "audio/opus": true,
- "audio/vnd.wave": true,
- "audio/wav": true,
- "audio/wave": true,
- "audio/webm": true,
- "audio/webm;codecs=opus": true,
- "audio/x-wav": true,
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "text/css": true,
- "text/csv": true,
- "text/html": true,
- "text/javascript": true,
- "text/markdown": true,
- "text/plain": true,
- "text/rtf": true,
- "text/x-python": true,
- "text/x-python-script": true,
- "text/x-typescript": true,
- "text/xml": true,
- "video/audio/s16le": true,
- "video/audio/wav": true,
- "video/jpeg2000": true,
- "video/mp4": true,
- "video/text/timestamp": true,
- "video/videoframe/jpeg2000": true,
- "video/webm": true
- },
- "modelId": "gemini-3.6-flash-medium"
- },
- {
- "label": "Gemini 3.6 Flash (Low)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M73"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 0.7300267,
- "resetTime": "2026-08-28T18:11:19Z"
- },
- "tagTitle": "Fast",
- "tagDescription": "Limited time",
- "supportedMimeTypes": {
- "application/json": true,
- "application/pdf": true,
- "application/rtf": true,
- "application/x-ipynb+json": true,
- "application/x-javascript": true,
- "application/x-python-code": true,
- "application/x-typescript": true,
- "audio/aac": true,
- "audio/flac": true,
- "audio/l16": true,
- "audio/m4a": true,
- "audio/mp3": true,
- "audio/mp4": true,
- "audio/mpeg": true,
- "audio/ogg": true,
- "audio/opus": true,
- "audio/vnd.wave": true,
- "audio/wav": true,
- "audio/wave": true,
- "audio/webm": true,
- "audio/webm;codecs=opus": true,
- "audio/x-wav": true,
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "text/css": true,
- "text/csv": true,
- "text/html": true,
- "text/javascript": true,
- "text/markdown": true,
- "text/plain": true,
- "text/rtf": true,
- "text/x-python": true,
- "text/x-python-script": true,
- "text/x-typescript": true,
- "text/xml": true,
- "video/audio/s16le": true,
- "video/audio/wav": true,
- "video/jpeg2000": true,
- "video/mp4": true,
- "video/text/timestamp": true,
- "video/videoframe/jpeg2000": true,
- "video/webm": true
- },
- "modelId": "gemini-3.6-flash-low"
- },
- {
- "label": "Gemini 3.5 Flash (High)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M84"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 0.7300267,
- "resetTime": "2026-08-28T18:11:19Z"
- },
- "tagTitle": "Fast",
- "tagDescription": "Limited time",
- "supportedMimeTypes": {
- "application/json": true,
- "application/pdf": true,
- "application/rtf": true,
- "application/x-ipynb+json": true,
- "application/x-javascript": true,
- "application/x-python-code": true,
- "application/x-typescript": true,
- "audio/aac": true,
- "audio/flac": true,
- "audio/l16": true,
- "audio/m4a": true,
- "audio/mp3": true,
- "audio/mp4": true,
- "audio/mpeg": true,
- "audio/ogg": true,
- "audio/opus": true,
- "audio/vnd.wave": true,
- "audio/wav": true,
- "audio/wave": true,
- "audio/webm": true,
- "audio/webm;codecs=opus": true,
- "audio/x-wav": true,
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "text/css": true,
- "text/csv": true,
- "text/html": true,
- "text/javascript": true,
- "text/markdown": true,
- "text/plain": true,
- "text/rtf": true,
- "text/x-python": true,
- "text/x-python-script": true,
- "text/x-typescript": true,
- "text/xml": true,
- "video/audio/s16le": true,
- "video/audio/wav": true,
- "video/jpeg2000": true,
- "video/mp4": true,
- "video/text/timestamp": true,
- "video/videoframe/jpeg2000": true,
- "video/webm": true
- },
- "modelId": "gemini-3-flash-agent"
- },
- {
- "label": "Gemini 3.5 Flash (Medium)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M20"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 0.7300267,
- "resetTime": "2026-08-28T18:11:19Z"
- },
- "tagTitle": "Fast",
- "tagDescription": "Limited time",
- "supportedMimeTypes": {
- "application/json": true,
- "application/pdf": true,
- "application/rtf": true,
- "application/x-ipynb+json": true,
- "application/x-javascript": true,
- "application/x-python-code": true,
- "application/x-typescript": true,
- "audio/aac": true,
- "audio/flac": true,
- "audio/l16": true,
- "audio/m4a": true,
- "audio/mp3": true,
- "audio/mp4": true,
- "audio/mpeg": true,
- "audio/ogg": true,
- "audio/opus": true,
- "audio/vnd.wave": true,
- "audio/wav": true,
- "audio/wave": true,
- "audio/webm": true,
- "audio/webm;codecs=opus": true,
- "audio/x-wav": true,
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "text/css": true,
- "text/csv": true,
- "text/html": true,
- "text/javascript": true,
- "text/markdown": true,
- "text/plain": true,
- "text/rtf": true,
- "text/x-python": true,
- "text/x-python-script": true,
- "text/x-typescript": true,
- "text/xml": true,
- "video/audio/s16le": true,
- "video/audio/wav": true,
- "video/jpeg2000": true,
- "video/mp4": true,
- "video/text/timestamp": true,
- "video/videoframe/jpeg2000": true,
- "video/webm": true
- },
- "modelId": "gemini-3.5-flash-low"
- },
- {
- "label": "Gemini 3.1 Pro (High)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M16"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 0.7300267,
- "resetTime": "2026-08-28T18:11:19Z"
- },
- "supportedMimeTypes": {
- "application/json": true,
- "application/pdf": true,
- "application/rtf": true,
- "application/x-ipynb+json": true,
- "application/x-javascript": true,
- "application/x-python-code": true,
- "application/x-typescript": true,
- "audio/aac": true,
- "audio/flac": true,
- "audio/l16": true,
- "audio/m4a": true,
- "audio/mp3": true,
- "audio/mp4": true,
- "audio/mpeg": true,
- "audio/ogg": true,
- "audio/opus": true,
- "audio/vnd.wave": true,
- "audio/wav": true,
- "audio/wave": true,
- "audio/webm": true,
- "audio/webm;codecs=opus": true,
- "audio/x-wav": true,
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "text/css": true,
- "text/csv": true,
- "text/html": true,
- "text/javascript": true,
- "text/markdown": true,
- "text/plain": true,
- "text/rtf": true,
- "text/x-python": true,
- "text/x-python-script": true,
- "text/x-typescript": true,
- "text/xml": true,
- "video/audio/s16le": true,
- "video/audio/wav": true,
- "video/jpeg2000": true,
- "video/mp4": true,
- "video/text/timestamp": true,
- "video/videoframe/jpeg2000": true,
- "video/webm": true
- },
- "modelId": "gemini-pro-agent"
- },
- {
- "label": "Gemini 3.7 Flash (Medium)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M299"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 0.7300267,
- "resetTime": "2026-08-28T18:11:19Z"
- },
- "tagTitle": "Fast",
- "tagDescription": "Limited time",
- "supportedMimeTypes": {
- "application/json": true,
- "application/pdf": true,
- "application/rtf": true,
- "application/x-ipynb+json": true,
- "application/x-javascript": true,
- "application/x-python-code": true,
- "application/x-typescript": true,
- "audio/aac": true,
- "audio/flac": true,
- "audio/l16": true,
- "audio/m4a": true,
- "audio/mp3": true,
- "audio/mp4": true,
- "audio/mpeg": true,
- "audio/ogg": true,
- "audio/opus": true,
- "audio/vnd.wave": true,
- "audio/wav": true,
- "audio/wave": true,
- "audio/webm": true,
- "audio/webm;codecs=opus": true,
- "audio/x-wav": true,
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "text/css": true,
- "text/csv": true,
- "text/html": true,
- "text/javascript": true,
- "text/markdown": true,
- "text/plain": true,
- "text/rtf": true,
- "text/x-python": true,
- "text/x-python-script": true,
- "text/x-typescript": true,
- "text/xml": true,
- "video/audio/s16le": true,
- "video/audio/wav": true,
- "video/jpeg2000": true,
- "video/mp4": true,
- "video/text/timestamp": true,
- "video/videoframe/jpeg2000": true,
- "video/webm": true
- },
- "modelId": "gemini-3.7-flash-medium"
- },
- {
- "label": "Gemini 3.5 Flash (Low)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M187"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 0.7300267,
- "resetTime": "2026-08-28T18:11:19Z"
- },
- "tagTitle": "Fast",
- "tagDescription": "Limited time",
- "supportedMimeTypes": {
- "application/json": true,
- "application/pdf": true,
- "application/rtf": true,
- "application/x-ipynb+json": true,
- "application/x-javascript": true,
- "application/x-python-code": true,
- "application/x-typescript": true,
- "audio/aac": true,
- "audio/flac": true,
- "audio/l16": true,
- "audio/m4a": true,
- "audio/mp3": true,
- "audio/mp4": true,
- "audio/mpeg": true,
- "audio/ogg": true,
- "audio/opus": true,
- "audio/vnd.wave": true,
- "audio/wav": true,
- "audio/wave": true,
- "audio/webm": true,
- "audio/webm;codecs=opus": true,
- "audio/x-wav": true,
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "text/css": true,
- "text/csv": true,
- "text/html": true,
- "text/javascript": true,
- "text/markdown": true,
- "text/plain": true,
- "text/rtf": true,
- "text/x-python": true,
- "text/x-python-script": true,
- "text/x-typescript": true,
- "text/xml": true,
- "video/audio/s16le": true,
- "video/audio/wav": true,
- "video/jpeg2000": true,
- "video/mp4": true,
- "video/text/timestamp": true,
- "video/videoframe/jpeg2000": true,
- "video/webm": true
- },
- "modelId": "gemini-3.5-flash-extra-low"
- },
- {
- "label": "Gemini 3.1 Pro (Low)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M36"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 0.7300267,
- "resetTime": "2026-08-28T18:11:19Z"
- },
- "supportedMimeTypes": {
- "application/json": true,
- "application/pdf": true,
- "application/rtf": true,
- "application/x-ipynb+json": true,
- "application/x-javascript": true,
- "application/x-python-code": true,
- "application/x-typescript": true,
- "audio/aac": true,
- "audio/flac": true,
- "audio/l16": true,
- "audio/m4a": true,
- "audio/mp3": true,
- "audio/mp4": true,
- "audio/mpeg": true,
- "audio/ogg": true,
- "audio/opus": true,
- "audio/vnd.wave": true,
- "audio/wav": true,
- "audio/wave": true,
- "audio/webm": true,
- "audio/webm;codecs=opus": true,
- "audio/x-wav": true,
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "text/css": true,
- "text/csv": true,
- "text/html": true,
- "text/javascript": true,
- "text/markdown": true,
- "text/plain": true,
- "text/rtf": true,
- "text/x-python": true,
- "text/x-python-script": true,
- "text/x-typescript": true,
- "text/xml": true,
- "video/audio/s16le": true,
- "video/audio/wav": true,
- "video/jpeg2000": true,
- "video/mp4": true,
- "video/text/timestamp": true,
- "video/videoframe/jpeg2000": true,
- "video/webm": true
- },
- "modelId": "gemini-3.1-pro-low"
- },
- {
- "label": "Claude Sonnet 4.6 (Thinking)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M35"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 1,
- "resetTime": "2026-08-28T18:56:56Z"
- },
- "supportedMimeTypes": {
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "video/jpeg2000": true,
- "video/videoframe/jpeg2000": true
- },
- "modelId": "claude-sonnet-4-6"
- },
- {
- "label": "Claude Opus 4.6 (Thinking)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M26"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 1,
- "resetTime": "2026-08-28T18:56:56Z"
- },
- "supportedMimeTypes": {
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "video/jpeg2000": true,
- "video/videoframe/jpeg2000": true
- },
- "modelId": "claude-opus-4-6-thinking"
- },
- {
- "label": "GPT-OSS 120B (Medium)",
- "modelOrAlias": {
- "model": "MODEL_OPENAI_GPT_OSS_120B_MEDIUM"
- },
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 1,
- "resetTime": "2026-08-28T18:56:56Z"
- },
- "modelId": "gpt-oss-120b-medium"
- },
- {
- "label": "Gemini 3.7 Flash (High)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M298"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 0.7300267,
- "resetTime": "2026-08-28T18:11:19Z"
- },
- "tagTitle": "Fast",
- "tagDescription": "Limited time",
- "supportedMimeTypes": {
- "application/json": true,
- "application/pdf": true,
- "application/rtf": true,
- "application/x-ipynb+json": true,
- "application/x-javascript": true,
- "application/x-python-code": true,
- "application/x-typescript": true,
- "audio/aac": true,
- "audio/flac": true,
- "audio/l16": true,
- "audio/m4a": true,
- "audio/mp3": true,
- "audio/mp4": true,
- "audio/mpeg": true,
- "audio/ogg": true,
- "audio/opus": true,
- "audio/vnd.wave": true,
- "audio/wav": true,
- "audio/wave": true,
- "audio/webm": true,
- "audio/webm;codecs=opus": true,
- "audio/x-wav": true,
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "text/css": true,
- "text/csv": true,
- "text/html": true,
- "text/javascript": true,
- "text/markdown": true,
- "text/plain": true,
- "text/rtf": true,
- "text/x-python": true,
- "text/x-python-script": true,
- "text/x-typescript": true,
- "text/xml": true,
- "video/audio/s16le": true,
- "video/audio/wav": true,
- "video/jpeg2000": true,
- "video/mp4": true,
- "video/text/timestamp": true,
- "video/videoframe/jpeg2000": true,
- "video/webm": true
- },
- "modelId": "gemini-3.7-flash-high"
- },
- {
- "label": "Gemini 3.7 Flash (Low)",
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M300"
- },
- "supportsImages": true,
- "isRecommended": true,
- "allowedTiers": [
- "TEAMS_TIER_PRO",
- "TEAMS_TIER_TEAMS",
- "TEAMS_TIER_ENTERPRISE_SELF_HOSTED",
- "TEAMS_TIER_ENTERPRISE_SAAS",
- "TEAMS_TIER_HYBRID",
- "TEAMS_TIER_PRO_ULTIMATE"
- ],
- "quotaInfo": {
- "remainingFraction": 0.7300267,
- "resetTime": "2026-08-28T18:11:19Z"
- },
- "tagTitle": "Fast",
- "tagDescription": "Limited time",
- "supportedMimeTypes": {
- "application/json": true,
- "application/pdf": true,
- "application/rtf": true,
- "application/x-ipynb+json": true,
- "application/x-javascript": true,
- "application/x-python-code": true,
- "application/x-typescript": true,
- "audio/aac": true,
- "audio/flac": true,
- "audio/l16": true,
- "audio/m4a": true,
- "audio/mp3": true,
- "audio/mp4": true,
- "audio/mpeg": true,
- "audio/ogg": true,
- "audio/opus": true,
- "audio/vnd.wave": true,
- "audio/wav": true,
- "audio/wave": true,
- "audio/webm": true,
- "audio/webm;codecs=opus": true,
- "audio/x-wav": true,
- "image/heic": true,
- "image/heif": true,
- "image/jpeg": true,
- "image/png": true,
- "image/webp": true,
- "text/css": true,
- "text/csv": true,
- "text/html": true,
- "text/javascript": true,
- "text/markdown": true,
- "text/plain": true,
- "text/rtf": true,
- "text/x-python": true,
- "text/x-python-script": true,
- "text/x-typescript": true,
- "text/xml": true,
- "video/audio/s16le": true,
- "video/audio/wav": true,
- "video/jpeg2000": true,
- "video/mp4": true,
- "video/text/timestamp": true,
- "video/videoframe/jpeg2000": true,
- "video/webm": true
- },
- "modelId": "gemini-3.7-flash-low"
- }
- ],
- "clientModelSorts": [
- {
- "name": "Recommended",
- "groups": [
- {
- "modelLabels": [
- "Gemini 3.7 Flash (High)",
- "Gemini 3.7 Flash (Medium)",
- "Gemini 3.7 Flash (Low)",
- "Gemini 3.6 Flash (High)",
- "Gemini 3.6 Flash (Medium)",
- "Gemini 3.6 Flash (Low)",
- "Gemini 3.5 Flash (High)",
- "Gemini 3.5 Flash (Medium)",
- "Gemini 3.5 Flash (Low)",
- "Gemini 3.1 Pro (High)",
- "Gemini 3.1 Pro (Low)",
- "Claude Sonnet 4.6 (Thinking)",
- "Claude Opus 4.6 (Thinking)",
- "GPT-OSS 120B (Medium)"
- ]
- }
- ]
- }
- ],
- "defaultOverrideModelConfig": {
- "modelOrAlias": {
- "model": "MODEL_PLACEHOLDER_M298"
- }
- }
- },
- "acceptedLatestTermsOfService": true,
- "userTier": {
- "id": "g1-pro-tier",
- "name": "Google AI Pro",
- "description": "Google AI Pro",
- "upgradeSubscriptionUri": "https://antigravity.google/g1-upgrade",
- "upgradeSubscriptionText": "You can upgrade to a Google AI Ultra plan to receive higher rate limits.",
- "availableCredits": [
- {
- "creditType": "GOOGLE_ONE_AI",
- "minimumCreditAmountForUsage": "50"
- }
- ]
- }
- }
-}
\ No newline at end of file
diff --git a/dump.json b/dump.json
deleted file mode 100644
index 5acdeb3..0000000
--- a/dump.json
+++ /dev/null
@@ -1,49 +0,0 @@
-{
- "response": {
- "groups": [
- {
- "displayName": "Gemini Models",
- "description": "Models within this group: Gemini Flash, Gemini Pro",
- "buckets": [
- {
- "bucketId": "gemini-weekly",
- "displayName": "Weekly Limit Remaining",
- "description": "You have used some of your weekly limit, it will fully refresh in 6 days, 10 hours.",
- "window": "weekly",
- "remainingFraction": 0.9899833,
- "resetTime": "2026-09-05T09:20:06Z"
- },
- {
- "bucketId": "gemini-5h",
- "displayName": "Five Hour Limit Remaining",
- "description": "You have used some of your 5-hour limit, it will fully refresh in 4 hours, 54 minutes.",
- "window": "5h",
- "remainingFraction": 0.9699,
- "resetTime": "2026-08-30T03:16:17Z"
- }
- ]
- },
- {
- "displayName": "Claude and GPT models",
- "description": "Models within this group: Claude Opus, Claude Sonnet, GPT-OSS",
- "buckets": [
- {
- "bucketId": "3p-weekly",
- "displayName": "Weekly Limit Remaining",
- "window": "weekly",
- "remainingFraction": 1,
- "resetTime": "2026-09-05T22:21:46Z"
- },
- {
- "bucketId": "3p-5h",
- "displayName": "Five Hour Limit Remaining",
- "window": "5h",
- "remainingFraction": 1,
- "resetTime": "2026-08-30T03:21:46Z"
- }
- ]
- }
- ],
- "description": "Within each group, models share a weekly limit and a 5-hour limit. Quota is consumed proportionally to the cost of the tokens. Thus, limits will last longer with shorter tasks or using more cost-effective models. The 5-hour limit smooths out aggregate demand to fairly distribute global capacity across all users, while your weekly limit is tied directly to your individual tier."
- }
-}
\ No newline at end of file
diff --git a/test-ag.js b/test-ag.js
deleted file mode 100644
index 637b454..0000000
--- a/test-ag.js
+++ /dev/null
@@ -1,64 +0,0 @@
-const fs = require('fs');
-const http = require('http');
-const https = require('https');
-const { execSync } = require('child_process');
-
-function extractArgument(commandLine, argumentName) {
- const escapedName = argumentName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
- const pattern = new RegExp(`--${escapedName}(?:=|\\s+)(?:"([^"]*)"|'([^']*)'|([^\\s]+))`, 'i');
- const match = commandLine.match(pattern);
- return match ? (match[1] ?? match[2] ?? match[3] ?? null) : null;
-}
-
-try {
- const stdout = execSync('powershell -NoProfile -Command "Get-CimInstance Win32_Process -Filter \\"name like \'language_server%\'\\" | Select-Object ProcessId,CommandLine | ConvertTo-Json -Depth 2"').toString();
- const processes = JSON.parse(stdout);
- const processInfo = Array.isArray(processes) ? processes.find(p => extractArgument(p.CommandLine, 'csrf_token')) : processes;
- if (!processInfo) { console.log('No LS found'); process.exit(0); }
-
- const csrfToken = extractArgument(processInfo.CommandLine, 'csrf_token');
- const pid = processInfo.ProcessId;
-
- const netstat = execSync('netstat -ano').toString();
- const ports = [];
- for (const line of netstat.split(/\r?\n/)) {
- if (!/(LISTEN|ABH)/i.test(line) || !new RegExp(`\\s${pid}\\s*$`).test(line)) continue;
- for (const match of line.matchAll(/(?:127\.0\.0\.1|\[?::1\]?):(\d{2,5})/g)) {
- ports.push(Number(match[1]));
- }
- }
-
- const requestBody = JSON.stringify({ metadata: { ideName: 'antigravity', extensionName: 'ag-usage', locale: 'en' } });
-
- for (const port of [...new Set(ports)]) {
- ['http', 'https'].forEach(protocol => {
- const client = protocol === 'https' ? https : http;
- const req = client.request({
- hostname: '127.0.0.1', port, path: '/exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary', method: 'POST',
- ...(protocol === 'https' ? { rejectUnauthorized: false } : {}),
- headers: {
- 'X-Codeium-Csrf-Token': csrfToken,
- 'Connect-Protocol-Version': '1',
- 'Content-Type': 'application/json',
- 'Content-Length': Buffer.byteLength(requestBody)
- }
- }, res => {
- let body = '';
- res.on('data', chunk => body += chunk);
- res.on('end', () => {
- console.log('Port', port, protocol, res.statusCode);
- if (res.statusCode === 200) {
- try {
- fs.writeFileSync('ag-debug.json', JSON.stringify(JSON.parse(body), null, 2));
- } catch(e) {}
- }
- });
- });
- req.on('error', () => {});
- req.write(requestBody);
- req.end();
- });
- }
-} catch (e) {
- console.error(e);
-}
diff --git a/test-dump.js b/test-dump.js
deleted file mode 100644
index 07fa342..0000000
--- a/test-dump.js
+++ /dev/null
@@ -1,209 +0,0 @@
-const http = require('http');
-const https = require('https');
-const os = require('os');
-const { exec } = require('child_process');
-const fs = require('fs');
-
-const COMMAND_TIMEOUT_MS = 5000;
-const MAX_BUFFER_BYTES = 10 * 1024 * 1024;
-
-function runCommand(command, timeout = COMMAND_TIMEOUT_MS) {
- return new Promise((resolve) => {
- exec(command, { timeout, maxBuffer: MAX_BUFFER_BYTES }, (error, stdout, stderr) => {
- resolve({ error, stdout: stdout || '', stderr: stderr || '' });
- });
- });
-}
-
-function parseWindowsProcessJson(stdout) {
- if (!stdout.trim()) return [];
- const parsed = JSON.parse(stdout);
- const rows = Array.isArray(parsed) ? parsed : [parsed];
- return rows
- .filter(row => row && row.ProcessId)
- .map(row => ({
- pid: Number(row.ProcessId),
- ppid: Number(row.ParentProcessId || 0),
- commandLine: row.CommandLine || row.ExecutablePath || '',
- }));
-}
-
-async function listLanguageServerProcesses() {
- const command = [
- 'powershell -NoProfile -Command',
- '"Get-CimInstance Win32_Process -Filter \\"name like \'language_server%\'\\"',
- '| Select-Object ProcessId,ParentProcessId,CommandLine,ExecutablePath',
- '| ConvertTo-Json -Depth 2"',
- ].join(' ');
- const result = await runCommand(command);
- if (result.error && !result.stdout.trim()) {
- throw new Error(result.stderr.trim() || result.error.message);
- }
- return parseWindowsProcessJson(result.stdout);
-}
-
-function extractArgument(commandLine, argumentName) {
- const escapedName = argumentName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
- const pattern = new RegExp(`--${escapedName}(?:=|\\s+)(?:"([^"]*)"|'([^']*)'|([^\\s]+))`, 'i');
- const match = commandLine.match(pattern);
- return match ? (match[1] ?? match[2] ?? match[3] ?? null) : null;
-}
-
-const API_PATH = '/exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary';
-const requestBody = JSON.stringify({ metadata: { ideName: 'antigravity', extensionName: 'ag-usage', locale: 'en' } });
-
-function tryPort(port, csrfToken, protocol) {
- return new Promise(resolve => {
- const client = protocol === 'https' ? https : http;
- const req = client.request({
- hostname: '127.0.0.1', port, path: API_PATH, method: 'POST',
- ...(protocol === 'https' ? { rejectUnauthorized: false } : {}),
- headers: {
- 'X-Codeium-Csrf-Token': csrfToken,
- 'Connect-Protocol-Version': '1',
- 'Content-Type': 'application/json',
- 'Content-Length': Buffer.byteLength(requestBody),
- },
- timeout: 3000,
- }, res => {
- let body = '';
- res.setEncoding('utf8');
- res.on('data', chunk => body += chunk);
- res.on('end', () => resolve({ port, statusCode: res.statusCode, body }));
- });
- req.on('error', () => resolve(null));
- req.on('timeout', () => { req.destroy(); resolve(null); });
- req.end(requestBody);
- });
-}
-
-function parseResponse(body) {
- const trimmed = body.trim();
- if (!trimmed) return null;
- try { return JSON.parse(trimmed); } catch {}
-
- // Fallback for NDJSON or streamed lines
- for (const line of trimmed.split(/\r?\n/).filter(Boolean)) {
- try { return JSON.parse(line); } catch {}
- }
- return null;
-}
-
-async function syncToTokenWatch(quotaData) {
- const postData = JSON.stringify(quotaData);
- // Ersetze diese URL durch die echte von TokenWatch auf der Jannik-Cloud, sobald sie läuft.
- const url = 'https://tokenwatch.orfel.de/api/webhook/antigravity';
- const isHttps = url.startsWith('https');
- const client = isHttps ? https : http;
-
- return new Promise((resolve) => {
- const req = client.request(url, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }
- }, (res) => {
- res.on('data', () => {});
- res.on('end', () => resolve(true));
- });
- req.on('error', (err) => {
- console.error('Webhook error:', err.message);
- resolve(false);
- });
- req.write(postData);
- req.end();
- });
-}
-
-async function main() {
- console.log('Suche Antigravity Language Server...');
- const processes = await listLanguageServerProcesses();
- const processInfo = processes.find(item => extractArgument(item.commandLine, 'csrf_token'));
- if (!processInfo) { console.error('Fehler: Kein Antigravity language_server Prozess gefunden.'); return; }
-
- const csrfToken = extractArgument(processInfo.commandLine, 'csrf_token');
- const extensionPort = Number(extractArgument(processInfo.commandLine, 'extension_server_port')) || null;
-
- function extractListeningPorts(stdout, pid) {
- const ports = [];
- for (const line of stdout.split(/\r?\n/)) {
- // (LISTEN|ABH) matches German 'ABHÖREN' from netstat
- if (!/(LISTEN|ABH)/i.test(line) || !new RegExp(`\\s${pid}\\s*$`).test(line)) continue;
- for (const match of line.matchAll(/(?:127\.0\.0\.1|\[?::1\]?):(\d{2,5})/g)) {
- const port = Number(match[1]);
- if (port > 0 && port < 65536) ports.push(port);
- }
- }
- return ports;
- }
-
- const netstatResult = await runCommand('netstat -ano');
- const listeningPorts = extractListeningPorts(netstatResult.stdout, processInfo.pid);
- const candidates = [...new Set(listeningPorts)].filter(port => port !== extensionPort).sort((a,b)=>a-b);
-
- let rawData = null;
- for (const port of candidates) {
- for (const protocol of ['https', 'http']) {
- const result = await tryPort(port, csrfToken, protocol);
- if (result && result.statusCode === 200) {
- rawData = parseResponse(result.body);
- if (rawData) break;
- }
- }
- if (rawData) break;
- }
-
- const actualData = Array.isArray(rawData) ? rawData[0] : rawData;
- const groups = actualData?.response?.groups;
-
- if (!groups) {
- console.error('Fehler: Konnte keine JSON-Antwort mit Quota auslesen.', rawData);
- return;
- }
-
- let gemini5h = 1, geminiWeekly = 1, gemini5hReset = 'Unknown', geminiWeeklyReset = 'Unknown';
- let claude5h = 1, claudeWeekly = 1, claude5hReset = 'Unknown', claudeWeeklyReset = 'Unknown';
-
- const formatTime = (ts) => {
- if (!ts) return 'Unknown';
- return new Date(ts).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
- };
-
- for (const group of groups) {
- const isGemini = group.displayName && group.displayName.toLowerCase().includes('gemini');
- for (const bucket of group.buckets || []) {
- if (isGemini) {
- if (bucket.window === '5h') {
- gemini5h = bucket.remainingFraction ?? 1;
- gemini5hReset = formatTime(bucket.resetTime);
- } else if (bucket.window === 'weekly') {
- geminiWeekly = bucket.remainingFraction ?? 1;
- geminiWeeklyReset = formatTime(bucket.resetTime);
- }
- } else {
- if (bucket.window === '5h') {
- claude5h = bucket.remainingFraction ?? 1;
- claude5hReset = formatTime(bucket.resetTime);
- } else if (bucket.window === 'weekly') {
- claudeWeekly = bucket.remainingFraction ?? 1;
- claudeWeeklyReset = formatTime(bucket.resetTime);
- }
- }
- }
- }
-
- const payload = {
- gemini_5h_remaining: Math.round(gemini5h * 100),
- gemini_weekly_remaining: Math.round(geminiWeekly * 100),
- claude_5h_remaining: Math.round(claude5h * 100),
- claude_weekly_remaining: Math.round(claudeWeekly * 100),
- gemini_5h_reset: `in ${gemini5hReset}`,
- gemini_weekly_reset: `in ${geminiWeeklyReset}`,
- claude_5h_reset: `in ${claude5hReset}`,
- claude_weekly_reset: `in ${claudeWeeklyReset}`
- };
-
- console.log('Gefundene Live-Daten:', payload);
- fs.writeFileSync('dump.json', JSON.stringify(actualData, null, 2)); console.log('Dumped');
- console.log('Erfolgreich an TokenWatch gesendet!');
-}
-
-main().catch(console.error);
diff --git a/test-raw.js b/test-raw.js
deleted file mode 100644
index 356b357..0000000
--- a/test-raw.js
+++ /dev/null
@@ -1,68 +0,0 @@
-const http = require('http');
-const https = require('https');
-const { execSync } = require('child_process');
-
-async function listLanguageServerProcesses() {
- const command = [
- 'powershell -NoProfile -Command',
- '"Get-CimInstance Win32_Process -Filter \\"name like \'language_server%\'\\"',
- '| Select-Object ProcessId,ParentProcessId,CommandLine,ExecutablePath',
- '| ConvertTo-Json -Depth 2"'
- ].join(' ');
- const result = execSync(command, { encoding: 'utf8' });
- return JSON.parse(result);
-}
-
-function extractArgument(commandLine, argumentName) {
- const escapedName = argumentName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
- const pattern = new RegExp(`--${escapedName}(?:=|\\s+)(?:"([^"]*)"|'([^']*)'|([^\\s]+))`, 'i');
- const match = commandLine.match(pattern);
- return match ? (match[1] ?? match[2] ?? match[3] ?? null) : null;
-}
-
-const API_PATH = '/exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary';
-const requestBody = JSON.stringify({ metadata: { ideName: 'antigravity', extensionName: 'ag-usage', locale: 'en' } });
-
-function tryPort(port, csrfToken, protocol) {
- return new Promise(resolve => {
- const client = protocol === 'https' ? https : http;
- const req = client.request({
- hostname: '127.0.0.1', port, path: API_PATH, method: 'POST',
- ...(protocol === 'https' ? { rejectUnauthorized: false } : {}),
- headers: {
- 'X-Codeium-Csrf-Token': csrfToken,
- 'Connect-Protocol-Version': '1',
- 'Content-Type': 'application/json',
- 'Content-Length': Buffer.byteLength(requestBody),
- },
- timeout: 3000,
- }, res => {
- let body = '';
- res.setEncoding('utf8');
- res.on('data', chunk => body += chunk);
- res.on('end', () => resolve({ port, statusCode: res.statusCode, body }));
- });
- req.on('error', () => resolve(null));
- req.write(requestBody);
- req.end();
- });
-}
-
-(async () => {
- const processes = await listLanguageServerProcesses();
- let procs = Array.isArray(processes) ? processes : (processes ? [processes] : []);
- let port, csrfToken, protocol;
- for (const proc of procs) {
- if (!proc.CommandLine) continue;
- const p = extractArgument(proc.CommandLine, 'api_server_port');
- const c = extractArgument(proc.CommandLine, 'csrf_token');
- if (p && c) {
- port = p; csrfToken = c;
- protocol = proc.CommandLine.includes('--api_server_protocol=https') ? 'https' : 'http';
- break;
- }
- }
- if (!port) return console.log('not found');
- const response = await tryPort(port, csrfToken, protocol);
- console.log(response.body);
-})();
diff --git a/update_index.js b/update_index.js
deleted file mode 100644
index e834c5b..0000000
--- a/update_index.js
+++ /dev/null
@@ -1,36 +0,0 @@
-const fs = require('fs');
-let html = fs.readFileSync('public/index.html', 'utf8');
-
-const generateRow = (id, icon, name) => `
-
-
-
- ${icon}
- ${name}
-
-
-
- 0%
- Loading...
-
-
-
-
`;
-
-const newSection = `
-${generateRow('poe', '🧠', 'POE')}
-${generateRow('ag-gemini-5h', '🤖', 'AG Gemini (5h)')}
-${generateRow('ag-gemini-weekly', '🤖', 'AG Gemini (Weekly)')}
-${generateRow('ag-claude-5h', 'âš¡', 'AG Claude (5h)')}
-${generateRow('ag-claude-weekly', 'âš¡', 'AG Claude (Weekly)')}
-${generateRow('minimax-5h', '🔥', 'MiniMax (5h)')}
-${generateRow('minimax-weekly', '🔥', 'MiniMax (Weekly)')}
- `;
-
-html = html.replace(/[\s\S]*?<\/section>/, newSection);
-fs.writeFileSync('public/index.html', html);
-console.log('updated index.html');