diff --git a/src/cli/output-utils.ts b/src/cli/output-utils.ts index 2989191..637cd74 100644 --- a/src/cli/output-utils.ts +++ b/src/cli/output-utils.ts @@ -16,6 +16,12 @@ export function printCallOutput(wrapped: CallResult, raw: T, format: Outpu if (jsonValue !== null && attemptPrintJson(jsonValue)) { return; } + // Still output valid JSON even when json() couldn't extract a typed payload. + // Falling through to printRaw() would emit util.inspect() output which is not + // valid JSON and breaks programmatic consumers. + if (attemptPrintJson(raw)) { + return; + } printRaw(raw); return; }