Preserve extension event ordering

This commit is contained in:
Eric Traut
2026-05-27 12:30:41 -07:00
parent c8221f8c3f
commit 83121bf58d
8 changed files with 105 additions and 59 deletions
@@ -1,13 +1,17 @@
use codex_protocol::protocol::Event;
use std::future::Future;
use std::pin::Pin;
/// Host-provided fire-and-forget sink for extension-generated events.
pub type ExtensionEventFuture<'a> = Pin<Box<dyn Future<Output = ()> + Send + 'a>>;
/// Host-provided sink for extension-generated events.
///
/// Extensions construct protocol events with the correlation id appropriate for
/// the callback they are handling, then leave persistence, ordering, transport
/// fanout, and logging decisions to the host.
pub trait ExtensionEventSink: Send + Sync {
/// Queue one protocol event for host-owned delivery.
fn emit(&self, event: Event);
fn emit<'a>(&'a self, event: Event) -> ExtensionEventFuture<'a>;
}
/// Event sink used when the host does not expose extension event emission.
@@ -15,5 +19,7 @@ pub trait ExtensionEventSink: Send + Sync {
pub struct NoopExtensionEventSink;
impl ExtensionEventSink for NoopExtensionEventSink {
fn emit(&self, _event: Event) {}
fn emit<'a>(&'a self, _event: Event) -> ExtensionEventFuture<'a> {
Box::pin(std::future::ready(()))
}
}
@@ -4,6 +4,7 @@ mod response_items;
pub use agent::AgentSpawnFuture;
pub use agent::AgentSpawner;
pub use events::ExtensionEventFuture;
pub use events::ExtensionEventSink;
pub use events::NoopExtensionEventSink;
pub use response_items::NoopResponseItemInjector;
+1
View File
@@ -5,6 +5,7 @@ mod state;
pub use capabilities::AgentSpawnFuture;
pub use capabilities::AgentSpawner;
pub use capabilities::ExtensionEventFuture;
pub use capabilities::ExtensionEventSink;
pub use capabilities::NoopExtensionEventSink;
pub use capabilities::NoopResponseItemInjector;