fix(cli): keep route-first json stdout clean · openclaw/openclaw@f568972
steipete
·
2026-04-28
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -16,6 +16,7 @@ Docs: https://docs.openclaw.ai
|
16 | 16 | ### Fixes |
17 | 17 | |
18 | 18 | - Channels/Telegram: skip the optional webhook-info API call during polling-mode status checks and startup bot-label probes so long-polling setups avoid an unnecessary Telegram round trip. Carries forward #72990. Thanks @danielgruneberg. |
| 19 | +- CLI/models: keep route-first `models status --json` stdout reserved for the JSON payload by routing auth-profile and startup diagnostics to stderr. Fixes #72962. Thanks @vishutdhar. |
19 | 20 | - Sessions: ignore future-dated session activity timestamps during reset freshness checks and cap future `updatedAt` values at the merge boundary so clock-skewed messages cannot keep stale sessions alive forever. Fixes #72989. Thanks @martingarramon. |
20 | 21 | - Plugins/CLI: allow managed plugin installs when the active extensions root is a symlink to a real state directory, while keeping nested target symlinks blocked and suppressing misleading hook-pack fallback errors for install-boundary failures. Fixes #72946. Thanks @mayank6136. |
21 | 22 | - Gateway/startup: keep hot Gateway boot paths on leaf config imports and add max-RSS reporting to the gateway startup bench so low-memory startup regressions are visible before release. Thanks @vincentkoc. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -111,6 +111,10 @@ Options:
|
111 | 111 | - `--probe-max-tokens <n>` |
112 | 112 | - `--agent <id>` (configured agent id; overrides `OPENCLAW_AGENT_DIR`/`PI_CODING_AGENT_DIR`) |
113 | 113 | |
| 114 | +`--json` keeps stdout reserved for the JSON payload. Auth-profile, provider, |
| 115 | +and startup diagnostics are routed to stderr so scripts can pipe stdout directly |
| 116 | +into tools such as `jq`. |
| 117 | + |
114 | 118 | Probe status buckets: |
115 | 119 | |
116 | 120 | - `ok` |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -93,7 +93,7 @@ describe("tryRouteCli", () => {
|
93 | 93 | expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledWith({ scope: "channels" }); |
94 | 94 | }); |
95 | 95 | |
96 | | -it("routes logs to stderr during plugin loading in --json mode and restores after", async () => { |
| 96 | +it("keeps logs routed to stderr for routed --json commands", async () => { |
97 | 97 | findRoutedCommandMock.mockReturnValue({ |
98 | 98 | loadPlugins: true, |
99 | 99 | run: runRouteMock, |
@@ -110,7 +110,22 @@ describe("tryRouteCli", () => {
|
110 | 110 | |
111 | 111 | expect(ensurePluginRegistryLoadedMock).toHaveBeenCalled(); |
112 | 112 | expect(captured[0]).toBe(true); |
113 | | -expect(loggingState.forceConsoleToStderr).toBe(false); |
| 113 | +expect(loggingState.forceConsoleToStderr).toBe(true); |
| 114 | +}); |
| 115 | + |
| 116 | +it("routes command-run logs to stderr for config-guard-skipping --json routes", async () => { |
| 117 | +const captured: boolean[] = []; |
| 118 | +runRouteMock.mockImplementationOnce(async () => { |
| 119 | +captured.push(loggingState.forceConsoleToStderr); |
| 120 | +return true; |
| 121 | +}); |
| 122 | + |
| 123 | +await expect(tryRouteCli(["node", "openclaw", "models", "status", "--json"])).resolves.toBe( |
| 124 | +true, |
| 125 | +); |
| 126 | + |
| 127 | +expect(ensureConfigReadyMock).not.toHaveBeenCalled(); |
| 128 | +expect(captured).toEqual([true]); |
114 | 129 | }); |
115 | 130 | |
116 | 131 | it("does not route logs to stderr during plugin loading without --json", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -23,7 +23,6 @@ async function prepareRoutedCommand(params: {
|
23 | 23 | const { VERSION } = await import("../version.js"); |
24 | 24 | await applyCliExecutionStartupPresentation({ |
25 | 25 | argv: params.argv, |
26 | | -routeLogsToStderrOnSuppress: false, |
27 | 26 | startupPolicy, |
28 | 27 | showBanner: process.stdout.isTTY && !startupPolicy.suppressDoctorStdout, |
29 | 28 | version: VERSION, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。