mirror of
https://github.com/openai/codex.git
synced 2026-11-10 21:00:47 +00:00
Preserve extension event ordering
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user