/** * LAFS-compliant output formatter for CLEO V2. * * LAFS (LLM-Agent-First Schema) ensures all CLI output is * machine-parseable JSON by default, with optional human-readable modes. * * All envelopes use the canonical CLI envelope shape: * { success, data?, error?, meta, page? } * * This replaces the three legacy shapes: * {ok, r, _m} (minimal MVI — removed) * {$schema, _meta, success, result} (full LAFS — now uses meta/data) * {success, result} (observe command — now uses data) * * Types are re-exported from the canonical source in src/types/lafs.ts. * * @epic T4663 * @task T4672 * @task T338 (ADR-039 envelope unification) */ import type { LafsEnvelope, LafsError, LafsSuccess } from '@cleocode/contracts'; import type { CliEnvelope, CliEnvelopeError, CliMeta, LAFSPage, Warning } from '@cleocode/lafs'; import { CleoError } from './errors.js'; export type { CliEnvelope, CliEnvelopeError, CliMeta, LafsEnvelope, LafsError, LafsSuccess }; /** * Push a deprecation or informational warning into the current envelope. * Warnings are drained (consumed) by the next formatSuccess/formatError call. * * @task T4669 * @epic T4663 */ export declare function pushWarning(warning: Warning): void; /** * Drain all pending warnings — both the legacy module-global queue (CORE * pushWarning) and any active ALS-bound WarningCollector (LAFS pushWarning). * * @returns Combined warning list, or `undefined` when neither source produced * any entries. * * @remarks * Two carriers must be merged transitionally because: * - The legacy `pendingWarnings` array is module-global and race-prone, but * is still used by several deprecation paths (T4669 et al.). * - The new {@link import('@cleocode/lafs').WarningCollector} is bound per * request via {@link import('@cleocode/lafs').withWarningCollector} from * the CLI entrypoint (T9769), so it correctly isolates concurrent commands. * * Subsequent waves of T9763 migrate every legacy producer to the ALS carrier; * the legacy queue can be removed once that sweep is complete. Until then, * this function is the single source of truth for what lands in * `meta.warnings[]`. * * Exported (T9772) so renderers in `@cleocode/cleo` that build their own * envelopes via `cliOutput` / `cliError` (instead of going through * `formatSuccess` / `formatError`) can attach queued warnings to `meta.warnings[]` * without duplicating the pending-queue state. * * @task T4669 * @task T9769 * @task T9772 * @epic T9763 */ export declare function drainWarnings(): Warning[] | undefined; /** * Options for envelope formatting. * * @task T4668 * @task T4670 * @epic T4663 */ export interface FormatOptions { operation?: string; page?: LAFSPage; extensions?: Record; /** MVI level to embed in the envelope _meta. Defaults to 'standard'. @task T4957 */ mvi?: import('@cleocode/lafs').MVILevel; } /** * Format a successful result as a canonical CLI envelope. * * Produces the unified `CliEnvelope` shape: `{success, data, meta, page?}`. * This replaces all three legacy shapes (minimal `{ok,r,_m}`, full `{$schema,_meta,result}`, * and observe `{success,result}`) with a single canonical format (ADR-039). * * The `mvi` option in `FormatOptions` is accepted for backward compatibility but * no longer affects the envelope shape — the canonical shape is always emitted. * * @param data - The operation result payload. * @param message - Optional success message (attached to `meta.message`). * @param operationOrOpts - Operation name string or `FormatOptions` object. * @returns JSON-serialized `CliEnvelope`. * * @task T4672 * @task T4668 * @task T4670 * @task T338 * @task T11420 * @epic T4663 */ export declare function formatSuccess(data: T, message?: string, operationOrOpts?: string | FormatOptions): string; /** * Format an error as a canonical CLI error envelope. * * Produces `{success: false, error: CliEnvelopeError, meta: CliMeta}`. * Every error envelope now always includes `meta` (ADR-039). * When operation is omitted, defaults to `'cli.output'`. * * @param error - The `CleoError` to format. * @param operation - Optional dot-delimited operation identifier. * @returns JSON-serialized error `CliEnvelope`. * * @task T4672 * @task T338 * @task T11420 * @epic T4663 */ export declare function formatError(error: CleoError, operation?: string): string; /** Format any result (success or error) as LAFS JSON. */ export declare function formatOutput(result: T | CleoError): string; //# sourceMappingURL=output.d.ts.map