Make Codex and Claude Code subscriptions go further: a local model router that gives routine agent work to economical models and keeps your strongest model for the hard parts.
Rust ai-agentsai-gatewayclaude-codecodexcoding-agentcost-optimizationdeepseekllm-gatewayllm-routerlocal-firstmodel-routingrusttask-routingtauri
Stabilize Agent discovery tests during version probe timeouts (#20)
澄潭bfa638ffe02e
diff --git a/crates/integrations/src/agents/executable/tests.rs b/crates/integrations/src/agents/executable/tests.rsindex 09be24cd..0d4ee1d8 100644--- a/crates/integrations/src/agents/executable/tests.rs+++ b/crates/integrations/src/agents/executable/tests.rs@@ -30,6 +30,7 @@ fn agent_probe_version_is_diagnostic_and_private_environment_is_not_inherited()dir.path(),"test -z \"$HOME\" || exit 4; printf 'codex-cli 99.123.456-beta.1\\n'",);+ let mut completed = 0;for _ in 0..64 {let found = match probe(&path, Duration::from_secs(1)) {ExecutableProbe::Installed(found) => found,@@ -38,8 +39,17 @@ fn agent_probe_version_is_diagnostic_and_private_environment_is_not_inherited()panic!("executable probe failed: {reason:?}")}};- assert_eq!(found.version, "99.123.456-beta.1");+ // A bounded diagnostic may time out before the interpreter runs when probes+ // launch concurrently. A completed probe still proves the child saw no HOME.+ if !found.version.is_empty() {+ assert_eq!(found.version, "99.123.456-beta.1");+ completed += 1;+ }}+ assert!(+ completed > 0,+ "no probe verified the private child environment"+ );}#[test]@@ -81,7 +91,19 @@ fn group_writable_executable_and_ancestor_are_allowed() {let ExecutableProbe::Installed(found) = probe(&path, Duration::from_secs(1)) else {panic!("group-writable installation was rejected");};- assert_eq!(found.version, "2.1.231");+ assert_eq!(+ found.canonical_path,+ std::fs::canonicalize(&target).unwrap().to_str().unwrap()+ );+ assert!(found.version.is_empty() || found.version == "2.1.231");+}++#[test]+fn agent_probe_parses_claude_version_without_running_a_process() {+ assert_eq!(+ parse_version(b"claude 2.1.231 (Claude Code)\n"),+ Some("2.1.231".to_owned())+ );}#[test]diff --git a/crates/integrations/src/agents/filesystem_tests.rs b/crates/integrations/src/agents/filesystem_tests.rsindex b9c705d8..90426fe6 100644--- a/crates/integrations/src/agents/filesystem_tests.rs+++ b/crates/integrations/src/agents/filesystem_tests.rs@@ -268,19 +268,15 @@ fn group_writable_claude_executable_is_probed_and_safe_configuration_is_discover.find(|result| outcome_agent_id(&result.outcome) == "agent_claude_default").unwrap();- assert!(matches!(- result.outcome,- AgentDiscoveryOutcomeV1::Supported { ref installation }- if installation.version == "2.1.231"- ));+ let AgentDiscoveryOutcomeV1::Supported { installation } = &result.outcome else {+ panic!("group-writable Claude installation was rejected");+ };+ assert!(installation.version.is_empty() || installation.version == "2.1.231");assert!(result.claude_configuration.is_some());assert!(result.discovered_credential.is_some());assert!(result.configuration_issue.is_none());assert!(result.managed_launch.is_some());- assert!(- version_probed.exists(),- "the bounded version probe did not run"- );+ assert!(installation.version.is_empty() || version_probed.exists());assert!(!helper_executed.exists(),"the configured helper was executed"@@ -372,22 +368,19 @@ fn group_writable_claude_reports_unknown_configuration_without_exposing_or_impor.into_iter().find(|result| outcome_agent_id(&result.outcome) == "agent_claude_default").unwrap();- assert!(matches!(- result.outcome,- AgentDiscoveryOutcomeV1::ReportOnly {- ref version,- ref reason,- ..- } if version == "2.1.231" && reason == &issue- ));+ let AgentDiscoveryOutcomeV1::ReportOnly {+ version, reason, ..+ } = &result.outcome+ else {+ panic!("unknown Claude configuration was not reported");+ };+ assert_eq!(reason, &issue);+ assert!(version.is_empty() || version == "2.1.231");assert_eq!(result.configuration_issue.as_ref(), Some(&issue));assert!(result.claude_configuration.is_none());assert!(result.discovered_credential.is_none());assert!(result.managed_launch.is_some());- assert!(- version_probed.exists(),- "the bounded version probe did not run"- );+ assert!(version.is_empty() || version_probed.exists());assert!(!helper_executed.exists(),"the configured helper was executed"@@ -405,6 +398,59 @@ fn group_writable_claude_reports_unknown_configuration_without_exposing_or_impor}}+#[cfg(unix)]+#[test]+fn group_writable_claude_stays_supported_when_version_probe_times_out() {+ use std::os::unix::fs::PermissionsExt;++ let directory = tempfile::tempdir().unwrap();+ let layout = layout(directory.path());+ let helper_executed = directory.path().join("claude-helper-executed");+ fs::write(+ &layout.claude_executable,+ b"#!/bin/sh\n/bin/sleep 30\nprintf '2.1.231 (Claude Code)\\n'\n",+ )+ .unwrap();+ fs::set_permissions(&layout.claude_executable, fs::Permissions::from_mode(0o777)).unwrap();+ fs::set_permissions(+ layout.claude_executable.parent().unwrap(),+ fs::Permissions::from_mode(0o775),+ )+ .unwrap();+ write_secret_settings(+ &layout.claude_user_settings,+ json!({+ "apiKeyHelper": format!("touch {}", helper_executed.display()),+ "env": {+ "ANTHROPIC_BASE_URL": "https://open.bigmodel.cn/api/anthropic",+ "ANTHROPIC_MODEL": "glm-5.3",+ "ANTHROPIC_AUTH_TOKEN": "secret-never-serialized"+ }+ }),+ );++ let result = FilesystemAgentScannerV1::new(layout, registry())+ .scan()+ .into_iter()+ .find(|result| outcome_agent_id(&result.outcome) == "agent_claude_default")+ .unwrap();+ assert!(matches!(+ result.outcome,+ AgentDiscoveryOutcomeV1::Supported { ref installation }+ if installation.version.is_empty()+ ));+ assert!(result.claude_configuration.is_some());+ assert!(result.discovered_credential.is_some());+ assert!(result.configuration_issue.is_none());+ assert!(result.managed_launch.is_some());+ assert!(!helper_executed.exists());+ assert!(+ !serde_json::to_string(&result)+ .unwrap()+ .contains("secret-never-serialized")+ );+}+#[test]fn claude_precedence_uses_process_then_launch_project_user_managed() {let directory = tempfile::tempdir().unwrap();