@@ -247,6 +247,36 @@ function getBindingChannelPlugin(channel: ChannelId) {
247247 return getLoadedChannelPlugin ( channel ) ?? getBundledChannelSetupPlugin ( channel ) ;
248248}
249249
250+ function resolveFeishuConversationBindingPeer (
251+ raw : string ,
252+ ) : { kind : "direct" | "group" ; id : string } | undefined {
253+ const trimmed = raw . trim ( ) ;
254+ if ( ! trimmed ) {
255+ return undefined ;
256+ }
257+ const lowered = trimmed . toLowerCase ( ) ;
258+ if (
259+ lowered . startsWith ( "user:" ) ||
260+ lowered . startsWith ( "dm:" ) ||
261+ lowered . startsWith ( "open_id:" ) ||
262+ lowered . startsWith ( "ou_" ) ||
263+ lowered . startsWith ( "on_" )
264+ ) {
265+ const id = trimmed . replace ( / ^ ( u s e r | d m | o p e n _ i d ) : / i, "" ) . trim ( ) ;
266+ return id ? { kind : "direct" , id } : undefined ;
267+ }
268+ if (
269+ lowered . startsWith ( "chat:" ) ||
270+ lowered . startsWith ( "group:" ) ||
271+ lowered . startsWith ( "channel:" ) ||
272+ lowered . startsWith ( "oc_" )
273+ ) {
274+ const id = trimmed . replace ( / ^ ( c h a t | g r o u p | c h a n n e l ) : / i, "" ) . trim ( ) ;
275+ return id ? { kind : "group" , id } : undefined ;
276+ }
277+ return undefined ;
278+ }
279+
250280function resolveBindingAccountId ( params : {
251281 channel : ChannelId ;
252282 config : OpenClawConfig ;
@@ -316,7 +346,9 @@ export function parseBindingSpecs(params: {
316346 if ( ! trimmed ) {
317347 continue ;
318348 }
319- const [ channelRaw , accountRaw ] = trimmed . split ( ":" , 2 ) ;
349+ const separatorIndex = trimmed . indexOf ( ":" ) ;
350+ const channelRaw = separatorIndex >= 0 ? trimmed . slice ( 0 , separatorIndex ) : trimmed ;
351+ const accountRaw = separatorIndex >= 0 ? trimmed . slice ( separatorIndex + 1 ) : undefined ;
320352 const channel = normalizeBindingChannelId ( channelRaw , params . config ) ;
321353 if ( ! channel ) {
322354 errors . push ( formatUnknownChannelMessage ( { channel : channelRaw } ) ) ;
@@ -329,16 +361,23 @@ export function parseBindingSpecs(params: {
329361 ) ;
330362 continue ;
331363 }
364+ const feishuPeer =
365+ channel === "feishu" && accountId
366+ ? resolveFeishuConversationBindingPeer ( accountId )
367+ : undefined ;
332368 accountId = resolveBindingAccountId ( {
333369 channel,
334370 config : params . config ,
335371 agentId,
336- explicitAccountId : accountId ,
372+ explicitAccountId : feishuPeer ? undefined : accountId ,
337373 } ) ;
338374 const match : AgentRouteBinding [ "match" ] = { channel } ;
339375 if ( accountId ) {
340376 match . accountId = accountId ;
341377 }
378+ if ( feishuPeer ) {
379+ match . peer = feishuPeer ;
380+ }
342381 bindings . push ( { type : "route" , agentId, match } ) ;
343382 }
344383 return { bindings, errors } ;
0 commit comments