export type LogFn = (message: string) => void; export type SecretRefSource = "env" | "file" | "exec"; export type SecretRef = { source: SecretRefSource; provider: string; id: string; }; export type SecretInput = string | SecretRef; export type DmPolicy = "open" | "pairing" | "allowlist"; export type GroupPolicy = "open" | "allowlist" | "disabled"; export type AllowlistMatch = { allowed: boolean; matchKey?: string; matchSource?: TSource; }; export type BaseProbeResult = { ok: boolean; target?: TTarget; error?: string; [key: string]: unknown; }; export type ReplyPayload = { text?: string; mediaUrl?: string; mediaUrls?: string[]; [key: string]: unknown; }; export type HistoryEntry = { sender: string; body: string; timestamp?: number; messageId?: string; }; export type GroupToolPolicyConfig = Record; export type ChannelGroupContext = { cfg: ClawdbotConfig; groupId?: string | null; [key: string]: unknown; }; export type ChannelMeta = { id: string; label: string; selectionLabel?: string; docsPath?: string; docsLabel?: string; blurb?: string; aliases?: string[]; order?: number; [key: string]: unknown; }; export type ChannelPlugin = { id: string; meta: ChannelMeta; config?: Record; onboarding?: ChannelOnboardingAdapter; [key: string]: unknown; __resolvedAccountType__?: ResolvedAccount; }; export type ChannelOutboundAdapter = Record; export type AnyAgentTool = { name?: string; description?: string; parameters?: Record; execute?: (toolCallId: string, params: unknown) => Promise | unknown; [key: string]: unknown; }; export type ResolvedAgentRoute = { agentId?: string; sessionKey?: string; [key: string]: unknown; }; export type InboundDebouncer = { run: (key: string, value: T, task: (value: T) => Promise) => void; clear: () => void; }; export type PluginRuntime = { version?: string; config: { loadConfig?: () => OpenClawConfig; writeConfigFile: (next: OpenClawConfig) => Promise; }; logging: { shouldLogVerbose: () => boolean; }; media: { detectMime: (params: { buffer: Buffer }) => Promise; loadWebMedia: ( url: string, options?: Record, ) => Promise>; }; channel: { media: { fetchRemoteMedia: (params: { url: string; maxBytes?: number; }) => Promise>; saveMediaBuffer: ( buffer: Buffer, contentType?: string, direction?: string, maxBytes?: number, ) => Promise<{ path: string; contentType?: string }>; }; text: { chunkMarkdownText: (text: string, limit: number) => string[]; resolveMarkdownTableMode: (params: Record) => unknown; convertMarkdownTables: (text: string, mode?: unknown) => string; resolveTextChunkLimit: ( cfg: OpenClawConfig, channel: string, accountId?: string, options?: Record, ) => number; resolveChunkMode: (cfg: OpenClawConfig, channel: string) => string; chunkTextWithMode: (text: string, limit: number, mode?: unknown) => string[]; hasControlCommand: (text: string, cfg: OpenClawConfig) => boolean; }; reply: { resolveEnvelopeFormatOptions: (cfg: OpenClawConfig) => Record; formatAgentEnvelope: (params: Record) => string; finalizeInboundContext: (params: Record) => Record; withReplyDispatcher: (params: Record) => Promise>; dispatchReplyFromConfig: (params: Record) => Promise>; createReplyDispatcherWithTyping: (params: Record) => { dispatcher: unknown; replyOptions: Record; markDispatchIdle: () => void; }; resolveHumanDelayConfig: (cfg: OpenClawConfig, agentId: string) => unknown; dispatchReplyWithBufferedBlockDispatcher?: ( params: Record, ) => Promise; }; routing: { resolveAgentRoute: (params: Record) => ResolvedAgentRoute | null; }; pairing: { readAllowFromStore: (params: { channel: string; accountId?: string }) => unknown; upsertPairingRequest: (params: Record) => Promise<{ code: string; created: boolean; }>; }; commands: { shouldComputeCommandAuthorized: (text: string) => boolean; resolveCommandAuthorizedFromAuthorizers: ( params: Record, ) => Promise | boolean; }; debounce: { resolveInboundDebounceMs: (params: Record) => number; createInboundDebouncer: (params: Record) => InboundDebouncer; }; }; [key: string]: unknown; }; export type RuntimeEnv = { log?: (message: string) => void; error?: (message: string) => void; warn?: (message: string) => void; debug?: (message: string) => void; info?: (message: string) => void; [key: string]: unknown; }; export type OpenClawPluginApi = { config: ClawdbotConfig; runtime: PluginRuntime; logger: { info: LogFn; warn: LogFn; error: LogFn; debug?: LogFn; }; registerTool: ( tool: | AnyAgentTool | ((ctx: Record) => AnyAgentTool | AnyAgentTool[] | null | undefined), opts?: { name?: string; names?: string[]; optional?: boolean }, ) => void; registerChannel: (registration: unknown) => void; [key: string]: unknown; }; export type WizardSelectOption = { value: T; label: string; hint?: string; }; export type WizardPrompter = { note: (message: string, title?: string) => Promise; text: (params: { message: string; placeholder?: string; initialValue?: string; validate?: (value: string) => string | undefined; }) => Promise; confirm: (params: { message: string; initialValue?: boolean }) => Promise; select: (params: { message: string; options: WizardSelectOption[]; initialValue?: T | string; }) => Promise; }; export type ChannelOnboardingDmPolicy = { label: string; channel: string; policyKey: string; allowFromKey: string; getCurrent: (cfg: ClawdbotConfig) => DmPolicy; setPolicy: (cfg: ClawdbotConfig, policy: DmPolicy) => ClawdbotConfig; promptAllowFrom: (params: { cfg: ClawdbotConfig; prompter: WizardPrompter; }) => Promise; }; export type ChannelOnboardingAdapter = { channel: string; getStatus: (params: { cfg: ClawdbotConfig }) => Promise<{ channel: string; configured: boolean; statusLines: string[]; selectionHint?: string; quickstartScore?: number; }>; configure: (params: { cfg: ClawdbotConfig; prompter: WizardPrompter; }) => Promise<{ cfg: ClawdbotConfig; accountId?: string }>; dmPolicy?: ChannelOnboardingDmPolicy; disable?: (cfg: ClawdbotConfig) => ClawdbotConfig; }; export type OpenClawConfig = { channels?: Record | undefined>; bindings?: Array<{ agentId?: string; match?: { channel?: string; peer?: { kind?: string; id?: string; }; }; }>; agents?: { list?: Array<{ id: string; workspace?: string; agentDir?: string; [key: string]: unknown; }>; [key: string]: unknown; }; broadcast?: Record; secrets?: { defaults?: { env?: string; file?: string; exec?: string; }; providers?: Record< string, { source?: SecretRefSource; path?: string; mode?: "singleValue" | "json"; command?: string; args?: string[]; [key: string]: unknown; } >; [key: string]: unknown; }; [key: string]: unknown; }; export type ClawdbotConfig = OpenClawConfig;