mirror of
https://github.com/openai/codex.git
synced 2026-11-06 08:31:30 +00:00
## Summary This PR adds an **experimental, feature-gated `js_repl` core runtime** so models can execute JavaScript in a persistent REPL context across tool calls. The implementation integrates with existing feature gating, tool registration, prompt composition, config/schema docs, and tests. ## What changed - Added new experimental feature flag: `features.js_repl`. - Added freeform `js_repl` tool and companion `js_repl_reset` tool. - Gated tool availability behind `Feature::JsRepl`. - Added conditional prompt-section injection for JS REPL instructions via marker-based prompt processing. - Implemented JS REPL handlers, including freeform parsing and pragma support (timeout/reset controls). - Added runtime resolution order for Node: 1. `CODEX_JS_REPL_NODE_PATH` 2. `js_repl_node_path` in config 3. `PATH` - Added JS runtime assets/version files and updated docs/schema. ## Why This enables richer agent workflows that require incremental JavaScript execution with preserved state, while keeping rollout safe behind an explicit feature flag. ## Testing Coverage includes: - Feature-flag gating behavior for tool exposure. - Freeform parser/pragma handling edge cases. - Runtime behavior (state persistence across calls and top-level `await` support). ## Usage ```toml [features] js_repl = true ``` Optional runtime override: - `CODEX_JS_REPL_NODE_PATH`, or - `js_repl_node_path` in config. #### [git stack](https://github.com/magus/git-stack-cli) - 👉 `1` https://github.com/openai/codex/pull/10674 - ⏳ `2` https://github.com/openai/codex/pull/10672 - ⏳ `3` https://github.com/openai/codex/pull/10671 - ⏳ `4` https://github.com/openai/codex/pull/10673 - ⏳ `5` https://github.com/openai/codex/pull/10670
51 lines
1.4 KiB
Rust
51 lines
1.4 KiB
Rust
pub mod apply_patch;
|
|
pub(crate) mod collab;
|
|
mod dynamic;
|
|
mod grep_files;
|
|
mod js_repl;
|
|
mod list_dir;
|
|
mod mcp;
|
|
mod mcp_resource;
|
|
mod plan;
|
|
mod read_file;
|
|
mod request_user_input;
|
|
mod search_tool_bm25;
|
|
mod shell;
|
|
mod test_sync;
|
|
mod unified_exec;
|
|
mod view_image;
|
|
|
|
pub use plan::PLAN_TOOL;
|
|
use serde::Deserialize;
|
|
|
|
use crate::function_tool::FunctionCallError;
|
|
pub use apply_patch::ApplyPatchHandler;
|
|
pub use collab::CollabHandler;
|
|
pub use dynamic::DynamicToolHandler;
|
|
pub use grep_files::GrepFilesHandler;
|
|
pub use js_repl::JsReplHandler;
|
|
pub use js_repl::JsReplResetHandler;
|
|
pub use list_dir::ListDirHandler;
|
|
pub use mcp::McpHandler;
|
|
pub use mcp_resource::McpResourceHandler;
|
|
pub use plan::PlanHandler;
|
|
pub use read_file::ReadFileHandler;
|
|
pub use request_user_input::RequestUserInputHandler;
|
|
pub(crate) use request_user_input::request_user_input_tool_description;
|
|
pub(crate) use search_tool_bm25::DEFAULT_LIMIT as SEARCH_TOOL_BM25_DEFAULT_LIMIT;
|
|
pub use search_tool_bm25::SearchToolBm25Handler;
|
|
pub use shell::ShellCommandHandler;
|
|
pub use shell::ShellHandler;
|
|
pub use test_sync::TestSyncHandler;
|
|
pub use unified_exec::UnifiedExecHandler;
|
|
pub use view_image::ViewImageHandler;
|
|
|
|
fn parse_arguments<T>(arguments: &str) -> Result<T, FunctionCallError>
|
|
where
|
|
T: for<'de> Deserialize<'de>,
|
|
{
|
|
serde_json::from_str(arguments).map_err(|err| {
|
|
FunctionCallError::RespondToModel(format!("failed to parse function arguments: {err}"))
|
|
})
|
|
}
|