@@ -4,8 +4,9 @@ import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking"
44// Catalog routing keys off plugin ids, docs surfaces render `meta.docsPath`,
55// and capability flags gate feature discovery, so every bundled channel must
66// keep identity metadata aligned with its catalog id and capability flags
7- // coherent with the adapters that implement them. Per-surface behavior checks
8- // live in the registry-backed shard suites; this suite pins the static shape.
7+ // coherent with the adapters that implement them. This suite already loads
8+ // every bundled plugin, so it also owns loaded-plugin parity for lightweight
9+ // artifacts while the artifact shards pin inventory, exports, and invocation.
910//
1011// Capability rules verified against every bundled channel before pinning.
1112// Dropped for legitimate exceptions rather than special-casing:
@@ -18,7 +19,11 @@ import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking"
1819import { beforeAll , describe , expect , it } from "vitest" ;
1920import { listBundledPackageChannelMetadata } from "../../../plugins/bundled-package-channel-metadata.js" ;
2021import {
22+ getBundledChannelGatewayAuthArtifactAsync ,
23+ getBundledChannelMessageToolArtifactAsync ,
2124 getBundledChannelPluginAsync ,
25+ getBundledChannelSessionKeyArtifactAsync ,
26+ getBundledChannelThreadBindingArtifactAsync ,
2227 listBundledChannelPluginIds ,
2328} from "./test-helpers/bundled-channel-plugin-loader.js" ;
2429
@@ -37,14 +42,46 @@ const SHARED_SANITIZER_CHANNEL_IDS = [
3742 "matrix" ,
3843 "slack" ,
3944] as const ;
45+ const MESSAGE_TOOL_ARTIFACT_PLUGIN_IDS = [ "imessage" , "slack" ] as const ;
46+ const SESSION_CONVERSATION_ARTIFACT_PLUGIN_IDS = [ "feishu" , "telegram" ] as const ;
47+ const THREAD_BINDING_ARTIFACT_PLUGIN_IDS = [ "discord" , "matrix" ] as const ;
48+
49+ type ExplicitSessionKeyNormalizer = (
50+ sessionKey : string ,
51+ ctx : { ChatType ?: string ; From ?: string ; SenderId ?: string } ,
52+ ) => string ;
4053
4154describe ( "bundled channel plugin shape coherence" , ( ) => {
4255 const plugins = new Map < string , Awaited < ReturnType < typeof getBundledChannelPluginAsync > > > ( ) ;
56+ const messageToolArtifacts = new Map <
57+ string ,
58+ Awaited < ReturnType < typeof getBundledChannelMessageToolArtifactAsync > >
59+ > ( ) ;
60+ const sessionKeyArtifacts = new Map <
61+ string ,
62+ Awaited < ReturnType < typeof getBundledChannelSessionKeyArtifactAsync > >
63+ > ( ) ;
64+ const threadBindingArtifacts = new Map <
65+ string ,
66+ Awaited < ReturnType < typeof getBundledChannelThreadBindingArtifactAsync > >
67+ > ( ) ;
68+ let gatewayAuthArtifact : Awaited < ReturnType < typeof getBundledChannelGatewayAuthArtifactAsync > > =
69+ null ;
4370
4471 beforeAll ( async ( ) => {
4572 for ( const id of bundledChannelPluginIds ) {
4673 plugins . set ( id , await getBundledChannelPluginAsync ( id ) ) ;
4774 }
75+ for ( const id of MESSAGE_TOOL_ARTIFACT_PLUGIN_IDS ) {
76+ messageToolArtifacts . set ( id , await getBundledChannelMessageToolArtifactAsync ( id ) ) ;
77+ }
78+ gatewayAuthArtifact = await getBundledChannelGatewayAuthArtifactAsync ( "mattermost" ) ;
79+ for ( const id of [ "discord" , ...SESSION_CONVERSATION_ARTIFACT_PLUGIN_IDS ] as const ) {
80+ sessionKeyArtifacts . set ( id , await getBundledChannelSessionKeyArtifactAsync ( id ) ) ;
81+ }
82+ for ( const id of THREAD_BINDING_ARTIFACT_PLUGIN_IDS ) {
83+ threadBindingArtifacts . set ( id , await getBundledChannelThreadBindingArtifactAsync ( id ) ) ;
84+ }
4885 } ) ;
4986
5087 it ( "discovers bundled channel plugins from the catalog" , ( ) => {
@@ -74,6 +111,80 @@ describe("bundled channel plugin shape coherence", () => {
74111 } ,
75112 ) ;
76113
114+ it . each ( MESSAGE_TOOL_ARTIFACT_PLUGIN_IDS ) (
115+ "keeps the %s message-tool artifact identical to the loaded plugin action surface" ,
116+ ( id ) => {
117+ const artifactDescribeMessageTool = messageToolArtifacts . get ( id ) ?. describeMessageTool ;
118+ const pluginDescribeMessageTool = plugins . get ( id ) ?. actions ?. describeMessageTool ;
119+
120+ expect ( typeof artifactDescribeMessageTool ) . toBe ( "function" ) ;
121+ expect ( typeof pluginDescribeMessageTool ) . toBe ( "function" ) ;
122+ expect ( artifactDescribeMessageTool ) . toBe ( pluginDescribeMessageTool ) ;
123+ } ,
124+ ) ;
125+
126+ it ( "keeps the mattermost gateway-auth artifact identical to the loaded plugin gateway surface" , ( ) => {
127+ const artifactResolveGatewayAuthBypassPaths =
128+ gatewayAuthArtifact ?. resolveGatewayAuthBypassPaths ;
129+ const pluginResolveGatewayAuthBypassPaths =
130+ plugins . get ( "mattermost" ) ?. gateway ?. resolveGatewayAuthBypassPaths ;
131+
132+ expect ( typeof artifactResolveGatewayAuthBypassPaths ) . toBe ( "function" ) ;
133+ expect ( typeof pluginResolveGatewayAuthBypassPaths ) . toBe ( "function" ) ;
134+ expect ( artifactResolveGatewayAuthBypassPaths ) . toBe ( pluginResolveGatewayAuthBypassPaths ) ;
135+ } ) ;
136+
137+ it . each ( SESSION_CONVERSATION_ARTIFACT_PLUGIN_IDS ) (
138+ "keeps the %s session-conversation artifact identical to the loaded plugin messaging hook" ,
139+ ( id ) => {
140+ const artifactResolveSessionConversation =
141+ sessionKeyArtifacts . get ( id ) ?. resolveSessionConversation ;
142+ const pluginResolveSessionConversation =
143+ plugins . get ( id ) ?. messaging ?. resolveSessionConversation ;
144+
145+ expect ( typeof artifactResolveSessionConversation ) . toBe ( "function" ) ;
146+ expect ( typeof pluginResolveSessionConversation ) . toBe ( "function" ) ;
147+ expect ( artifactResolveSessionConversation ) . toBe ( pluginResolveSessionConversation ) ;
148+ } ,
149+ ) ;
150+
151+ it ( "keeps the discord session-key artifact behavior aligned with the loaded plugin adapter" , ( ) => {
152+ const normalize = sessionKeyArtifacts . get ( "discord" ) ?. normalizeExplicitDiscordSessionKey as
153+ | ExplicitSessionKeyNormalizer
154+ | undefined ;
155+ const pluginNormalize = plugins . get ( "discord" ) ?. messaging ?. normalizeExplicitSessionKey ;
156+
157+ expect ( typeof normalize ) . toBe ( "function" ) ;
158+ expect ( typeof pluginNormalize ) . toBe ( "function" ) ;
159+ if ( typeof normalize !== "function" || typeof pluginNormalize !== "function" ) {
160+ throw new Error ( "Missing discord session-key normalizer parity surface" ) ;
161+ }
162+
163+ // The plugin hook adapts core's params-object shape onto the artifact's
164+ // positional export, so pin behavioral parity over representative keys.
165+ const cases = [
166+ { sessionKey : "discord:channel:123" , ctx : { ChatType : "direct" , SenderId : "123" } } ,
167+ { sessionKey : "discord:dm:42" , ctx : { ChatType : "dm" , From : "discord:42" } } ,
168+ { sessionKey : "agent:m:discord:channel:9" , ctx : { ChatType : "direct" , From : "discord:9" } } ,
169+ { sessionKey : "Discord:Channel:77" , ctx : { ChatType : "group" , SenderId : "77" } } ,
170+ ] as const ;
171+ for ( const { sessionKey, ctx } of cases ) {
172+ expect ( pluginNormalize ( { sessionKey, ctx } ) ) . toBe ( normalize ( sessionKey , ctx ) ) ;
173+ }
174+ } ) ;
175+
176+ it . each ( THREAD_BINDING_ARTIFACT_PLUGIN_IDS ) (
177+ "keeps the %s thread-binding artifact equal to the loaded plugin default" ,
178+ ( id ) => {
179+ const artifactPlacement = threadBindingArtifacts . get ( id ) ?. defaultTopLevelPlacement ;
180+ const pluginPlacement = plugins . get ( id ) ?. conversationBindings ?. defaultTopLevelPlacement ;
181+
182+ expect ( [ "current" , "child" ] ) . toContain ( artifactPlacement ) ;
183+ expect ( [ "current" , "child" ] ) . toContain ( pluginPlacement ) ;
184+ expect ( artifactPlacement ) . toBe ( pluginPlacement ) ;
185+ } ,
186+ ) ;
187+
77188 describe . each ( bundledChannelPluginIds ) ( "%s" , ( id ) => {
78189 it ( "keeps plugin identity aligned with the catalog id" , ( ) => {
79190 const plugin = plugins . get ( id ) ;
0 commit comments