import type { ReplyPayload } from "../../auto-reply/types.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { GroupToolPolicyConfig } from "../../config/types.tools.js"; import type { OutboundDeliveryResult, OutboundSendDeps } from "../../infra/outbound/deliver.js"; import type { OutboundIdentity } from "../../infra/outbound/identity.js"; import type { RuntimeEnv } from "../../runtime.js"; import type { ChannelAccountSnapshot, ChannelAccountState, ChannelDirectoryEntry, ChannelGroupContext, ChannelHeartbeatDeps, ChannelLogSink, ChannelOutboundTargetMode, ChannelPollContext, ChannelPollResult, ChannelSecurityContext, ChannelSecurityDmPolicy, ChannelSetupInput, ChannelStatusIssue } from "./types.core.js"; export type ChannelSetupAdapter = { resolveAccountId?: (params: { cfg: OpenClawConfig; accountId?: string; }) => string; applyAccountName?: (params: { cfg: OpenClawConfig; accountId: string; name?: string; }) => OpenClawConfig; applyAccountConfig: (params: { cfg: OpenClawConfig; accountId: string; input: ChannelSetupInput; }) => OpenClawConfig; validateInput?: (params: { cfg: OpenClawConfig; accountId: string; input: ChannelSetupInput; }) => string | null; }; export type ChannelConfigAdapter = { listAccountIds: (cfg: OpenClawConfig) => string[]; resolveAccount: (cfg: OpenClawConfig, accountId?: string | null) => ResolvedAccount; defaultAccountId?: (cfg: OpenClawConfig) => string; setAccountEnabled?: (params: { cfg: OpenClawConfig; accountId: string; enabled: boolean; }) => OpenClawConfig; deleteAccount?: (params: { cfg: OpenClawConfig; accountId: string; }) => OpenClawConfig; isEnabled?: (account: ResolvedAccount, cfg: OpenClawConfig) => boolean; disabledReason?: (account: ResolvedAccount, cfg: OpenClawConfig) => string; isConfigured?: (account: ResolvedAccount, cfg: OpenClawConfig) => boolean | Promise; unconfiguredReason?: (account: ResolvedAccount, cfg: OpenClawConfig) => string; describeAccount?: (account: ResolvedAccount, cfg: OpenClawConfig) => ChannelAccountSnapshot; resolveAllowFrom?: (params: { cfg: OpenClawConfig; accountId?: string | null; }) => string[] | undefined; formatAllowFrom?: (params: { cfg: OpenClawConfig; accountId?: string | null; allowFrom: Array; }) => string[]; }; export type ChannelGroupAdapter = { resolveRequireMention?: (params: ChannelGroupContext) => boolean | undefined; resolveGroupIntroHint?: (params: ChannelGroupContext) => string | undefined; resolveToolPolicy?: (params: ChannelGroupContext) => GroupToolPolicyConfig | undefined; }; export type ChannelOutboundContext = { cfg: OpenClawConfig; to: string; text: string; mediaUrl?: string; mediaLocalRoots?: readonly string[]; gifPlayback?: boolean; replyToId?: string | null; threadId?: string | number | null; accountId?: string | null; identity?: OutboundIdentity; deps?: OutboundSendDeps; silent?: boolean; }; export type ChannelOutboundPayloadContext = ChannelOutboundContext & { payload: ReplyPayload; }; export type ChannelOutboundAdapter = { deliveryMode: "direct" | "gateway" | "hybrid"; chunker?: ((text: string, limit: number) => string[]) | null; chunkerMode?: "text" | "markdown"; textChunkLimit?: number; pollMaxOptions?: number; resolveTarget?: (params: { cfg?: OpenClawConfig; to?: string; allowFrom?: string[]; accountId?: string | null; mode?: ChannelOutboundTargetMode; }) => { ok: true; to: string; } | { ok: false; error: Error; }; sendPayload?: (ctx: ChannelOutboundPayloadContext) => Promise; sendText?: (ctx: ChannelOutboundContext) => Promise; sendMedia?: (ctx: ChannelOutboundContext) => Promise; sendPoll?: (ctx: ChannelPollContext) => Promise; }; export type ChannelStatusAdapter = { defaultRuntime?: ChannelAccountSnapshot; buildChannelSummary?: (params: { account: ResolvedAccount; cfg: OpenClawConfig; defaultAccountId: string; snapshot: ChannelAccountSnapshot; }) => Record | Promise>; probeAccount?: (params: { account: ResolvedAccount; timeoutMs: number; cfg: OpenClawConfig; }) => Promise; auditAccount?: (params: { account: ResolvedAccount; timeoutMs: number; cfg: OpenClawConfig; probe?: Probe; }) => Promise; buildAccountSnapshot?: (params: { account: ResolvedAccount; cfg: OpenClawConfig; runtime?: ChannelAccountSnapshot; probe?: Probe; audit?: Audit; }) => ChannelAccountSnapshot | Promise; logSelfId?: (params: { account: ResolvedAccount; cfg: OpenClawConfig; runtime: RuntimeEnv; includeChannelPrefix?: boolean; }) => void; resolveAccountState?: (params: { account: ResolvedAccount; cfg: OpenClawConfig; configured: boolean; enabled: boolean; }) => ChannelAccountState; collectStatusIssues?: (accounts: ChannelAccountSnapshot[]) => ChannelStatusIssue[]; }; export type ChannelGatewayContext = { cfg: OpenClawConfig; accountId: string; account: ResolvedAccount; runtime: RuntimeEnv; abortSignal: AbortSignal; log?: ChannelLogSink; getStatus: () => ChannelAccountSnapshot; setStatus: (next: ChannelAccountSnapshot) => void; }; export type ChannelLogoutResult = { cleared: boolean; loggedOut?: boolean; [key: string]: unknown; }; export type ChannelLoginWithQrStartResult = { qrDataUrl?: string; message: string; }; export type ChannelLoginWithQrWaitResult = { connected: boolean; message: string; }; export type ChannelLogoutContext = { cfg: OpenClawConfig; accountId: string; account: ResolvedAccount; runtime: RuntimeEnv; log?: ChannelLogSink; }; export type ChannelPairingAdapter = { idLabel: string; normalizeAllowEntry?: (entry: string) => string; notifyApproval?: (params: { cfg: OpenClawConfig; id: string; runtime?: RuntimeEnv; }) => Promise; }; export type ChannelGatewayAdapter = { startAccount?: (ctx: ChannelGatewayContext) => Promise; stopAccount?: (ctx: ChannelGatewayContext) => Promise; loginWithQrStart?: (params: { accountId?: string; force?: boolean; timeoutMs?: number; verbose?: boolean; }) => Promise; loginWithQrWait?: (params: { accountId?: string; timeoutMs?: number; }) => Promise; logoutAccount?: (ctx: ChannelLogoutContext) => Promise; }; export type ChannelAuthAdapter = { login?: (params: { cfg: OpenClawConfig; accountId?: string | null; runtime: RuntimeEnv; verbose?: boolean; channelInput?: string | null; }) => Promise; }; export type ChannelHeartbeatAdapter = { checkReady?: (params: { cfg: OpenClawConfig; accountId?: string | null; deps?: ChannelHeartbeatDeps; }) => Promise<{ ok: boolean; reason: string; }>; resolveRecipients?: (params: { cfg: OpenClawConfig; opts?: { to?: string; all?: boolean; }; }) => { recipients: string[]; source: string; }; }; export type ChannelDirectoryAdapter = { self?: (params: { cfg: OpenClawConfig; accountId?: string | null; runtime: RuntimeEnv; }) => Promise; listPeers?: (params: { cfg: OpenClawConfig; accountId?: string | null; query?: string | null; limit?: number | null; runtime: RuntimeEnv; }) => Promise; listPeersLive?: (params: { cfg: OpenClawConfig; accountId?: string | null; query?: string | null; limit?: number | null; runtime: RuntimeEnv; }) => Promise; listGroups?: (params: { cfg: OpenClawConfig; accountId?: string | null; query?: string | null; limit?: number | null; runtime: RuntimeEnv; }) => Promise; listGroupsLive?: (params: { cfg: OpenClawConfig; accountId?: string | null; query?: string | null; limit?: number | null; runtime: RuntimeEnv; }) => Promise; listGroupMembers?: (params: { cfg: OpenClawConfig; accountId?: string | null; groupId: string; limit?: number | null; runtime: RuntimeEnv; }) => Promise; }; export type ChannelResolveKind = "user" | "group"; export type ChannelResolveResult = { input: string; resolved: boolean; id?: string; name?: string; note?: string; }; export type ChannelResolverAdapter = { resolveTargets: (params: { cfg: OpenClawConfig; accountId?: string | null; inputs: string[]; kind: ChannelResolveKind; runtime: RuntimeEnv; }) => Promise; }; export type ChannelElevatedAdapter = { allowFromFallback?: (params: { cfg: OpenClawConfig; accountId?: string | null; }) => Array | undefined; }; export type ChannelCommandAdapter = { enforceOwnerForCommands?: boolean; skipWhenConfigEmpty?: boolean; }; export type ChannelSecurityAdapter = { resolveDmPolicy?: (ctx: ChannelSecurityContext) => ChannelSecurityDmPolicy | null; collectWarnings?: (ctx: ChannelSecurityContext) => Promise | string[]; };