mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
## What changed - Add callback lifetimes to extension `ToolCall`, `ToolEnvironment`, turn-input context, and skill-read request types. - Require extension tool executors to handle calls for any invocation lifetime and tie their returned futures to that lifetime. - Update built-in extensions, adapters, and tests to use the lifetime-scoped APIs without retaining host-owned environment capabilities. GitOrigin-RevId: aca9ce3a1b6870df550bc84ec9308cc65533f161
84 lines
2.9 KiB
Rust
84 lines
2.9 KiB
Rust
use std::future::Future;
|
|
use std::marker::PhantomData;
|
|
use std::pin::Pin;
|
|
use std::sync::Arc;
|
|
|
|
mod executor;
|
|
mod host;
|
|
mod orchestrator;
|
|
|
|
use crate::HostSkillsSnapshot;
|
|
use codex_exec_server::ExecutorCapabilityDiscoverySnapshot;
|
|
use codex_exec_server::FileSystemSandboxContext;
|
|
use codex_exec_server::ResolvedSelectedCapabilityRoot;
|
|
use codex_mcp::McpResourceClient;
|
|
use codex_protocol::capabilities::SelectedCapabilityRoot;
|
|
|
|
use crate::catalog::SkillAuthority;
|
|
use crate::catalog::SkillCatalog;
|
|
use crate::catalog::SkillPackageId;
|
|
use crate::catalog::SkillProviderResult;
|
|
use crate::catalog::SkillReadResult;
|
|
use crate::catalog::SkillResourceId;
|
|
use crate::catalog::SkillSearchResult;
|
|
|
|
pub use executor::ExecutorSkillProvider;
|
|
pub(crate) use executor::attribute_executor_plugins;
|
|
pub use host::HostSkillProvider;
|
|
pub use orchestrator::OrchestratorSkillProvider;
|
|
|
|
pub(crate) const MAX_SKILL_RESOURCE_CONTENT_BYTES: usize = 1024 * 1024;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct SkillListQuery {
|
|
pub turn_id: String,
|
|
pub executor_roots: Vec<SelectedCapabilityRoot>,
|
|
pub resolved_executor_roots: Vec<ResolvedSelectedCapabilityRoot>,
|
|
pub host_snapshot: Option<Arc<HostSkillsSnapshot>>,
|
|
pub include_host_skills: bool,
|
|
pub include_bundled_skills: bool,
|
|
pub include_orchestrator_skills: bool,
|
|
pub mcp_resources: Option<Arc<McpResourceClient>>,
|
|
/// Present only when the opt-in high-level executor discovery path is selected.
|
|
pub executor_capability_discovery: Option<ExecutorCapabilityDiscoverySnapshot>,
|
|
}
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct SkillReadRequest<'a> {
|
|
// TODO(anp): Replace the marker with callback-scoped environment access.
|
|
pub _lifetime: PhantomData<&'a ()>,
|
|
pub authority: SkillAuthority,
|
|
pub package: SkillPackageId,
|
|
pub resource: SkillResourceId,
|
|
pub resolved_executor_roots: Vec<ResolvedSelectedCapabilityRoot>,
|
|
pub sandbox: Option<FileSystemSandboxContext>,
|
|
pub host_snapshot: Option<Arc<HostSkillsSnapshot>>,
|
|
pub mcp_resources: Option<Arc<McpResourceClient>>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
pub struct SkillSearchRequest {
|
|
pub authority: SkillAuthority,
|
|
pub package: SkillPackageId,
|
|
pub query: String,
|
|
}
|
|
|
|
pub type SkillProviderFuture<'a, T> =
|
|
Pin<Box<dyn Future<Output = SkillProviderResult<T>> + Send + 'a>>;
|
|
|
|
/// Source-specific skill catalog and resource access.
|
|
///
|
|
/// Implementations must preserve authority boundaries: a resource listed by a
|
|
/// provider must be read or searched through the same provider/authority rather
|
|
/// than converted into an ambient local path.
|
|
pub trait SkillProvider: Send + Sync {
|
|
fn list(&self, query: SkillListQuery) -> SkillProviderFuture<'_, SkillCatalog>;
|
|
|
|
fn read<'a>(
|
|
&'a self,
|
|
request: SkillReadRequest<'a>,
|
|
) -> SkillProviderFuture<'a, SkillReadResult>;
|
|
|
|
fn search(&self, request: SkillSearchRequest) -> SkillProviderFuture<'_, SkillSearchResult>;
|
|
}
|