mirror of
https://github.com/openai/codex.git
synced 2026-11-07 20:30:33 +00:00
Expose thread APIs for message board access (#59154)
## What changed - Add `CodexThread` methods for reading the registration source, resolving agent references, and reading the configured clock. - Replace the board-specific thread lookup with public `ThreadManager::get_thread_with_extension`, which requires matching typed extension data and never loads a missing runtime. - Update the local message board host to use these APIs and thread startup metadata instead of accessing session internals directly. GitOrigin-RevId: 143b798cc710e079e20be59a84d05738a3bc6a0b
This commit is contained in:
@@ -1025,25 +1025,24 @@ impl ThreadManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// Board hosts may reach internal runtimes only through a matching explicit connection.
|
||||
pub(crate) async fn get_thread_for_board(
|
||||
/// Finds a registered runtime whose host-owned extension data matches the supplied scope.
|
||||
/// Unlike `get_thread`, this can return internal runtimes, but only after validating their
|
||||
/// explicit extension attachment. It never loads a missing runtime.
|
||||
pub async fn get_thread_with_extension<T: Send + Sync + 'static>(
|
||||
&self,
|
||||
thread_id: ThreadId,
|
||||
connection: &codex_message_board::LocalBoardConnection,
|
||||
matches: impl FnOnce(&T) -> bool,
|
||||
) -> CodexResult<Arc<CodexThread>> {
|
||||
self.state
|
||||
.threads
|
||||
.read()
|
||||
.await
|
||||
let threads = self.state.threads.read().await;
|
||||
let thread = threads
|
||||
.get(&thread_id)
|
||||
.filter(|thread| {
|
||||
thread
|
||||
.thread_extension_data()
|
||||
.get::<codex_message_board::LocalBoardConnection>()
|
||||
.is_some_and(|other| connection.same_board(&other))
|
||||
})
|
||||
.cloned()
|
||||
.ok_or(CodexErr::ThreadNotFound(thread_id))
|
||||
.ok_or(CodexErr::ThreadNotFound(thread_id))?;
|
||||
let extension = thread.thread_extension_data().get::<T>();
|
||||
if extension.as_deref().is_some_and(matches) {
|
||||
Ok(Arc::clone(thread))
|
||||
} else {
|
||||
Err(CodexErr::ThreadNotFound(thread_id))
|
||||
}
|
||||
}
|
||||
|
||||
/// Updates metadata for loaded and cold threads through one entrypoint.
|
||||
|
||||
Reference in New Issue
Block a user