import { type Command, type Registry } from "@cotal-ai/core"; import { type ErrorCode, type Outcome } from "@cotal-ai/workspace"; /** * Anonymous usage telemetry for the CLI: one small event per command, sent as the process exits, and * at `regular` one install event per UTC day. docs/telemetry.md lists every field. Nothing here * reads an argument value, a path or a name; the error text a failure carries at `regular` goes * through {@link scrubErrorText} first. Nothing here can change a command's outcome: every failure * is swallowed, and the send is bounded by {@link SEND_TIMEOUT_MS}. */ export declare const TELEMETRY_URL = "https://cotal.ai/v1/telemetry"; export declare const SEND_TIMEOUT_MS = 1500; export declare const TELEMETRY_NOTICE = "Cotal collects anonymous usage data at the \"regular\" level (command names, outcomes, error text with values and paths masked, version, OS, installed connectors; never arguments, paths, names or content). Change it with \"cotal telemetry minimal\" or \"cotal telemetry off\". Details: https://docs.cotal.ai/telemetry"; /** An error message with what could identify someone masked: quoted words (the CLI quotes every * user value it echoes), URLs, email addresses, IPv4 addresses, paths (the home directory first, * so a path under it reads as one) and any token-shaped run of 32 characters or more. */ export declare function scrubErrorText(text: string, max?: number): string; /** The frames of a stack with every file path cut down to its part inside `node_modules` (the * installed package and file, never the directory it is installed under); a frame outside one is * ``. The first line, the message, is not part of it. */ export declare function scrubStack(stack: string): string; /** The intake: the public one, or `COTAL_TELEMETRY_URL` for a self-hosted intake. */ export declare function telemetryUrl(env?: NodeJS.ProcessEnv): string; /** The names of the flags in `words`, values stripped: `--server=x` and `--server x` both read as * `--server`, and a word after `--` is text. An unknown flag counts by name too. */ export declare function flagNames(cmd: Command, words: readonly string[]): string[]; /** * The account hash sent at `regular`: sha256 of the IdP URL and the subject id of this home's * cached sign-in, cut to 32 hex characters, so one person counts once across machines and * workspaces. The id itself is never sent. `null` with no cached sign-in, and on any read problem; * with several sign-ins, the first by IdP URL. */ export declare function accountHash(): string | null; /** Record the typed failure the kernel is exiting with, so the event carries its code, and its * text unless {@link recordTelemetryError} already recorded the error it was classified from. */ export declare function recordTelemetryFailure(outcome: Outcome, code: ErrorCode, error?: unknown): void; /** Record the error a command threw, once: the first one recorded is the original, and a wrapper * the kernel builds from it afterwards does not replace it. */ export declare function recordTelemetryError(error: unknown): void; /** * Arm the exit hook for `cmd`, once: decide the level, print the one-time notice, and register the * send on `exit`, which fires for a normal return, a set exit code, `process.exit()` anywhere and an * uncaught failure. Throws the typed refusal of a bad `COTAL_TELEMETRY` or settings file; the kernel * reports it as it reports any refusal. */ export declare function armTelemetry(registry: Registry, cmd: Command, words: readonly string[], startedAt: number): void; /** Post each body to `url`, blocking the calling thread for at most {@link SEND_TIMEOUT_MS}. */ export declare function sendTelemetry(url: string, bodies: readonly string[]): void; //# sourceMappingURL=telemetry.d.ts.map