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:
jif
2026-11-03 13:17:38 +00:00
committed by copyberry
parent f05aa41da6
commit 4a971492e7
3 changed files with 56 additions and 49 deletions
+14 -15
View File
@@ -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.