From c245c8b39d39fa6b978d50c785a9abf12f05da6a Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Wed, 18 Mar 2026 11:27:07 +0530 Subject: [PATCH] refactor(plugin-sdk): split interactive runtime helpers --- extensions/discord/src/actions/handle-action.ts | 2 +- extensions/discord/src/shared-interactive.ts | 7 +++++-- extensions/slack/src/blocks-render.ts | 4 ++-- extensions/slack/src/message-action-dispatch.ts | 8 +++----- extensions/slack/src/outbound-adapter.ts | 4 ++-- extensions/telegram/src/button-types.ts | 4 ++-- extensions/telegram/src/outbound-adapter.ts | 2 +- package.json | 4 ++++ scripts/lib/plugin-sdk-entrypoints.json | 1 + src/plugin-sdk/interactive-runtime.ts | 17 +++++++++++++++++ 10 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 src/plugin-sdk/interactive-runtime.ts diff --git a/extensions/discord/src/actions/handle-action.ts b/extensions/discord/src/actions/handle-action.ts index 0fca934e86f..9726b07cdda 100644 --- a/extensions/discord/src/actions/handle-action.ts +++ b/extensions/discord/src/actions/handle-action.ts @@ -7,7 +7,7 @@ import { import { readBooleanParam } from "openclaw/plugin-sdk/boolean-param"; import { resolveReactionMessageId } from "openclaw/plugin-sdk/channel-runtime"; import type { ChannelMessageActionContext } from "openclaw/plugin-sdk/channel-runtime"; -import { normalizeInteractiveReply } from "openclaw/plugin-sdk/channel-runtime"; +import { normalizeInteractiveReply } from "openclaw/plugin-sdk/interactive-runtime"; import { buildDiscordInteractiveComponents } from "../shared-interactive.js"; import { resolveDiscordChannelId } from "../targets.js"; import { tryHandleDiscordMessageActionGuildAdmin } from "./handle-action.guild-admin.js"; diff --git a/extensions/discord/src/shared-interactive.ts b/extensions/discord/src/shared-interactive.ts index bb8bf1dac70..393b94cdf92 100644 --- a/extensions/discord/src/shared-interactive.ts +++ b/extensions/discord/src/shared-interactive.ts @@ -1,5 +1,8 @@ -import { reduceInteractiveReply } from "openclaw/plugin-sdk/channel-runtime"; -import type { InteractiveButtonStyle, InteractiveReply } from "openclaw/plugin-sdk/channel-runtime"; +import { reduceInteractiveReply } from "openclaw/plugin-sdk/interactive-runtime"; +import type { + InteractiveButtonStyle, + InteractiveReply, +} from "openclaw/plugin-sdk/interactive-runtime"; import type { DiscordComponentButtonStyle, DiscordComponentMessageSpec } from "./components.js"; function resolveDiscordInteractiveButtonStyle( diff --git a/extensions/slack/src/blocks-render.ts b/extensions/slack/src/blocks-render.ts index 775b988c521..f19d32c2c53 100644 --- a/extensions/slack/src/blocks-render.ts +++ b/extensions/slack/src/blocks-render.ts @@ -1,6 +1,6 @@ import type { Block, KnownBlock } from "@slack/web-api"; -import { reduceInteractiveReply } from "openclaw/plugin-sdk/channel-runtime"; -import type { InteractiveReply } from "openclaw/plugin-sdk/channel-runtime"; +import { reduceInteractiveReply } from "openclaw/plugin-sdk/interactive-runtime"; +import type { InteractiveReply } from "openclaw/plugin-sdk/interactive-runtime"; import { truncateSlackText } from "./truncate.js"; export const SLACK_REPLY_BUTTON_ACTION_ID = "openclaw:reply_button"; diff --git a/extensions/slack/src/message-action-dispatch.ts b/extensions/slack/src/message-action-dispatch.ts index b6a48035627..4a2e17f5455 100644 --- a/extensions/slack/src/message-action-dispatch.ts +++ b/extensions/slack/src/message-action-dispatch.ts @@ -1,11 +1,9 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; -import { - normalizeInteractiveReply, - type ChannelMessageActionContext, -} from "openclaw/plugin-sdk/channel-runtime"; +import type { ChannelMessageActionContext } from "openclaw/plugin-sdk/channel-runtime"; +import { normalizeInteractiveReply } from "openclaw/plugin-sdk/interactive-runtime"; +import { readNumberParam, readStringParam } from "../../../src/agents/tools/common.js"; import { parseSlackBlocksInput } from "./blocks-input.js"; import { buildSlackInteractiveBlocks } from "./blocks-render.js"; -import { readNumberParam, readStringParam } from "./runtime-api.js"; type SlackActionInvoke = ( action: Record, diff --git a/extensions/slack/src/outbound-adapter.ts b/extensions/slack/src/outbound-adapter.ts index 56a5c995e40..42888ea12b4 100644 --- a/extensions/slack/src/outbound-adapter.ts +++ b/extensions/slack/src/outbound-adapter.ts @@ -5,11 +5,11 @@ import { } from "openclaw/plugin-sdk/channel-runtime"; import type { ChannelOutboundAdapter } from "openclaw/plugin-sdk/channel-runtime"; import { resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-runtime"; +import type { OutboundIdentity } from "openclaw/plugin-sdk/infra-runtime"; import { resolveInteractiveTextFallback, type InteractiveReply, -} from "openclaw/plugin-sdk/channel-runtime"; -import type { OutboundIdentity } from "openclaw/plugin-sdk/infra-runtime"; +} from "openclaw/plugin-sdk/interactive-runtime"; import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime"; import { parseSlackBlocksInput } from "./blocks-input.js"; import { buildSlackInteractiveBlocks, type SlackBlock } from "./blocks-render.js"; diff --git a/extensions/telegram/src/button-types.ts b/extensions/telegram/src/button-types.ts index 15c307ca8c0..9aaaf55e655 100644 --- a/extensions/telegram/src/button-types.ts +++ b/extensions/telegram/src/button-types.ts @@ -1,9 +1,9 @@ -import { reduceInteractiveReply } from "openclaw/plugin-sdk/channel-runtime"; +import { reduceInteractiveReply } from "openclaw/plugin-sdk/interactive-runtime"; import { normalizeInteractiveReply, type InteractiveReply, type InteractiveReplyButton, -} from "openclaw/plugin-sdk/channel-runtime"; +} from "openclaw/plugin-sdk/interactive-runtime"; export type TelegramButtonStyle = "danger" | "success" | "primary"; diff --git a/extensions/telegram/src/outbound-adapter.ts b/extensions/telegram/src/outbound-adapter.ts index 1b12c5203a1..16ef036d93d 100644 --- a/extensions/telegram/src/outbound-adapter.ts +++ b/extensions/telegram/src/outbound-adapter.ts @@ -4,7 +4,7 @@ import { } from "openclaw/plugin-sdk/channel-runtime"; import type { ChannelOutboundAdapter } from "openclaw/plugin-sdk/channel-runtime"; import { resolveOutboundSendDep, type OutboundSendDeps } from "openclaw/plugin-sdk/channel-runtime"; -import { resolveInteractiveTextFallback } from "openclaw/plugin-sdk/channel-runtime"; +import { resolveInteractiveTextFallback } from "openclaw/plugin-sdk/interactive-runtime"; import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime"; import type { TelegramInlineButtons } from "./button-types.js"; import { resolveTelegramInlineButtons } from "./button-types.js"; diff --git a/package.json b/package.json index 6c536f0a518..5b9c9866ba9 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,10 @@ "types": "./dist/plugin-sdk/channel-runtime.d.ts", "default": "./dist/plugin-sdk/channel-runtime.js" }, + "./plugin-sdk/interactive-runtime": { + "types": "./dist/plugin-sdk/interactive-runtime.d.ts", + "default": "./dist/plugin-sdk/interactive-runtime.js" + }, "./plugin-sdk/infra-runtime": { "types": "./dist/plugin-sdk/infra-runtime.d.ts", "default": "./dist/plugin-sdk/infra-runtime.js" diff --git a/scripts/lib/plugin-sdk-entrypoints.json b/scripts/lib/plugin-sdk-entrypoints.json index 237f69282f2..55c22bf8470 100644 --- a/scripts/lib/plugin-sdk-entrypoints.json +++ b/scripts/lib/plugin-sdk-entrypoints.json @@ -14,6 +14,7 @@ "config-runtime", "reply-runtime", "channel-runtime", + "interactive-runtime", "infra-runtime", "media-runtime", "media-understanding-runtime", diff --git a/src/plugin-sdk/interactive-runtime.ts b/src/plugin-sdk/interactive-runtime.ts new file mode 100644 index 00000000000..2eef796733a --- /dev/null +++ b/src/plugin-sdk/interactive-runtime.ts @@ -0,0 +1,17 @@ +export { reduceInteractiveReply } from "../channels/plugins/outbound/interactive.js"; +export type { + InteractiveButtonStyle, + InteractiveReply, + InteractiveReplyBlock, + InteractiveReplyButton, + InteractiveReplyOption, + InteractiveReplySelectBlock, + InteractiveReplyTextBlock, +} from "../interactive/payload.js"; +export { + hasInteractiveReplyBlocks, + hasReplyChannelData, + hasReplyContent, + normalizeInteractiveReply, + resolveInteractiveTextFallback, +} from "../interactive/payload.js";