Skip to content

Commit c09fd4f

Browse files
committed
fix(sandbox): match both 'anthropic' and 'claude' provider types and preserve existing .claude.json
1 parent 869e8a9 commit c09fd4f

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

  • crates/openshell-sandbox/src

crates/openshell-sandbox/src/lib.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ pub async fn run_sandbox(
208208
}
209209
};
210210

211-
let has_anthropic = provider_result.has_provider_type("anthropic");
211+
let has_anthropic = provider_result.has_provider_type("anthropic")
212+
|| provider_result.has_provider_type("claude");
212213
let (provider_env, secret_resolver) =
213214
SecretResolver::from_provider_env(provider_result.flatten());
214215
let secret_resolver = secret_resolver.map(Arc::new);
@@ -1221,9 +1222,19 @@ fn write_provider_configs(has_anthropic: bool, policy: &SandboxPolicy) -> Result
12211222

12221223
let claude_json_path = std::path::Path::new(&home).join(".claude.json");
12231224

1224-
let config = serde_json::json!({
1225-
"hasCompletedOnboarding": true
1226-
});
1225+
// Merge into existing .claude.json if present, so we don't clobber
1226+
// user-supplied or BYOC-baked configuration.
1227+
let mut config: serde_json::Value = if claude_json_path.exists() {
1228+
let existing = std::fs::read_to_string(&claude_json_path).into_diagnostic()?;
1229+
serde_json::from_str(&existing).unwrap_or_else(|_| serde_json::json!({}))
1230+
} else {
1231+
serde_json::json!({})
1232+
};
1233+
1234+
if let Some(obj) = config.as_object_mut() {
1235+
obj.entry("hasCompletedOnboarding")
1236+
.or_insert(serde_json::Value::Bool(true));
1237+
}
12271238

12281239
if let Some(parent) = claude_json_path.parent() {
12291240
std::fs::create_dir_all(parent).into_diagnostic()?;

0 commit comments

Comments
 (0)