/** * Opt-in telemetry writer for openlore. * * Gate: OPENLORE_TELEMETRY=1 (disabled by default). * Records tool calls, agent identity and latency, error messages, decision * titles, and lease events as append-only JSONL under * .openlore/telemetry/.jsonl. * Local only: events are never transmitted; error/module paths are relativized. * Never throws — telemetry must not crash the hot path. * * Rotation: when a domain file exceeds ROTATE_THRESHOLD_BYTES, it is renamed * to .1.jsonl and older rotated files shifted (keeps MAX_ROTATED_FILES). */ /** Number of rotated archive files kept per domain (`.1.jsonl` … `.N.jsonl`). * Exported so readers that must span rotation (e.g. the panic accuracy gate) stay in lockstep. */ export declare const MAX_ROTATED_FILES = 5; /** Shared implementation exported only so separator parity is testable on every OS. */ export declare function _relativizeTelemetryPathsWithPrefixes(value: string, root: string, home: string, caseInsensitive?: boolean): string; /** * Remove local absolute-path disclosure from telemetry fields that carry free * text. Paths under the project become project-relative; paths elsewhere under * the user's home become `~`-relative. Other text is unchanged. */ export declare function relativizeTelemetryPaths(directory: string, value: string): string; export interface TelemetryIdentity { /** Emitting agent (MCP `clientInfo.name`, or `cli:` for CLI runs). */ agent: string; /** Emitting agent's version, `unknown` when the source did not state one. */ agent_version: string; /** Stable for this process, distinct across processes. */ session_id: string; } /** Identity source registered by the host, resolved lazily and at most once. */ type IdentitySource = () => { agent?: string; agentVersion?: string; }; /** * Register the emitting agent directly (MCP servers know it at initialize time). * Re-registering replaces the name but KEEPS the session id: one process is one * session, even if the client identifies itself late. */ export declare function setTelemetryIdentity(agent: string, agentVersion?: string): void; /** * Register a lazy identity source for hosts that only know the agent later (the * CLI derives it from the invoked command). Resolved at most once, on first emit. */ export declare function setTelemetryIdentitySource(source: IdentitySource): void; /** * The identity stamped on every event. Never throws: a source that throws, or one * that yields nothing, degrades to `unknown` — an unattributed event is honest, * a missing event is not. */ export declare function getTelemetryIdentity(): TelemetryIdentity; /** Test seam: forget the resolved identity so a case can register its own. */ export declare function resetTelemetryIdentityForTests(): void; /** * Emit a telemetry event to .openlore/telemetry/.jsonl. * * @param directory - project root (must be absolute) * @param domain - log file name without extension (e.g. 'mcp', 'cache', 'epistemic-lease') * @param payload - arbitrary fields merged with the timestamp */ export declare function emit(directory: string, domain: string, payload: Record): void; export {}; //# sourceMappingURL=telemetry.d.ts.map