From e94e9347a4fbabb612a7c3293636698370ac9bc7 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 29 Apr 2026 01:25:48 +0100 Subject: [PATCH] fix(cli): load plugins for local JSON agent runs --- src/cli/command-catalog.ts | 2 +- src/cli/command-path-policy.test.ts | 2 +- src/cli/command-startup-policy.test.ts | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/cli/command-catalog.ts b/src/cli/command-catalog.ts index eacfc9fe3c7..3407ebf406c 100644 --- a/src/cli/command-catalog.ts +++ b/src/cli/command-catalog.ts @@ -52,7 +52,7 @@ export const cliCommandCatalog: readonly CliCommandCatalogEntry[] = [ { commandPath: ["agent"], policy: { - loadPlugins: "text-only", + loadPlugins: ({ argv, jsonOutputMode }) => hasFlag(argv, "--local") || !jsonOutputMode, networkProxy: ({ argv }) => (hasFlag(argv, "--local") ? "default" : "bypass"), }, }, diff --git a/src/cli/command-path-policy.test.ts b/src/cli/command-path-policy.test.ts index 009550b1478..9a2f4c0a2be 100644 --- a/src/cli/command-path-policy.test.ts +++ b/src/cli/command-path-policy.test.ts @@ -70,7 +70,7 @@ describe("command-path-policy", () => { expect(resolveCliCommandPathPolicy(["agent"])).toEqual({ bypassConfigGuard: false, routeConfigGuard: "never", - loadPlugins: "text-only", + loadPlugins: expect.any(Function), hideBanner: false, ensureCliPath: true, networkProxy: expect.any(Function), diff --git a/src/cli/command-startup-policy.test.ts b/src/cli/command-startup-policy.test.ts index daa0183937b..1b48c2ef845 100644 --- a/src/cli/command-startup-policy.test.ts +++ b/src/cli/command-startup-policy.test.ts @@ -92,6 +92,27 @@ describe("command-startup-policy", () => { jsonOutputMode: true, }), ).toBe(false); + expect( + shouldLoadPluginsForCommandPath({ + argv: ["node", "openclaw", "agent", "--json"], + commandPath: ["agent"], + jsonOutputMode: true, + }), + ).toBe(false); + expect( + shouldLoadPluginsForCommandPath({ + argv: ["node", "openclaw", "agent", "--json", "--local"], + commandPath: ["agent"], + jsonOutputMode: true, + }), + ).toBe(true); + expect( + shouldLoadPluginsForCommandPath({ + argv: ["node", "openclaw", "agent"], + commandPath: ["agent"], + jsonOutputMode: false, + }), + ).toBe(true); expect( shouldLoadPluginsForCommandPath({ commandPath: ["agents", "list"],