11import { afterEach , describe , expect , it , vi } from "vitest" ;
2+ import type { ChannelMessageCapability } from "../../channels/plugins/message-capabilities.js" ;
23import type { ChannelMessageActionName , ChannelPlugin } from "../../channels/plugins/types.js" ;
34import type { MessageActionRunResult } from "../../infra/outbound/message-action-runner.js" ;
45import { setActivePluginRegistry } from "../../plugins/runtime.js" ;
@@ -47,9 +48,10 @@ function createChannelPlugin(params: {
4748 blurb : string ;
4849 actions ?: ChannelMessageActionName [ ] ;
4950 listActions ?: NonNullable < NonNullable < ChannelPlugin [ "actions" ] > [ "listActions" ] > ;
50- supportsButtons ?: boolean ;
51+ capabilities ?: readonly ChannelMessageCapability [ ] ;
5152 messaging ?: ChannelPlugin [ "messaging" ] ;
5253} ) : ChannelPlugin {
54+ const actionCapabilities = params . capabilities ;
5355 return {
5456 id : params . id as ChannelPlugin [ "id" ] ,
5557 meta : {
@@ -71,7 +73,9 @@ function createChannelPlugin(params: {
7173 ( ( ) => {
7274 return ( params . actions ?? [ ] ) as never ;
7375 } ) ,
74- ...( params . supportsButtons ? { supportsButtons : ( ) => true } : { } ) ,
76+ ...( actionCapabilities
77+ ? { getCapabilities : ( _params : { cfg : unknown } ) => actionCapabilities }
78+ : { } ) ,
7579 } ,
7680 } ;
7781}
@@ -145,7 +149,7 @@ describe("message tool schema scoping", () => {
145149 docsPath : "/channels/telegram" ,
146150 blurb : "Telegram test plugin." ,
147151 actions : [ "send" , "react" , "poll" ] ,
148- supportsButtons : true ,
152+ capabilities : [ "interactive" , "buttons" ] ,
149153 } ) ;
150154
151155 const discordPlugin = createChannelPlugin ( {
@@ -154,6 +158,16 @@ describe("message tool schema scoping", () => {
154158 docsPath : "/channels/discord" ,
155159 blurb : "Discord test plugin." ,
156160 actions : [ "send" , "poll" , "poll-vote" ] ,
161+ capabilities : [ "interactive" , "components" ] ,
162+ } ) ;
163+
164+ const slackPlugin = createChannelPlugin ( {
165+ id : "slack" ,
166+ label : "Slack" ,
167+ docsPath : "/channels/slack" ,
168+ blurb : "Slack test plugin." ,
169+ actions : [ "send" , "react" ] ,
170+ capabilities : [ "interactive" , "blocks" ] ,
157171 } ) ;
158172
159173 afterEach ( ( ) => {
@@ -164,6 +178,7 @@ describe("message tool schema scoping", () => {
164178 {
165179 provider : "telegram" ,
166180 expectComponents : false ,
181+ expectBlocks : false ,
167182 expectButtons : true ,
168183 expectButtonStyle : true ,
169184 expectTelegramPollExtras : true ,
@@ -172,16 +187,27 @@ describe("message tool schema scoping", () => {
172187 {
173188 provider : "discord" ,
174189 expectComponents : true ,
190+ expectBlocks : false ,
175191 expectButtons : false ,
176192 expectButtonStyle : false ,
177193 expectTelegramPollExtras : true ,
178194 expectedActions : [ "send" , "poll" , "poll-vote" , "react" ] ,
179195 } ,
196+ {
197+ provider : "slack" ,
198+ expectComponents : false ,
199+ expectBlocks : true ,
200+ expectButtons : false ,
201+ expectButtonStyle : false ,
202+ expectTelegramPollExtras : true ,
203+ expectedActions : [ "send" , "react" , "poll" , "poll-vote" ] ,
204+ } ,
180205 ] ) (
181206 "scopes schema fields for $provider" ,
182207 ( {
183208 provider,
184209 expectComponents,
210+ expectBlocks,
185211 expectButtons,
186212 expectButtonStyle,
187213 expectTelegramPollExtras,
@@ -191,6 +217,7 @@ describe("message tool schema scoping", () => {
191217 createTestRegistry ( [
192218 { pluginId : "telegram" , source : "test" , plugin : telegramPlugin } ,
193219 { pluginId : "discord" , source : "test" , plugin : discordPlugin } ,
220+ { pluginId : "slack" , source : "test" , plugin : slackPlugin } ,
194221 ] ) ,
195222 ) ;
196223
@@ -206,6 +233,11 @@ describe("message tool schema scoping", () => {
206233 } else {
207234 expect ( properties . components ) . toBeUndefined ( ) ;
208235 }
236+ if ( expectBlocks ) {
237+ expect ( properties . blocks ) . toBeDefined ( ) ;
238+ } else {
239+ expect ( properties . blocks ) . toBeUndefined ( ) ;
240+ }
209241 if ( expectButtons ) {
210242 expect ( properties . buttons ) . toBeDefined ( ) ;
211243 } else {
@@ -263,7 +295,7 @@ describe("message tool schema scoping", () => {
263295 . channels ?. telegram ;
264296 return telegramCfg ?. actions ?. poll === false ? [ "send" , "react" ] : [ "send" , "react" , "poll" ] ;
265297 } ,
266- supportsButtons : true ,
298+ capabilities : [ "interactive" , "buttons" ] ,
267299 } ) ;
268300
269301 setActivePluginRegistry (
0 commit comments