mirror of
https://github.com/openai/codex.git
synced 2026-09-20 12:47:38 +00:00
## What changed Add a public, object-safe `AgentControl` trait and request/response types for coordinating an agent tree independently of where its threads run. Define contracts for lifecycle operations, message delivery, status observation, execution admission, usage accounting, shared configuration, and guardian evidence. Move shared agent types out of the local controller and export them from `codex-core`. Let `AgentExecutionGuard` own a backend-provided reservation while preserving the local limiter's release-on-drop behavior. Include `root_thread_id` in `GuardianRootSnapshot` to identify the source of authorization evidence. ## Testing Add tests for reservation release when a guard is dropped or a turn is cancelled, and extend the guardian authorization test to assert the root thread identity. Check trait object safety at compile time. GitOrigin-RevId: 9385c9fbfd189f08429539fd89061ef8c9efe0d9
250 lines
8.6 KiB
Rust
250 lines
8.6 KiB
Rust
//! Root of the `codex-core` library.
|
|
|
|
// Prevent accidental direct writes to stdout/stderr in library code. All
|
|
// user-visible output must go through the appropriate abstraction (e.g.,
|
|
// the TUI or the tracing stack).
|
|
#![deny(clippy::print_stdout, clippy::print_stderr)]
|
|
|
|
mod apply_patch;
|
|
mod apps;
|
|
mod client;
|
|
mod client_common;
|
|
mod realtime_context;
|
|
mod realtime_conversation;
|
|
mod realtime_history;
|
|
mod realtime_prompt;
|
|
mod responses_headers;
|
|
pub use responses_headers::CodexResponsesHeaders;
|
|
mod responses_metadata;
|
|
mod responses_retry;
|
|
pub(crate) mod session;
|
|
pub use codex_protocol::turn_input::NotSubmittedReason;
|
|
pub use codex_protocol::turn_input::RecoverTurnRequest;
|
|
pub use codex_protocol::turn_input::StartIfIdleSubmission;
|
|
pub use codex_protocol::turn_input::SteerSubmission;
|
|
pub use codex_protocol::turn_input::SuspendTurnOutcome;
|
|
pub use codex_protocol::turn_input::TurnInput;
|
|
pub use codex_protocol::turn_input::TurnInputRequest;
|
|
pub use codex_protocol::turn_input::TurnInputSubmission;
|
|
pub use codex_protocol::turn_input::TurnStartOptions;
|
|
pub use responses_metadata::CodexResponsesMetadata;
|
|
pub use turn_metadata::detached_memory_responses_metadata;
|
|
mod codex_thread;
|
|
mod compact_model_fallback;
|
|
mod compact_remote_history;
|
|
mod compact_remote_v2;
|
|
mod compact_token_budget;
|
|
mod thread_startup_metadata;
|
|
pub use codex_network_proxy::EnvironmentNetworkPolicy;
|
|
pub use codex_network_proxy::NetworkDomainPermission;
|
|
pub use codex_network_proxy::NetworkDomainPermissionEntry;
|
|
pub use codex_network_proxy::NetworkDomainPermissions;
|
|
pub use codex_network_proxy::NetworkUnixSocketPermission;
|
|
pub use codex_network_proxy::NetworkUnixSocketPermissions;
|
|
pub use codex_protocol::mcp_policy::EnvironmentMcpPolicy;
|
|
pub use codex_protocol::protocol::EnvironmentConfig;
|
|
pub use codex_thread::BackgroundTerminalInfo;
|
|
pub use codex_thread::CodexThread;
|
|
pub use codex_thread::CodexThreadSettingsOverrides;
|
|
pub use codex_thread::GuardianAuthorizationVersion;
|
|
pub use codex_thread::GuardianRootMessage;
|
|
pub use codex_thread::GuardianRootSnapshot;
|
|
pub use codex_thread::ThreadConfigSnapshot;
|
|
pub use session::turn_context::TurnContext;
|
|
pub use thread_startup_metadata::ThreadStartupMetadata;
|
|
mod agent;
|
|
pub use agent::api::AgentConfigUpdate;
|
|
pub use agent::api::AgentControl;
|
|
pub use agent::api::AgentInfo;
|
|
pub use agent::api::AgentInput;
|
|
pub use agent::api::AgentPage;
|
|
pub use agent::api::AgentQuery;
|
|
pub use agent::api::AgentScope;
|
|
pub use agent::api::AgentTarget;
|
|
pub use agent::api::AgentTurnOutcome;
|
|
pub use agent::api::AgentVisibility;
|
|
pub use agent::api::ControlIdentity;
|
|
pub use agent::api::DeliveryReceipt;
|
|
pub use agent::api::SendRequest;
|
|
pub use agent::api::SpawnRequest;
|
|
pub use agent::api::StatusSubscription;
|
|
pub use agent::types::AgentExecutionGuard;
|
|
pub use agent::types::AgentMessage;
|
|
pub use agent::types::AgentMetadata;
|
|
pub use agent::types::LiveAgent;
|
|
pub use agent::types::MessageDeliveryMode;
|
|
pub use agent::types::ResolvedMultiAgentV2UsageHints;
|
|
pub use agent::types::SpawnAgentForkMode;
|
|
pub use agent::types::SpawnAgentOptions;
|
|
pub use rollout_budget::RolloutBudgetReminder;
|
|
mod agent_communication;
|
|
mod attestation;
|
|
mod codex_delegate;
|
|
mod command_canonicalization;
|
|
pub mod config;
|
|
pub mod connectors;
|
|
pub mod context;
|
|
mod context_manager;
|
|
mod current_time;
|
|
mod cyber_access_program;
|
|
mod elicitation;
|
|
mod environment_selection;
|
|
pub mod exec;
|
|
pub mod exec_env;
|
|
mod exec_policy;
|
|
#[cfg(test)]
|
|
mod git_info_tests;
|
|
mod guardian;
|
|
pub mod guardian_review;
|
|
mod hook_mcp_executor;
|
|
mod hook_runtime;
|
|
mod image_preparation;
|
|
mod installation_id;
|
|
pub(crate) mod mcp;
|
|
mod mcp_skill_dependencies;
|
|
mod mcp_tool_approval_templates;
|
|
mod mcp_tool_exposure;
|
|
mod network_policy_decision;
|
|
pub use mcp::McpManager;
|
|
mod original_image_detail;
|
|
pub use codex_mcp::CodexAppsToolsCache;
|
|
pub use codex_mcp::SandboxState;
|
|
mod mcp_openai_file;
|
|
mod mcp_tool_call;
|
|
pub(crate) mod mention_syntax;
|
|
pub(crate) mod utils;
|
|
pub use mention_syntax::PLUGIN_TEXT_MENTION_SIGIL;
|
|
pub use mention_syntax::TOOL_MENTION_SIGIL;
|
|
pub use utils::path_utils;
|
|
pub(crate) mod plugins;
|
|
pub use plugins::plugins_manager_for_config;
|
|
#[doc(hidden)]
|
|
pub(crate) mod prompt_debug;
|
|
#[doc(hidden)]
|
|
pub use prompt_debug::build_prompt_input;
|
|
pub(crate) mod mentions {
|
|
pub(crate) use crate::plugins::build_connector_slug_counts;
|
|
pub(crate) use crate::plugins::collect_explicit_app_ids;
|
|
pub(crate) use crate::plugins::collect_explicit_plugin_mentions;
|
|
pub(crate) use crate::plugins::collect_tool_mentions_from_messages;
|
|
}
|
|
mod sandbox_tags;
|
|
pub mod sandboxing;
|
|
mod session_prefix;
|
|
mod session_startup_prewarm;
|
|
mod skills;
|
|
pub(crate) use skills::maybe_emit_implicit_skill_invocation;
|
|
pub(crate) use skills::skills_load_input_from_config;
|
|
mod stream_events_utils;
|
|
pub mod test_support;
|
|
mod unified_exec;
|
|
pub mod windows_sandbox;
|
|
#[cfg(windows)]
|
|
mod windows_system_config;
|
|
pub use client::X_RESPONSESAPI_INCLUDE_TIMING_METRICS_HEADER;
|
|
pub use codex_protocol::config_types::ModelProviderAuthInfo;
|
|
mod event_mapping;
|
|
pub use codex_prompts as review_prompts;
|
|
mod thread_manager;
|
|
pub(crate) mod web_search;
|
|
pub(crate) mod windows_sandbox_read_grants;
|
|
pub use thread_manager::ForkSnapshot;
|
|
pub use thread_manager::InternalSessionParent;
|
|
pub use thread_manager::NewThread;
|
|
pub use thread_manager::StartThreadOptions;
|
|
pub use thread_manager::ThreadManager;
|
|
pub use thread_manager::ThreadShutdownReport;
|
|
pub use thread_manager::build_models_manager;
|
|
pub use thread_manager::local_agent_graph_store_from_state_db;
|
|
pub use thread_manager::passthrough_image_store;
|
|
pub use thread_manager::thread_store_from_config;
|
|
pub use tools::handlers::WaitForEnvironmentToolConfig;
|
|
pub use web_search::web_search_action_detail;
|
|
pub use windows_sandbox_read_grants::grant_read_root_non_elevated;
|
|
#[deprecated(note = "use ThreadManager")]
|
|
pub type ConversationManager = ThreadManager;
|
|
#[deprecated(note = "use NewThread")]
|
|
pub type NewConversation = NewThread;
|
|
#[deprecated(note = "use CodexThread")]
|
|
pub type CodexConversation = CodexThread;
|
|
pub(crate) mod agents_md;
|
|
mod agents_md_manager;
|
|
pub use agents_md::DEFAULT_AGENTS_MD_FILENAME;
|
|
pub use agents_md::LOCAL_AGENTS_MD_FILENAME;
|
|
pub use agents_md::LoadedAgentsMd;
|
|
mod rollout;
|
|
mod rollout_budget;
|
|
pub(crate) mod safety;
|
|
mod session_rollout_init_error;
|
|
pub mod shell;
|
|
pub(crate) mod shell_snapshot;
|
|
pub mod spawn;
|
|
pub(crate) mod state_db_bridge;
|
|
pub use state_db_bridge::StateDbHandle;
|
|
pub use state_db_bridge::init_state_db;
|
|
mod thread_rollout_truncation;
|
|
pub use thread_rollout_truncation::truncate_rollout_after_turn_id;
|
|
pub use thread_rollout_truncation::truncate_rollout_before_turn_id;
|
|
mod tools;
|
|
pub(crate) mod turn_diff_tracker;
|
|
mod turn_metadata;
|
|
mod turn_timing;
|
|
pub use rollout::ARCHIVED_SESSIONS_SUBDIR;
|
|
pub use rollout::Cursor;
|
|
pub use rollout::INTERACTIVE_SESSION_SOURCES;
|
|
pub use rollout::RolloutRecorder;
|
|
pub use rollout::RolloutRecorderParams;
|
|
pub use rollout::SESSIONS_SUBDIR;
|
|
pub use rollout::SessionMeta;
|
|
pub use rollout::SortDirection;
|
|
pub use rollout::ThreadItem;
|
|
pub use rollout::ThreadSortKey;
|
|
pub use rollout::ThreadsPage;
|
|
pub use rollout::append_thread_name;
|
|
pub use rollout::find_archived_thread_path_by_id_str;
|
|
#[deprecated(note = "use find_thread_path_by_id_str")]
|
|
pub use rollout::find_conversation_path_by_id_str;
|
|
pub use rollout::find_thread_meta_by_name_str;
|
|
pub use rollout::find_thread_name_by_id;
|
|
pub use rollout::find_thread_names_by_ids;
|
|
pub use rollout::find_thread_path_by_id_str;
|
|
pub use rollout::parse_cursor;
|
|
pub use rollout::read_head_for_summary;
|
|
pub use rollout::read_session_meta_line;
|
|
pub use rollout::rollout_date_parts;
|
|
mod feedback_config;
|
|
mod function_tool;
|
|
mod state;
|
|
mod tasks;
|
|
mod user_shell_command;
|
|
pub mod util;
|
|
|
|
pub use attestation::AttestationContext;
|
|
pub use attestation::AttestationProvider;
|
|
pub use attestation::GenerateAttestationFuture;
|
|
pub use client::ModelClient;
|
|
pub use client::ModelClientSession;
|
|
pub use client::X_CODEX_INSTALLATION_ID_HEADER;
|
|
pub use client::X_CODEX_ROUTING_HINT_HEADER;
|
|
pub use client::X_CODEX_TURN_METADATA_HEADER;
|
|
pub use client_common::Prompt;
|
|
pub use client_common::ResponseEvent;
|
|
pub use client_common::ResponseStream;
|
|
pub use codex_prompts::REVIEW_PROMPT;
|
|
pub use compact::content_items_to_text;
|
|
pub use current_time::SleepFuture;
|
|
pub use current_time::TimeFuture;
|
|
pub use current_time::TimeProvider;
|
|
pub use event_mapping::parse_turn_item;
|
|
pub use exec_policy::ExecPolicyError;
|
|
pub use exec_policy::check_execpolicy_for_warnings;
|
|
pub use exec_policy::format_exec_policy_error_with_source;
|
|
pub use exec_policy::load_exec_policy;
|
|
pub use installation_id::resolve_installation_id;
|
|
pub mod compact;
|
|
mod memory_usage;
|
|
pub mod otel_init;
|
|
|
|
// Captured environment bindings can be passed back to ThreadManager by internal reviewers.
|
|
pub use environment_selection::TurnEnvironmentSnapshot;
|