/** * Durable pending-event buffer for telemetry that failed to send. * * Note on scope: this buffer handles Optimus backend unavailability, not * general internet connectivity loss. If the developer is fully offline, * the AI agent itself cannot reach its API, so no tool calls are generated * and hooks never fire — there is nothing to buffer. The realistic failure * modes this covers are: Optimus backend deploying or restarting mid-session, * transient 5xx errors, and network path issues specific to app.optimuslabs.io * while the AI API endpoint remains reachable. * * On network failure or 5xx, events are appended as JSONL to * ~/opt-ai-sec/management/telemetry/pending_events.jsonl. * On the next hook invocation, drainPendingEvents() atomically claims that * file (via rename) so a concurrent hook process won't double-send the same * batch. */ import type { TelemetryEvent } from "./telemetry.js"; /** * Resolve the telemetry directory at call time so that tests can override it * by setting OPTIMUS_TELEMETRY_DIR before calling any function. */ export declare function getPendingDir(): string; export declare function getPendingFile(): string; export declare function getClientErrorsFile(): string; /** * Append events to the pending file for retry on the next hook invocation. * Used for network failures and transient server errors (5xx). */ export declare function appendPendingEvents(events: TelemetryEvent[]): void; /** * Log events that failed with a 4xx HTTP error. * These are not retried — the request was malformed or rejected by the server. * Each line is a JSON object with the HTTP status, timestamp, and original event. */ export declare function appendClientErrors(events: TelemetryEvent[], httpStatus: number): void; /** * Atomically claim and parse the pending file. * Uses rename so two concurrent hook processes never read the same batch. * Returns [] if the file does not exist or cannot be read. * * Crash safety: if `pending_events.jsonl` is missing but `pending_events.jsonl.draining` * exists (process died after rename, before successful read), the draining file is moved * back to the pending path and processed normally. If read/unlink fails after claim, the * batch is renamed back to `pending_events.jsonl` so it can be retried instead of being * stranded under `.draining`. */ export declare function drainPendingEvents(): TelemetryEvent[]; //# sourceMappingURL=pending-events.d.ts.map