mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
feat: async approval contrib (#23690)
This commit is contained in:
1 parent
b555dd5d1d
commit
f64fce61b3
3 files changed
+25
-21
No files matched your search
@@ -134,18 +134,15 @@ pub trait ToolLifecycleContributor: Send + Sync {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Future returned by one claimed approval-review contribution.
|
|
||||||
pub type ApprovalReviewFuture<'a> =
|
|
||||||
std::pin::Pin<Box<dyn Future<Output = ReviewDecision> + Send + 'a>>;
|
|
||||||
|
|
||||||
/// Extension contribution that can claim rendered approval-review prompts.
|
/// Extension contribution that can claim rendered approval-review prompts.
|
||||||
|
#[async_trait::async_trait]
|
||||||
pub trait ApprovalReviewContributor: Send + Sync {
|
pub trait ApprovalReviewContributor: Send + Sync {
|
||||||
fn contribute<'a>(
|
async fn contribute(
|
||||||
&'a self,
|
&self,
|
||||||
session_store: &'a ExtensionData,
|
session_store: &ExtensionData,
|
||||||
thread_store: &'a ExtensionData,
|
thread_store: &ExtensionData,
|
||||||
prompt: &'a str,
|
prompt: &str,
|
||||||
) -> Option<ApprovalReviewFuture<'a>>;
|
) -> Option<ReviewDecision>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Future returned by one ordered turn-item contribution.
|
/// Future returned by one ordered turn-item contribution.
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ pub use codex_tools::ToolPayload;
|
|||||||
pub use codex_tools::ToolSpec;
|
pub use codex_tools::ToolSpec;
|
||||||
pub use codex_tools::parse_tool_input_schema;
|
pub use codex_tools::parse_tool_input_schema;
|
||||||
pub use contributors::ApprovalReviewContributor;
|
pub use contributors::ApprovalReviewContributor;
|
||||||
pub use contributors::ApprovalReviewFuture;
|
|
||||||
pub use contributors::ConfigContributor;
|
pub use contributors::ConfigContributor;
|
||||||
pub use contributors::ContextContributor;
|
pub use contributors::ContextContributor;
|
||||||
pub use contributors::PromptFragment;
|
pub use contributors::PromptFragment;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use codex_protocol::protocol::ReviewDecision;
|
||||||
|
|
||||||
use crate::ApprovalReviewContributor;
|
use crate::ApprovalReviewContributor;
|
||||||
use crate::ApprovalReviewFuture;
|
|
||||||
use crate::ConfigContributor;
|
use crate::ConfigContributor;
|
||||||
use crate::ContextContributor;
|
use crate::ContextContributor;
|
||||||
use crate::ExtensionData;
|
use crate::ExtensionData;
|
||||||
@@ -171,15 +172,22 @@ impl<C: Sync> ExtensionRegistry<C> {
|
|||||||
|
|
||||||
/// Claims the first rendered approval-review prompt accepted by an
|
/// Claims the first rendered approval-review prompt accepted by an
|
||||||
/// installed contributor.
|
/// installed contributor.
|
||||||
pub fn approval_review<'a>(
|
pub async fn approval_review(
|
||||||
&'a self,
|
&self,
|
||||||
session_store: &'a ExtensionData,
|
session_store: &ExtensionData,
|
||||||
thread_store: &'a ExtensionData,
|
thread_store: &ExtensionData,
|
||||||
prompt: &'a str,
|
prompt: &str,
|
||||||
) -> Option<ApprovalReviewFuture<'a>> {
|
) -> Option<ReviewDecision> {
|
||||||
self.approval_review_contributors
|
for contributor in &self.approval_review_contributors {
|
||||||
.iter()
|
if let Some(decision) = contributor
|
||||||
.find_map(|contributor| contributor.contribute(session_store, thread_store, prompt))
|
.contribute(session_store, thread_store, prompt)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
return Some(decision);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the registered prompt contributors.
|
/// Returns the registered prompt contributors.
|
||||||
|
|||||||
Reference in new issue
Block a user