mirror of
https://github.com/openai/codex.git
synced 2026-11-17 14:58:36 +00:00
Add app-server MCP event streaming (#39761)
## What changed - Add experimental `mcpServer/event/stream/start` and `mcpServer/event/stream/stop` requests for hosted apps, plus `mcpServer/event/stream/notification` forwarding. - Scope subscriptions to the owning app-server connection and subscribed thread, enforce unique IDs and a per-connection limit, and clean them up when the thread is unsubscribed or the connection closes. - Wait for the MCP active notification before completing startup, retry streams that close immediately, and terminate them when authentication or hosted runtime ownership changes. ## Testing - Add an app-server integration test covering activation, event forwarding, duplicate subscription rejection, and explicit cancellation. GitOrigin-RevId: 8a6fc1615adfc5af7e67def3b824fa5909ab3e7b
This commit is contained in:
1 parent
8a40095ea3
commit
097825f75a
30 files changed
+1043
-66
No files matched your search
@@ -55,15 +55,10 @@ pub(crate) fn event_notification_channel() -> (EventNotificationSender, EventNot
|
||||
}
|
||||
|
||||
impl EventNotificationSender {
|
||||
async fn send(
|
||||
&self,
|
||||
notification: CustomNotification,
|
||||
notification_bytes: usize,
|
||||
) -> Result<(), ()> {
|
||||
fn send(&self, notification: CustomNotification, notification_bytes: usize) -> Result<(), ()> {
|
||||
let bytes = u32::try_from(notification_bytes).map_err(|_| ())?;
|
||||
let permit = Arc::clone(&self.available_bytes)
|
||||
.acquire_many_owned(bytes)
|
||||
.await
|
||||
.try_acquire_many_owned(bytes)
|
||||
.map_err(|_| ())?;
|
||||
self.notifications
|
||||
.send(QueuedEventNotification {
|
||||
@@ -231,7 +226,6 @@ where
|
||||
}
|
||||
if route
|
||||
.send(notification.clone(), notification_bytes)
|
||||
.await
|
||||
.is_err()
|
||||
&& let Some(route) = self
|
||||
.routes
|
||||
@@ -239,6 +233,13 @@ where
|
||||
.unwrap_or_else(PoisonError::into_inner)
|
||||
.remove(&subscription_id)
|
||||
{
|
||||
let _ = route.send(
|
||||
CustomNotification::new(
|
||||
"notifications/events/terminated",
|
||||
/*params*/ None,
|
||||
),
|
||||
/*notification_bytes*/ 0,
|
||||
);
|
||||
route.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user