Files
antigravity-usage-monitor/sidecars/panel/src/main.js
T
fish 76669d5cc7 feat(panel): add standalone Web monitor mode and full Antigravity CLI 1.5.9 telemetry support
- Add zero-SDK standalone HTTP server (`standalone.mjs` / `standalone-server.mjs`) with responsive centered Web shell, `127.0.0.1` default loopback guard, mandatory `--token` enforcement on non-loopback binds (`HttpOnly; SameSite=Strict` cookie + `Bearer` auth), and optional background auto-hosting via `standalonePort` / `USAGE_MONITOR_STANDALONE_PORT`.
- Extend multi-root data discovery across `~/.gemini/antigravity` and `~/.gemini/antigravity-cli`, plus `daemon/hub_*.json` and `/proc` + `ss` Language Server endpoint discovery on minimal headless Linux hosts without `lsof`.
- Add read-only `node:sqlite` + lightweight protobuf wire reader (`cli-sqlite-reader.mjs`) to recover CLI session titles (`annotations/*.pbtxt` & `conversation_summaries.db`), nanosecond request duration/TPS, native TTFT, thinking/response token split, 10-channel context breakdown, and `Antigravity CLI` source attribution.
- Add regression tests (124 passing) and bilingual CLI / SSH tunnel / `--token` documentation in `README.zh-CN.md` and `README.md`.

Closes #18
2026-11-16 02:28:34 +09:00

67 lines
1.9 KiB
JavaScript

/**
* @fileoverview Async entry point for Antigravity Usage & Speed Monitor.
* Automatically branches between Auxiliary Sidebar Webview mode (`#app-root`)
* and Main Window Dual-Mount Overlay mode (`window.__AGUsageMonitorBridge`).
*/
import { App } from './App.js';
import { mountWindowOverlay } from './components/layout/WindowOverlayShell.js';
import { applyAppearanceToRoot } from './core/appearance.js';
import { isWindowOverlayMode } from './core/httpClient.js';
import { setI18nLanguage } from './i18n/index.js';
import { startAsyncTelemetryLoop, telemetryStore } from './store/telemetryStore.js';
async function bootstrapApp(mountTarget = document.getElementById('app-root')) {
if (!mountTarget) return null;
const appInstance = App();
mountTarget.appendChild(appInstance.el);
const unsubAppearance = telemetryStore.subscribe(
(st) => st.telemetry?.settings,
(settings) => {
setI18nLanguage(settings?.language);
if (typeof document !== 'undefined' && document.documentElement) {
applyAppearanceToRoot(document.documentElement, settings, { includeFontScale: true });
}
}
);
const stopPolling = startAsyncTelemetryLoop(2000);
return {
appInstance,
stopPolling: () => {
unsubAppearance();
stopPolling();
},
};
}
function startEntry() {
if (isWindowOverlayMode()) {
mountWindowOverlay();
return;
}
if (
typeof window !== 'undefined' &&
!window.sidecar?.fetch &&
typeof document !== 'undefined' &&
document.documentElement
) {
document.documentElement.setAttribute('data-standalone', 'true');
}
bootstrapApp();
}
function init() {
if (typeof document === 'undefined') return;
if (document.readyState === 'loading' && typeof document.addEventListener === 'function') {
document.addEventListener('DOMContentLoaded', () => {
startEntry();
});
} else {
startEntry();
}
}
init();