mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:20:43 +00:00
fix(cli): resolve message channel plugin scopes
This commit is contained in:
@@ -34,6 +34,10 @@ const mocks = vi.hoisted(() => ({
|
||||
getActivePluginRegistry: vi.fn<typeof import("../plugins/runtime.js").getActivePluginRegistry>(),
|
||||
resolveConfiguredChannelPluginIds:
|
||||
vi.fn<typeof import("../plugins/channel-plugin-ids.js").resolveConfiguredChannelPluginIds>(),
|
||||
resolveDiscoverableScopedChannelPluginIds:
|
||||
vi.fn<
|
||||
typeof import("../plugins/channel-plugin-ids.js").resolveDiscoverableScopedChannelPluginIds
|
||||
>(),
|
||||
resolveChannelPluginIds:
|
||||
vi.fn<typeof import("../plugins/channel-plugin-ids.js").resolveChannelPluginIds>(),
|
||||
resolvePluginRuntimeLoadContext:
|
||||
@@ -59,6 +63,9 @@ vi.mock("../plugins/channel-plugin-ids.js", () => ({
|
||||
resolveConfiguredChannelPluginIds: (
|
||||
...args: Parameters<typeof mocks.resolveConfiguredChannelPluginIds>
|
||||
) => mocks.resolveConfiguredChannelPluginIds(...args),
|
||||
resolveDiscoverableScopedChannelPluginIds: (
|
||||
...args: Parameters<typeof mocks.resolveDiscoverableScopedChannelPluginIds>
|
||||
) => mocks.resolveDiscoverableScopedChannelPluginIds(...args),
|
||||
resolveChannelPluginIds: (...args: Parameters<typeof mocks.resolveChannelPluginIds>) =>
|
||||
mocks.resolveChannelPluginIds(...args),
|
||||
}));
|
||||
@@ -119,12 +126,14 @@ describe("ensurePluginRegistryLoaded", () => {
|
||||
mocks.resolveRuntimePluginRegistry.mockReset();
|
||||
mocks.getActivePluginRegistry.mockReset();
|
||||
mocks.resolveConfiguredChannelPluginIds.mockReset();
|
||||
mocks.resolveDiscoverableScopedChannelPluginIds.mockReset();
|
||||
mocks.resolveChannelPluginIds.mockReset();
|
||||
mocks.resolvePluginRuntimeLoadContext.mockReset();
|
||||
resetPluginRegistryLoadedForTests();
|
||||
|
||||
mocks.getActivePluginRegistry.mockReturnValue(createEmptyPluginRegistry());
|
||||
mocks.resolveRuntimePluginRegistry.mockReturnValue(undefined);
|
||||
mocks.resolveDiscoverableScopedChannelPluginIds.mockReturnValue([]);
|
||||
mocks.resolvePluginRuntimeLoadContext.mockImplementation((options) => {
|
||||
const rawConfig = (options?.config ?? {}) as Record<string, unknown>;
|
||||
return {
|
||||
|
||||
@@ -98,7 +98,7 @@ describe("runMessageAction", () => {
|
||||
|
||||
expect(ensurePluginRegistryLoaded).toHaveBeenCalledWith({
|
||||
scope: "configured-channels",
|
||||
onlyPluginIds: ["discord"],
|
||||
onlyChannelIds: ["discord"],
|
||||
});
|
||||
expect(exitMock).toHaveBeenCalledOnce();
|
||||
expect(exitMock).toHaveBeenCalledWith(0);
|
||||
@@ -117,7 +117,7 @@ describe("runMessageAction", () => {
|
||||
|
||||
expect(ensurePluginRegistryLoaded).toHaveBeenCalledWith({
|
||||
scope: "configured-channels",
|
||||
onlyPluginIds: ["telegram"],
|
||||
onlyChannelIds: ["telegram"],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ async function runPluginStopHooks(): Promise<void> {
|
||||
|
||||
function resolveMessagePluginLoadOptions(
|
||||
opts: Record<string, unknown>,
|
||||
): { scope: PluginRegistryScope; onlyPluginIds?: string[] } | undefined {
|
||||
): { scope: PluginRegistryScope; onlyChannelIds?: string[] } | undefined {
|
||||
const scopedChannel = resolveMessageSecretScope({
|
||||
channel: opts.channel,
|
||||
target: opts.target,
|
||||
targets: opts.targets,
|
||||
}).channel;
|
||||
if (scopedChannel) {
|
||||
return { scope: "configured-channels", onlyPluginIds: [scopedChannel] };
|
||||
return { scope: "configured-channels", onlyChannelIds: [scopedChannel] };
|
||||
}
|
||||
return { scope: "configured-channels" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user