Files
antigravity-usage-monitor/sidecars/panel/shared/window-bridge-protocol.mjs
T
hejun01 253da45607 feat(panel): support SSH remote windows with per-endpoint isolation and context window overrides
- Add per-endpoint registry and isolated caches (endpoint-registry.mjs, multi-path trajectory-cache-file.mjs) so local and SSH remote windows maintain independent conversations, telemetry, quotas, and consumption analytics (Antigravity SSH) without remote plugin installation
- Classify local vs. SSH Desktop targets via two-pass hub port and metadata probing in window-bridge.mjs and ls-discovery.mjs, routing HTTP/CDP requests with authoritative X-Usage-Monitor-Endpoint headers and preventing local data leaks or 503-triggered CDP downgrades
- Implement two-tier read-only remote LS RPC transport in ls-rpc.mjs (loopback HTTP/HTTPS with size/wall-clock limits and 60s circuit breaker falling back to stateless same-origin window.fetch / connect-websocket via CDP)
- Enable per-endpoint verified context window overrides in SSH Desktop windows (context-windows.mjs, window-bridge.mjs, api-actions.mjs) without double-wrapping window.fetch
- Surface an SSH badge in TopSessionHeader, cleanly flush stale requests/queues on endpoint rebind, rebuild app.js/styles.css, and add 13 unit/E2E tests in test/ssh-remote-endpoints.test.mjs (157/157 passing)
2026-11-20 11:41:39 +08:00

38 lines
1.8 KiB
JavaScript

export const WINDOW_BRIDGE_KEY = '__AGUsageMonitorBridge';
export const WINDOW_BRIDGE_ROUTE_KEY = 'hostRouteCascadeId';
export const WINDOW_BRIDGE_ENDPOINT_KEY = 'endpointId';
export const WINDOW_BRIDGE_ENDPOINT_HEADER = 'X-Usage-Monitor-Endpoint';
export const LOCAL_ENDPOINT_ID = 'local';
export const WINDOW_OVERLAY_KEY = '__AGUsageMonitorOverlay';
export const CONTEXT_WINDOWS_GLOBAL_KEY = '__AGUsageMonitorContextWindows';
export const WINDOW_OVERLAY_METHODS = Object.freeze({
ensureAlive: 'ensureAlive',
getDockKind: 'getDockKind',
getMountMode: 'getMountMode',
updateBridge: 'updateBridge',
applyMountMode: 'applyMountMode',
syncHostRoute: 'syncHostRoute',
deliverRpc: 'deliverRpc',
dispose: 'dispose',
});
export const BRIDGE_API_ROUTE_DEFS = Object.freeze([
Object.freeze({ path: '/api/telemetry', method: 'GET', action: 'telemetry' }),
Object.freeze({ path: '/api/settings', method: 'POST', action: 'settings' }),
Object.freeze({ path: '/api/accounts', method: 'GET', action: 'accounts_get' }),
Object.freeze({ path: '/api/accounts/update', method: 'POST', action: 'accounts_update' }),
Object.freeze({ path: '/api/context-window', method: 'POST', action: 'context_window' }),
Object.freeze({ path: '/api/settings/reset', method: 'POST', action: 'settings_reset' }),
Object.freeze({ path: '/api/cache/rebuild', method: 'POST', action: 'cache_rebuild' }),
Object.freeze({ path: '/api/cloud-sync', method: 'POST', action: 'cloud_sync' }),
Object.freeze({ path: '/api/plugin-update', method: 'POST', action: 'plugin_update' }),
Object.freeze({ path: '/api/bridge/relaunch', method: 'POST', action: 'bridge_relaunch' }),
]);
export const BRIDGE_API_PATHS = Object.freeze(BRIDGE_API_ROUTE_DEFS.map((r) => r.path));
export function readInjectedWindowBridge() {
return typeof window === 'undefined' ? undefined : window[WINDOW_BRIDGE_KEY];
}