mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:18:25 +00:00
refactor: route channel runtime via plugin api
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { CHAT_CHANNEL_ORDER, type ChatChannelId, normalizeChatChannelId } from "../registry.js";
|
||||
import { CHAT_CHANNEL_ORDER, type ChatChannelId, normalizeAnyChannelId } from "../registry.js";
|
||||
import type { ChannelId, ChannelPlugin } from "./types.js";
|
||||
import { getActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
import { requireActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
|
||||
// Channel plugins registry (runtime).
|
||||
//
|
||||
@@ -10,8 +10,7 @@ import { getActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
//
|
||||
// Channel plugins are registered by the plugin loader (extensions/ or configured paths).
|
||||
function listPluginChannels(): ChannelPlugin[] {
|
||||
const registry = getActivePluginRegistry();
|
||||
if (!registry) return [];
|
||||
const registry = requireActivePluginRegistry();
|
||||
return registry.channels.map((entry) => entry.plugin);
|
||||
}
|
||||
|
||||
@@ -46,18 +45,9 @@ export function getChannelPlugin(id: ChannelId): ChannelPlugin | undefined {
|
||||
}
|
||||
|
||||
export function normalizeChannelId(raw?: string | null): ChannelId | null {
|
||||
// Channel docking: keep input normalization centralized in src/channels/registry.ts
|
||||
// so CLI/API/protocol can rely on stable aliases without plugin init side effects.
|
||||
const normalized = normalizeChatChannelId(raw);
|
||||
if (normalized) return normalized;
|
||||
const trimmed = raw?.trim();
|
||||
if (!trimmed) return null;
|
||||
const key = trimmed.toLowerCase();
|
||||
const plugin = listChannelPlugins().find((entry) => {
|
||||
if (entry.id.toLowerCase() === key) return true;
|
||||
return (entry.meta.aliases ?? []).some((alias) => alias.trim().toLowerCase() === key);
|
||||
});
|
||||
return plugin?.id ?? null;
|
||||
// Channel docking: keep input normalization centralized in src/channels/registry.ts.
|
||||
// Plugin registry must be initialized before calling.
|
||||
return normalizeAnyChannelId(raw);
|
||||
}
|
||||
export {
|
||||
listDiscordDirectoryGroupsFromConfig,
|
||||
|
||||
Reference in New Issue
Block a user