mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 02:40:24 +00:00
refactor: rename setup helper surfaces
This commit is contained in:
@@ -3,7 +3,7 @@ import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { DEFAULT_ACCOUNT_ID } from "../../routing/session-key.js";
|
||||
|
||||
const promptAccountIdSdkMock = vi.hoisted(() => vi.fn(async () => "default"));
|
||||
vi.mock("../../plugin-sdk/onboarding.js", () => ({
|
||||
vi.mock("../../plugin-sdk/setup.js", () => ({
|
||||
promptAccountId: promptAccountIdSdkMock,
|
||||
}));
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import type { DmPolicy, GroupPolicy } from "../../config/types.js";
|
||||
import type { SecretInput } from "../../config/types.secrets.js";
|
||||
import { promptAccountId as promptAccountIdSdk } from "../../plugin-sdk/onboarding.js";
|
||||
import { promptAccountId as promptAccountIdSdk } from "../../plugin-sdk/setup.js";
|
||||
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../routing/session-key.js";
|
||||
import type { WizardPrompter } from "../../wizard/prompts.js";
|
||||
import type { PromptAccountId, PromptAccountIdParams } from "./setup-flow-types.js";
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { RuntimeEnv } from "../../runtime.js";
|
||||
import type { WizardPrompter } from "../../wizard/prompts.js";
|
||||
import type { ChannelId, ChannelPlugin } from "./types.js";
|
||||
|
||||
export type ChannelOnboardingSetupPlugin = Pick<
|
||||
export type ChannelSetupPlugin = Pick<
|
||||
ChannelPlugin,
|
||||
"id" | "meta" | "capabilities" | "config" | "setup" | "setupWizard"
|
||||
>;
|
||||
@@ -15,7 +15,7 @@ export type SetupChannelsOptions = {
|
||||
onSelection?: (selection: ChannelId[]) => void;
|
||||
accountIds?: Partial<Record<ChannelId, string>>;
|
||||
onAccountId?: (channel: ChannelId, accountId: string) => void;
|
||||
onResolvedPlugin?: (channel: ChannelId, plugin: ChannelOnboardingSetupPlugin) => void;
|
||||
onResolvedPlugin?: (channel: ChannelId, plugin: ChannelSetupPlugin) => void;
|
||||
promptAccountIds?: boolean;
|
||||
whatsappAccountId?: string;
|
||||
promptWhatsAppAccountId?: boolean;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/ag
|
||||
import { listChannelPluginCatalogEntries } from "../../channels/plugins/catalog.js";
|
||||
import { parseOptionalDelimitedEntries } from "../../channels/plugins/helpers.js";
|
||||
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
|
||||
import type { ChannelOnboardingSetupPlugin } from "../../channels/plugins/setup-flow-types.js";
|
||||
import type { ChannelSetupPlugin } from "../../channels/plugins/setup-flow-types.js";
|
||||
import { moveSingleAccountChannelSectionToDefaultAccount } from "../../channels/plugins/setup-helpers.js";
|
||||
import type { ChannelId, ChannelPlugin, ChannelSetupInput } from "../../channels/plugins/types.js";
|
||||
import { writeConfigFile, type OpenClawConfig } from "../../config/config.js";
|
||||
@@ -57,7 +57,7 @@ export async function channelsAddCommand(
|
||||
const prompter = createClackPrompter();
|
||||
let selection: ChannelChoice[] = [];
|
||||
const accountIds: Partial<Record<ChannelChoice, string>> = {};
|
||||
const resolvedPlugins = new Map<ChannelChoice, ChannelOnboardingSetupPlugin>();
|
||||
const resolvedPlugins = new Map<ChannelChoice, ChannelSetupPlugin>();
|
||||
await prompter.intro("Channel setup");
|
||||
let nextConfig = await setupChannels(cfg, runtime, prompter, {
|
||||
allowDisable: false,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
|
||||
import { listChannelPluginCatalogEntries } from "../channels/plugins/catalog.js";
|
||||
import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js";
|
||||
import type { ChannelOnboardingSetupPlugin } from "../channels/plugins/setup-flow-types.js";
|
||||
import type { ChannelSetupPlugin } from "../channels/plugins/setup-flow-types.js";
|
||||
import {
|
||||
getChannelSetupPlugin,
|
||||
listChannelSetupPlugins,
|
||||
@@ -91,7 +91,7 @@ async function promptRemovalAccountId(params: {
|
||||
prompter: WizardPrompter;
|
||||
label: string;
|
||||
channel: ChannelChoice;
|
||||
plugin?: ChannelOnboardingSetupPlugin;
|
||||
plugin?: ChannelSetupPlugin;
|
||||
}): Promise<string> {
|
||||
const { cfg, prompter, label, channel } = params;
|
||||
const plugin = params.plugin ?? getChannelSetupPlugin(channel);
|
||||
@@ -118,7 +118,7 @@ async function collectChannelStatus(params: {
|
||||
cfg: OpenClawConfig;
|
||||
options?: SetupChannelsOptions;
|
||||
accountOverrides: Partial<Record<ChannelChoice, string>>;
|
||||
installedPlugins?: ChannelOnboardingSetupPlugin[];
|
||||
installedPlugins?: ChannelSetupPlugin[];
|
||||
resolveAdapter?: (channel: ChannelChoice) => ChannelSetupFlowAdapter | undefined;
|
||||
}): Promise<ChannelStatusSummary> {
|
||||
const installedPlugins = params.installedPlugins ?? listChannelSetupPlugins();
|
||||
@@ -347,19 +347,17 @@ export async function setupChannels(
|
||||
const accountOverrides: Partial<Record<ChannelChoice, string>> = {
|
||||
...options?.accountIds,
|
||||
};
|
||||
const scopedPluginsById = new Map<ChannelChoice, ChannelOnboardingSetupPlugin>();
|
||||
const scopedPluginsById = new Map<ChannelChoice, ChannelSetupPlugin>();
|
||||
const resolveWorkspaceDir = () => resolveAgentWorkspaceDir(next, resolveDefaultAgentId(next));
|
||||
const rememberScopedPlugin = (plugin: ChannelOnboardingSetupPlugin) => {
|
||||
const rememberScopedPlugin = (plugin: ChannelSetupPlugin) => {
|
||||
const channel = plugin.id;
|
||||
scopedPluginsById.set(channel, plugin);
|
||||
options?.onResolvedPlugin?.(channel, plugin);
|
||||
};
|
||||
const getVisibleChannelPlugin = (
|
||||
channel: ChannelChoice,
|
||||
): ChannelOnboardingSetupPlugin | undefined =>
|
||||
const getVisibleChannelPlugin = (channel: ChannelChoice): ChannelSetupPlugin | undefined =>
|
||||
scopedPluginsById.get(channel) ?? getChannelSetupPlugin(channel);
|
||||
const listVisibleInstalledPlugins = (): ChannelOnboardingSetupPlugin[] => {
|
||||
const merged = new Map<string, ChannelOnboardingSetupPlugin>();
|
||||
const listVisibleInstalledPlugins = (): ChannelSetupPlugin[] => {
|
||||
const merged = new Map<string, ChannelSetupPlugin>();
|
||||
for (const plugin of listChannelSetupPlugins()) {
|
||||
merged.set(plugin.id, plugin);
|
||||
}
|
||||
@@ -371,7 +369,7 @@ export async function setupChannels(
|
||||
const loadScopedChannelPlugin = async (
|
||||
channel: ChannelChoice,
|
||||
pluginId?: string,
|
||||
): Promise<ChannelOnboardingSetupPlugin | undefined> => {
|
||||
): Promise<ChannelSetupPlugin | undefined> => {
|
||||
const existing = getVisibleChannelPlugin(channel);
|
||||
if (existing) {
|
||||
return existing;
|
||||
|
||||
Reference in New Issue
Block a user