Skip to content

Commit e07c51b

Browse files
authored
CLI: avoid plugin preload for health --json route (openclaw#31108)
* CLI routes: skip plugin preload for health --json * CLI routes tests: cover health --json plugin preload
1 parent 1551187 commit e07c51b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/cli/program/routes.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ describe("program routes", () => {
1818
expect(route?.loadPlugins).toBe(true);
1919
});
2020

21-
it("matches health route and preloads plugins for channel diagnostics", () => {
21+
it("matches health route and preloads plugins only for text output", () => {
2222
const route = expectRoute(["health"]);
23-
expect(route?.loadPlugins).toBe(true);
23+
expect(typeof route?.loadPlugins).toBe("function");
24+
const shouldLoad = route?.loadPlugins as (argv: string[]) => boolean;
25+
expect(shouldLoad(["node", "openclaw", "health"])).toBe(true);
26+
expect(shouldLoad(["node", "openclaw", "health", "--json"])).toBe(false);
2427
});
2528

2629
it("returns false when status timeout flag value is missing", async () => {

src/cli/program/routes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export type RouteSpec = {
99

1010
const routeHealth: RouteSpec = {
1111
match: (path) => path[0] === "health",
12-
// Health output uses channel plugin metadata for account fallback/log details.
13-
// Keep routed behavior aligned with non-routed command execution.
14-
loadPlugins: true,
12+
// `health --json` only relays gateway RPC output and does not need local plugin metadata.
13+
// Keep plugin preload for text output where channel diagnostics/logSelfId are rendered.
14+
loadPlugins: (argv) => !hasFlag(argv, "--json"),
1515
run: async (argv) => {
1616
const json = hasFlag(argv, "--json");
1717
const verbose = getVerboseFlag(argv, { includeDebug: true });

0 commit comments

Comments
 (0)