-
Notifications
You must be signed in to change notification settings - Fork 117
Refactor WebSocket method names to sessions.* and add dynamic filtering to sessions.list #295
Description
Summary
Refactor WebSocket method names for OpenClaw compatibility and implement dynamic sessions.list endpoint with filtering capabilities.
Background & Motivation
- Naming Consistency: The previous WebSocket method names (e.g.,
session_delete,sessions_send) used a mix of snake_case and lacked a consistent namespace structure. They needed to be standardized to thesessions.xxxformat (e.g.,sessions.delete,sessions.send) to maintain internal consistency and ensure full compatibility with the OpenClaw API specification. - Hardcoded Logic: In the initial implementation of the
sessions.listmethod, the session filtering logic was hardcoded in the backend service (.filter(|s| s.session_key.starts_with("chatclaw:microclaw"))). This was inflexible and violated the OpenClaw API contract, which specifies that filtering should be driven by client-provided request parameters.
Expected Behavior
- WebSocket clients must use the new
sessions.xxxmethod names. - Clients calling
sessions.listcan optionally provideagentIdorsearchparameters to filter the returned session list. - If a client calls
sessions.listwith an empty payload{}, the server will return all available recent sessions without any filtering.
Impact
Medium - Improves API standardization and aligns the implementation with the OpenClaw specification, enabling better integration with compatible clients.
Future Use Case: Claw Chrome Extension Integration
These enhancements to the WebSocket methods serve a broader goal: establishing a reliable foundation for building a Claw-ecosystem Chrome Extension.
By strictly adhering to the OpenClaw API contract (like sessions.list and standardizing to sessions.*), the MicroClaw backend can now seamlessly serve as the local agent engine for the Chrome Extension. This will allow the extension to query session history dynamically, manage chat sessions via standard WebSocket events, and provide users with a unified, browser-native AI assistant experience.
