Skip to content

Commit f98ca67

Browse files
authored
Merge branch 'main' into add-github-action-for-nix
2 parents d6658f6 + e857426 commit f98ca67

18 files changed

+1334
-262
lines changed

codex-rs/code

Whitespace-only changes.

codex-rs/core/src/client.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,23 @@ impl ModelClient {
184184

185185
let input_with_instructions = prompt.get_formatted_input();
186186

187-
// Only include `text.verbosity` for GPT-5 family models
188-
let text = if self.config.model_family.family == "gpt-5" {
189-
create_text_param_for_request(self.config.model_verbosity, &prompt.output_schema)
190-
} else {
191-
if self.config.model_verbosity.is_some() {
192-
warn!(
193-
"model_verbosity is set but ignored for non-gpt-5 model family: {}",
194-
self.config.model_family.family
195-
);
187+
let verbosity = match &self.config.model_family.family {
188+
family if family == "gpt-5" => self.config.model_verbosity,
189+
_ => {
190+
if self.config.model_verbosity.is_some() {
191+
warn!(
192+
"model_verbosity is set but ignored for non-gpt-5 model family: {}",
193+
self.config.model_family.family
194+
);
195+
}
196+
197+
None
196198
}
197-
None
198199
};
199200

201+
// Only include `text.verbosity` for GPT-5 family models
202+
let text = create_text_param_for_request(verbosity, &prompt.output_schema);
203+
200204
// In general, we want to explicitly send `store: false` when using the Responses API,
201205
// but in practice, the Azure Responses API rejects `store: false`:
202206
//

codex-rs/core/src/is_safe_command.rs renamed to codex-rs/core/src/command_safety/is_safe_command.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ use crate::bash::try_parse_bash;
22
use crate::bash::try_parse_word_only_commands_sequence;
33

44
pub fn is_known_safe_command(command: &[String]) -> bool {
5+
#[cfg(target_os = "windows")]
6+
{
7+
use super::windows_safe_commands::is_safe_command_windows;
8+
if is_safe_command_windows(command) {
9+
return true;
10+
}
11+
}
12+
513
if is_safe_to_call_with_exec(command) {
614
return true;
715
}
@@ -24,7 +32,6 @@ pub fn is_known_safe_command(command: &[String]) -> bool {
2432
{
2533
return true;
2634
}
27-
2835
false
2936
}
3037

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub mod is_safe_command;
2+
#[cfg(target_os = "windows")]
3+
pub mod windows_safe_commands;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// This is a WIP. This will eventually contain a real list of common safe Windows commands.
2+
pub fn is_safe_command_windows(_command: &[String]) -> bool {
3+
false
4+
}
5+
6+
#[cfg(test)]
7+
mod tests {
8+
use super::is_safe_command_windows;
9+
10+
fn vec_str(args: &[&str]) -> Vec<String> {
11+
args.iter().map(ToString::to_string).collect()
12+
}
13+
14+
#[test]
15+
fn everything_is_unsafe() {
16+
for cmd in [
17+
vec_str(&["powershell.exe", "-NoLogo", "-Command", "echo hello"]),
18+
vec_str(&["copy", "foo", "bar"]),
19+
vec_str(&["del", "file.txt"]),
20+
vec_str(&["powershell.exe", "Get-ChildItem"]),
21+
] {
22+
assert!(!is_safe_command_windows(&cmd));
23+
}
24+
}
25+
}

codex-rs/core/src/flags.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
use std::time::Duration;
2-
31
use env_flags::env_flags;
42

53
env_flags! {
6-
pub OPENAI_API_BASE: &str = "https://api.openai.com/v1";
7-
8-
/// Fallback when the provider-specific key is not set.
9-
pub OPENAI_API_KEY: Option<&str> = None;
10-
pub OPENAI_TIMEOUT_MS: Duration = Duration::from_millis(300_000), |value| {
11-
value.parse().map(Duration::from_millis)
12-
};
13-
144
/// Fixture path for offline tests (see client.rs).
155
pub CODEX_RS_SSE_FIXTURE: Option<&str> = None;
166
}

codex-rs/core/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub mod codex;
1515
mod codex_conversation;
1616
pub mod token_data;
1717
pub use codex_conversation::CodexConversation;
18+
mod command_safety;
1819
pub mod config;
1920
pub mod config_edit;
2021
pub mod config_profile;
@@ -29,7 +30,6 @@ pub mod exec_env;
2930
mod flags;
3031
pub mod git_info;
3132
pub mod internal_storage;
32-
mod is_safe_command;
3333
pub mod landlock;
3434
mod mcp_connection_manager;
3535
mod mcp_tool_call;
@@ -80,6 +80,7 @@ mod user_notification;
8080
pub mod util;
8181

8282
pub use apply_patch::CODEX_APPLY_PATCH_ARG1;
83+
pub use command_safety::is_safe_command;
8384
pub use safety::get_platform_sandbox;
8485
// Re-export the protocol types from the standalone `codex-protocol` crate so existing
8586
// `codex_core::protocol::...` references continue to work across the workspace.

codex-rs/core/tests/suite/json_result.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ const SCHEMA: &str = r#"
3030
"#;
3131

3232
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
33-
async fn codex_returns_json_result() -> anyhow::Result<()> {
33+
async fn codex_returns_json_result_for_gpt5() -> anyhow::Result<()> {
34+
codex_returns_json_result("gpt-5".to_string()).await
35+
}
36+
37+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
38+
async fn codex_returns_json_result_for_gpt5_codex() -> anyhow::Result<()> {
39+
codex_returns_json_result("gpt-5-codex".to_string()).await
40+
}
41+
42+
async fn codex_returns_json_result(model: String) -> anyhow::Result<()> {
3443
non_sandbox_test!(result);
3544

3645
let server = start_mock_server().await;
@@ -72,7 +81,7 @@ async fn codex_returns_json_result() -> anyhow::Result<()> {
7281
cwd: cwd.path().to_path_buf(),
7382
approval_policy: AskForApproval::Never,
7483
sandbox_policy: SandboxPolicy::DangerFullAccess,
75-
model: "gpt-5".to_string(),
84+
model,
7685
effort: None,
7786
summary: ReasoningSummary::Auto,
7887
})

0 commit comments

Comments
 (0)