Skip to content

Commit 342bf48

Browse files
committed
fix(cli): preserve json stdout while keeping doctor migration (#24368) (thanks @altaywtf)
1 parent 67b9813 commit 342bf48

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Docs: https://docs.openclaw.ai
126126
- Discord/Application ID fallback: parse bot application IDs from token prefixes without numeric precision loss and use token fallback only on transport/timeout failures when probing `/oauth2/applications/@me`. Landed from contributor PR #29695 by @dhananjai1729. Thanks @dhananjai1729.
127127
- Discord/EventQueue timeout config: expose per-account `channels.discord.accounts.<id>.eventQueue.listenerTimeout` (and related queue options) so long-running handlers can avoid Carbon listener timeout drops. Landed from contributor PR #28945 by @Glucksberg. Thanks @Glucksberg.
128128
- CLI/Cron run exit code: return exit code `0` only when `cron run` reports `{ ok: true, ran: true }`, and `1` for non-run/error outcomes so scripting/debugging reflects actual execution status. Landed from contributor PR #31121 by @Sid-Qin. Thanks @Sid-Qin.
129+
- CLI/JSON preflight output: keep `--json` command stdout machine-readable by suppressing doctor preflight note output while still running legacy migration/config doctor flow. (#24368) Thanks @altaywtf.
129130
- Nodes/Screen recording guardrails: cap `nodes` tool `screen_record` `durationMs` to 5 minutes at both schema-validation and runtime invocation layers to prevent long-running blocking captures from unbounded durations. Landed from contributor PR #31106 by @BlueBirdBack. Thanks @BlueBirdBack.
130131
- Telegram/Empty final replies: skip outbound send for null/undefined final text payloads without media so Telegram typing indicators do not linger on `text must be non-empty` errors, with added regression coverage for undefined final payload dispatch. Landed from contributor PRs #30969 by @haosenwang1018 and #30746 by @rylena. Thanks @haosenwang1018 and @rylena.
131132
- Telegram/Proxy dispatcher preservation: preserve proxy-aware global undici dispatcher behavior in Telegram network workarounds so proxy-backed Telegram + model traffic is not broken by dispatcher replacement. Landed from contributor PR #30367 by @Phineas1500. Thanks @Phineas1500.

src/cli/program/config-guard.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,19 @@ export async function ensureConfigReady(params: {
5252
if (!params.suppressDoctorStdout) {
5353
await runDoctorConfigFlow();
5454
} else {
55-
const originalStdoutWrite = process.stdout.write;
56-
process.stdout.write = ((() => true) as unknown) as typeof process.stdout.write;
55+
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
56+
const originalSuppressNotes = process.env.OPENCLAW_SUPPRESS_NOTES;
57+
process.stdout.write = (() => true) as unknown as typeof process.stdout.write;
58+
process.env.OPENCLAW_SUPPRESS_NOTES = "1";
5759
try {
5860
await runDoctorConfigFlow();
5961
} finally {
6062
process.stdout.write = originalStdoutWrite;
63+
if (originalSuppressNotes === undefined) {
64+
delete process.env.OPENCLAW_SUPPRESS_NOTES;
65+
} else {
66+
process.env.OPENCLAW_SUPPRESS_NOTES = originalSuppressNotes;
67+
}
6168
}
6269
}
6370
}

src/terminal/note.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ const URL_PREFIX_RE = /^(https?:\/\/|file:\/\/)/i;
66
const WINDOWS_DRIVE_RE = /^[a-zA-Z]:[\\/]/;
77
const FILE_LIKE_RE = /^[a-zA-Z0-9._-]+$/;
88

9+
function isSuppressedByEnv(value: string | undefined): boolean {
10+
if (!value) {
11+
return false;
12+
}
13+
const normalized = value.trim().toLowerCase();
14+
if (!normalized) {
15+
return false;
16+
}
17+
return normalized !== "0" && normalized !== "false" && normalized !== "off";
18+
}
19+
920
function splitLongWord(word: string, maxLen: number): string[] {
1021
if (maxLen <= 0) {
1122
return [word];
@@ -130,5 +141,8 @@ export function wrapNoteMessage(
130141
}
131142

132143
export function note(message: string, title?: string) {
144+
if (isSuppressedByEnv(process.env.OPENCLAW_SUPPRESS_NOTES)) {
145+
return;
146+
}
133147
clackNote(wrapNoteMessage(message), stylePromptTitle(title));
134148
}

0 commit comments

Comments
 (0)