Skip to content

feat: cross-session message query (read permission + search shared-groups) #144

@Jerry-Xin

Description

@Jerry-Xin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions