mirror of
https://github.com/openai/codex.git
synced 2026-11-07 20:30:33 +00:00
39 lines
972 B
Rust
39 lines
972 B
Rust
use std::sync::Arc;
|
|
|
|
use codex_extension_api::ExtensionEventSink;
|
|
use codex_protocol::protocol::Event;
|
|
use codex_protocol::protocol::EventMsg;
|
|
use codex_protocol::protocol::ThreadGoal;
|
|
use codex_protocol::protocol::ThreadGoalUpdatedEvent;
|
|
|
|
#[derive(Clone)]
|
|
pub(crate) struct GoalEventEmitter {
|
|
sink: Arc<dyn ExtensionEventSink>,
|
|
}
|
|
|
|
impl GoalEventEmitter {
|
|
pub(crate) fn new(sink: Arc<dyn ExtensionEventSink>) -> Self {
|
|
Self { sink }
|
|
}
|
|
|
|
pub(crate) fn thread_goal_updated(
|
|
&self,
|
|
event_id: impl Into<String>,
|
|
turn_id: Option<String>,
|
|
goal: ThreadGoal,
|
|
) {
|
|
let thread_id = goal.thread_id;
|
|
self.sink.emit(
|
|
thread_id,
|
|
Event {
|
|
id: event_id.into(),
|
|
msg: EventMsg::ThreadGoalUpdated(ThreadGoalUpdatedEvent {
|
|
thread_id,
|
|
turn_id,
|
|
goal,
|
|
}),
|
|
},
|
|
);
|
|
}
|
|
}
|