Skip to content

Feat/platform context injection#122

Merged
Qsnh merged 55 commits intomainfrom
feat/platform-context-injection
Apr 23, 2026
Merged

Feat/platform context injection#122
Qsnh merged 55 commits intomainfrom
feat/platform-context-injection

Conversation

@Qsnh
Copy link
Copy Markdown
Contributor

@Qsnh Qsnh commented Apr 22, 2026

No description provided.

Qsnh and others added 30 commits April 21, 2026 22:39
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add buildDingTalkContext helper function to construct a JSON string
containing DingTalk-specific context fields (sender info, conversation
details, admin status, etc.). Populate the PlatformContext field in
InboundMessage with this JSON for platform context injection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Populate platform_context in the <task_meta> JSON when PlatformContext
is present on the inbound message, using json.RawMessage so it embeds
as structured JSON rather than an escaped string. Omits the field when
empty (omitempty). Adds internal tests for both the present and absent
cases via TDD.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t injection

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…plication

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ntext

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tors in app

- Remove PlatformContext field from InboundMessage struct in internal/platform/interfaces.go
- Register platform context extractors (feishu, dingtalk, wecom) at the start of buildPlatforms() in internal/app/app.go
- Build verification: only dispatcher.go errors remain (expected, will be fixed in Task 8)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s raw

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…text

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ExtractContext now parses message.mentions from the raw event and
injects them (key, open_id, union_id, name) into platform_context so
the AI can identify who was @-mentioned. tenant_key removed from both
sender and mention fields.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Move RegisterExtractor calls inside each platform's Enabled guard so
  extractors are only registered for enabled platforms
- Remove redundant senderID local variable in wecom ExtractContext
- Drop WHAT-only comments that the code already makes self-evident

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…aces

- Nest open_id, union_id, sender_type under sender namespace
- Nest chat_id, chat_type, message_id, message_type, mentions under message namespace
- Add message_type and sender_type fields to extracted context

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
User @_user_X keys are kept as-is in message content; only the bot's
mention key is replaced with its display name so the downstream
stripBotMentions pass continues to work correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Qsnh and others added 25 commits April 22, 2026 02:14
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ntext

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tContext

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bee is platform-agnostic and does not need platform_context in its
message metadata. Worker retains platform_context injection unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bee is platform-agnostic and does not need platform_context.
Worker injection in dispatcher.go is unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use wecomContextFields typed struct to preserve original WeCom wire
format field names (msgid, aibotid, chatid, chattype, from, msgtype).
Removes chatid override logic for single chats and adds msgtype.
Consistent with DingTalk's typed struct pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each platform's @mention regex is now isolated to messages from that
platform. Eliminates cross-platform prefix collision (e.g. DingTalk
'openbee' regex mangling WeCom 'openbee本地测试' messages).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the flat name pool with an explicit platform→name map so each
platform's strip regex is isolated to its own messages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The buildREs helper was keying the regex map by the message's own
platform, so the "unknown platform" case always matched. Add regPlatform
field to separate registration platform from message platform so the
test correctly exercises the no-op path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…and centralize ExtractContext marshal pattern

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ped platform names

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Drop wecomContextFields struct; inline selected fields as map[string]any directly in ExtractContext
- Delete WHAT comment on removed struct
- Trim resolveMentions comment to non-obvious WHY only
- Replace strings.NewReplacer with strings.ReplaceAll in resolveMentions (at most one bot key)
- Add @ pre-filter in stripBotMention to skip regex scan for non-mention messages

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…imBatch

- Make stripBotMention a method on *Gateway instead of a free function taking the map as a parameter
- Fix buildREs test helper to delegate to WithPlatformBotNames so regex pattern changes propagate automatically
- Trim implementation-narrating clause from resolveMentions comment in feishu handler
- Remove Raw field from ClaimedMessage and drop raw from ClaimBatch SELECT; the feeder never uses it and the field adds unnecessary DB I/O on every poll tick

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merge main branch changes (worker uniqueness validation, BotNames config
helper, feeder/manager improvements) into the platform context injection
feature branch, keeping per-platform bot name stripping via
WithPlatformBotNames.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Qsnh Qsnh merged commit af78f15 into main Apr 23, 2026
@Qsnh Qsnh deleted the feat/platform-context-injection branch April 23, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant