Monitor Antigravity session token usage and review session activity in a dashboard.
Antigravity Token Monitor is a VS Code extension that automatically collects, analyzes, and visualizes token usage across your Antigravity coding sessions. It connects to the running Antigravity process via internal RPC, exports token metadata as local JSONL artifacts, and presents the data through a rich Svelte-powered dashboard and a persistent status bar indicator.
- π₯ Real-time Token Tracking β Automatically monitors token usage across all Antigravity sessions
- π°οΈ Historical Session Recovery β Recovers session data that existed before the extension was started by directly querying the RPC server for sessions missing from the active list
- π Interactive Dashboard β Svelte-based webview with KPI cards, heatmaps, model usage tables, and session leaderboards
- π Sidebar Overview β Activity Barμ μμ£Όνλ λ―Έλ λμ보λ (KPI, ν ν° λΈλ μ΄ν¬λ€μ΄, λͺ¨λΈ μ¬μ©λ, 30μΌ ννΈλ§΅, μΈμ 리μ€νΈ)
- π° Cost Estimation β Per-model cost calculation using LiteLLM open-source pricing data
- π·οΈ Model Breakdown β Per-model token breakdown (input, output, cache read/write, reasoning) with automatic resolution of internal model placeholder IDs
- π Activity Heatmap β 180-day activity visualization showing daily token usage and cost patterns
- π RPC Export β Periodically exports session data from the Antigravity RPC server into local JSONL artifacts
- π Multi-instance Safety β File-based locking prevents duplicate refresh/export across multiple VS Code windows
- β±οΈ Refresh Countdown β Visual countdown timer with circular progress ring showing time until the next auto-refresh
- π₯οΈ Status Bar β Always-visible total token count in the VS Code status bar
Warning
- This is an unofficial, community-driven project and is not affiliated with or endorsed by Google.
- The extension relies on undocumented internal RPC endpoints of the Antigravity process. These may change or break without notice in any Antigravity update.
- Token counts labeled as "estimated" are heuristic approximations (
text length Γ· 4) and may differ significantly from actual usage. - Cost estimates are based on LiteLLM's open-source pricing data and may not reflect your actual billing. Do not use these values for financial decisions.
- The extension makes local HTTPS requests to
127.0.0.1to communicate with the Antigravity process. No data is sent to external servers (except fetching the LiteLLM pricing JSON from GitHub). - When
exportStepsJsonlis enabled, conversation content that Antigravity normally stores encrypted will be exported as plain-text JSONL and cached on your local machine (~/.gemini/antigravity/.token-monitor/). Be aware that this may expose sensitive conversation data in an unencrypted form.
- VS Code
β₯ 1.96.0 - Node.js
β₯ 18 - A running Antigravity instance (the extension auto-detects the process)
# Clone the repository
git clone https://github.com/user/antigravity-token-monitor.git
cd antigravity-token-monitor
# Install dependencies
npm install
# Compile the extension
npm run compile
# Or watch for changes during development
npm run watchThen press F5 in VS Code to launch the Extension Development Host.
- Open the Command Palette (
Cmd+Shift+P/Ctrl+Shift+P) - Run
Antigravity Token Monitor: Open Dashboard - The dashboard opens in a webview panel, displaying token usage data
You can also click the token counter in the status bar to open the dashboard.
Sidebar: Activity Barμ κ·Έλν μμ΄μ½μ ν΄λ¦νλ©΄ μ¬μ΄λλ°μ ν ν° μ¬μ©λ μμ½μ΄ νμ νμλ©λλ€.
| Command | Description |
|---|---|
Antigravity Token Monitor: Open Dashboard |
Open the token monitoring dashboard |
Antigravity Token Monitor: Refresh Now |
Trigger an immediate data refresh |
Antigravity Token Monitor: Export Sessions Now |
Force-export all sessions and display the count |
Antigravity Token Monitor: Reset Cache |
Delete all cached data and re-process from scratch |
All settings are under antigravity-token-monitor.* in VS Code settings.
| Setting | Default | Description |
|---|---|---|
sessionRoot |
~/.gemini/antigravity |
Override the Antigravity session root directory |
pollIntervalMs |
60000 |
How often the extension rescans sessions (ms) |
historyLimit |
120 |
Max snapshots to keep per session |
| MS: | maxFileBytes |
10485760 (10MB) |
| WR: | useRpcExport |
true |
| BS: | exportStepsJsonl |
false |
| NR: | rpcExportIntervalMs |
300000 |
| SK: | rpcTimeoutMs |
5000 |
See docs/ISSUES.md for known issues and solutions.
The extension follows a layered pipeline architecture:
Data Acquisition β Analysis β Orchestration β Presentation
Data Acquisition: The ProcessLocator detects the running Antigravity language_server process, the AntigravityRpcClient fetches token metadata via HTTPS RPC, and the TrajectoryExporter serializes it into local usage.jsonl files. Sessions not found in the active RPC list are recovered via direct fallback queries, enabling historical session data collection even for sessions that existed before the extension was started. The modelAliases module resolves internal model placeholder IDs (MODEL_PLACEHOLDER_*) to human-readable names.
Analysis: The SessionScanner enumerates session directories, the AntigravitySessionParser extracts token counts (either from structured usage records or text-based estimation), and the LiteLlmPricingCatalog calculates per-model costs.
Orchestration: The TokenMonitorService coordinates periodic polling, RPC exports, and event emission with debounced updates. A file-based PollLock mechanism prevents duplicate processing when multiple VS Code instances are running.
Presentation: The TokenStatusBar shows a persistent token count, the DashboardPanel renders a Svelte webview with 13 UI components including KPI strips, heatmaps, model tables, session leaderboards, and a real-time refresh countdown timer, and the SidebarViewProvider renders a compact WebviewView in the Activity Bar with 6 sidebar-optimized components (KPI, token mix, model usage, mini heatmap, session list, sync status).
For a detailed breakdown, see docs/architecture.md in this repository.
src/
βββ extension.ts # Extension entry point
βββ config.ts # Configuration reader
βββ types.ts # Shared type definitions
βββ modelAliases.ts # Model placeholder ID β name resolution
βββ rpc/ # Data acquisition (RPC layer)
βββ monitor/ # Scanning, analysis, orchestration
β βββ pollLock.ts # File-based lock for multi-instance safety
βββ parser/ # Token parsing (reported/estimated)
βββ pricing/ # LiteLLM-based cost estimation
βββ storage/ # Persistence (artifacts + snapshots)
βββ statusBar/ # VS Code status bar
βββ webview/ # Svelte UI
βββ components/ # 13 dashboard components
βββ sidebar/ # Sidebar mini-dashboard
β βββ components/ # 6 sidebar-optimized components
β βββ SidebarApp.svelte # Sidebar root
β βββ main.ts # Sidebar entry point
β βββ sidebarApi.ts # Sidebar β extension messaging
βββ sidebarViewProvider.ts # WebviewViewProvider for Activity Bar
βββ getSidebarHtml.ts # Sidebar HTML shell
βββ lib/ # Shared stores, formatters, utilities
# Compile
npm run compile
# Watch mode
npm run watch
# Type check (extension)
npm run typecheck
# Type check (webview)
npm run typecheck:webview
# Run webview tests
npm run test:webview| Layer | Technology |
|---|---|
| Extension | TypeScript, Node.js |
| Webview UI | Svelte 5 |
| Bundler | esbuild + esbuild-svelte |
| Testing | Vitest, Testing Library |
- Process Detection β Finds the Antigravity
language_serverprocess viapsand extracts its CSRF token and port - RPC Communication β Calls
GetCascadeTrajectoryGeneratorMetadatato fetch per-session token usage metadata - Historical Recovery β Sessions missing from the active RPC list are queried directly using file-system session IDs as a fallback, recovering data from sessions that existed before the extension was started
- Model Resolution β Internal model placeholder IDs (
MODEL_PLACEHOLDER_*) are resolved to human-readable names via a static mapping, withresponseModelfields taking priority when available - JSONL Serialization β Normalizes metadata into
usage.jsonlrecords stored under.token-monitor/rpc-cache/ - Token Parsing β Extracts model-specific token breakdowns (input, output, cache, reasoning) from structured records, or estimates from text length as fallback
- Cost Calculation β Matches models against LiteLLM's open-source pricing catalog to compute USD costs
- Visualization β Renders data in the status bar, a sidebar mini-dashboard (Activity Bar), and a full Svelte webview dashboard with a real-time refresh countdown
- antigravity-storage-manager β Session token parsing approach
- tokscale β Token usage tracking and visualization
This project is licensed under the MIT License.
