mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
[elicitations] Switch to use MCP style elicitation payload for mcp tool approvals. (#13621)
- [x] Switch to use MCP style elicitation payload for mcp tool approvals. - [ ] TODO: Update the UI to support the full spec.
This commit is contained in:
1 parent
ee1a20258a
commit
98dca99db7
59 files changed
+5165
-100
No files matched your search
@@ -11,6 +11,8 @@ use tokio_util::task::AbortOnDropHandle;
|
||||
use codex_protocol::dynamic_tools::DynamicToolResponse;
|
||||
use codex_protocol::models::ResponseInputItem;
|
||||
use codex_protocol::request_user_input::RequestUserInputResponse;
|
||||
use codex_rmcp_client::ElicitationResponse;
|
||||
use rmcp::model::RequestId;
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
use crate::codex::TurnContext;
|
||||
@@ -72,6 +74,7 @@ impl ActiveTurn {
|
||||
pub(crate) struct TurnState {
|
||||
pending_approvals: HashMap<String, oneshot::Sender<ReviewDecision>>,
|
||||
pending_user_input: HashMap<String, oneshot::Sender<RequestUserInputResponse>>,
|
||||
pending_elicitations: HashMap<(String, RequestId), oneshot::Sender<ElicitationResponse>>,
|
||||
pending_dynamic_tools: HashMap<String, oneshot::Sender<DynamicToolResponse>>,
|
||||
pending_input: Vec<ResponseInputItem>,
|
||||
pub(crate) tool_calls: u64,
|
||||
@@ -97,6 +100,7 @@ impl TurnState {
|
||||
pub(crate) fn clear_pending(&mut self) {
|
||||
self.pending_approvals.clear();
|
||||
self.pending_user_input.clear();
|
||||
self.pending_elicitations.clear();
|
||||
self.pending_dynamic_tools.clear();
|
||||
self.pending_input.clear();
|
||||
}
|
||||
@@ -116,6 +120,25 @@ impl TurnState {
|
||||
self.pending_user_input.remove(key)
|
||||
}
|
||||
|
||||
pub(crate) fn insert_pending_elicitation(
|
||||
&mut self,
|
||||
server_name: String,
|
||||
request_id: RequestId,
|
||||
tx: oneshot::Sender<ElicitationResponse>,
|
||||
) -> Option<oneshot::Sender<ElicitationResponse>> {
|
||||
self.pending_elicitations
|
||||
.insert((server_name, request_id), tx)
|
||||
}
|
||||
|
||||
pub(crate) fn remove_pending_elicitation(
|
||||
&mut self,
|
||||
server_name: &str,
|
||||
request_id: &RequestId,
|
||||
) -> Option<oneshot::Sender<ElicitationResponse>> {
|
||||
self.pending_elicitations
|
||||
.remove(&(server_name.to_string(), request_id.clone()))
|
||||
}
|
||||
|
||||
pub(crate) fn insert_pending_dynamic_tool(
|
||||
&mut self,
|
||||
key: String,
|
||||
|
||||
Reference in new issue
Block a user