UNPKG

aiwg

Version:

Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo

114 lines 4.18 kB
/** * Telemetry Event Schema and In-Memory Store * * Defines the canonical event types emitted by the agent loop, MC conductor, * and ralph launcher. Events are stored in-memory per session and forwarded * to the browser via WebSocket push. Persisted to fortemi-react IndexedDB * on the browser side (#717). * * Emission points: * - src/cli/handlers/ralph-launcher.ts → iteration.*, gate.*, tokens.used * - src/cli/handlers/mc.ts → session.*, mission.*, agent.* * * @issue #716 * @see #717 — fortemi-react storage layer (browser) */ export type TelemetryEventType = 'session.start' | 'session.end' | 'mission.dispatch' | 'mission.complete' | 'mission.abort' | 'iteration.start' | 'iteration.complete' | 'gate.pass' | 'gate.fail' | 'tokens.used' | 'agent.spawn' | 'agent.complete' | 'scope.unit.complete' | 'v1.deprecation.observed' | 'v1.dispatch.fallback' | 'a2a.webhook.received'; export interface TelemetryEvent { /** Unique event ID */ id: string; /** PTY / agent session ID */ sessionId: string; /** Mission ID (if event is scoped to a mission) */ missionId?: string; /** ISO 8601 timestamp */ timestamp: string; type: TelemetryEventType; payload: Record<string, unknown>; } /** Payload shapes for well-known event types */ export interface TokensUsedPayload { input: number; output: number; model: string; } export interface IterationCompletePayload { iteration: number; durationMs: number; } export interface GatePayload { criteria: string; result: 'pass' | 'fail'; details?: string; } export interface ScopeUnitPayload { unit: string; total: number; done: number; } export interface AgentPayload { agentId: string; agentType: string; } /** Payload for `v1.dispatch.fallback`. Emitted by the dispatch router when * a v2 A2A `messages:send` returns 404 and we fall back to the executor's * v1 `/dispatch` endpoint. Powers the trend-to-zero check for the * v1 → v2 dispatch migration (#1252 + #1259). */ export interface V1DispatchFallbackPayload { executorId: string; reason: string; sunset?: string; } /** Payload for `v1.deprecation.observed`. Emitted by the A2A HTTP client * whenever it observes a `Sunset` or `Deprecated` header on a v1 * endpoint, deduplicated per (path, sunset) pair. Powers the trend-to-zero * check on the v1 → v2 dispatch migration (#1259). */ export interface V1DeprecationObservedPayload { /** Request path that returned the deprecation headers. */ path: string; /** `Sunset` header value (RFC 8594), if present. */ sunset?: string; /** `Deprecated` header value, if present. */ deprecated?: string; /** Successor URL extracted from `Link: <…>; rel="successor-version"`. */ successor?: string; } export declare class TelemetryStore { private events; private listeners; /** Ingest a new event */ ingest(event: TelemetryEvent): void; /** Get all events for a session, optionally filtered by type */ query(sessionId: string, opts?: { types?: TelemetryEventType[]; limit?: number; since?: string; }): TelemetryEvent[]; /** Get aggregate metrics for a session */ metrics(sessionId: string): SessionMetrics; /** Subscribe to new events (returns unsubscribe fn) */ subscribe(listener: (event: TelemetryEvent) => void): () => void; /** Clear all events for a session */ clear(sessionId: string): void; /** Get all known session IDs */ sessions(): string[]; } export interface SessionMetrics { sessionId: string; totalInputTokens: number; totalOutputTokens: number; tokensByModel: Record<string, { input: number; output: number; }>; iterations: number; gatePasses: number; gateFails: number; passRate: number | null; scopeDone: number; scopeTotal: number; activeAgents: number; } export declare const telemetryStore: TelemetryStore; export declare function createEvent(type: TelemetryEventType, sessionId: string, payload: Record<string, unknown>, missionId?: string): TelemetryEvent; //# sourceMappingURL=telemetry.d.ts.map