From 296083a49acbbb3902752307bf6538b0d0fad24b Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Mon, 16 Mar 2026 10:05:40 +0000 Subject: [PATCH] Plugin SDK: consolidate shared channel exports --- src/plugin-sdk/channel-plugin-common.ts | 4 +++ src/plugin-sdk/core.ts | 12 +++++---- src/plugin-sdk/discord.ts | 20 ++++++++++++++- src/plugin-sdk/imessage.ts | 20 ++++++++++++++- src/plugin-sdk/line.ts | 13 +++++----- src/plugin-sdk/signal.ts | 20 ++++++++++++++- src/plugin-sdk/slack.ts | 20 ++++++++++++++- src/plugin-sdk/subpaths.test.ts | 11 +++++++++ src/plugin-sdk/telegram.ts | 33 +++++++++++++------------ src/plugin-sdk/whatsapp.ts | 27 +++++++++++--------- 10 files changed, 137 insertions(+), 43 deletions(-) diff --git a/src/plugin-sdk/channel-plugin-common.ts b/src/plugin-sdk/channel-plugin-common.ts index 59c347c8f0c..3c5153733c0 100644 --- a/src/plugin-sdk/channel-plugin-common.ts +++ b/src/plugin-sdk/channel-plugin-common.ts @@ -1,4 +1,8 @@ +// Canonical shared prelude for channel-oriented plugin SDK surfaces. +// Keep `core` and channel-specific SDK entrypoints derived from this module +// so bundled channel entrypoints do not drift across overlapping exports. export type { ChannelPlugin } from "../channels/plugins/types.plugin.js"; +export type { ChannelMessageActionContext } from "../channels/plugins/types.js"; export type { PluginRuntime } from "../plugins/runtime/types.js"; export type { OpenClawPluginApi } from "../plugins/types.js"; diff --git a/src/plugin-sdk/core.ts b/src/plugin-sdk/core.ts index 2b23eff6b14..1e33cafe4e9 100644 --- a/src/plugin-sdk/core.ts +++ b/src/plugin-sdk/core.ts @@ -1,6 +1,5 @@ export type { AnyAgentTool, - OpenClawPluginApi, OpenClawPluginConfigSchema, ProviderDiscoveryContext, ProviderCatalogContext, @@ -52,9 +51,6 @@ export type { SshSandboxSession, SshSandboxSettings, } from "../agents/sandbox.js"; -export type { ChannelPlugin } from "../channels/plugins/types.plugin.js"; -export type { ChannelMessageActionContext } from "../channels/plugins/types.js"; -export type { PluginRuntime } from "../plugins/runtime/types.js"; export type { OpenClawConfig } from "../config/config.js"; export type { GatewayRequestHandlerOptions } from "../gateway/server-methods/types.js"; export type { @@ -62,8 +58,14 @@ export type { UsageProviderId, UsageWindow, } from "../infra/provider-usage.types.js"; +export type { + ChannelMessageActionContext, + ChannelPlugin, + OpenClawPluginApi, + PluginRuntime, +} from "./channel-plugin-common.js"; -export { emptyPluginConfigSchema } from "../plugins/config-schema.js"; +export { emptyPluginConfigSchema } from "./channel-plugin-common.js"; export { buildExecRemoteCommand, buildRemoteCommand, diff --git a/src/plugin-sdk/discord.ts b/src/plugin-sdk/discord.ts index 82ffb8dde5c..d15f5091b9d 100644 --- a/src/plugin-sdk/discord.ts +++ b/src/plugin-sdk/discord.ts @@ -1,7 +1,25 @@ export type { ChannelMessageActionAdapter } from "../channels/plugins/types.js"; export type { OpenClawConfig } from "../config/config.js"; export type { DiscordAccountConfig, DiscordActionConfig } from "../config/types.js"; -export * from "./channel-plugin-common.js"; +export type { + ChannelMessageActionContext, + ChannelPlugin, + OpenClawPluginApi, + PluginRuntime, +} from "./channel-plugin-common.js"; +export { + DEFAULT_ACCOUNT_ID, + PAIRING_APPROVED_MESSAGE, + applyAccountNameToChannelSection, + buildChannelConfigSchema, + deleteAccountFromConfigSection, + emptyPluginConfigSchema, + formatPairingApproveHint, + getChatChannelMeta, + migrateBaseNameToDefaultAccount, + normalizeAccountId, + setAccountEnabledInConfigSection, +} from "./channel-plugin-common.js"; export { projectCredentialSnapshotFields, diff --git a/src/plugin-sdk/imessage.ts b/src/plugin-sdk/imessage.ts index f896799b323..a974910e680 100644 --- a/src/plugin-sdk/imessage.ts +++ b/src/plugin-sdk/imessage.ts @@ -1,5 +1,23 @@ export type { IMessageAccountConfig } from "../config/types.js"; -export * from "./channel-plugin-common.js"; +export type { + ChannelMessageActionContext, + ChannelPlugin, + OpenClawPluginApi, + PluginRuntime, +} from "./channel-plugin-common.js"; +export { + DEFAULT_ACCOUNT_ID, + PAIRING_APPROVED_MESSAGE, + applyAccountNameToChannelSection, + buildChannelConfigSchema, + deleteAccountFromConfigSection, + emptyPluginConfigSchema, + formatPairingApproveHint, + getChatChannelMeta, + migrateBaseNameToDefaultAccount, + normalizeAccountId, + setAccountEnabledInConfigSection, +} from "./channel-plugin-common.js"; export { formatTrimmedAllowFromEntries, resolveIMessageConfigAllowFrom, diff --git a/src/plugin-sdk/line.ts b/src/plugin-sdk/line.ts index c21ee9661fb..b6617199472 100644 --- a/src/plugin-sdk/line.ts +++ b/src/plugin-sdk/line.ts @@ -6,15 +6,14 @@ export type { export type { ChannelPlugin } from "../channels/plugins/types.plugin.js"; export type { OpenClawConfig } from "../config/config.js"; export type { ReplyPayload } from "../auto-reply/types.js"; -export type { PluginRuntime } from "../plugins/runtime/types.js"; -export type { OpenClawPluginApi } from "../plugins/types.js"; export type { ChannelSetupAdapter } from "../channels/plugins/types.adapters.js"; +export type { OpenClawPluginApi, PluginRuntime } from "./channel-plugin-common.js"; -export { emptyPluginConfigSchema } from "../plugins/config-schema.js"; - -export { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; - -export { buildChannelConfigSchema } from "../channels/plugins/config-schema.js"; +export { + DEFAULT_ACCOUNT_ID, + buildChannelConfigSchema, + emptyPluginConfigSchema, +} from "./channel-plugin-common.js"; export { clearAccountEntryFields } from "../channels/plugins/config-helpers.js"; export { diff --git a/src/plugin-sdk/signal.ts b/src/plugin-sdk/signal.ts index 86f83b06318..8fd6fd2afd0 100644 --- a/src/plugin-sdk/signal.ts +++ b/src/plugin-sdk/signal.ts @@ -1,6 +1,24 @@ export type { ChannelMessageActionAdapter } from "../channels/plugins/types.js"; export type { SignalAccountConfig } from "../config/types.js"; -export * from "./channel-plugin-common.js"; +export type { + ChannelMessageActionContext, + ChannelPlugin, + OpenClawPluginApi, + PluginRuntime, +} from "./channel-plugin-common.js"; +export { + DEFAULT_ACCOUNT_ID, + PAIRING_APPROVED_MESSAGE, + applyAccountNameToChannelSection, + buildChannelConfigSchema, + deleteAccountFromConfigSection, + emptyPluginConfigSchema, + formatPairingApproveHint, + getChatChannelMeta, + migrateBaseNameToDefaultAccount, + normalizeAccountId, + setAccountEnabledInConfigSection, +} from "./channel-plugin-common.js"; export { looksLikeSignalTargetId, diff --git a/src/plugin-sdk/slack.ts b/src/plugin-sdk/slack.ts index 93ad140bfad..f7533b95687 100644 --- a/src/plugin-sdk/slack.ts +++ b/src/plugin-sdk/slack.ts @@ -1,6 +1,24 @@ export type { OpenClawConfig } from "../config/config.js"; export type { SlackAccountConfig } from "../config/types.slack.js"; -export * from "./channel-plugin-common.js"; +export type { + ChannelMessageActionContext, + ChannelPlugin, + OpenClawPluginApi, + PluginRuntime, +} from "./channel-plugin-common.js"; +export { + DEFAULT_ACCOUNT_ID, + PAIRING_APPROVED_MESSAGE, + applyAccountNameToChannelSection, + buildChannelConfigSchema, + deleteAccountFromConfigSection, + emptyPluginConfigSchema, + formatPairingApproveHint, + getChatChannelMeta, + migrateBaseNameToDefaultAccount, + normalizeAccountId, + setAccountEnabledInConfigSection, +} from "./channel-plugin-common.js"; export { projectCredentialSnapshotFields, diff --git a/src/plugin-sdk/subpaths.test.ts b/src/plugin-sdk/subpaths.test.ts index 0a65721ceb4..856bacbca10 100644 --- a/src/plugin-sdk/subpaths.test.ts +++ b/src/plugin-sdk/subpaths.test.ts @@ -19,6 +19,11 @@ import { describe, expect, expectTypeOf, it } from "vitest"; import type { ChannelMessageActionContext } from "../channels/plugins/types.js"; import type { PluginRuntime } from "../plugins/runtime/types.js"; import type { OpenClawPluginApi } from "../plugins/types.js"; +import type { + ChannelMessageActionContext as SharedChannelMessageActionContext, + OpenClawPluginApi as SharedOpenClawPluginApi, + PluginRuntime as SharedPluginRuntime, +} from "./channel-plugin-common.js"; import { pluginSdkSubpaths } from "./entrypoints.js"; const importPluginSdkSubpath = (specifier: string) => import(/* @vite-ignore */ specifier); @@ -49,6 +54,12 @@ describe("plugin-sdk subpath exports", () => { expectTypeOf().toMatchTypeOf(); }); + it("keeps core shared types aligned with the channel prelude", () => { + expectTypeOf().toMatchTypeOf(); + expectTypeOf().toMatchTypeOf(); + expectTypeOf().toMatchTypeOf(); + }); + it("exports Discord helpers", () => { expect(typeof discordSdk.buildChannelConfigSchema).toBe("function"); expect(typeof discordSdk.DiscordConfigSchema).toBe("object"); diff --git a/src/plugin-sdk/telegram.ts b/src/plugin-sdk/telegram.ts index 397a48fa019..2eed87097f0 100644 --- a/src/plugin-sdk/telegram.ts +++ b/src/plugin-sdk/telegram.ts @@ -3,28 +3,29 @@ export type { ChannelGatewayContext, ChannelMessageActionAdapter, } from "../channels/plugins/types.js"; -export type { ChannelPlugin } from "../channels/plugins/types.plugin.js"; export type { OpenClawConfig } from "../config/config.js"; -export type { PluginRuntime } from "../plugins/runtime/types.js"; -export type { OpenClawPluginApi } from "../plugins/types.js"; export type { TelegramAccountConfig, TelegramActionConfig } from "../config/types.js"; - -export { emptyPluginConfigSchema } from "../plugins/config-schema.js"; -export { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js"; - +export type { + ChannelMessageActionContext, + ChannelPlugin, + OpenClawPluginApi, + PluginRuntime, +} from "./channel-plugin-common.js"; export { + DEFAULT_ACCOUNT_ID, + PAIRING_APPROVED_MESSAGE, applyAccountNameToChannelSection, - migrateBaseNameToDefaultAccount, -} from "../channels/plugins/setup-helpers.js"; -export { buildChannelConfigSchema } from "../channels/plugins/config-schema.js"; -export { + buildChannelConfigSchema, deleteAccountFromConfigSection, - clearAccountEntryFields, + emptyPluginConfigSchema, + formatPairingApproveHint, + getChatChannelMeta, + migrateBaseNameToDefaultAccount, + normalizeAccountId, setAccountEnabledInConfigSection, -} from "../channels/plugins/config-helpers.js"; -export { formatPairingApproveHint } from "../channels/plugins/helpers.js"; -export { PAIRING_APPROVED_MESSAGE } from "../channels/plugins/pairing-message.js"; -export { getChatChannelMeta } from "../channels/registry.js"; +} from "./channel-plugin-common.js"; + +export { clearAccountEntryFields } from "../channels/plugins/config-helpers.js"; export { projectCredentialSnapshotFields, diff --git a/src/plugin-sdk/whatsapp.ts b/src/plugin-sdk/whatsapp.ts index 7e4debbef43..df814fa04eb 100644 --- a/src/plugin-sdk/whatsapp.ts +++ b/src/plugin-sdk/whatsapp.ts @@ -1,20 +1,25 @@ export type { ChannelMessageActionName } from "../channels/plugins/types.js"; -export type { ChannelPlugin } from "../channels/plugins/types.plugin.js"; export type { OpenClawConfig } from "../config/config.js"; export type { DmPolicy, GroupPolicy, WhatsAppAccountConfig } from "../config/types.js"; -export type { PluginRuntime } from "../plugins/runtime/types.js"; -export type { OpenClawPluginApi } from "../plugins/types.js"; - -export { emptyPluginConfigSchema } from "../plugins/config-schema.js"; -export { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js"; - +export type { + ChannelMessageActionContext, + ChannelPlugin, + OpenClawPluginApi, + PluginRuntime, +} from "./channel-plugin-common.js"; export { + DEFAULT_ACCOUNT_ID, + PAIRING_APPROVED_MESSAGE, applyAccountNameToChannelSection, + buildChannelConfigSchema, + deleteAccountFromConfigSection, + emptyPluginConfigSchema, + formatPairingApproveHint, + getChatChannelMeta, migrateBaseNameToDefaultAccount, -} from "../channels/plugins/setup-helpers.js"; -export { buildChannelConfigSchema } from "../channels/plugins/config-schema.js"; -export { formatPairingApproveHint } from "../channels/plugins/helpers.js"; -export { getChatChannelMeta } from "../channels/registry.js"; + normalizeAccountId, + setAccountEnabledInConfigSection, +} from "./channel-plugin-common.js"; export { formatWhatsAppConfigAllowFromEntries, resolveWhatsAppConfigAllowFrom,