Base: codex-main originale (prima del fork aKode)
This commit is contained in:
30
codex-rs/hooks/src/mcp.rs
Normal file
30
codex-rs/hooks/src/mcp.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
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,
|
||||
}
|
||||
|
||||
/// Text returned by an MCP hook and the callable namespace that supplied it.
|
||||
pub struct HookMcpOutput {
|
||||
pub text: String,
|
||||
pub source_tool_namespace: Option<String>,
|
||||
}
|
||||
|
||||
/// 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<HookMcpOutput>>;
|
||||
}
|
||||
Reference in New Issue
Block a user