Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
Grok: its own WebFetch is off, so it can't read kwnt's API without a card
Lin (kwant bot)5d4045b9413f
diff --git a/src/drivers/cli.rs b/src/drivers/cli.rsindex 1ad48037..ea2b7468 100644--- a/src/drivers/cli.rs+++ b/src/drivers/cli.rs@@ -162,11 +162,13 @@ const CODEX_MCP_LIST_TIMEOUT: Duration = Duration::from_secs(15);/// `codex exec` overrides limiting the model's shell commands to codex's "core" env/// (PATH, HOME, USER, SHELL...). codex's default passes its whole env, provider key included.-/// grok's headless mode refuses anything it would ask about. Like claude's policy (see-/// `mcp::builtin_tools`): fetching pages anywhere, and editing files inside the bot's working-/// folder, run without asking. Shell commands stay refused: grok has no approval hook for kwnt.+/// grok's headless mode refuses anything it would ask about, and grok has no approval hook for+/// kwnt, so only what is safe without a card is allowed: editing files inside the bot's working+/// folder. Shell commands stay refused. grok's own WebFetch is removed (see+/// [`GROK_DISALLOWED_TOOLS`]): pre-allowed, it could read kwnt's own API on this machine in every+/// approval mode. grok bots read pages with kwnt's `browser_*` tools, which go through approvals.pub fn grok_builtin_rules(folder: Option<&Path>) -> Vec<String> {- let mut rules = vec!["--allow".to_string(), "WebFetch".to_string()];+ let mut rules = Vec::new();// grok matches paths lexically, so the folder's real path keeps a symlinked folder workingif let Some(dir) = folder.and_then(|d| d.canonicalize().ok()) {let dir = dir.display().to_string().replace(')', "\\)");@@ -195,7 +197,9 @@ pub const CLAUDE_DISALLOWED_TOOLS: &[&str] = &[];/// grok's own scheduler, for the same reason. Its subagents are already off (`--no-subagents`).-pub const GROK_DISALLOWED_TOOLS: &[&str] = &["SchedulerCreate", "SchedulerDelete", "SchedulerList"];+/// Its WebFetch too: grok can't ask kwnt before fetching, so a fetch of kwnt's own API+/// (`http://localhost:<port>/api/...`) would run without a card (see [`grok_builtin_rules`]).+pub const GROK_DISALLOWED_TOOLS: &[&str] = &["SchedulerCreate", "SchedulerDelete", "SchedulerList", "WebFetch"];/// codex features kept off for the same reason: its local automations and its cross-session/// memories. `-c features.<name>=false` rather than `--disable`, which refuses names a later codex@@ -1098,12 +1102,13 @@ mod tests {use crate::db::models::{Kwant, Message};#[test]- fn grok_may_fetch_pages_and_edit_only_inside_the_folder() {- assert_eq!(grok_builtin_rules(None), ["--allow", "WebFetch"]);+ fn grok_may_edit_only_inside_the_folder_and_never_fetches_on_its_own() {+ assert!(grok_builtin_rules(None).is_empty());let tmp = tempfile::tempdir().unwrap();let real = tmp.path().canonicalize().unwrap().display().to_string();let rules = grok_builtin_rules(Some(tmp.path()));- assert_eq!(rules, ["--allow", "WebFetch", "--allow", &format!("Edit({real}/**)"), "--allow", &format!("Write({real}/**)")]);+ assert_eq!(rules, ["--allow", &format!("Edit({real}/**)"), "--allow", &format!("Write({real}/**)")]);+ assert!(!rules.iter().any(|r| r.contains("WebFetch")), "grok's WebFetch can't ask kwnt first");assert!(!rules.iter().any(|r| r.starts_with("Bash")), "shell commands stay refused");}@@ -1118,7 +1123,8 @@ mod tests {// kwnt's own tools and claude's lookups stay usableassert!(!tools.iter().any(|t| t.starts_with("mcp__") || ["WebSearch", "WebFetch", "Read"].contains(t)));- assert_eq!(grok_disallowed_args(), ["--disallowed-tools", "SchedulerCreate,SchedulerDelete,SchedulerList"]);+ // grok's WebFetch would read kwnt's own API with no card, so it is removed+ assert_eq!(grok_disallowed_args(), ["--disallowed-tools", "SchedulerCreate,SchedulerDelete,SchedulerList,WebFetch"]);let codex = codex_feature_args();assert_eq!(codex, ["-c", "features.in_app_local_automation=false", "-c", "features.memories=false"]);diff --git a/tests/grok_driver_test.rs b/tests/grok_driver_test.rsindex 90fafce5..5bfb9cd3 100644--- a/tests/grok_driver_test.rs+++ b/tests/grok_driver_test.rs@@ -334,7 +334,7 @@ async fn grok_gets_the_gateway_with_the_token_in_env_only() {let config_text = grok.out("config.toml");let env = grok.out("env");assert!(- argv.contains("--allow\nMCPTool(kwnt__*)\n--allow\nWebFetch\n--output-format\nstreaming-json\n"),+ argv.contains("--allow\nMCPTool(kwnt__*)\n--output-format\nstreaming-json\n"),"{argv}");assert_eq!(@@ -381,7 +381,10 @@ async fn grok_without_tools_gets_no_gateway() {grok.run(None).await;let argv = grok.out("argv");assert!(!argv.contains("MCPTool("), "{argv}");- assert!(argv.contains("--allow\nWebFetch\n"), "grok may still read web pages: {argv}");+ // grok's own WebFetch can't ask kwnt first, so it is off rather than pre-allowed: a Grok bot+ // could otherwise read kwnt's own API (http://localhost:<port>/api/...) in every approval mode+ assert!(!argv.contains("--allow\nWebFetch"), "{argv}");+ assert!(argv.contains("--disallowed-tools\nSchedulerCreate,SchedulerDelete,SchedulerList,WebFetch\n"), "{argv}");assert!(argv.contains("--output-format\nstreaming-json\n"), "{argv}");assert_eq!(env_value(&grok.out("env"), "KWNT_MCP_GATEWAY_TOKEN"), None);assert!(!grok.out("config.toml").contains("mcp_servers"));diff --git a/tests/mcp_runtime_test.rs b/tests/mcp_runtime_test.rsindex 177abe9f..0e60c755 100644--- a/tests/mcp_runtime_test.rs+++ b/tests/mcp_runtime_test.rs@@ -475,7 +475,8 @@ async fn grok_cli_reaches_mcp_only_through_kwnts_gateway() {let tmp = tempdir().unwrap();let (argv, token, notes, _) = fake_agent_run("grok", Some(ctx(tmp.path(), Arc::new(FixedApprover(true)))), Some(USER_SERVERS)).await;assert_eq!(token, "gw-secret-token", "token comes through the env");- assert!(argv.contains("--allow MCPTool(kwnt__*) --allow WebFetch --output-format streaming-json"), "{argv}");+ assert!(argv.contains("--allow MCPTool(kwnt__*) --output-format streaming-json"), "{argv}");+ assert!(!argv.contains("--allow WebFetch") && argv.contains("SchedulerList,WebFetch"), "{argv}");for secret in ["gw-secret-token", "sk-very-secret", "hdr-secret", "/usr/bin/true", "mcp.example.test"] {assert!(!argv.contains(secret), "{secret} in argv: {argv}");}