Respect app-server turn admission for agent mailbox wakes (#62537)

## Why

Automatic mailbox wakes can start new turns while the app-server is
draining or has paused turn admission. Native child results still need
to reach the parent during drain so they can survive a daemon restart.

## What changed

- Require a turn admission permit for ordinary automatic mailbox wakes
  and hold it through turn registration. Retry queued work when a
  temporary pause ends. Explicit follow-ups and native child results can
  still wake the parent during drain.
- Let `thread/inject_items` queue plain-text agent messages for native
  child threads when native tools are enabled. Injected mail follows the
  ordinary wake rules.
- Extract the remote app-server client, shared event and request types,
  and WebSocket compression into `codex-app-server-remote-client` so
  callers can use them without linking the app-server runtime.

## Testing

Cover delivery of queued mail when admission reopens, injection into
native child threads, and recovery of a child result after a daemon
restart.

GitOrigin-RevId: 4c5ceeca8829c2612cc2b6b74c03d0c7677a9244
This commit is contained in:
jif
2026-11-19 15:45:17 +00:00
committed by copyberry
parent 27e16c08c3
commit 0b248182be
30 changed files with 858 additions and 231 deletions
+9 -1
View File
@@ -259,11 +259,19 @@ impl InputQueue {
}
pub(crate) async fn has_trigger_turn_mailbox_items(&self) -> bool {
self.has_mailbox_items_matching(|mail| mail.trigger_turn)
.await
}
pub(crate) async fn has_mailbox_items_matching(
&self,
predicate: impl Fn(&crate::PendingAgentMessage) -> bool,
) -> bool {
self.mailbox_pending_mails
.lock()
.await
.iter()
.any(|mail| mail.communication.trigger_turn)
.any(|mail| predicate(&mail.communication))
}
pub(crate) async fn drain_mailbox(&self) -> Vec<PendingMailboxCommunication> {