mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
fix(config): auto-enable configured plugins
This commit is contained in:
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { applyPluginAutoEnable } from "./plugin-auto-enable.js";
|
||||
|
||||
describe("applyPluginAutoEnable", () => {
|
||||
it("configures channel plugins with disabled state and updates allowlist", () => {
|
||||
it("auto-enables channel plugins and updates allowlist", () => {
|
||||
const result = applyPluginAutoEnable({
|
||||
config: {
|
||||
channels: { slack: { botToken: "x" } },
|
||||
@@ -11,9 +11,9 @@ describe("applyPluginAutoEnable", () => {
|
||||
env: {},
|
||||
});
|
||||
|
||||
expect(result.config.plugins?.entries?.slack?.enabled).toBe(false);
|
||||
expect(result.config.plugins?.entries?.slack?.enabled).toBe(true);
|
||||
expect(result.config.plugins?.allow).toEqual(["telegram", "slack"]);
|
||||
expect(result.changes.join("\n")).toContain("Slack configured, not enabled yet.");
|
||||
expect(result.changes.join("\n")).toContain("Slack configured, enabled automatically.");
|
||||
});
|
||||
|
||||
it("respects explicit disable", () => {
|
||||
@@ -29,7 +29,7 @@ describe("applyPluginAutoEnable", () => {
|
||||
expect(result.changes).toEqual([]);
|
||||
});
|
||||
|
||||
it("configures irc as disabled when configured via env", () => {
|
||||
it("auto-enables irc when configured via env", () => {
|
||||
const result = applyPluginAutoEnable({
|
||||
config: {},
|
||||
env: {
|
||||
@@ -38,11 +38,11 @@ describe("applyPluginAutoEnable", () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.config.plugins?.entries?.irc?.enabled).toBe(false);
|
||||
expect(result.changes.join("\n")).toContain("IRC configured, not enabled yet.");
|
||||
expect(result.config.plugins?.entries?.irc?.enabled).toBe(true);
|
||||
expect(result.changes.join("\n")).toContain("IRC configured, enabled automatically.");
|
||||
});
|
||||
|
||||
it("configures provider auth plugins as disabled when profiles exist", () => {
|
||||
it("auto-enables provider auth plugins when profiles exist", () => {
|
||||
const result = applyPluginAutoEnable({
|
||||
config: {
|
||||
auth: {
|
||||
@@ -57,7 +57,7 @@ describe("applyPluginAutoEnable", () => {
|
||||
env: {},
|
||||
});
|
||||
|
||||
expect(result.config.plugins?.entries?.["google-antigravity-auth"]?.enabled).toBe(false);
|
||||
expect(result.config.plugins?.entries?.["google-antigravity-auth"]?.enabled).toBe(true);
|
||||
});
|
||||
|
||||
it("skips when plugins are globally disabled", () => {
|
||||
@@ -85,10 +85,12 @@ describe("applyPluginAutoEnable", () => {
|
||||
env: {},
|
||||
});
|
||||
|
||||
expect(result.config.plugins?.entries?.bluebubbles?.enabled).toBe(false);
|
||||
expect(result.config.plugins?.entries?.bluebubbles?.enabled).toBe(true);
|
||||
expect(result.config.plugins?.entries?.imessage?.enabled).toBeUndefined();
|
||||
expect(result.changes.join("\n")).toContain("bluebubbles configured, not enabled yet.");
|
||||
expect(result.changes.join("\n")).not.toContain("iMessage configured, not enabled yet.");
|
||||
expect(result.changes.join("\n")).toContain("bluebubbles configured, enabled automatically.");
|
||||
expect(result.changes.join("\n")).not.toContain(
|
||||
"iMessage configured, enabled automatically.",
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps imessage enabled if already explicitly enabled (non-destructive)", () => {
|
||||
@@ -103,7 +105,7 @@ describe("applyPluginAutoEnable", () => {
|
||||
env: {},
|
||||
});
|
||||
|
||||
expect(result.config.plugins?.entries?.bluebubbles?.enabled).toBe(false);
|
||||
expect(result.config.plugins?.entries?.bluebubbles?.enabled).toBe(true);
|
||||
expect(result.config.plugins?.entries?.imessage?.enabled).toBe(true);
|
||||
});
|
||||
|
||||
@@ -120,8 +122,8 @@ describe("applyPluginAutoEnable", () => {
|
||||
});
|
||||
|
||||
expect(result.config.plugins?.entries?.bluebubbles?.enabled).toBe(false);
|
||||
expect(result.config.plugins?.entries?.imessage?.enabled).toBe(false);
|
||||
expect(result.changes.join("\n")).toContain("iMessage configured, not enabled yet.");
|
||||
expect(result.config.plugins?.entries?.imessage?.enabled).toBe(true);
|
||||
expect(result.changes.join("\n")).toContain("iMessage configured, enabled automatically.");
|
||||
});
|
||||
|
||||
it("allows imessage auto-configure when bluebubbles is in deny list", () => {
|
||||
@@ -137,10 +139,10 @@ describe("applyPluginAutoEnable", () => {
|
||||
});
|
||||
|
||||
expect(result.config.plugins?.entries?.bluebubbles?.enabled).toBeUndefined();
|
||||
expect(result.config.plugins?.entries?.imessage?.enabled).toBe(false);
|
||||
expect(result.config.plugins?.entries?.imessage?.enabled).toBe(true);
|
||||
});
|
||||
|
||||
it("configures imessage as disabled when only imessage is configured", () => {
|
||||
it("auto-enables imessage when only imessage is configured", () => {
|
||||
const result = applyPluginAutoEnable({
|
||||
config: {
|
||||
channels: { imessage: { cliPath: "/usr/local/bin/imsg" } },
|
||||
@@ -148,8 +150,8 @@ describe("applyPluginAutoEnable", () => {
|
||||
env: {},
|
||||
});
|
||||
|
||||
expect(result.config.plugins?.entries?.imessage?.enabled).toBe(false);
|
||||
expect(result.changes.join("\n")).toContain("iMessage configured, not enabled yet.");
|
||||
expect(result.config.plugins?.entries?.imessage?.enabled).toBe(true);
|
||||
expect(result.changes.join("\n")).toContain("iMessage configured, enabled automatically.");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -407,7 +407,7 @@ function registerPluginEntry(cfg: OpenClawConfig, pluginId: string): OpenClawCon
|
||||
...cfg.plugins?.entries,
|
||||
[pluginId]: {
|
||||
...(cfg.plugins?.entries?.[pluginId] as Record<string, unknown> | undefined),
|
||||
enabled: false,
|
||||
enabled: true,
|
||||
},
|
||||
};
|
||||
return {
|
||||
@@ -426,7 +426,7 @@ function formatAutoEnableChange(entry: PluginEnableChange): string {
|
||||
const label = getChatChannelMeta(channelId).label;
|
||||
reason = reason.replace(new RegExp(`^${channelId}\\b`, "i"), label);
|
||||
}
|
||||
return `${reason}, not enabled yet.`;
|
||||
return `${reason}, enabled automatically.`;
|
||||
}
|
||||
|
||||
export function applyPluginAutoEnable(params: {
|
||||
|
||||
Reference in New Issue
Block a user