import { Jsonifiable } from "type-fest"; //#region src/cli/shared/error-json.d.ts export interface ErrorToJsonOptions { /** Include the original stack trace in the error envelope. */ includeStack?: boolean; } /** * Convert a CLI failure into the stable JSON error envelope. * @param error - Failure to serialize * @param options - JSON serialization options * @returns JSON-compatible error envelope */ export declare function errorToJson(error: unknown, options?: ErrorToJsonOptions): { error: Readonly>; }; /** * Serialize a CLI failure into the stable JSON error envelope. * * Redacts registered secrets from every string, number, boolean, and `null` *value* in the * envelope, however deeply nested, before this function's own `JSON.stringify` call, rather * than relying only on the redaction `logger.log()` does on the final string: an upstream * error message (or `error.context`, an arbitrary record) can already embed a secret in * JSON-escaped form (e.g. echoed back inside a JSON API error body), and stringifying the * envelope would escape that a second time, no longer matching a registered secret's * single-level-escaped form. Redacting non-string bare tokens here also matters because the * later, structure-unaware `redactSecrets()` pass over the fully rendered JSON text cannot * tell a bare token apart from a JSON string, so a secret whose value coincides with an * unrelated number/boolean/`null` elsewhere in the envelope would otherwise become an * unquoted `` and break the output as JSON. * * Does not cover a secret used as an object *key* (e.g. `context: { [secret]: true }`) — * `JSON.stringify`'s replacer can only transform values, never rename keys. No current * caller does this (`context` keys are always fixed, SDK-chosen strings), and the CLI's own * `logger.log(serializeError(...))` call site is still protected regardless, since that * redaction pass re-scans the fully rendered JSON text and does not distinguish key * position from value position. * @param error - Failure to serialize * @param options - JSON serialization options * @returns Serialized JSON error envelope */ export declare function serializeError(error: unknown, options?: ErrorToJsonOptions): string; //#endregion