feat: add message:received and message:sent internal hook events#2307
Closed
AhmedTheGeek wants to merge 1 commit intoopenclaw:mainfrom
Closed
feat: add message:received and message:sent internal hook events#2307AhmedTheGeek wants to merge 1 commit intoopenclaw:mainfrom
AhmedTheGeek wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Add message:received and message:sent events to the internal hook system, enabling HOOK.md-based hooks to subscribe to message lifecycle events. Changes: - Add "message" to InternalHookEventType union - Fire message:received internal hook in dispatch-from-config alongside existing plugin hook (hoisted shared variables for both hook systems) - Add onDelivered callback to ReplyDispatcherOptions for post-delivery hooks - Fire message:sent internal hook + plugin hook after successful delivery - Wire the existing (but previously unused) plugin message_sent hook - Update docs: move message events from Future to documented event types - Add tests for message:received and message:sent event handling
Member
|
Closing due to merge conflicts. Please rebase on |
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.
Adds
message:receivedandmessage:sentevents to the internal hook system, enabling HOOK.md-based hooks to subscribe to message lifecycle events.Changes
"message"toInternalHookEventTypemessage:receivedinternal hook in dispatch-from-config alongside existing plugin hookonDeliveredcallback toReplyDispatcherOptionsfor post-delivery hooksmessage:sentinternal hook after successful reply deliverymessage_senthookMotivation
These events were listed as "Future Events" in the hooks documentation. They enable audit trail tools and other integrations that need to observe the full message lifecycle.
Details
message:received(dispatch-from-config.ts)Hoisted the hook context variables (content, channelId, conversationId, timestamp, messageId) out of the plugin-only
ifblock so both the pluginmessage_receivedhook and the new internalmessage:receivedhook share them. The internal hook fires unconditionally (fire-and-forget viavoid).message:sent(dispatch.ts + reply-dispatcher.ts)Added an
onDeliveredcallback toReplyDispatcherOptionsthat fires after each successfuldeliver()call. Indispatch.ts, bothdispatchInboundMessageWithBufferedDispatcheranddispatchInboundMessageWithDispatcherwrap this callback to fire both the internalmessage:senthook and the pluginmessage_senthook. Extracted a sharedcreateMessageSentHook()helper to avoid duplication.Tests
Added 4 new test cases covering:
message:receivedhandler triggeringmessage:senthandler triggeringmessagehandler catching both events