Summary
Enable DMWork Bot users to query message history from other sessions (groups/DMs) they participate in, with proper permission checks.
Key Features
1. read action — add permission checks
- Currently
read allows querying any channel with zero permission checks
- Add
requesterSenderId validation: users can only read channels they participate in
- Owner can read any channel
- Cross-channel results wrapped with prompt injection protection
2. search action — shared-groups discovery
- New
search action (query=shared-groups) returns groups shared between requester and bot
- Uses cached group member data with reverse index for performance
3. Supporting infrastructure
permission.ts: centralized permission check logic
member-cache.ts: group member cache with reverse index, TTL-based expiry, startup preloading
owner-registry.ts: module-level owner_uid storage (extracted from startAccount closure)
audit.ts: structured audit logging for all cross-channel queries
Security Model
- Permission checks use framework-injected
requesterSenderId (trusted, not from LLM)
- DM: only
channelId === requesterSenderId allowed (or owner)
- Group: only current members allowed (or owner)
- Owner: full access to all bot channels
- Zero OpenClaw core changes required
References
Summary
Enable DMWork Bot users to query message history from other sessions (groups/DMs) they participate in, with proper permission checks.
Key Features
1.
readaction — add permission checksreadallows querying any channel with zero permission checksrequesterSenderIdvalidation: users can only read channels they participate in2.
searchaction — shared-groups discoverysearchaction (query=shared-groups) returns groups shared between requester and bot3. Supporting infrastructure
permission.ts: centralized permission check logicmember-cache.ts: group member cache with reverse index, TTL-based expiry, startup preloadingowner-registry.ts: module-level owner_uid storage (extracted from startAccount closure)audit.ts: structured audit logging for all cross-channel queriesSecurity Model
requesterSenderId(trusted, not from LLM)channelId === requesterSenderIdallowed (or owner)References