mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
refactor: centralize tool exposure planning (#23876)
## Why Tool exposure is a planning concern, but the deferred MCP path and dispatch-only legacy shell path were carrying those decisions in handler constructors and a shell-only tool-family builder. Keeping those decisions in `spec_plan` makes the core tool plan easier to follow and keeps handlers focused on runtime behavior. ## What changed - add `PlannedTools` helpers for ordinary runtimes, exposure overrides, dispatch-only runtimes, and hosted specs - inline shell tool assembly into `core/src/tools/spec_plan.rs` and remove the shell-only `tool_family` module - remove exposure state and special exposure constructors from `McpHandler` and `ShellCommandHandler` - keep hidden runtime behavior centralized in `ExposureOverride`, including disabling parallel tool calls for hidden handlers ## Testing - Not run (refactor only)
This commit is contained in:
1 parent
2a25602783
commit
e6c8371e4e
7 files changed
+132
-208
No files matched your search
@@ -22,7 +22,6 @@ use crate::tools::registry::CoreToolRuntime;
|
||||
use crate::tools::registry::PostToolUsePayload;
|
||||
use crate::tools::registry::PreToolUsePayload;
|
||||
use crate::tools::registry::ToolExecutor;
|
||||
use crate::tools::registry::ToolExposure;
|
||||
use crate::tools::runtimes::shell::ShellRuntimeBackend;
|
||||
use codex_tools::ToolSpec;
|
||||
|
||||
@@ -41,7 +40,6 @@ enum ShellCommandBackend {
|
||||
pub struct ShellCommandHandler {
|
||||
backend: ShellCommandBackend,
|
||||
options: ShellCommandHandlerOptions,
|
||||
exposure: ToolExposure,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -53,23 +51,11 @@ pub(crate) struct ShellCommandHandlerOptions {
|
||||
|
||||
impl ShellCommandHandler {
|
||||
pub(crate) fn new(options: ShellCommandHandlerOptions) -> Self {
|
||||
Self::with_exposure(options, ToolExposure::Direct)
|
||||
}
|
||||
|
||||
pub(crate) fn hidden(options: ShellCommandHandlerOptions) -> Self {
|
||||
Self::with_exposure(options, ToolExposure::Hidden)
|
||||
}
|
||||
|
||||
fn with_exposure(options: ShellCommandHandlerOptions, exposure: ToolExposure) -> Self {
|
||||
let backend = match options.backend_config {
|
||||
ShellCommandBackendConfig::Classic => ShellCommandBackend::Classic,
|
||||
ShellCommandBackendConfig::ZshFork => ShellCommandBackend::ZshFork,
|
||||
};
|
||||
Self {
|
||||
backend,
|
||||
options,
|
||||
exposure,
|
||||
}
|
||||
Self { backend, options }
|
||||
}
|
||||
|
||||
fn shell_runtime_backend(&self) -> ShellRuntimeBackend {
|
||||
@@ -130,7 +116,7 @@ impl ShellCommandHandler {
|
||||
|
||||
impl From<ShellCommandBackendConfig> for ShellCommandHandler {
|
||||
fn from(backend_config: ShellCommandBackendConfig) -> Self {
|
||||
Self::hidden(ShellCommandHandlerOptions {
|
||||
Self::new(ShellCommandHandlerOptions {
|
||||
backend_config,
|
||||
allow_login_shell: false,
|
||||
exec_permission_approvals_enabled: false,
|
||||
@@ -151,12 +137,8 @@ impl ToolExecutor<ToolInvocation> for ShellCommandHandler {
|
||||
})
|
||||
}
|
||||
|
||||
fn exposure(&self) -> ToolExposure {
|
||||
self.exposure
|
||||
}
|
||||
|
||||
fn supports_parallel_tool_calls(&self) -> bool {
|
||||
self.exposure != ToolExposure::Hidden
|
||||
true
|
||||
}
|
||||
|
||||
async fn handle(
|
||||
|
||||
Reference in new issue
Block a user