-
-
Notifications
You must be signed in to change notification settings - Fork 57.8k
Open
Description
Problem
Agents must use 26-character Mattermost channel IDs to send messages (e.g. target: "uygoe35x3idumqo5mb5jfbqrdh"). This is error-prone and requires maintaining external ID mappings.
Solution
Add a directory adapter to the Mattermost channel plugin that enables name-based resolution. Agents can now use target: "infra" or target: "off-topic" and core's built-in resolveMessagingTarget handles the lookup.
Changes
src/mattermost/directory.ts (new, ~130 lines)
listMattermostDirectoryGroups— scans ALL enabled bot accounts (deduplicated by token) and returns public + private channels. Multi-account scanning is essential because private channels are only visible to bots that are members.listMattermostDirectoryPeers— returns team members via first available client (all bots see the same user list).- Graceful error handling: invalid/expired tokens are skipped with debug logging.
src/channel.ts (+15 lines)
- Added
directoryproperty withlistGroups/listGroupsLive/listPeers/listPeersLive. Core'sDirectoryCachehandles caching at the resolver level.
src/normalize.ts (3 lines changed)
normalizeMattermostMessagingTarget: bare names (no prefix) now returnundefinedinstead ofchannel:${name}, allowing fallthrough to directory lookup.looksLikeMattermostTargetId: stricter regex —/^[a-z0-9]{26}$/ifor standard IDs +/^[a-z0-9]{26}__[a-z0-9]{26}$/ifor DM channel IDs. Previously/^[a-z0-9]{8,}$/imatched channel names like "infra" as IDs.
Known limitations
per_page=200for channel/member listing — covers most instances but very large ones may see incomplete results.- Peers use first team only (
teams[0]) — multi-team setups would need iteration.
Testing
Tested live with 19 bot accounts, successfully resolves both public and private channel names.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels