Unified Client (@xtnd/vantage)
Package:
@xtnd/vantage
Source Directory:xtnd-vantage/packages/vantage/
1. Overview
@xtnd/vantage is the developer-facing umbrella package that bundles and configures all seven modular sub-packages into a single ergonomic client facade: VantageClient.
It provides:
- Automatic initialization of the event bus, storage manager, and transports.
- Environment-aware storage selection (
IndexedDBStorageAdapterin browsers,MemoryStorageAdapterin Node/Workers). - A pre-instantiated global singleton:
vantage. - Universal re-exports of all underlying types and utilities.
2. The VantageClient Architecture
export interface VantageClientOptions {
/** Ingestion API endpoint (defaults to local memory buffer if undefined) */
endpoint?: string;
/** API Key or Bearer Token for authenticated ingestion */
apiKey?: string;
/** Force use of browser IndexedDB storage (defaults to true in browser) */
useIndexedDB?: boolean;
/** Automatically start the background batch sync interval (default: true) */
autoSync?: boolean;
/** Interval in milliseconds between batch flushes (default: 10,000ms) */
syncIntervalMs?: number;
}
Initialized Subsystems
When instantiated, VantageClient wires up all internal components:
export class VantageClient {
public bus: VantageEventBus;
public storageManager: VantageStorageManager;
public sonar: VantageAIQuotaTracker;
public radar: VantageBrowserDispatcher;
public sentinel: VantageCircuitBreaker;
public aegis: VantageStatusProbe;
public edgeInterceptor: VantageEdgeInterceptor;
}
3. Usage Examples
3.1 Using the Pre-Configured Global Singleton
import { vantage } from '@xtnd/vantage';
// 1. Dispatch page load telemetry
vantage.radar.initPage({ appName: 'X360 Task Command' });
// 2. Track AI quota spend
vantage.sonar.updateQuota({
provider: 'anthropic',
monthlyLimitUsd: 2000,
currentSpendUsd: 840.50,
billingRenewsAt: '2026-10-01T00:00:00Z',
});
// 3. Guard agent execution
if (vantage.sentinel.canExecute()) {
runAutonomousAgent();
}
3.2 Custom Production Initialization
import { VantageClient } from '@xtnd/vantage';
const client = new VantageClient({
endpoint: 'https://api.vantage.xgi.io',
apiKey: process.env.VANTAGE_API_KEY,
useIndexedDB: true,
syncIntervalMs: 5000, // 5-second flushes
});
// Access the underlying event bus
client.bus.on('*', (event) => {
console.log(`[Vantage Event] ${event.type} (Priority: ${event.priority})`);
});