Skip to content

client,event,bridgev2: add support for Beeper's custom ephemeral events and AI stream events#457

Merged
batuhan merged 17 commits intomainfrom
batuhan/com-beeper-ephemeral
Mar 4, 2026
Merged

client,event,bridgev2: add support for Beeper's custom ephemeral events and AI stream events#457
batuhan merged 17 commits intomainfrom
batuhan/com-beeper-ephemeral

Conversation

@batuhan
Copy link
Contributor

@batuhan batuhan commented Feb 4, 2026

Adds send, power-level helpers, and bridge dispatch for com.beeper.ephemeral & com.beeper.ai.stream_event

spec
https://github.com/beeper/ai-bridge/blob/main/docs/msc/com.beeper.mscXXXX-ephemeral.md

@batuhan batuhan force-pushed the batuhan/com-beeper-ephemeral branch from 8f6c5e9 to 399b72c Compare March 1, 2026 00:08
batuhan and others added 8 commits March 1, 2026 01:16
Add BeeperActionHint, BeeperActionHints, and BeeperActionResponseEventContent
structs. Register BeeperActionResponse event type with TypeMap and GuessClass.
Add ActionResponseHandlingNetworkAPI interface and route action response events
through portal.handleMatrixActionResponse. This enables clients to send
structured button responses (Allow/Always/Deny) for tool approval flows.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Register and handle action-response ephemeral events and improve MSS error reporting across the bridge.

- Add ErrActionResponseNotSupported and register BeeperActionResponse event handler in the Matrix connector.
- Short-circuit AI stream ephemerals when ignored in matrix event handling.
- Return EventHandlingResult* values with MSS error context in portal ephemeral handling (failed and success paths) and return Ignored with ErrActionResponseNotSupported when network API lacks action-response support.
- Minor cleanup: remove/adjust redundant comments, small formatting tweaks, and update copyright years in tests.
@batuhan batuhan changed the title Add com.beeper.ephemeral support Add com.beeper.ephemeral + com.beeper.action_response support Mar 2, 2026
batuhan added 4 commits March 2, 2026 15:35
Rename generic ephemeral APIs to Beeper-specific variants and add support for Beeper's AI stream ephemeral event. Changes include: renaming SendEphemeralEvent -> BeeperSendEphemeralEvent in client, appservice intent and AS intent; introducing BeeperEphemeralEventAIStream event type and BeeperFeatureAIStreamEvent feature flag; gating AI stream handling on homeserver feature support; updating connector/portal handling and network/matrix interfaces to use Beeper-prefixed action-response and AI stream types; and updating related tests. These changes separate Beeper unstable ephemeral semantics from generic ephemeral handling and ensure feature negotiation before sending AI stream events.
Add support for Beeper AI stream events by introducing BeeperAIStreamEventContent and updating the event type mapping. Rename the action-response network API and types to BeeperAIStream (BeeperAIStreamHandlingNetworkAPI, HandleMatrixBeeperAIStream, MatrixBeeperAIStream) and update the error constant to ErrBeeperAIStreamNotSupported. Remove legacy Beeper action response handling and registration, and wire the portal to dispatch AI stream events to the new network API with appropriate content validation and error handling.
Remove the BeeperActionResponse event definition and all related code. Deleted the BeeperActionResponseEventContent struct and its Get/Set helpers from event/beeper.go, removed the type mapping and gob registration and Content.AsBeeperActionResponse helper from event/content.go, and removed the BeeperActionResponse Type constant and its case from event/type.go. This cleans up references to the obsolete/unused BeeperActionResponse event.
Delete the BeeperActionHint and BeeperActionHints structs from event/beeper.go and remove the BeeperActionHints field from MessageEventContent in event/message.go. This cleans up the now-unneeded action hint types and their usage in message event content.
@batuhan batuhan changed the title Add com.beeper.ephemeral + com.beeper.action_response support Add com.beeper.ephemeral + com.beeper.ai.stream_event support Mar 2, 2026
return
}
if !br.SpecVersions.Supports(mautrix.BeeperFeatureAIStreamEvent) {
return
Copy link
Member

Choose a reason for hiding this comment

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

This check should be when sending, not receiving

go br.sendSuccessCheckpoint(ctx, decrypted, status.MsgStepDecrypted, retryCount)
decrypted.Mautrix.CheckpointSent = true
decrypted.Mautrix.DecryptionDuration = duration
decrypted.Mautrix.EventSource |= original.Mautrix.EventSource
Copy link
Member

Choose a reason for hiding this comment

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

This looks sus, but now that I think about it, the line below is also wrong. OlmMachine.DecryptMegolmEvent should just do EventSource: evt.Mautrix.EventSource | event.SourceDecrypted in the return value

br.EventProcessor.On(event.EventReaction, br.handleRoomEvent)
br.EventProcessor.On(event.EventRedaction, br.handleRoomEvent)
br.EventProcessor.On(event.EventEncrypted, br.handleEncryptedEvent)
br.EventProcessor.On(event.Type{Type: event.EventEncrypted.Type, Class: event.EphemeralEventType}, br.handleEncryptedEvent)
Copy link
Member

Choose a reason for hiding this comment

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

This should be added as a new EphemeralEventEncrypted type in the event package

Comment on lines +244 to +248
if decrypted.Mautrix.EventSource&event.SourceEphemeral != 0 {
br.handleEphemeralEvent(ctx, decrypted)
} else {
br.EventProcessor.Dispatch(ctx, decrypted)
}
Copy link
Member

Choose a reason for hiding this comment

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

Why is this special-cased? The event processor should just be configured to route events correctly

client.go Outdated
Comment on lines +1381 to +1391
if eventType == event.BeeperEphemeralEventAIStream {
if cli.SpecVersions == nil {
_, err = cli.Versions(ctx)
if err != nil {
return nil, fmt.Errorf("failed to check homeserver feature support via /versions: %w", err)
}
}
if !cli.SpecVersions.Supports(BeeperFeatureAIStreamEvent) {
return nil, MUnrecognized.WithMessage("Homeserver does not advertise com.beeper.ai.stream_event support")
}
}
Copy link
Member

Choose a reason for hiding this comment

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

It's probably enough to have the check in the appservice or bridgev2 wrapper methods which already have SpecVersions always loaded

versions.go Outdated
BeeperFeatureAccountDataMute = UnstableFeature{UnstableFlag: "com.beeper.account_data_mute"}
BeeperFeatureInboxState = UnstableFeature{UnstableFlag: "com.beeper.inbox_state"}
BeeperFeatureArbitraryMemberChange = UnstableFeature{UnstableFlag: "com.beeper.arbitrary_member_change"}
BeeperFeatureAIStreamEvent = UnstableFeature{UnstableFlag: "com.beeper.ai.stream_event"}
Copy link
Member

Choose a reason for hiding this comment

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

Also this should be a flag for the custom ephemeral event support, not specific to AI stream events

EventsDefault int `json:"events_default,omitempty"`

ephemeralLock sync.RWMutex
Ephemeral map[string]int `json:"com.beeper.ephemeral,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Power level fields/methods should also have the Beeper prefix

@tulir tulir changed the title Add com.beeper.ephemeral + com.beeper.ai.stream_event support client,event,bridgev2: add support for Beeper's custom ephemeral events and AI stream events Mar 3, 2026
@batuhan batuhan merged commit fef4326 into main Mar 4, 2026
10 checks passed
@batuhan batuhan deleted the batuhan/com-beeper-ephemeral branch March 4, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants