Base: codex-main originale (prima del fork aKode)

This commit is contained in:
Andrea
2026-11-09 10:37:42 +01:00
commit 7874033c81
10166 changed files with 2728937 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
use std::future::Future;
use codex_async_utils::OrCancelExt;
pub use codex_tools::FunctionCallError;
use tokio_util::sync::CancellationToken;
/// Maps cancellation to the standard tool-call error while preserving the future's output.
pub(crate) trait OrCancelToolExt: OrCancelExt + Send {
fn or_cancel_tool(
self,
token: &CancellationToken,
) -> impl Future<Output = Result<Self::Output, FunctionCallError>> + Send;
}
impl<F: OrCancelExt + Send> OrCancelToolExt for F {
async fn or_cancel_tool(
self,
token: &CancellationToken,
) -> Result<Self::Output, FunctionCallError> {
self.or_cancel(token)
.await
.map_err(|_| FunctionCallError::RespondToModel("tool call cancelled".to_string()))
}
}