




















@@ -1,9 +1,7 @@
11import { resolveChannelDefaultAccountId } from "../../channels/plugins/helpers.js";
2-import {
3-getChannelPlugin,
4-listChannelPlugins,
5-normalizeChannelId,
6-} from "../../channels/plugins/index.js";
2+import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
3+import { listReadOnlyChannelPluginsForConfig } from "../../channels/plugins/read-only.js";
4+import type { ChannelPlugin } from "../../channels/plugins/types.plugin.js";
75import { commitConfigWithPendingPluginInstalls } from "../../cli/plugins-install-record-commit.js";
86import { refreshPluginRegistryAfterConfigMutation } from "../../cli/plugins-registry-refresh.js";
97import { replaceConfigFile, type OpenClawConfig } from "../../config/config.js";
@@ -24,8 +22,12 @@ export type ChannelsRemoveOptions = {
2422delete?: boolean;
2523};
262427-function listAccountIds(cfg: OpenClawConfig, channel: ChatChannel): string[] {
28-const plugin = getChannelPlugin(channel);
25+function listAccountIds(
26+cfg: OpenClawConfig,
27+channel: ChatChannel,
28+plugin?: ChannelPlugin,
29+): string[] {
30+plugin ??= getChannelPlugin(channel);
2931if (!plugin) {
3032return [];
3133}
@@ -47,23 +49,29 @@ export async function channelsRemoveCommand(
4749const useWizard = shouldUseWizard(params);
4850const prompter = useWizard ? createClackPrompter() : null;
4951const rawChannel = normalizeOptionalString(opts.channel) ?? "";
52+let lookupChannel = rawChannel;
5053let channel: ChatChannel | null = normalizeChannelId(rawChannel);
5154let accountId = normalizeAccountId(opts.account);
5255const deleteConfig = Boolean(opts.delete);
53565457if (useWizard && prompter) {
5558await prompter.intro("Remove channel account");
59+const readOnlyPlugins = listReadOnlyChannelPluginsForConfig(cfg, {
60+includeSetupRuntimeFallback: true,
61+});
5662const selectedChannel = await prompter.select({
5763message: "Channel",
58-options: listChannelPlugins().map((plugin) => ({
64+options: readOnlyPlugins.map((plugin) => ({
5965value: plugin.id,
6066label: plugin.meta.label,
6167})),
6268});
6369channel = selectedChannel;
70+lookupChannel = selectedChannel;
64716572accountId = await (async () => {
66-const ids = listAccountIds(cfg, selectedChannel);
73+const readOnlyPlugin = readOnlyPlugins.find((plugin) => plugin.id === selectedChannel);
74+const ids = listAccountIds(cfg, selectedChannel, readOnlyPlugin);
6775const choice = await prompter.select({
6876message: "Account",
6977options: ids.map((id) => ({
@@ -102,16 +110,15 @@ export async function channelsRemoveCommand(
102110}
103111}
104112105-const shouldResolveInstallablePlugin =
106-!useWizard && rawChannel && (!channel || !getChannelPlugin(channel));
113+const shouldResolveInstallablePlugin = Boolean(lookupChannel || channel);
107114const resolvedPluginState = shouldResolveInstallablePlugin
108115 ? await (async () => {
109116const { resolveInstallableChannelPlugin } =
110117await import("../channel-setup/channel-plugin-resolution.js");
111118return await resolveInstallableChannelPlugin({
112119 cfg,
113120 runtime,
114- rawChannel,
121+rawChannel: lookupChannel,
115122allowInstall: true,
116123});
117124})()
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。