feat(channels): read setup discovery from installed index

This commit is contained in:
Vincent Koc
2026-04-24 23:23:22 -07:00
parent 0b2bc8c5f6
commit 15d27d1527
2 changed files with 10 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { PluginAutoEnableResult } from "../../config/plugin-auto-enable.js";
const loadPluginManifestRegistry = vi.hoisted(() => vi.fn());
const loadInstalledPluginIndex = vi.hoisted(() => vi.fn());
const listChannelPluginCatalogEntries = vi.hoisted(() => vi.fn((): unknown[] => []));
const listChatChannels = vi.hoisted(() => vi.fn((): Array<Record<string, string>> => []));
const applyPluginAutoEnable = vi.hoisted(() =>
@@ -14,8 +14,8 @@ const applyPluginAutoEnable = vi.hoisted(() =>
),
);
vi.mock("../../plugins/manifest-registry.js", () => ({
loadPluginManifestRegistry: (...args: unknown[]) => loadPluginManifestRegistry(...args),
vi.mock("../../plugins/installed-plugin-index.js", () => ({
loadInstalledPluginIndex: (...args: unknown[]) => loadInstalledPluginIndex(...args),
}));
vi.mock("../../config/plugin-auto-enable.js", () => ({
@@ -35,7 +35,7 @@ import { listManifestInstalledChannelIds, resolveChannelSetupEntries } from "./d
describe("listManifestInstalledChannelIds", () => {
beforeEach(() => {
loadPluginManifestRegistry.mockReset().mockReturnValue({
loadInstalledPluginIndex.mockReset().mockReturnValue({
plugins: [],
diagnostics: [],
});
@@ -61,8 +61,8 @@ describe("listManifestInstalledChannelIds", () => {
slack: ["slack configured"],
},
});
loadPluginManifestRegistry.mockReturnValue({
plugins: [{ id: "slack", channels: ["slack"] }],
loadInstalledPluginIndex.mockReturnValue({
plugins: [{ pluginId: "slack", contributions: { channels: ["slack"] } }],
diagnostics: [],
});
@@ -76,7 +76,7 @@ describe("listManifestInstalledChannelIds", () => {
config: {},
env: { OPENCLAW_HOME: "/tmp/home" },
});
expect(loadPluginManifestRegistry).toHaveBeenCalledWith({
expect(loadInstalledPluginIndex).toHaveBeenCalledWith({
config: autoEnabledConfig,
workspaceDir: "/tmp/workspace",
env: { OPENCLAW_HOME: "/tmp/home" },

View File

@@ -7,7 +7,7 @@ import type { ChannelPlugin } from "../../channels/plugins/types.plugin.js";
import type { ChannelMeta } from "../../channels/plugins/types.public.js";
import { applyPluginAutoEnable } from "../../config/plugin-auto-enable.js";
import type { OpenClawConfig } from "../../config/types.openclaw.js";
import { loadPluginManifestRegistry } from "../../plugins/manifest-registry.js";
import { loadInstalledPluginIndex } from "../../plugins/installed-plugin-index.js";
import type { ChannelChoice } from "../onboard-types.js";
import {
listSetupDiscoveryChannelPluginCatalogEntries,
@@ -48,11 +48,11 @@ export function listManifestInstalledChannelIds(params: {
}).config;
const workspaceDir = resolveWorkspaceDir(resolvedConfig, params.workspaceDir);
return new Set(
loadPluginManifestRegistry({
loadInstalledPluginIndex({
config: resolvedConfig,
workspaceDir,
env: params.env ?? process.env,
}).plugins.flatMap((plugin) => plugin.channels as ChannelChoice[]),
}).plugins.flatMap((plugin) => plugin.contributions.channels as ChannelChoice[]),
);
}