mirror of
https://github.com/openai/codex.git
synced 2026-10-22 17:58:46 +00:00
## What changed - Scope executor-provided stop-hook calls to the MCP server environment that registered the hook, and reject calls when that environment does not match. - Forward turn metadata with executor stop-hook requests while retaining the hook call's `threadId` metadata. ## Testing - Cover environment matching for MCP tool calls and verify executor stop hooks receive their environment ID and request metadata. GitOrigin-RevId: b544ea3a6ca1f61389fb4597978ed7aac27d529a
25 lines
837 B
Rust
25 lines
837 B
Rust
use std::time::Duration;
|
|
|
|
use futures::future::BoxFuture;
|
|
use serde_json::Map;
|
|
use serde_json::Value;
|
|
|
|
/// One MCP tool call requested by a configured hook handler.
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct HookMcpCall {
|
|
pub server: String,
|
|
pub tool: String,
|
|
pub environment_id: Option<String>,
|
|
pub metadata: Option<Map<String, Value>>,
|
|
pub input: Map<String, Value>,
|
|
pub timeout: Duration,
|
|
}
|
|
|
|
/// Executes already-connected MCP tools on behalf of hooks without coupling this crate to core.
|
|
///
|
|
/// Implementations own server readiness, policy enforcement, timeout handling, and elicitation.
|
|
pub trait HookMcpExecutor: Send + Sync {
|
|
/// Returns text that is interpreted using ordinary command-hook output semantics.
|
|
fn execute(&self, call: HookMcpCall) -> BoxFuture<'_, anyhow::Result<String>>;
|
|
}
|