/** * Output mode system for non-TTY / JSON support. * * Resolves once at startup, drives output formatting only. * In JSON mode: structured JSON to stdout, structured errors to stderr. * In human mode: chalk-formatted output (existing behavior). */ import { type TableColumn } from './table.js'; import type { RecoveryHints } from './recovery-hints.js'; import type { InteractionModeInfo } from './interaction-mode.js'; export type OutputMode = 'human' | 'json'; /** * Resolve the output mode based on flags and environment. * * Priority: * 1. Explicit --json flag * 2. WORKOS_FORCE_TTY env var → human output compatibility * 3. WORKOS_NO_PROMPT legacy compatibility → json * 4. Non-TTY auto-detection → json * 5. Default → human */ export declare function resolveOutputMode(jsonFlag?: boolean): OutputMode; export declare function resolveEffectiveOutputMode(mode: OutputMode, interaction: InteractionModeInfo): OutputMode; export declare function setOutputMode(mode: OutputMode): void; export declare function getOutputMode(): OutputMode; export declare function isJsonMode(): boolean; /** Write structured JSON to stdout (one line, no pretty-print). */ export declare function outputJson(data: unknown): void; /** Write a success result — chalk in human mode, JSON in json mode. */ export declare function outputSuccess(message: string, data?: object, options?: { warnings?: Array<{ code: string; message: string; }>; }): void; export interface StructuredError { code: string; message: string; details?: unknown; /** * Optional structured recovery metadata for agents. * * Only include for deterministic recovery paths. Human output prints the * first hint as a follow-up line; JSON output serializes the full structure. */ recovery?: RecoveryHints; } /** Write a structured error to stderr. */ export declare function outputError(error: StructuredError): void; /** Write tabular data — chalk table in human mode, JSON array in json mode. */ export declare function outputTable(columns: TableColumn[], rows: string[][], rawData?: unknown[]): void; export declare function exitWithError(error: StructuredError & { apiContext?: { status?: number; code?: string; resource?: string; }; }): never;