refactor: route channel runtime via plugin api

This commit is contained in:
Peter Steinberger
2026-01-18 11:00:19 +00:00
parent 676d41d415
commit ee6e534ccb
82 changed files with 1253 additions and 3167 deletions

View File

@@ -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,