Skip to content

feat: decouple webhook event delivery from sdk#447

Merged
lotharking merged 19 commits into
mainfrom
fix/decouple-webhook-event-delivery-from-sdk
May 27, 2026
Merged

feat: decouple webhook event delivery from sdk#447
lotharking merged 19 commits into
mainfrom
fix/decouple-webhook-event-delivery-from-sdk

Conversation

@lotharking

Copy link
Copy Markdown
Collaborator

Changes

  • Remove legacy webhook file
  • Create EventEmitter class to handle events
  • Replace events with webhookUrl configuration
  • Update testing

Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
@lotharking lotharking requested review from genaris and tarunvadde May 21, 2026 15:44
@lotharking lotharking linked an issue May 21, 2026 that may be closed by this pull request
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
Comment thread packages/agent-sdk/src/utils/EventEmitter.ts Outdated
Comment thread apps/vs-agent/src/main.ts Outdated
Comment thread packages/agent-sdk/src/types.ts Outdated

@tarunvadde tarunvadde left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this PR conflict with #448?

Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
@lotharking

Copy link
Copy Markdown
Collaborator Author

Hey @tarunvadde, it probably depends on which one gets approved first. I still need to implement the changes in the other one.

@lotharking lotharking requested a review from tarunvadde May 22, 2026 22:52

@genaris genaris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the SDK (with its VsAgent object) and its plug-ins should be the ones in charge of emitting events, and the app being the one that listens for them and executes the logic it requires (logging, webhooks, executing callbacks, etc.).

My first suggestion is to simplify the implementation by using VsAgent's internal emitter, and a second one (and bigger in terms of refactoring) would be to move most of the credo-ts message processing (i.e. most of what is currently under apps/vs-agent/BaseMessageEvents and apps/vs-agent/ConnectionEvents) to SDK, in such a way that it serves as an abstraction layer of any complexity given by DIDComm/credo-ts's internal events. In my opinion, ideally the SDK should trigger a MessageReceived event and vs-agent app listen to it and trigger webhooks (or executing presentation callback in case of presentations).

With these two together, I think this refactoring will be significant enough to have a consistent behaviour in terms of event flow.

Comment thread packages/agent-sdk/src/utils/EventPublisher.ts Outdated
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
@lotharking lotharking requested review from genaris and tarunvadde May 25, 2026 23:23
Comment thread apps/vs-agent/src/plugins/MessagingPlugin.ts Outdated
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
@lotharking lotharking requested a review from genaris May 26, 2026 15:37

@genaris genaris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking better, but I think it still has some overengineered pieces that can be simplified.

Comment on lines +54 to +64
export function emitVsAgentEvent(agent: VsAgent, eventOrMessage: Event | BaseMessage): void {
const event =
eventOrMessage instanceof Event
? eventOrMessage
: new MessageReceived({ timestamp: eventOrMessage.timestamp, message: eventOrMessage })

agent.events.emit(agent.context, {
type: busTypeByEventType[event.type],
payload: { event },
})
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the reason of making this so ugly, i.e. just having a method called emitVsAgentEvent(agent: VsAgent, event: Event) and a separate emitVsAgentMessageReceivedEvent(agent: VsAgent, message: BaseMessage). Or even better: don't create any utility method at all, and just call e.g. agent.events.emit(agent.context, { type: VsAgentEventType.ConnectionStateUpdated, payload: { event } in the method that is actually sending such a message.

Why don't simply follow the event pattern we have in Credo, in such a way we won't need to do these "bus channel names"? I think this is overcomplicating the things.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I created a single emitVsAgentEvent function mainly to avoid duplicating the emit logic, but I agree that conceptually it should stay aligned with the Credo event structure.

Comment thread apps/vs-agent/src/utils/webhookEvent.ts Outdated
Comment thread packages/agent-sdk/src/events/BaseMessageEvents.ts Outdated
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
@lotharking lotharking requested a review from genaris May 26, 2026 22:42
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>

@genaris genaris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a comment to make event naming consistent.

Comment thread packages/model/src/events/EventType.ts Outdated
lotharking and others added 4 commits May 27, 2026 08:06
Co-authored-by: Ariel Gentile <gentilester@gmail.com>
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
Signed-off-by: andres vallecilla <andresfelipe083195@hotmail.com>
@lotharking lotharking merged commit 703a196 into main May 27, 2026
3 checks passed
@lotharking lotharking deleted the fix/decouple-webhook-event-delivery-from-sdk branch May 27, 2026 14:19
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.

Decouple webhook event delivery from SDK

3 participants