Synced from monorepo

Changes:
- grok-shell: request workspaces:read/write OAuth2 scopes
- security: fix SSRF bypass via HTTP redirect in hook runner
- fix(grok-build): enterprise STT WSS URL + API-key voice bearer
- Harden identity-change purge and sync-marker invariants
- sandbox + workspace-server: delete the legacy ready-file arm
- Show billing URL when browser cannot open
- fix(pager): show folder-trust UI in minimal mode
- fix(pager): drain task_backgrounded before no-wait headless exit
- grok-agent-sdk: stop SDK-spawned agents from staging self-updates they can never adopt
- Split settings_modal into directory module
- Delegate VS Code SSH file links
- grok-shell: release the workspace session binding when a session is removed
- keep skills reachable when their name collides with a client builtin
- Preserve semantic link targets
This commit is contained in:
grokkybara[bot] 2026-07-16 20:27:30 +01:00
commit 8adf9013a0
117 changed files with 16998 additions and 14540 deletions

View file

@ -6,9 +6,10 @@ edition.workspace = true
description = "Foundation modules for the grok shell crate family: environment presets, CPU profiling, and process/filesystem utilities."
[features]
# CI default set: builds a single shared rlib per crate, so downstream test
# targets need the test-only helper surface compiled in.
default-bazel = []
# Exposes `#[cfg(test)]`-only helpers (`env::EnvVarGuard`,
# `cpu_profile` test seams) to downstream crates' test targets. Enabled by
test-support = ["xai-grok-env/test-support"]
default-bazel = ["test-support"]
[dependencies]
anyhow = { workspace = true }
@ -41,7 +42,7 @@ windows = { workspace = true }
tempfile = { workspace = true }
# `cfg(test)` in this crate does not enable features on dependencies, so the
# tests' `EnvVarGuard` re-export needs the feature turned on explicitly.
xai-grok-env = { workspace = true, features = [] }
xai-grok-env = { workspace = true, features = ["test-support"] }
[lints]
workspace = true

View file

@ -204,7 +204,7 @@ impl CpuProfileManager {
Self::default()
}
#[cfg(test)]
#[cfg(any(test, feature = "test-support"))]
pub fn force_unsupported_for_test(&mut self) {
self.force_unsupported = true;
}
@ -518,7 +518,7 @@ fn now_timestamp() -> String {
// Module-level (not inside `mod tests`) so downstream crates' test targets
// can reach it in test-only builds.
#[cfg(test)]
#[cfg(any(test, feature = "test-support"))]
impl CpuProfileManager {
pub fn start_with_engine_for_test(
&mut self,

View file

@ -11,7 +11,7 @@
//! per-session gateway bridge actor and routes prompts through
//! it. Unset → falls back to [`GrokBuildEnvironment::gateway_ws_url`] for
//! sessions created in gateway mode; otherwise local-mode (unchanged).
#[cfg(test)]
#[cfg(any(test, feature = "test-support"))]
pub use xai_grok_env::EnvVarGuard;
pub use xai_grok_env::{
GrokBuildEnvironment, PROD_ASSET_SERVER_URL, PROD_CLI_CHAT_PROXY_BASE_URL, PROD_GATEWAY_WS_URL,
@ -37,39 +37,19 @@ pub fn custom_bridge_disabled() -> bool {
})
.unwrap_or(false)
}
/// Parse `GROK_GATEWAY_URL` into a [`url::Url`]. Unset, empty, or
/// malformed → `None` (malformed is warned and falls back to local
/// mode so the shell doesn't refuse to start).
/// Parse `GROK_GATEWAY_URL` into a [`url::Url`].
///
/// The malformed-URL warning intentionally does **not** log the raw
/// env-var value — a mistyped credential URL of the form
/// `wss://user:pass@host` would leak `pass` if the parse failed. The
/// operator can inspect their own env var directly.
///
/// Hard-off (always `None`) without the `chat` feature so release
/// builds can't activate the bridge via env.
/// This build ignores the variable and stays in local mode (warns if set).
pub fn parse_gateway_url() -> Option<url::Url> {
let raw = std::env::var(GROK_GATEWAY_URL_ENV).ok()?;
if raw.is_empty() {
return None;
}
if true {
tracing::warn!(
env = GROK_GATEWAY_URL_ENV,
"GROK_GATEWAY_URL is set but this build lacks the `chat` feature; staying in local mode"
);
return None;
}
match url::Url::parse(&raw) {
Ok(url) => Some(url),
Err(err) => {
tracing::warn!(
env = GROK_GATEWAY_URL_ENV, error = % err,
"GROK_GATEWAY_URL is not a valid URL; falling back to local mode (raw value omitted to avoid leaking userinfo)"
);
None
}
}
tracing::warn!(
env = GROK_GATEWAY_URL_ENV,
"GROK_GATEWAY_URL is set but this build does not support gateway-bridge mode; staying in local mode"
);
None
}
#[cfg(test)]
mod tests {
@ -85,11 +65,11 @@ mod tests {
assert!(parse_gateway_url().is_none());
}
#[test]
fn parse_gateway_url_returns_none_for_malformed_url() {
let _env = EnvVarGuard::set(GROK_GATEWAY_URL_ENV, "not a url");
fn parse_gateway_url_hard_off_without_gateway_bridge() {
let _env = EnvVarGuard::set(GROK_GATEWAY_URL_ENV, "wss://gateway.example.com/ws");
assert!(
parse_gateway_url().is_none(),
"malformed URL falls back to None"
"valid URL must still be ignored in this build"
);
}
#[test]

View file

@ -55,11 +55,18 @@ fn matches_trusted_base_url(candidate: &str, trusted_base: &str) -> bool {
}
/// True for cli-chat-proxy URLs (production, plus local-dev hosts when the
/// optional non-production feature is enabled). When that feature is on,
/// runtime env overrides can extend this trust set.
/// runtime env overrides can extend this trust set. Loopback is always
/// accepted (unit tests and local mock servers on arbitrary ports).
pub fn is_cli_chat_proxy_url(url: &str) -> bool {
if matches_trusted_base_url(url, crate::env::PROD_CLI_CHAT_PROXY_BASE_URL) {
return true;
}
if let Ok(u) = reqwest::Url::parse(url)
&& let Some(h) = u.host_str()
&& (h == "localhost" || h == "127.0.0.1" || h == "::1")
{
return true;
}
false
}
/// True for first-party xAI endpoints (`*.x.ai`, cli-chat-proxy, and optional