mirror of
https://github.com/openai/codex.git
synced 2026-12-01 00:20:48 +00:00
Lots of changes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
[advisories]
|
||||
ignore = [
|
||||
"RUSTSEC-2024-0388", # derivative 2.2.0 via starlark; upstream crate is unmaintained
|
||||
# .cargo/audit.toml
|
||||
"RUSTSEC-2025-0057", # fxhash 0.2.1 via starlark_map; upstream crate is unmaintained
|
||||
"RUSTSEC-2024-0436", # paste 1.0.15 via starlark/ratatui; upstream crate is unmaintained
|
||||
]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
[target.'cfg(all(windows, target_env = "msvc"))']
|
||||
rustflags = ["-C", "link-arg=/STACK:8388608"]
|
||||
# .cargo/config.toml
|
||||
|
||||
[target.'cfg(all(windows, target_env = "gnu"))']
|
||||
rustflags = ["-C", "link-arg=-Wl,--stack,8388608"]
|
||||
|
||||
@@ -4,6 +4,7 @@ slow-timeout = { period = "15s", terminate-after = 2 }
|
||||
|
||||
|
||||
[[profile.default.overrides]]
|
||||
# .config/nextest.toml
|
||||
# Do not add new tests here
|
||||
filter = 'test(rmcp_client) | test(humanlike_typing_1000_chars_appears_live_no_placeholder)'
|
||||
slow-timeout = { period = "1m", terminate-after = 4 }
|
||||
|
||||
+1
@@ -11,6 +11,7 @@ permissions:
|
||||
|
||||
jobs:
|
||||
audit:
|
||||
# .github/workflows/cargo-audit.yml
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/target-*/
|
||||
|
||||
# Recommended value of CARGO_TARGET_DIR when using Docker as explained in .devcontainer/README.md.
|
||||
# .gitignore
|
||||
/target-amd64/
|
||||
|
||||
# Value of CARGO_TARGET_DIR when using .devcontainer/devcontainer.json.
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
# BUILD.bazel
|
||||
|
||||
|
||||
Generated
+1
@@ -4497,6 +4497,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf33f538733d1a5a3494b836ba913207f14d9d4a1d3cd67030c5061bdd2cac85"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
# Cargo.lock
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ landlock = "0.4.4"
|
||||
lazy_static = "1"
|
||||
libc = "0.2.177"
|
||||
log = "0.4"
|
||||
# Cargo.toml
|
||||
lru = "0.16.3"
|
||||
maplit = "1.0.2"
|
||||
mime_guess = "2.0.5"
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# Codex CLI (Rust Implementation)
|
||||
|
||||
We provide Codex CLI as a standalone, native executable to ensure a zero-dependency install.
|
||||
It’s written in Rust, so it’s fast, safe, and emotionally supportive when `cargo` compiles on the first try.
|
||||
|
||||
## Installing Codex
|
||||
|
||||
126
|
||||
Today, the easiest way to install Codex is via `npm`:
|
||||
|
||||
```shell
|
||||
@@ -46,6 +48,7 @@ Use `codex mcp` to add/list/get/remove MCP server launchers defined in `config.t
|
||||
|
||||
### Notifications
|
||||
|
||||
<!-- README.md -->
|
||||
You can enable notifications by configuring a script that is run whenever the agent finishes a turn. The [notify documentation](../docs/config.md#notify) includes a detailed example that explains how to get desktop notifications via [terminal-notifier](https://github.com/julienXX/terminal-notifier) on macOS. When Codex detects that it is running under WSL 2 inside Windows Terminal (`WT_SESSION` is set), the TUI automatically falls back to native Windows toast notifications so approval prompts and completed turns surface even though Windows Terminal does not implement OSC 9.
|
||||
|
||||
### `codex exec` to run Codex programmatically/non-interactively
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
load("//:defs.bzl", "codex_rust_crate")
|
||||
|
||||
codex_rust_crate(
|
||||
# ansi-escape/BUILD.bazel
|
||||
name = "ansi-escape",
|
||||
crate_name = "codex_ansi_escape",
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ license.workspace = true
|
||||
|
||||
[lib]
|
||||
name = "codex_ansi_escape"
|
||||
# ansi-escape/Cargo.toml
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -5,6 +5,7 @@ Small helper functions that wrap functionality from
|
||||
|
||||
```rust
|
||||
pub fn ansi_escape_line(s: &str) -> Line<'static>
|
||||
<!-- ansi-escape/README.md -->
|
||||
pub fn ansi_escape<'a>(s: &'a str) -> Text<'a>
|
||||
```
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ pub fn ansi_escape_line(s: &str) -> Line<'static> {
|
||||
// Normalize tabs to spaces to avoid odd gutter collisions in transcript mode.
|
||||
let s = expand_tabs(s);
|
||||
let text = ansi_escape(&s);
|
||||
// ansi-escape/src/lib.rs
|
||||
match text.lines.as_slice() {
|
||||
[] => "".into(),
|
||||
[only] => only.clone(),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
load("//:defs.bzl", "codex_rust_crate")
|
||||
|
||||
codex_rust_crate(
|
||||
# app-server-protocol/BUILD.bazel
|
||||
name = "app-server-protocol",
|
||||
crate_name = "codex_app_server_protocol",
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
# app-server-protocol/Cargo.toml
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
codex-protocol = { workspace = true }
|
||||
codex-utils-absolute-path = { workspace = true }
|
||||
|
||||
@@ -9,6 +9,7 @@ use std::path::PathBuf;
|
||||
struct Args {
|
||||
/// Output directory where generated files will be written
|
||||
#[arg(short = 'o', long = "out", value_name = "DIR")]
|
||||
// app-server-protocol/src/bin/export.rs
|
||||
out_dir: PathBuf,
|
||||
|
||||
/// Optional Prettier executable path to format generated TypeScript files
|
||||
|
||||
@@ -471,6 +471,7 @@ fn annotate_object(map: &mut Map<String, Value>, base: Option<&str>) {
|
||||
let owner = map.get("title").and_then(Value::as_str).map(str::to_owned);
|
||||
if let Some(owner) = owner.as_deref()
|
||||
&& let Some(Value::Object(props)) = map.get_mut("properties")
|
||||
// app-server-protocol/src/export.rs
|
||||
{
|
||||
set_discriminator_titles(props, owner);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ pub enum JSONRPCMessage {
|
||||
pub struct JSONRPCRequest {
|
||||
pub id: RequestId,
|
||||
pub method: String,
|
||||
// app-server-protocol/src/jsonrpc_lite.rs
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub params: Option<serde_json::Value>,
|
||||
|
||||
@@ -4,6 +4,7 @@ mod protocol;
|
||||
|
||||
pub use export::generate_json;
|
||||
pub use export::generate_ts;
|
||||
// app-server-protocol/src/lib.rs
|
||||
pub use export::generate_types;
|
||||
pub use jsonrpc_lite::*;
|
||||
pub use protocol::common::*;
|
||||
|
||||
@@ -452,6 +452,7 @@ macro_rules! server_notification_definitions {
|
||||
pub fn export_server_notification_schemas(
|
||||
out_dir: &::std::path::Path,
|
||||
) -> ::anyhow::Result<Vec<GeneratedSchema>> {
|
||||
// app-server-protocol/src/protocol/common.rs
|
||||
let mut schemas = Vec::new();
|
||||
$(schemas.push(crate::export::write_json_schema::<$payload>(out_dir, stringify!($payload))?);)*
|
||||
Ok(schemas)
|
||||
|
||||
@@ -5,6 +5,7 @@ impl From<v1::ExecOneOffCommandParams> for v2::CommandExecParams {
|
||||
fn from(value: v1::ExecOneOffCommandParams) -> Self {
|
||||
Self {
|
||||
command: value.command,
|
||||
// app-server-protocol/src/protocol/mappers.rs
|
||||
timeout_ms: value
|
||||
.timeout_ms
|
||||
.map(|timeout| i64::try_from(timeout).unwrap_or(60_000)),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Exposes protocol pieces used by `lib.rs` via `pub use protocol::common::*;`.
|
||||
|
||||
pub mod common;
|
||||
// app-server-protocol/src/protocol/mod.rs
|
||||
mod mappers;
|
||||
pub mod thread_history;
|
||||
pub mod v1;
|
||||
|
||||
@@ -277,6 +277,7 @@ mod tests {
|
||||
];
|
||||
|
||||
let turns = build_turns_from_event_msgs(&events);
|
||||
// app-server-protocol/src/protocol/thread_history.rs
|
||||
assert_eq!(turns.len(), 2);
|
||||
|
||||
let first = &turns[0];
|
||||
|
||||
@@ -270,6 +270,7 @@ pub struct GitDiffToRemoteParams {
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CancelLoginChatGptResponse {}
|
||||
// app-server-protocol/src/protocol/v1.rs
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
||||
@@ -1301,6 +1301,7 @@ pub struct SkillInterface {
|
||||
#[ts(optional)]
|
||||
pub short_description: Option<String>,
|
||||
#[ts(optional)]
|
||||
// app-server-protocol/src/protocol/v2.rs
|
||||
pub icon_small: Option<PathBuf>,
|
||||
#[ts(optional)]
|
||||
pub icon_large: Option<PathBuf>,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
load("//:defs.bzl", "codex_rust_crate")
|
||||
|
||||
codex_rust_crate(
|
||||
# app-server-test-client/BUILD.bazel
|
||||
name = "codex-app-server-test-client",
|
||||
crate_name = "codex_app_server_test_client",
|
||||
)
|
||||
|
||||
+1
@@ -647,6 +647,7 @@ version = "1.0.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da"
|
||||
dependencies = [
|
||||
# app-server-test-client/Cargo.lock
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
|
||||
@@ -6,6 +6,7 @@ license.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
# app-server-test-client/Cargo.toml
|
||||
|
||||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
# App Server Test Client
|
||||
<!-- app-server-test-client/README.md -->
|
||||
Exercises simple `codex app-server` flows end-to-end, logging JSON-RPC messages sent between client and server to stdout.
|
||||
|
||||
@@ -473,6 +473,7 @@ impl CodexClient {
|
||||
message: &str,
|
||||
) -> Result<SendUserMessageResponse> {
|
||||
let request_id = self.request_id();
|
||||
// app-server-test-client/src/main.rs
|
||||
let request = ClientRequest::SendUserMessage {
|
||||
request_id: request_id.clone(),
|
||||
params: SendUserMessageParams {
|
||||
|
||||
@@ -2,6 +2,7 @@ load("//:defs.bzl", "codex_rust_crate")
|
||||
|
||||
codex_rust_crate(
|
||||
name = "app-server",
|
||||
# app-server/BUILD.bazel
|
||||
crate_name = "codex_app_server",
|
||||
integration_deps_extra = ["//codex-rs/app-server/tests/common:common"],
|
||||
test_tags = ["no-sandbox"],
|
||||
|
||||
@@ -27,6 +27,7 @@ codex-protocol = { workspace = true }
|
||||
codex-app-server-protocol = { workspace = true }
|
||||
codex-feedback = { workspace = true }
|
||||
codex-rmcp-client = { workspace = true }
|
||||
# app-server/Cargo.toml
|
||||
codex-utils-absolute-path = { workspace = true }
|
||||
codex-utils-json-to-toml = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
|
||||
@@ -311,6 +311,7 @@ with an `enteredReviewMode` item so clients can show progress:
|
||||
"id": "turn_900",
|
||||
"review": "current changes"
|
||||
}
|
||||
<!-- app-server/README.md -->
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1223,6 +1223,7 @@ async fn maybe_emit_raw_response_item_completed(
|
||||
}
|
||||
|
||||
async fn find_and_remove_turn_summary(
|
||||
// app-server/src/bespoke_event_handling.rs
|
||||
conversation_id: ThreadId,
|
||||
turn_summary_store: &TurnSummaryStore,
|
||||
) -> TurnSummary {
|
||||
|
||||
@@ -2187,6 +2187,7 @@ impl CodexMessageProcessor {
|
||||
params: ListConversationsParams,
|
||||
) {
|
||||
let ListConversationsParams {
|
||||
// app-server/src/codex_message_processor.rs
|
||||
page_size,
|
||||
cursor,
|
||||
model_providers,
|
||||
|
||||
@@ -75,6 +75,7 @@ fn map_requirements_toml_to_api(requirements: ConfigRequirementsToml) -> ConfigR
|
||||
allowed_approval_policies: requirements.allowed_approval_policies.map(|policies| {
|
||||
policies
|
||||
.into_iter()
|
||||
// app-server/src/config_api.rs
|
||||
.map(codex_app_server_protocol::AskForApproval::from)
|
||||
.collect()
|
||||
}),
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
pub(crate) const INVALID_REQUEST_ERROR_CODE: i64 = -32600;
|
||||
// app-server/src/error_code.rs
|
||||
pub(crate) const INTERNAL_ERROR_CODE: i64 = -32603;
|
||||
|
||||
@@ -44,6 +44,7 @@ pub(crate) async fn run_fuzzy_file_search(
|
||||
match file_search::run(
|
||||
query.as_str(),
|
||||
limit_per_root,
|
||||
// app-server/src/fuzzy_file_search.rs
|
||||
&search_dir,
|
||||
Vec::new(),
|
||||
threads,
|
||||
|
||||
@@ -122,6 +122,7 @@ pub async fn run_main(
|
||||
let feedback = CodexFeedback::new();
|
||||
|
||||
let otel = codex_core::otel_init::build_provider(
|
||||
// app-server/src/lib.rs
|
||||
&config,
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
Some("codex_app_server"),
|
||||
|
||||
@@ -19,6 +19,7 @@ fn main() -> anyhow::Result<()> {
|
||||
run_main(
|
||||
codex_linux_sandbox_exe,
|
||||
CliConfigOverrides::default(),
|
||||
// app-server/src/main.rs
|
||||
loader_overrides,
|
||||
false,
|
||||
)
|
||||
|
||||
@@ -137,6 +137,7 @@ impl MessageProcessor {
|
||||
code: INVALID_REQUEST_ERROR_CODE,
|
||||
message: format!(
|
||||
"Invalid clientInfo.name: '{name}'. Must be a valid HTTP header value."
|
||||
// app-server/src/message_processor.rs
|
||||
),
|
||||
data: None,
|
||||
};
|
||||
|
||||
@@ -20,6 +20,7 @@ pub async fn supported_models(thread_manager: Arc<ThreadManager>, config: &Confi
|
||||
|
||||
fn model_from_preset(preset: ModelPreset) -> Model {
|
||||
Model {
|
||||
// app-server/src/models.rs
|
||||
id: preset.id.to_string(),
|
||||
model: preset.model.to_string(),
|
||||
display_name: preset.display_name.to_string(),
|
||||
|
||||
@@ -150,6 +150,7 @@ pub(crate) struct OutgoingResponse {
|
||||
pub result: Result,
|
||||
}
|
||||
|
||||
// app-server/src/outgoing_message.rs
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
pub(crate) struct OutgoingError {
|
||||
pub error: JSONRPCErrorError,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Single integration test binary that aggregates all test modules.
|
||||
// app-server/tests/all.rs
|
||||
// The submodules live in `tests/suite/`.
|
||||
mod suite;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
load("//:defs.bzl", "codex_rust_crate")
|
||||
|
||||
codex_rust_crate(
|
||||
# app-server/tests/common/BUILD.bazel
|
||||
name = "common",
|
||||
crate_name = "app_test_support",
|
||||
crate_srcs = glob(["*.rs"]),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ anyhow = { workspace = true }
|
||||
base64 = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
codex-app-server-protocol = { workspace = true }
|
||||
# app-server/tests/common/Cargo.toml
|
||||
codex-core = { workspace = true, features = ["test-support"] }
|
||||
codex-protocol = { workspace = true }
|
||||
codex-utils-cargo-bin = { workspace = true }
|
||||
|
||||
@@ -65,6 +65,7 @@ impl ChatGptAuthFixture {
|
||||
}
|
||||
}
|
||||
|
||||
// app-server/tests/common/auth_fixtures.rs
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ChatGptIdTokenClaims {
|
||||
pub email: Option<String>,
|
||||
|
||||
@@ -18,6 +18,7 @@ pub use core_test_support::test_path_buf_with_windows;
|
||||
pub use core_test_support::test_tmp_path;
|
||||
pub use core_test_support::test_tmp_path_buf;
|
||||
pub use mcp_process::DEFAULT_CLIENT_NAME;
|
||||
// app-server/tests/common/lib.rs
|
||||
pub use mcp_process::McpProcess;
|
||||
pub use mock_model_server::create_mock_responses_server_repeating_assistant;
|
||||
pub use mock_model_server::create_mock_responses_server_sequence;
|
||||
|
||||
@@ -363,6 +363,7 @@ impl McpProcess {
|
||||
|
||||
/// Send a `thread/rollback` JSON-RPC request.
|
||||
pub async fn send_thread_rollback_request(
|
||||
// app-server/tests/common/mcp_process.rs
|
||||
&mut self,
|
||||
params: ThreadRollbackParams,
|
||||
) -> anyhow::Result<i64> {
|
||||
|
||||
@@ -38,6 +38,7 @@ pub async fn create_mock_responses_server_sequence_unchecked(responses: Vec<Stri
|
||||
let seq_responder = SeqResponder {
|
||||
num_calls: AtomicUsize::new(0),
|
||||
responses,
|
||||
// app-server/tests/common/mock_model_server.rs
|
||||
};
|
||||
|
||||
Mock::given(method("POST"))
|
||||
|
||||
@@ -39,6 +39,7 @@ fn preset_to_info(preset: &ModelPreset, priority: i32) -> ModelInfo {
|
||||
experimental_supported_tools: Vec::new(),
|
||||
}
|
||||
}
|
||||
// app-server/tests/common/models_cache.rs
|
||||
|
||||
/// Write a models_cache.json file to the codex home directory.
|
||||
/// This prevents ModelsManager from making network requests to refresh models.
|
||||
|
||||
@@ -40,6 +40,7 @@ pub fn create_apply_patch_sse_response(
|
||||
responses::ev_completed("resp-1"),
|
||||
]))
|
||||
}
|
||||
// app-server/tests/common/responses.rs
|
||||
|
||||
pub fn create_exec_command_sse_response(call_id: &str) -> anyhow::Result<String> {
|
||||
let (cmd, args) = if cfg!(windows) {
|
||||
|
||||
@@ -87,6 +87,7 @@ pub fn create_fake_rollout(
|
||||
"timestamp": meta_rfc3339,
|
||||
"type":"event_msg",
|
||||
"payload": {
|
||||
// app-server/tests/common/rollout.rs
|
||||
"type":"user_message",
|
||||
"message": preview,
|
||||
"kind": "plain"
|
||||
|
||||
@@ -45,6 +45,7 @@ async fn archive_conversation_moves_rollout_into_archived_directory() -> Result<
|
||||
"expected rollout path {} to exist",
|
||||
rollout_path.display()
|
||||
);
|
||||
// app-server/tests/suite/archive_thread.rs
|
||||
|
||||
let archive_request_id = mcp
|
||||
.send_archive_conversation_request(ArchiveConversationParams {
|
||||
|
||||
@@ -113,6 +113,7 @@ async fn get_auth_status_no_auth() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// app-server/tests/suite/auth.rs
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_auth_status_with_api_key() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
|
||||
@@ -255,6 +255,7 @@ async fn test_send_user_turn_changes_approval_policy_behavior() -> Result<()> {
|
||||
)?;
|
||||
|
||||
// Expect an ExecCommandApproval request (elicitation)
|
||||
// app-server/tests/suite/codex_message_processor_flow.rs
|
||||
let request = timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_request_message(),
|
||||
|
||||
@@ -77,6 +77,7 @@ async fn get_config_toml_parses_all_fields() -> Result<()> {
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(request_id)),
|
||||
)
|
||||
// app-server/tests/suite/config.rs
|
||||
.await??;
|
||||
|
||||
let config: GetUserSavedConfigResponse = to_response(resp)?;
|
||||
|
||||
@@ -69,6 +69,7 @@ async fn test_conversation_create_and_send_message_ok() -> Result<()> {
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(add_listener_id)),
|
||||
)
|
||||
.await??,
|
||||
// app-server/tests/suite/create_thread.rs
|
||||
)?;
|
||||
|
||||
// Now send a user message via the wire API and expect an OK (empty object) result.
|
||||
|
||||
@@ -68,6 +68,7 @@ async fn fork_conversation_creates_new_rollout() -> Result<()> {
|
||||
)
|
||||
.await??;
|
||||
let session_configured: ServerNotification = notification.try_into()?;
|
||||
// app-server/tests/suite/fork_thread.rs
|
||||
let ServerNotification::SessionConfigured(SessionConfiguredNotification {
|
||||
model,
|
||||
session_id,
|
||||
|
||||
@@ -62,6 +62,7 @@ async fn test_fuzzy_file_search_sorts_and_includes_indices() -> Result<()> {
|
||||
"score": 88,
|
||||
"indices": [0, 1, 2],
|
||||
},
|
||||
// app-server/tests/suite/fuzzy_file_search.rs
|
||||
{
|
||||
"root": root_path.clone(),
|
||||
"path": "abcde",
|
||||
|
||||
@@ -79,6 +79,7 @@ async fn shell_command_interruption() -> anyhow::Result<()> {
|
||||
let new_conv_resp: JSONRPCResponse = timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(new_conv_id)),
|
||||
// app-server/tests/suite/interrupt.rs
|
||||
)
|
||||
.await??;
|
||||
let new_conv_resp = to_response::<NewConversationResponse>(new_conv_resp)?;
|
||||
|
||||
@@ -217,6 +217,7 @@ async fn test_list_and_resume_conversations() -> Result<()> {
|
||||
// Then the response for resumeConversation
|
||||
let resume_resp: JSONRPCResponse = timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
// app-server/tests/suite/list_resume.rs
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(resume_req_id)),
|
||||
)
|
||||
.await??;
|
||||
|
||||
@@ -78,6 +78,7 @@ async fn logout_chatgpt_removes_auth() -> Result<()> {
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(status_id)),
|
||||
)
|
||||
.await??;
|
||||
// app-server/tests/suite/login.rs
|
||||
let status: GetAuthStatusResponse = to_response(status_resp)?;
|
||||
assert_eq!(status.auth_method, None);
|
||||
assert_eq!(status.auth_token, None);
|
||||
|
||||
@@ -6,6 +6,7 @@ mod create_thread;
|
||||
mod fork_thread;
|
||||
mod fuzzy_file_search;
|
||||
mod interrupt;
|
||||
// app-server/tests/suite/mod.rs
|
||||
mod list_resume;
|
||||
mod login;
|
||||
mod output_schema;
|
||||
|
||||
@@ -140,6 +140,7 @@ async fn send_user_turn_output_schema_is_per_turn_v1() -> Result<()> {
|
||||
create_config_toml(codex_home.path(), &server.uri())?;
|
||||
|
||||
let mut mcp = McpProcess::new(codex_home.path()).await?;
|
||||
// app-server/tests/suite/output_schema.rs
|
||||
timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??;
|
||||
|
||||
let new_conv_id = mcp
|
||||
|
||||
@@ -216,6 +216,7 @@ async fn test_send_message_raw_notifications_opt_in() -> Result<()> {
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(send_id)),
|
||||
)
|
||||
// app-server/tests/suite/send_message.rs
|
||||
.await??;
|
||||
let _ok: SendUserMessageResponse = to_response::<SendUserMessageResponse>(response)?;
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ async fn set_default_model_persists_overrides() -> Result<()> {
|
||||
|
||||
let resp: JSONRPCResponse = timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
// app-server/tests/suite/set_default_model.rs
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(request_id)),
|
||||
)
|
||||
.await??;
|
||||
|
||||
@@ -19,6 +19,7 @@ async fn get_user_agent_returns_current_codex_user_agent() -> Result<()> {
|
||||
timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??;
|
||||
|
||||
let request_id = mcp.send_get_user_agent_request().await?;
|
||||
// app-server/tests/suite/user_agent.rs
|
||||
let response: JSONRPCResponse = timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(request_id)),
|
||||
|
||||
@@ -21,6 +21,7 @@ async fn user_info_returns_email_from_auth_json() -> Result<()> {
|
||||
write_chatgpt_auth(
|
||||
codex_home.path(),
|
||||
ChatGptAuthFixture::new("access")
|
||||
// app-server/tests/suite/user_info.rs
|
||||
.refresh_token("refresh")
|
||||
.email("user@example.com"),
|
||||
AuthCredentialsStoreMode::File,
|
||||
|
||||
@@ -244,6 +244,7 @@ async fn login_account_chatgpt_rejected_when_forced_api() -> Result<()> {
|
||||
async fn login_account_chatgpt_start_can_be_cancelled() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
create_config_toml(codex_home.path(), CreateConfigTomlParams::default())?;
|
||||
// app-server/tests/suite/v2/account.rs
|
||||
|
||||
let mut mcp = McpProcess::new(codex_home.path()).await?;
|
||||
timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??;
|
||||
|
||||
@@ -31,6 +31,7 @@ async fn app_server_default_analytics_disabled_without_flag() -> Result<()> {
|
||||
&config,
|
||||
SERVICE_VERSION,
|
||||
Some("codex_app_server"),
|
||||
// app-server/tests/suite/v2/analytics.rs
|
||||
false,
|
||||
)
|
||||
.map_err(|err| anyhow::anyhow!(err.to_string()))?;
|
||||
|
||||
@@ -41,6 +41,7 @@ async fn list_collaboration_modes_returns_presets() -> Result<()> {
|
||||
)
|
||||
.await??;
|
||||
|
||||
// app-server/tests/suite/v2/collaboration_mode_list.rs
|
||||
let CollaborationModeListResponse { data: items } =
|
||||
to_response::<CollaborationModeListResponse>(response)?;
|
||||
|
||||
|
||||
@@ -237,6 +237,7 @@ writable_roots = [{}]
|
||||
.as_ref()
|
||||
.expect("sandbox workspace write");
|
||||
assert_eq!(sandbox.writable_roots, vec![system_dir]);
|
||||
// app-server/tests/suite/v2/config_rpc.rs
|
||||
assert_eq!(
|
||||
origins
|
||||
.get("sandbox_workspace_write.writable_roots.0")
|
||||
|
||||
@@ -66,6 +66,7 @@ async fn initialize_respects_originator_override_env_var() -> Result<()> {
|
||||
|
||||
let JSONRPCMessage::Response(response) = message else {
|
||||
anyhow::bail!("expected initialize response, got {message:?}");
|
||||
// app-server/tests/suite/v2/initialize.rs
|
||||
};
|
||||
let InitializeResponse { user_agent } = to_response::<InitializeResponse>(response)?;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ mod model_list;
|
||||
mod output_schema;
|
||||
mod rate_limits;
|
||||
mod request_user_input;
|
||||
// app-server/tests/suite/v2/mod.rs
|
||||
mod review;
|
||||
mod thread_archive;
|
||||
mod thread_fork;
|
||||
|
||||
@@ -141,6 +141,7 @@ async fn list_models_returns_all_models_with_large_limit() -> Result<()> {
|
||||
.to_string(),
|
||||
},
|
||||
ReasoningEffortOption {
|
||||
// app-server/tests/suite/v2/model_list.rs
|
||||
reasoning_effort: ReasoningEffort::High,
|
||||
description: "Maximizes reasoning depth for complex or ambiguous problems"
|
||||
.to_string(),
|
||||
|
||||
@@ -115,6 +115,7 @@ async fn turn_start_output_schema_is_per_turn_v2() -> Result<()> {
|
||||
create_config_toml(codex_home.path(), &server.uri())?;
|
||||
|
||||
let mut mcp = McpProcess::new(codex_home.path()).await?;
|
||||
// app-server/tests/suite/v2/output_schema.rs
|
||||
timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??;
|
||||
|
||||
let thread_req = mcp
|
||||
|
||||
@@ -90,6 +90,7 @@ async fn get_account_rate_limits_returns_snapshot() -> Result<()> {
|
||||
AuthCredentialsStoreMode::File,
|
||||
)?;
|
||||
|
||||
// app-server/tests/suite/v2/rate_limits.rs
|
||||
let server = MockServer::start().await;
|
||||
let server_url = server.uri();
|
||||
write_chatgpt_base_url(codex_home.path(), &server_url)?;
|
||||
|
||||
@@ -65,6 +65,7 @@ async fn request_user_input_round_trip() -> Result<()> {
|
||||
let turn_start_resp: JSONRPCResponse = timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(turn_start_id)),
|
||||
// app-server/tests/suite/v2/request_user_input.rs
|
||||
)
|
||||
.await??;
|
||||
let TurnStartResponse { turn, .. } = to_response(turn_start_resp)?;
|
||||
|
||||
@@ -159,6 +159,7 @@ async fn review_start_rejects_empty_base_branch() -> Result<()> {
|
||||
"unexpected message: {}",
|
||||
error.error.message
|
||||
);
|
||||
// app-server/tests/suite/v2/review.rs
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ async fn thread_archive_moves_rollout_into_archived_directory() -> Result<()> {
|
||||
.expect("expected rollout path for thread id to exist");
|
||||
assert!(
|
||||
rollout_path.exists(),
|
||||
// app-server/tests/suite/v2/thread_archive.rs
|
||||
"expected {} to exist",
|
||||
rollout_path.display()
|
||||
);
|
||||
|
||||
@@ -68,6 +68,7 @@ async fn thread_fork_creates_new_thread_and_emits_started() -> Result<()> {
|
||||
.await??;
|
||||
let ThreadForkResponse { thread, .. } = to_response::<ThreadForkResponse>(fork_resp)?;
|
||||
|
||||
// app-server/tests/suite/v2/thread_fork.rs
|
||||
let after_contents = std::fs::read_to_string(&original_path)?;
|
||||
assert_eq!(
|
||||
after_contents, original_contents,
|
||||
|
||||
@@ -404,6 +404,7 @@ async fn thread_list_stops_when_not_enough_filtered_results_exist() -> Result<()
|
||||
data.len(),
|
||||
7,
|
||||
"all available filtered threads should be returned"
|
||||
// app-server/tests/suite/v2/thread_list.rs
|
||||
);
|
||||
assert!(
|
||||
data.iter()
|
||||
|
||||
@@ -67,6 +67,7 @@ async fn thread_loaded_list_paginates() -> Result<()> {
|
||||
})
|
||||
.await?;
|
||||
let resp: JSONRPCResponse = timeout(
|
||||
// app-server/tests/suite/v2/thread_loaded_list.rs
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(list_id)),
|
||||
)
|
||||
|
||||
@@ -134,6 +134,7 @@ async fn thread_resume_returns_rollout_history() -> Result<()> {
|
||||
text: preview.to_string(),
|
||||
text_elements: text_elements.clone().into_iter().map(Into::into).collect(),
|
||||
}]
|
||||
// app-server/tests/suite/v2/thread_resume.rs
|
||||
);
|
||||
}
|
||||
other => panic!("expected user message item, got {other:?}"),
|
||||
|
||||
@@ -88,6 +88,7 @@ async fn thread_rollback_drops_last_turns_and_persists_to_rollout() -> Result<()
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(turn2_id)),
|
||||
)
|
||||
.await??;
|
||||
// app-server/tests/suite/v2/thread_rollback.rs
|
||||
let _completed2 = timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_notification_message("turn/completed"),
|
||||
|
||||
@@ -45,6 +45,7 @@ async fn thread_start_creates_thread_and_emits_started() -> Result<()> {
|
||||
model_provider,
|
||||
..
|
||||
} = to_response::<ThreadStartResponse>(resp)?;
|
||||
// app-server/tests/suite/v2/thread_start.rs
|
||||
assert!(!thread.id.is_empty(), "thread id should not be empty");
|
||||
assert!(
|
||||
thread.preview.is_empty(),
|
||||
|
||||
@@ -70,6 +70,7 @@ async fn turn_interrupt_aborts_running_turn() -> Result<()> {
|
||||
// Start a turn that triggers a long-running command.
|
||||
let turn_req = mcp
|
||||
.send_turn_start_request(TurnStartParams {
|
||||
// app-server/tests/suite/v2/turn_interrupt.rs
|
||||
thread_id: thread.id.clone(),
|
||||
input: vec![V2UserInput::Text {
|
||||
text: "run sleep".to_string(),
|
||||
|
||||
@@ -761,6 +761,7 @@ async fn turn_start_updates_sandbox_and_cwd_between_turns_v2() -> Result<()> {
|
||||
let first_turn = mcp
|
||||
.send_turn_start_request(TurnStartParams {
|
||||
thread_id: thread.id.clone(),
|
||||
// app-server/tests/suite/v2/turn_start.rs
|
||||
input: vec![V2UserInput::Text {
|
||||
text: "first turn".to_string(),
|
||||
text_elements: Vec::new(),
|
||||
|
||||
@@ -3,6 +3,7 @@ load("//:defs.bzl", "codex_rust_crate")
|
||||
exports_files(["apply_patch_tool_instructions.md"])
|
||||
|
||||
codex_rust_crate(
|
||||
# apply-patch/BUILD.bazel
|
||||
name = "apply-patch",
|
||||
crate_name = "codex_apply_patch",
|
||||
compile_data = [
|
||||
|
||||
@@ -13,6 +13,7 @@ name = "apply_patch"
|
||||
path = "src/main.rs"
|
||||
|
||||
[lints]
|
||||
# apply-patch/Cargo.toml
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -35,6 +35,7 @@ For instructions on [context_before] and [context_after]:
|
||||
[3 lines of pre-context]
|
||||
- [old_code]
|
||||
+ [new_code]
|
||||
<!-- apply-patch/apply_patch_tool_instructions.md -->
|
||||
[3 lines of post-context]
|
||||
|
||||
The full grammar definition is below:
|
||||
|
||||
@@ -404,6 +404,7 @@ mod tests {
|
||||
strs_to_strings(&["pwsh", "-NoProfile", "-Command", script])
|
||||
}
|
||||
|
||||
// apply-patch/src/invocation.rs
|
||||
fn args_cmd(script: &str) -> Vec<String> {
|
||||
strs_to_strings(&["cmd.exe", "/c", script])
|
||||
}
|
||||
|
||||
@@ -530,6 +530,7 @@ pub fn print_summary(
|
||||
out: &mut impl std::io::Write,
|
||||
) -> std::io::Result<()> {
|
||||
writeln!(out, "Success. Updated the following files:")?;
|
||||
// apply-patch/src/lib.rs
|
||||
for path in &affected.added {
|
||||
writeln!(out, "A {}", path.display())?;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
pub fn main() -> ! {
|
||||
// apply-patch/src/main.rs
|
||||
codex_apply_patch::main()
|
||||
}
|
||||
|
||||
@@ -379,6 +379,7 @@ fn parse_update_file_chunk(
|
||||
change_context,
|
||||
old_lines: Vec::new(),
|
||||
new_lines: Vec::new(),
|
||||
// apply-patch/src/parser.rs
|
||||
is_end_of_file: false,
|
||||
};
|
||||
let mut parsed_lines = 0;
|
||||
|
||||
@@ -73,6 +73,7 @@ pub(crate) fn seek_sequence(
|
||||
// differences when locating context lines.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
// apply-patch/src/seek_sequence.rs
|
||||
fn normalise(s: &str) -> String {
|
||||
s.trim()
|
||||
.chars()
|
||||
|
||||
@@ -27,6 +27,7 @@ pub fn run_main() -> i32 {
|
||||
match std::io::stdin().read_to_string(&mut buf) {
|
||||
Ok(_) => {
|
||||
if buf.is_empty() {
|
||||
// apply-patch/src/standalone_executable.rs
|
||||
eprintln!("Usage: apply_patch 'PATCH'\n echo 'PATCH' | apply-patch");
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Single integration test binary that aggregates all test modules.
|
||||
// apply-patch/tests/all.rs
|
||||
// The submodules live in `tests/suite/`.
|
||||
mod suite;
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
# apply-patch/tests/fixtures/scenarios/.gitattributes
|
||||
** text eol=lf
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user