import type { OpenClawConfig } from "../../config/config.js"; import type { DmPolicy } from "../../config/types.js"; import type { RuntimeEnv } from "../../runtime.js"; import type { WizardPrompter } from "../../wizard/prompts.js"; import type { ChannelId, ChannelPlugin } from "./types.js"; export type ChannelSetupPlugin = Pick; export type SetupChannelsOptions = { allowDisable?: boolean; allowSignalInstall?: boolean; onSelection?: (selection: ChannelId[]) => void; onPostWriteHook?: (hook: ChannelOnboardingPostWriteHook) => void; accountIds?: Partial>; onAccountId?: (channel: ChannelId, accountId: string) => void; onResolvedPlugin?: (channel: ChannelId, plugin: ChannelSetupPlugin) => void; promptAccountIds?: boolean; whatsappAccountId?: string; promptWhatsAppAccountId?: boolean; onWhatsAppAccountId?: (accountId: string) => void; forceAllowFromChannels?: ChannelId[]; skipStatusNote?: boolean; skipDmPolicyPrompt?: boolean; skipConfirm?: boolean; quickstartDefaults?: boolean; initialSelection?: ChannelId[]; secretInputMode?: "plaintext" | "ref"; }; export type PromptAccountIdParams = { cfg: OpenClawConfig; prompter: WizardPrompter; label: string; currentId?: string; listAccountIds: (cfg: OpenClawConfig) => string[]; defaultAccountId: string; }; export type PromptAccountId = (params: PromptAccountIdParams) => Promise; export type ChannelSetupStatus = { channel: ChannelId; configured: boolean; statusLines: string[]; selectionHint?: string; quickstartScore?: number; }; export type ChannelSetupStatusContext = { cfg: OpenClawConfig; options?: SetupChannelsOptions; accountOverrides: Partial>; }; export type ChannelSetupConfigureContext = { cfg: OpenClawConfig; runtime: RuntimeEnv; prompter: WizardPrompter; options?: SetupChannelsOptions; accountOverrides: Partial>; shouldPromptAccountIds: boolean; forceAllowFrom: boolean; }; export type ChannelOnboardingPostWriteContext = { previousCfg: OpenClawConfig; cfg: OpenClawConfig; accountId: string; runtime: RuntimeEnv; }; export type ChannelOnboardingPostWriteHook = { channel: ChannelId; accountId: string; run: (ctx: { cfg: OpenClawConfig; runtime: RuntimeEnv; }) => Promise | void; }; export type ChannelSetupResult = { cfg: OpenClawConfig; accountId?: string; }; export type ChannelSetupConfiguredResult = ChannelSetupResult | "skip"; export type ChannelSetupInteractiveContext = ChannelSetupConfigureContext & { configured: boolean; label: string; }; export type ChannelSetupDmPolicy = { label: string; channel: ChannelId; policyKey: string; allowFromKey: string; resolveConfigKeys?: (cfg: OpenClawConfig, accountId?: string) => { policyKey: string; allowFromKey: string; }; getCurrent: (cfg: OpenClawConfig, accountId?: string) => DmPolicy; setPolicy: (cfg: OpenClawConfig, policy: DmPolicy, accountId?: string) => OpenClawConfig; promptAllowFrom?: (params: { cfg: OpenClawConfig; prompter: WizardPrompter; accountId?: string; }) => Promise; }; export type ChannelSetupWizardAdapter = { channel: ChannelId; getStatus: (ctx: ChannelSetupStatusContext) => Promise; configure: (ctx: ChannelSetupConfigureContext) => Promise; configureInteractive?: (ctx: ChannelSetupInteractiveContext) => Promise; configureWhenConfigured?: (ctx: ChannelSetupInteractiveContext) => Promise; afterConfigWritten?: (ctx: ChannelOnboardingPostWriteContext) => Promise | void; dmPolicy?: ChannelSetupDmPolicy; onAccountRecorded?: (accountId: string, options?: SetupChannelsOptions) => void; disable?: (cfg: OpenClawConfig) => OpenClawConfig; };