M2 audit: excise managed connectors and xAI media-gen tools

Managed connectors (grok.com MCP admin) removed root-and-branch:
- The managed-MCP fetch/injection pipeline is gone, including the whole
  kigi-shell-session-support crate (managed-config fetch client, gateway
  tool catalog + dispatch, header injection, refresh task), reactive
  managed re-auth, mcp_doctor's grok.com-source discovery, and the
  [managed_mcps] config surface.
- TUI: the 'Managed by grok.com' section, connectors URL/deep-link,
  Action::OpenManagedConnectors, and session_team_id are gone. Local MCP
  management (list/toggle/add/remove/auth/tools) is fully intact.
- Kept as LOCAL policy: managed-settings.json MCP allow/deny enforcement,
  the multi-source local MCP merge, folder-trust gating. PluginOrigin
  Project/User labels kept (they tag locally discovered plugin dirs).

imagine/media-gen tools (xAI image/video generation) removed:
- image_gen, image_edit, video_gen, image_to_video, reference_to_video
  implementations, registrations, ToolKind/ToolInput/Output variants
  (serde-safe), config plumbing end to end, ZDR video machinery,
  /imagine + /imagine-video commands and guidance text, the bundled
  imagine skill (added to legacy cleanup so user installs delete it),
  and the media-gen render path.
