Synced from monorepo
Changes: - Classify clipboard delivery confidence - Add durable session update append - Scope the xAI session bearer to first-party memory embedding endpoints - Persist subagent outputs to disk and bound long-lived agent state - Add MiniSweAgent:bash for mini-swe-agent parity - Revert taking local sessions off the persistent shell - Contextual tip recommending grok wrap on SSH sessions - Voice STT bearer from model BYOK env_key/api_key - Define exact website policies for sandbox - Gate unsafe shell environments - Shared pin hoist; single require_sha gate for marketplace plugins - Server-signed is-managed claim (closes sidecar-removal downgrade) - Optional require_sha pin for remote plugin installs - Show session title and last exchange in the exit resume hint - Gate shell output redirects - Warn when fail_closed is present but not a boolean - Add canonical text editing core (ratatui-textarea) - Keep execution state out of goal scratch - Add acknowledged persistence primitives - Inherit child network restrictions in sandbox - Fail closed when hook matchers fail to recompile - Add MCP setup preferences for plugin MCPs - Gate sourced shell scripts - Gate file-typed project hooks - grok wrap: restore terminal modes on child death - Harden owner-only permissions on auth and MCP credentials - Create crash dump files with owner-only permissions - Write the agent_id cache owner-only (0600) - SessionMetrics mode skips Mixpanel profile sync - Dashboard: slim live-tail peek - Yank full queued prompt text, not (+N lines) - Defeat clock-rollback on the signed managed-config cache - Stop early session/cancel from overtaking the prompt and wedging the turn slot - Self-heal a diverged agent entrypoint on startup - Add matched inference expectations in test-support - Add AuthSingleFlight cancel/successor gap tests - Remove consumer from external OTEL allowlist and pin scrub coverage - Enable /copy in minimal mode - Surface capacity and API-key detail on 429 errors - Single-flight interactive auth - Fix PageUp/PageDown skipping lines behind sticky prompt header
This commit is contained in:
parent
8adf9013a0
commit
98c3b2438a
225 changed files with 18836 additions and 7156 deletions
|
|
@ -3586,6 +3586,105 @@ async fn shared_api_key_provider_disk_memo_follows_rewrites() {
|
|||
assert_eq!(provider.current_api_key_async().await, None);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial_test::serial]
|
||||
async fn process_key_from_model_env_key() {
|
||||
use crate::agent::config::{Config, resolve_model_list};
|
||||
use xai_grok_test_support::EnvGuard;
|
||||
|
||||
const ENV: &str = "TEST_MODEL_ENV_KEY";
|
||||
const TOKEN: &str = "model-env-token";
|
||||
|
||||
let _xai = EnvGuard::unset("XAI_API_KEY");
|
||||
let _legacy = EnvGuard::unset("GROK_CODE_XAI_API_KEY");
|
||||
let _tok = EnvGuard::set(ENV, TOKEN);
|
||||
|
||||
let dm = crate::models::default_model();
|
||||
let cfg = Config::new_from_toml_cfg(
|
||||
&toml::from_str(&format!(
|
||||
r#"
|
||||
[model."{dm}"]
|
||||
model = "{dm}"
|
||||
env_key = "{ENV}"
|
||||
"#
|
||||
))
|
||||
.unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let key = resolve_model_list(&cfg, None)
|
||||
.get(dm)
|
||||
.and_then(|m| m.own_credential())
|
||||
.unwrap();
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mgr = Arc::new(AuthManager::new(dir.path(), GrokComConfig::default()));
|
||||
assert!(mgr.current().is_none());
|
||||
mgr.set_process_static_api_key(Some(key));
|
||||
assert_eq!(
|
||||
shared_api_key_provider(mgr)
|
||||
.current_api_key_async()
|
||||
.await
|
||||
.as_deref(),
|
||||
Some(TOKEN)
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial_test::serial]
|
||||
async fn process_key_precedence() {
|
||||
use xai_grok_test_support::EnvGuard;
|
||||
|
||||
let _xai = EnvGuard::unset("XAI_API_KEY");
|
||||
let _legacy = EnvGuard::unset("GROK_CODE_XAI_API_KEY");
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mgr = Arc::new(AuthManager::new(dir.path(), GrokComConfig::default()));
|
||||
let provider = shared_api_key_provider(mgr.clone());
|
||||
|
||||
assert_eq!(provider.current_api_key_async().await, None);
|
||||
|
||||
crate::auth::store_api_key(dir.path(), "disk").unwrap();
|
||||
assert_eq!(
|
||||
provider.current_api_key_async().await.as_deref(),
|
||||
Some("disk")
|
||||
);
|
||||
|
||||
mgr.set_process_static_api_key(Some(" process ".into()));
|
||||
assert_eq!(
|
||||
provider.current_api_key_async().await.as_deref(),
|
||||
Some("process")
|
||||
);
|
||||
|
||||
{
|
||||
let _key = EnvGuard::set("XAI_API_KEY", "env");
|
||||
assert_eq!(
|
||||
provider.current_api_key_async().await.as_deref(),
|
||||
Some("env")
|
||||
);
|
||||
}
|
||||
|
||||
mgr.set_process_static_api_key(None);
|
||||
assert_eq!(
|
||||
provider.current_api_key_async().await.as_deref(),
|
||||
Some("disk")
|
||||
);
|
||||
|
||||
let dir_blocked = tempfile::tempdir().unwrap();
|
||||
let blocked = Arc::new(AuthManager::new(
|
||||
dir_blocked.path(),
|
||||
GrokComConfig {
|
||||
disable_api_key_auth: Some(true),
|
||||
..GrokComConfig::default()
|
||||
},
|
||||
));
|
||||
blocked.set_process_static_api_key(Some("ignored".into()));
|
||||
assert_eq!(
|
||||
shared_api_key_provider(blocked)
|
||||
.current_api_key_async()
|
||||
.await,
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
fn expired_oidc() -> GrokAuth {
|
||||
GrokAuth {
|
||||
key: "expired-key".into(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue