mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:00:42 +00:00
fix: keep channel command discovery read-only
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { resolveChannelDefaultAccountId } from "../../channels/plugins/helpers.js";
|
||||
import { listChannelPlugins } from "../../channels/plugins/index.js";
|
||||
import {
|
||||
createMessageActionDiscoveryContext,
|
||||
resolveMessageActionDiscoveryForPlugin,
|
||||
} from "../../channels/plugins/message-action-discovery.js";
|
||||
import { listReadOnlyChannelPluginsForConfig } from "../../channels/plugins/read-only.js";
|
||||
import type {
|
||||
ChannelCapabilities,
|
||||
ChannelCapabilitiesDiagnostics,
|
||||
@@ -239,7 +239,9 @@ export async function channelsCapabilitiesCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
const plugins = listChannelPlugins();
|
||||
const plugins = listReadOnlyChannelPluginsForConfig(cfg, {
|
||||
includeSetupRuntimeFallback: true,
|
||||
});
|
||||
const selected =
|
||||
!rawChannel || rawChannel === "all"
|
||||
? plugins
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { resolveChannelDefaultAccountId } from "../../channels/plugins/helpers.js";
|
||||
import {
|
||||
getChannelPlugin,
|
||||
listChannelPlugins,
|
||||
normalizeChannelId,
|
||||
} from "../../channels/plugins/index.js";
|
||||
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
|
||||
import { listReadOnlyChannelPluginsForConfig } from "../../channels/plugins/read-only.js";
|
||||
import type { ChannelPlugin } from "../../channels/plugins/types.plugin.js";
|
||||
import { commitConfigWithPendingPluginInstalls } from "../../cli/plugins-install-record-commit.js";
|
||||
import { refreshPluginRegistryAfterConfigMutation } from "../../cli/plugins-registry-refresh.js";
|
||||
import { replaceConfigFile, type OpenClawConfig } from "../../config/config.js";
|
||||
@@ -24,8 +22,12 @@ export type ChannelsRemoveOptions = {
|
||||
delete?: boolean;
|
||||
};
|
||||
|
||||
function listAccountIds(cfg: OpenClawConfig, channel: ChatChannel): string[] {
|
||||
const plugin = getChannelPlugin(channel);
|
||||
function listAccountIds(
|
||||
cfg: OpenClawConfig,
|
||||
channel: ChatChannel,
|
||||
plugin?: ChannelPlugin,
|
||||
): string[] {
|
||||
plugin ??= getChannelPlugin(channel);
|
||||
if (!plugin) {
|
||||
return [];
|
||||
}
|
||||
@@ -47,23 +49,29 @@ export async function channelsRemoveCommand(
|
||||
const useWizard = shouldUseWizard(params);
|
||||
const prompter = useWizard ? createClackPrompter() : null;
|
||||
const rawChannel = normalizeOptionalString(opts.channel) ?? "";
|
||||
let lookupChannel = rawChannel;
|
||||
let channel: ChatChannel | null = normalizeChannelId(rawChannel);
|
||||
let accountId = normalizeAccountId(opts.account);
|
||||
const deleteConfig = Boolean(opts.delete);
|
||||
|
||||
if (useWizard && prompter) {
|
||||
await prompter.intro("Remove channel account");
|
||||
const readOnlyPlugins = listReadOnlyChannelPluginsForConfig(cfg, {
|
||||
includeSetupRuntimeFallback: true,
|
||||
});
|
||||
const selectedChannel = await prompter.select({
|
||||
message: "Channel",
|
||||
options: listChannelPlugins().map((plugin) => ({
|
||||
options: readOnlyPlugins.map((plugin) => ({
|
||||
value: plugin.id,
|
||||
label: plugin.meta.label,
|
||||
})),
|
||||
});
|
||||
channel = selectedChannel;
|
||||
lookupChannel = selectedChannel;
|
||||
|
||||
accountId = await (async () => {
|
||||
const ids = listAccountIds(cfg, selectedChannel);
|
||||
const readOnlyPlugin = readOnlyPlugins.find((plugin) => plugin.id === selectedChannel);
|
||||
const ids = listAccountIds(cfg, selectedChannel, readOnlyPlugin);
|
||||
const choice = await prompter.select({
|
||||
message: "Account",
|
||||
options: ids.map((id) => ({
|
||||
@@ -102,8 +110,7 @@ export async function channelsRemoveCommand(
|
||||
}
|
||||
}
|
||||
|
||||
const shouldResolveInstallablePlugin =
|
||||
!useWizard && rawChannel && (!channel || !getChannelPlugin(channel));
|
||||
const shouldResolveInstallablePlugin = Boolean(lookupChannel || channel);
|
||||
const resolvedPluginState = shouldResolveInstallablePlugin
|
||||
? await (async () => {
|
||||
const { resolveInstallableChannelPlugin } =
|
||||
@@ -111,7 +118,7 @@ export async function channelsRemoveCommand(
|
||||
return await resolveInstallableChannelPlugin({
|
||||
cfg,
|
||||
runtime,
|
||||
rawChannel,
|
||||
rawChannel: lookupChannel,
|
||||
allowInstall: true,
|
||||
});
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user