mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:50:43 +00:00
fix(cli): skip plugin preload for json agent runs
This commit is contained in:
@@ -52,7 +52,7 @@ export const cliCommandCatalog: readonly CliCommandCatalogEntry[] = [
|
||||
{
|
||||
commandPath: ["agent"],
|
||||
policy: {
|
||||
loadPlugins: ({ argv, jsonOutputMode }) => hasFlag(argv, "--local") || !jsonOutputMode,
|
||||
loadPlugins: "text-only",
|
||||
networkProxy: ({ argv }) => (hasFlag(argv, "--local") ? "default" : "bypass"),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -67,6 +67,15 @@ describe("command-path-policy", () => {
|
||||
});
|
||||
|
||||
it("keeps config-only agent commands on config-only startup", () => {
|
||||
expect(resolveCliCommandPathPolicy(["agent"])).toEqual({
|
||||
bypassConfigGuard: false,
|
||||
routeConfigGuard: "never",
|
||||
loadPlugins: "text-only",
|
||||
hideBanner: false,
|
||||
ensureCliPath: true,
|
||||
networkProxy: expect.any(Function),
|
||||
});
|
||||
|
||||
for (const commandPath of [
|
||||
["agents", "bind"],
|
||||
["agents", "bindings"],
|
||||
|
||||
@@ -145,6 +145,10 @@ describe("registerPreActionHooks", () => {
|
||||
program.command("onboard").action(() => {});
|
||||
const channels = program.command("channels");
|
||||
channels.command("add").action(() => {});
|
||||
channels
|
||||
.command("send")
|
||||
.option("--json")
|
||||
.action(() => {});
|
||||
program
|
||||
.command("plugins")
|
||||
.command("install")
|
||||
@@ -229,7 +233,7 @@ describe("registerPreActionHooks", () => {
|
||||
processTitleSetSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("loads plugins for local agent runs", async () => {
|
||||
it("loads plugins for text local agent runs", async () => {
|
||||
await runPreAction({
|
||||
parseArgv: ["agent"],
|
||||
processArgv: ["node", "openclaw", "agent", "--local", "--message", "hi"],
|
||||
@@ -242,6 +246,20 @@ describe("registerPreActionHooks", () => {
|
||||
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledWith({ scope: "all" });
|
||||
});
|
||||
|
||||
it("skips broad plugin preload for json local agent runs", async () => {
|
||||
await runPreAction({
|
||||
parseArgv: ["agent"],
|
||||
processArgv: ["node", "openclaw", "agent", "--local", "--message", "hi", "--json"],
|
||||
});
|
||||
|
||||
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
|
||||
runtime: runtimeMock,
|
||||
commandPath: ["agent", "hi"],
|
||||
suppressDoctorStdout: true,
|
||||
});
|
||||
expect(ensurePluginRegistryLoadedMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps setup alias and channels add manifest-first", async () => {
|
||||
await runPreAction({
|
||||
parseArgv: ["onboard"],
|
||||
@@ -394,8 +412,8 @@ describe("registerPreActionHooks", () => {
|
||||
|
||||
it("routes logs to stderr in --json mode so stdout stays clean", async () => {
|
||||
await runPreAction({
|
||||
parseArgv: ["agent"],
|
||||
processArgv: ["node", "openclaw", "agent", "--message", "hi", "--json"],
|
||||
parseArgv: ["channels", "send"],
|
||||
processArgv: ["node", "openclaw", "channels", "send", "--json"],
|
||||
});
|
||||
|
||||
expect(routeLogsToStderrMock).toHaveBeenCalledOnce();
|
||||
@@ -484,8 +502,8 @@ describe("registerPreActionHooks", () => {
|
||||
});
|
||||
|
||||
await runPreAction({
|
||||
parseArgv: ["agent"],
|
||||
processArgv: ["node", "openclaw", "agent", "--local", "--message", "hi", "--json"],
|
||||
parseArgv: ["channels", "send"],
|
||||
processArgv: ["node", "openclaw", "channels", "send", "--json"],
|
||||
});
|
||||
|
||||
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalled();
|
||||
|
||||
Reference in New Issue
Block a user