feat: add mention entities support with structured @[uid:name] format#134
Merged
yujiawei merged 3 commits intodmwork-org:mainfrom Mar 30, 2026
Merged
feat: add mention entities support with structured @[uid:name] format#134yujiawei merged 3 commits intodmwork-org:mainfrom
yujiawei merged 3 commits intodmwork-org:mainfrom
Conversation
- Add MentionEntity interface and entities field to MentionPayload - Fix MENTION_PATTERN with lookbehind for email exclusion and extended Unicode support (Latin accented, Japanese kana, Korean syllables) - Add parseStructuredMentions for @[uid:name] format parsing - Add convertStructuredMentions with incremental offset tracking - Add buildEntitiesFromFallback for plain @name entity construction - Add extractMentionUids with invalid-entities-to-uids fallback - Add convertContentForLLM for history message mention conversion - Add learnMembersFromMessage with entities-first learning - Extend sendMessage/sendMediaMessage to accept mentionEntities - Fix sendText name-as-uid bug in channel.ts - Inject group member list into LLM prompt for @[uid:name] learning - Support mixed structured + fallback mentions in reply processing - Rebuild uids from sorted entities for consistent ordering
- types.ts: add MentionEntity interface + entities field to MentionPayload - mention-utils.ts: add parseStructuredMentions, convertContentForLLM, buildSenderPrefix, extractMentionUids with email-aware lookbehind - inbound.ts: add learnMembersFromMessage with entities v2 priority path, v1 positional fallback; integrate sender prefix + content conversion - actions.ts: use buildEntitiesFromFallback for outbound mentions - api-fetch.ts: support mentionEntities in sendMessage/sendMediaMessage Fixes email-in-content causing positional mapping offset (Bug 3/6)
- Delete learnMembersFromMessage entirely (API is single source of truth) - convertContentForLLM v1 fallback: memberMap name->uid lookup instead of positional pairing with uids (fixes email/non-member offset bug) - buildMemberListPrefix: ≤10 members full list, >10 members tool hint - 251 tests passing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #133
What
Add support for the new
mention.entitiesprotocol in the bot adapter, enabling structured mention parsing for LLM consumption.Key Changes
parseMentionEntities(),convertContentForLLM(),buildSenderPrefix()displayName(uid)MentionEntityinterfaceuids+ regex)Protocol
Input (from frontend):
Output (to LLM):
Tests
237 unit tests covering:
Files Changed (8 files, +1089/-173)
mention-utils.tsmention-utils.test.tsinbound.tsinbound.test.tstypes.tsapi-fetch.tschannel.tsactions.tsRelated PRs