- Kept: image INPUT (paste/attach, [Image #N] meta, pdf/image fetch,
  clipboard wrap), generic media-ref rendering, and the generic tool
  401-retry machinery (tests renamed, assertions unweakened).
- deploy_app stays: it is a permanently-disabled local stub deploying
  nowhere.

121 files changed, 8 deleted. Gates: workspace check/clippy 0/0, fmt,
deny ok; suites green (tools 2554, shell 4862, tui 6608, workspace
1042). Remaining grok.com strings live only in the auth-method ids and
changelog archives (§9/M3 sweep).
This commit is contained in:
ZacharyZhang-NY committed 2026-07-17 23:45:05 -04:00
1 parent fa75eb139a
commit 5e4e24db99
120 files changed
+301 -11327

No files matched your search

+7 -226
View File
@@ -1,15 +1,8 @@
//! MCP server data types, status enum, response conversion, and section
//! presentation helpers (labels, description lines, connectors URLs).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum McpWireSource {
Managed,
Local,
}
//! presentation helpers (labels).
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum McpSectionId {
Managed,
Plugin(String),
Local,
}
@@ -24,9 +17,6 @@ impl Ord for McpSectionId {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
use std::cmp::Ordering;
match (self, other) {
(Self::Managed, Self::Managed) => Ordering::Equal,
(Self::Managed, _) => Ordering::Less,
(_, Self::Managed) => Ordering::Greater,
(Self::Plugin(a), Self::Plugin(b)) => a.cmp(b),
(Self::Plugin(_), Self::Local) => Ordering::Less,
(Self::Local, Self::Plugin(_)) => Ordering::Greater,
@@ -38,86 +28,28 @@ impl Ord for McpSectionId {
/// Collapse/expand key for a section header row in the MCP servers tab.
pub fn section_key(section: &McpSectionId) -> String {
match section {
McpSectionId::Managed => "mcp-section:managed".into(),
McpSectionId::Plugin(name) => format!("mcp-section:plugin:{name}"),
McpSectionId::Local => "mcp-section:local".into(),
}
}
/// Display label for a section header, e.g. `"Managed by grok.com (3)"`.
/// Display label for a section header, e.g. `"Local (3)"`.
pub fn section_label(section: &McpSectionId, count: usize) -> String {
match section {
McpSectionId::Managed => format!("Managed by grok.com ({count})"),
McpSectionId::Plugin(name) => format!("Plugin: {name} ({count})"),
McpSectionId::Local => format!("Local ({count})"),
}
}
/// Base grok.com connectors URL (no team). Prefer [`managed_connectors_url`] when opening.
pub const MANAGED_SECTION_CONNECTORS_URL: &str = "https://grok.com/connectors";
/// Connectors deep link, appending percent-encoded `teamId` when the session is a team principal.
pub fn managed_connectors_url(team_id: Option<&str>) -> String {
match team_id.filter(|id| !id.is_empty()) {
Some(id) => format!(
"{MANAGED_SECTION_CONNECTORS_URL}?teamId={}",
urlencoding::encode(id)
),
None => MANAGED_SECTION_CONNECTORS_URL.to_string(),
}
}
/// Display form of [`managed_connectors_url`] with the `https://` scheme dropped.
///
/// Used for the Managed section subtitle so the URL is shorter and more likely
/// to fit on one row; the Ctrl+O action still opens the full-scheme URL.
pub fn managed_connectors_url_display(team_id: Option<&str>) -> String {
let url = managed_connectors_url(team_id);
url.strip_prefix("https://").unwrap_or(&url).to_string()
}
/// Description lines shown under the Managed section header (when expanded).
/// `team_id` matches the Ctrl+O / open-connectors deep link for the session.
pub fn section_description_lines(section: &McpSectionId, team_id: Option<&str>) -> Vec<String> {
match section {
McpSectionId::Managed => {
let url = managed_connectors_url_display(team_id);
vec![
"Add, remove, or manage connectors. Ctrl+O to open or go to:".into(),
format!("[{url}]"),
]
}
McpSectionId::Plugin(_) | McpSectionId::Local => vec![],
}
}
/// Classify a server into a UI section.
///
/// Priority: `grok_com_` prefix or managed wire source → Managed; else plugin
/// label → Plugin; else Local. A managed server with a plugin display label
/// still lands in Managed.
/// Classify a server into a UI section: plugin label → Plugin; else Local.
pub fn section_for(server: &McpServerInfo) -> McpSectionId {
if server.name.starts_with("grok_com_") || server.wire_source == McpWireSource::Managed {
McpSectionId::Managed
} else if let Some(ref name) = server.plugin_name {
if let Some(ref name) = server.plugin_name {
McpSectionId::Plugin(name.clone())
} else {
McpSectionId::Local
}
}
/// Whether the user may delete this server from local config.
pub fn is_removable(server: &McpServerInfo) -> bool {
server.wire_source == McpWireSource::Local && !server.name.starts_with("grok_com_")
}
fn parse_wire_source(raw: Option<&str>) -> McpWireSource {
match raw {
Some("managed") => McpWireSource::Managed,
_ => McpWireSource::Local,
}
}
fn parse_plugin_name(source_label: &str) -> Option<String> {
let rest = source_label.strip_prefix("plugin:")?.trim();
if rest.is_empty() {
@@ -181,11 +113,8 @@ pub struct McpServerInfo {
pub enabled: bool,
/// Display label from `source_label` or wire `source` (e.g. `"plugin: foo"`).
pub source: String,
/// Wire `source` enum before display overlay.
pub wire_source: McpWireSource,
/// Plugin name parsed from `source_label` (`"plugin: …"`).
pub plugin_name: Option<String>,
pub is_managed_gateway: bool,
}
#[derive(Debug, Clone, Copy, PartialEq)]
@@ -262,10 +191,7 @@ pub fn convert_list_response(resp: McpsListResponse) -> Vec<McpServerInfo> {
} else {
(McpServerDisplayStatus::Unavailable, 0, vec![], false, false)
};
let wire_source = parse_wire_source(entry.source.as_deref());
let plugin_name = entry.source_label.as_deref().and_then(parse_plugin_name);
let is_managed_gateway = entry.name.starts_with("managed_gateway:")
|| entry.config_type.as_deref() == Some("managedGateway");
let source = entry
.source_label
.or(entry.source)
@@ -279,19 +205,16 @@ pub fn convert_list_response(resp: McpsListResponse) -> Vec<McpServerInfo> {
tools,
enabled,
source,
wire_source,
plugin_name,
is_managed_gateway,
}
})
.collect::<Vec<_>>();
// Stable sort: managed before plugin/local, then alphabetical by name.
// Stable sort: plugin before local, then alphabetical by name.
servers.sort_by(|a, b| {
let source_rank = |s: &McpServerInfo| match section_for(s) {
McpSectionId::Managed => 0,
McpSectionId::Plugin(_) => 1,
McpSectionId::Local => 2,
McpSectionId::Plugin(_) => 0,
McpSectionId::Local => 1,
};
source_rank(a)
.cmp(&source_rank(b))
@@ -354,9 +277,7 @@ mod tests {
tools: Vec::new(),
enabled: true,
source: "local".to_string(),
wire_source: McpWireSource::Local,
plugin_name: None,
is_managed_gateway: false,
}
}
@@ -394,71 +315,6 @@ mod tests {
.unwrap()
}
#[test]
fn section_description_lines_managed_includes_connectors_url() {
let lines = section_description_lines(&McpSectionId::Managed, None);
assert_eq!(lines.len(), 2);
// Instruction leads; Ctrl+O hint lives on the first line.
assert!(
lines[0].contains("Ctrl+O"),
"should mention Ctrl+O shortcut: {}",
lines[0]
);
// URL sits alone on the second line, scheme-stripped and bracket-highlighted.
assert_eq!(lines[1], "[grok.com/connectors]");
assert!(
!lines[1].contains("https://"),
"displayed URL should drop the scheme: {}",
lines[1]
);
let with_team = section_description_lines(&McpSectionId::Managed, Some("team-1"));
assert_eq!(with_team[1], "[grok.com/connectors?teamId=team-1]");
}
#[test]
fn managed_connectors_url_display_strips_scheme() {
assert_eq!(managed_connectors_url_display(None), "grok.com/connectors");
assert_eq!(
managed_connectors_url_display(Some("team-uuid-1")),
"grok.com/connectors?teamId=team-uuid-1"
);
}
#[test]
fn managed_connectors_url_appends_team_id_when_present() {
assert_eq!(managed_connectors_url(None), MANAGED_SECTION_CONNECTORS_URL);
assert_eq!(
managed_connectors_url(Some("")),
MANAGED_SECTION_CONNECTORS_URL
);
assert_eq!(
managed_connectors_url(Some("team-uuid-1")),
format!("{MANAGED_SECTION_CONNECTORS_URL}?teamId=team-uuid-1")
);
assert_eq!(
managed_connectors_url(Some("a b/c")),
format!(
"{MANAGED_SECTION_CONNECTORS_URL}?teamId={}",
urlencoding::encode("a b/c")
)
);
}
#[test]
fn section_description_lines_local_is_empty() {
assert!(section_description_lines(&McpSectionId::Local, None).is_empty());
}
#[test]
fn section_for_grok_com_with_plugin_label_is_managed() {
let server = server_from_wire(
"grok_com_linear",
Some("managed"),
Some("plugin: my-plugin"),
);
assert_eq!(section_for(&server), McpSectionId::Managed);
}
#[test]
fn section_for_plugin_labeled_local_is_plugin_section() {
let server = server_from_wire("my-mcp", Some("local"), Some("plugin: linter"));
@@ -468,86 +324,13 @@ mod tests {
);
}
#[test]
fn is_removable_plugin_labeled_local_server() {
let server = server_from_wire("my-mcp", Some("local"), Some("plugin: linter"));
assert!(is_removable(&server));
}
#[test]
fn is_removable_rejects_managed_wire_source() {
let server = server_from_wire("custom", Some("managed"), None);
assert!(!is_removable(&server));
}
#[test]
fn is_removable_rejects_grok_com_prefix() {
let server = server_from_wire("grok_com_slack", Some("local"), None);
assert!(!is_removable(&server));
}
#[test]
fn convert_list_response_parses_plugin_name() {
let server = server_from_wire("srv", Some("local"), Some("plugin: example"));
assert_eq!(server.wire_source, McpWireSource::Local);
assert_eq!(server.plugin_name.as_deref(), Some("example"));
assert_eq!(server.source, "plugin: example");
}
#[test]
fn convert_list_response_classifies_managed_gateway_only_for_gateway_rows() {
let gateway = server_from_wire_with_type(
"managed_gateway:linear",
Some("managed"),
None,
Some("managedGateway"),
);
assert!(gateway.is_managed_gateway);
let legacy_managed = server_from_wire("grok_com_slack", Some("managed"), None);
assert!(!legacy_managed.is_managed_gateway);
}
#[test]
fn gateway_row_uses_managed_section_not_local_uninstall() {
let gateway = server_from_wire_with_type(
"managed_gateway:linear",
Some("managed"),
None,
Some("managedGateway"),
);
assert_eq!(section_for(&gateway), McpSectionId::Managed);
assert!(!is_removable(&gateway));
}
#[test]
fn convert_list_response_orders_gateway_rows_by_display_name() {
fn gateway_entry(name: &str, display_name: &str) -> McpsServerEntry {
McpsServerEntry {
name: name.to_string(),
display_name: Some(display_name.to_string()),
source: Some("managed".to_string()),
source_label: None,
config_type: Some("managedGateway".to_string()),
session: Some(McpsServerSession {
enabled: true,
status: Some("ready".to_string()),
tools: vec![],
auth_required: false,
}),
}
}
let servers = convert_list_response(McpsListResponse {
servers: vec![
gateway_entry("managed_gateway:zeta", "Alpha"),
gateway_entry("managed_gateway:alpha", "Zeta"),
],
});
assert_eq!(servers[0].display_name.as_deref(), Some("Alpha"));
assert_eq!(servers[0].name, "managed_gateway:zeta");
assert_eq!(servers[1].display_name.as_deref(), Some("Zeta"));
}
#[test]
fn patch_server_row_updates_existing() {
let mut servers = vec![
@@ -614,9 +397,7 @@ mod tests {
}],
enabled: true,
source: "local".into(),
wire_source: McpWireSource::Local,
plugin_name: None,
is_managed_gateway: false,
}];
let mutated = patch_server_row(
&mut servers,