mirror of
https://github.com/openai/codex.git
synced 2026-11-29 00:00:54 +00:00
## Why Extensions can already expose typed contributions and receive host capabilities such as `AgentSpawner`, but they do not have a typed way to send protocol events back through the host. Extensions that need to surface progress or status should not have to own persistence, ordering, transport fanout, or logging decisions themselves. ## What - Add `ExtensionEventSink`, a host-provided fire-and-forget sink for `codex_protocol::protocol::Event`. - Add `NoopExtensionEventSink` so hosts that do not expose extension event emission keep the existing empty-registry behavior. - Store the sink on `ExtensionRegistryBuilder` / `ExtensionRegistry`, with `with_event_sink(...)` and `event_sink()` accessors, and re-export the new capability from `codex-extension-api`. ## Testing - Not run locally; PR metadata/body update only.
20 lines
703 B
Rust
20 lines
703 B
Rust
use codex_protocol::protocol::Event;
|
|
|
|
/// Host-provided fire-and-forget 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);
|
|
}
|
|
|
|
/// Event sink used when the host does not expose extension event emission.
|
|
#[derive(Debug, Default, Clone, Copy)]
|
|
pub struct NoopExtensionEventSink;
|
|
|
|
impl ExtensionEventSink for NoopExtensionEventSink {
|
|
fn emit(&self, _event: Event) {}
|
|
}
|