Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
refactor(agent): rename the bash tool to shell (#9130)
Akarshan Biswase5694a2a5507
diff --git a/adk/python/tests/test_adk.py b/adk/python/tests/test_adk.pyindex e80d00086..feda204bd 100644--- a/adk/python/tests/test_adk.py+++ b/adk/python/tests/test_adk.py@@ -202,7 +202,7 @@ class AdkTest(unittest.TestCase):self.assertTrue(fork.id)self.assertNotEqual(fork.id, first.id)self.assertEqual(fork.model, "stub-model")- self.assertIn("bash", fork.get_tools()["tools"])+ self.assertIn("shell", fork.get_tools()["tools"])def test_a_turn_is_bounded_when_nobody_drains_it(self) -> None:scratch = self.prepare([prose("unread")])diff --git a/docs/src/pages/docs/agent/cli.mdx b/docs/src/pages/docs/agent/cli.mdxindex f87e28c5d..ba2ccf6ce 100644--- a/docs/src/pages/docs/agent/cli.mdx+++ b/docs/src/pages/docs/agent/cli.mdx@@ -295,7 +295,7 @@ Each tool is advertised to the model as `host__<name>`. A name that is not ASCIIoriginal name is appended so names that sanitize alike stay distinct. `yam.move_ee_ik` isadvertised as `host__yam_move_ee_ik_<hash>`. The mapping is deterministic, and `init.tool_specs`shows the name the model will call. Still refused: an empty name, a name with a control character,-a built-in's name (`bash`, `read`, ...), and two declarations that land on the same advertised name.+a built-in's name (`shell`, `read`, ...), and two declarations that land on the same advertised name.When the model calls one, the run emits a `tool_request` and waits:@@ -394,7 +394,7 @@ The first line of a `stream-json` run is always an `init` record, printed beforeevent:```json-{"type":"init","protocol_version":1,"session_id":"3f7a91c2-4e5d-4a6b-8c7d-0e1f2a3b4c5d","model":"tokamak-1-preview","cwd":"/home/me/app","tools":["read","write","bash","host__robot_arm_move"],"tool_specs":[{"type":"function","function":{"name":"host__robot_arm_move","description":"Move the arm.","parameters":{"type":"object"}}}],"input_kinds":["user","abort","permission","tool_result"],"input_content_parts":{"mime_types":["image/png","image/jpeg","image/gif","image/webp"],"max_image_bytes":5242880,"max_message_image_bytes":10485760,"max_images":8,"max_line_bytes":16777216,"max_echo_bytes":4096}}+{"type":"init","protocol_version":1,"session_id":"3f7a91c2-4e5d-4a6b-8c7d-0e1f2a3b4c5d","model":"tokamak-1-preview","cwd":"/home/me/app","tools":["read","write","shell","host__robot_arm_move"],"tool_specs":[{"type":"function","function":{"name":"host__robot_arm_move","description":"Move the arm.","parameters":{"type":"object"}}}],"input_kinds":["user","abort","permission","tool_result"],"input_content_parts":{"mime_types":["image/png","image/jpeg","image/gif","image/webp"],"max_image_bytes":5242880,"max_message_image_bytes":10485760,"max_images":8,"max_line_bytes":16777216,"max_echo_bytes":4096}}```| Field | Notes |@@ -736,7 +736,7 @@ jan mcp serve --tool read --tool grep # narrow the set| `--port <PORT>` | Port for `http`. Defaults to an ephemeral one || `--token <TOKEN>` | Bearer token for `http`. One is generated and printed if omitted || `--allow-write` | Offer `write` and `edit`, confined to the project root |-| `--allow-exec` | Offer `bash`, under the same OS sandbox the agent's shell uses |+| `--allow-exec` | Offer `shell`, under the same OS sandbox the agent's shell uses || `--tool <NAME>` | Serve only these tools. Repeatable; never widens what the flags above permit |The default set touches no project file, and the two classes that can change the machine are opt-in:diff --git a/docs/src/pages/docs/agent/files.mdx b/docs/src/pages/docs/agent/files.mdxindex 08ac3d510..b6692e03e 100644--- a/docs/src/pages/docs/agent/files.mdx+++ b/docs/src/pages/docs/agent/files.mdx@@ -71,7 +71,7 @@ produced before it lands.| Tool | What it does || --- | --- |-| `bash` | Run a shell command in the project root |+| `shell` | Run a shell command in the project root |Output is combined stdout and stderr, followed by a final `[exit N]` line. That last part matters:it's how the agent knows a command actually failed rather than assuming it worked.@@ -93,7 +93,7 @@ command. If you only meant to allow this one, use `y`.## Staying inside the projectPath arguments are checked against the project root, so a write outside the project is caught before-it happens rather than silently allowed. `bash` runs with the project root as its working directory.+it happens rather than silently allowed. `shell` runs with the project root as its working directory.This is a guard, not a jail: a shell command can still reach outside if you approve it. Plan modeblocks the whole category, and that's the control to reach for when you want a hard boundary. Seediff --git a/docs/src/pages/docs/agent/hide-secrets.mdx b/docs/src/pages/docs/agent/hide-secrets.mdxindex fa09a5205..ce30c8088 100644--- a/docs/src/pages/docs/agent/hide-secrets.mdx+++ b/docs/src/pages/docs/agent/hide-secrets.mdx@@ -45,7 +45,7 @@ schemas and ids are left alone. It applies to the main run, subagents and compac```texttool output "token=ghp_abc…" -> provider sees "token=$$GITHUBTOKEN_3P8W5JH1TK2Q$$"-model calls bash("curl -H $$GITHUBTOKEN_3P8W5JH1TK2Q$$") -> bash runs with the real token+model calls shell("curl -H $$GITHUBTOKEN_3P8W5JH1TK2Q$$") -> shell runs with the real token```- A placeholder is derived from the secret and a random key kept in `~/.jan/secret-placeholder.key`diff --git a/docs/src/pages/docs/agent/hooks.mdx b/docs/src/pages/docs/agent/hooks.mdxindex 121ac6396..1554761b4 100644--- a/docs/src/pages/docs/agent/hooks.mdx+++ b/docs/src/pages/docs/agent/hooks.mdx@@ -13,11 +13,11 @@ prompt is submitted, when a session starts or ends, and before a compaction. Thestdin as JSON and the command's stdout is its answer.The point is to make a team policy enforceable rather than merely requested. "Run `cargo fmt` after-every `edit`", "never let `bash` touch `infra/`", "log every tool call to our audit sink" used to+every `edit`", "never let `shell` touch `infra/`", "log every tool call to our audit sink" used tohave only one lever - a line in the system prompt, which the model is free to ignore. A hook is notadvice. A `PreToolUse` hook that answers `deny` stops the call.-A hook is a shell command, not a plugin runtime. It runs through the same confinement `bash` gets,+A hook is a shell command, not a plugin runtime. It runs through the same confinement `shell` gets,so nothing here is a new execution primitive.## A first hook@@ -82,7 +82,7 @@ shared config does not take the other hooks down with it - it is dropped, with a```json[- { "event": "PreToolUse", "matcher": "bash", "command": "./hooks/audit.sh", "timeout_secs": 10 },+ { "event": "PreToolUse", "matcher": "shell", "command": "./hooks/audit.sh", "timeout_secs": 10 },{ "event": "SessionEnd", "command": "./hooks/report.sh" }]```@@ -121,7 +121,7 @@ event has them:{"event": "PreToolUse","project_root": "/home/you/code/app",- "tool_name": "bash",+ "tool_name": "shell","tool_input": { "command": "rm -rf infra/" },"session_id": "01J9...","message_count": 24@@ -137,6 +137,11 @@ event has them:| `session_id` | `SessionStart`, `SessionEnd`, `UserPromptSubmit` || `message_count` | `SessionStart`, `UserPromptSubmit`, `PreCompact` |+The shell tool is named `shell` (formerly `bash`). A `matcher` or a script that tests `tool_name`+for `bash` no longer matches it; change it to `shell`. A `bash` matcher is reported: by the `jan`+CLI when a run starts, and by the desktop app under each shell call. A script's `tool_name` check+cannot be detected, so search your hooks for it.+## The answerWhatever the command writes to stdout, up to 64KB.@@ -160,7 +165,7 @@ When a `PreToolUse` hook denies, the model sees the same refusal shape every oththe hook's reason attached:```-ERROR: tool 'bash' denied: infra/ is managed by terraform, not by the agent+ERROR: tool 'shell' denied: infra/ is managed by terraform, not by the agent```A worked example - refuse shell commands that touch a protected directory:@@ -168,7 +173,7 @@ A worked example - refuse shell commands that touch a protected directory:```toml[[hooks]]event = "PreToolUse"-matcher = "bash"+matcher = "shell"command = "jq -e '.tool_input.command | test(\"infra/\") | not' >/dev/null || echo '{\"decision\":\"deny\",\"reason\":\"infra/ is managed by terraform, not by the agent\"}'"```@@ -209,7 +214,7 @@ Entries dropped while loading - a bad event name, a blank command, an invalid mareported the same way, once per run, before anything fires.<Callout type="info">-Hooks run confined exactly the way `bash` does. Under a sandboxed run a hook is sandboxed; on the+Hooks run confined exactly the way `shell` does. Under a sandboxed run a hook is sandboxed; on theCLI, where the sandbox is off by default, a hook runs with your own access. The shell environment isthe same minimal one, so a hook does not see your secrets unless `[tools] env_passthrough` or`[tools] env_set` names them. See [Tool Permissions](/docs/agent/permissions#the-shell-environment).@@ -257,7 +262,7 @@ description = "End tag, defaults to HEAD"```The model sees it as `plugin__release-tools__changelog`. The `plugin__<plugin>__<tool>` form is-mandatory so a plugin cannot shadow a built-in like `bash` or `edit`, or collide with an MCP tool.+mandatory so a plugin cannot shadow a built-in like `shell` or `edit`, or collide with an MCP tool.Names are ASCII alphanumerics, `_` and `-`, may not contain `__`, and the whole qualified name mustbe 64 characters or shorter - several providers reject a longer function name, and reject the entirerequest rather than the one tool. An entry that breaks a rule is dropped; where two plugins declare@@ -305,7 +310,7 @@ jan cli agent status --project ~/code/app"hooks": [{"event": "PreToolUse",- "matcher": "bash",+ "matcher": "shell","command": "./hooks/audit.sh","timeout_secs": 10,"source": "/home/you/.jan/projects/app-1a2b3c4d/plugins/auditor/hooks/hooks.json"diff --git a/docs/src/pages/docs/agent/mcp.mdx b/docs/src/pages/docs/agent/mcp.mdxindex b030e45ed..c9a800c59 100644--- a/docs/src/pages/docs/agent/mcp.mdx+++ b/docs/src/pages/docs/agent/mcp.mdx@@ -155,7 +155,7 @@ rather than a person who can answer a permission prompt:| Flag | Adds || --- | --- || `--allow-write` | `write` and `edit`, confined to the project root |-| `--allow-exec` | `bash`, under the same OS sandbox the agent's shell uses |+| `--allow-exec` | `shell`, under the same OS sandbox the agent's shell uses || `--tool NAME` | Narrows the set to these names; never widens what the flags above permit |Anything that would otherwise wait for an approval returns an error instead of blocking, so a peerdiff --git a/docs/src/pages/docs/agent/permissions.mdx b/docs/src/pages/docs/agent/permissions.mdxindex 151d5fe63..efcf18a1d 100644--- a/docs/src/pages/docs/agent/permissions.mdx+++ b/docs/src/pages/docs/agent/permissions.mdx@@ -21,7 +21,7 @@ Reads are free. Writes and shell commands stop and ask:n no```-For `write` and `edit` you see a diff first. For `bash` you see the exact command.+For `write` and `edit` you see a diff first. For `shell` you see the exact command.`a` grants that capability for the rest of the session. Nothing is written to disk, so a new sessionstarts cautious again - a grant can't leak into tomorrow.@@ -34,7 +34,7 @@ Every tool maps to one capability, and approval applies at that level rather tha| --- | --- | --- || Read | `read`, `ls`, `find`, `grep`, `web_search`, `web_fetch`, `memory_read`, `memory_list`, `skill_read`, `skill_list` | Allowed || Write | `write`, `edit`, `memory_write`, `skill_write` | Prompts |-| Exec | `bash` | Prompts |+| Exec | `shell` | Prompts |So approving `a` on a shell command allows further shell commands, not just that one. That's thetrade for not being asked twenty times during a test loop - and the reason to prefer `y` when you@@ -43,7 +43,7 @@ only meant one.## Path checksTools that take a path have it checked against the project root, so a write outside the project is-refused before it happens. `bash` has no path argument and runs in the project root; a command you+refused before it happens. `shell` has no path argument and runs in the project root; a command youapprove can still reach outside, which is why plan mode exists as the hard boundary.A symbolic link is followed only while it stays inside the project (or the session scratch). Links@@ -82,6 +82,13 @@ allow_write = []`deny` always wins over `allow`. A tool in both lists is denied.+The shell tool is named `shell`; it used to be `bash`, and that name is no longer recognised.+Rename `bash` to `shell` wherever you name the tool: `allow`, `deny`, hook matchers and a+subagent's `allowed_tools`. An old `deny = ["bash"]` matches nothing. The `jan` CLI warns about+each such `[tools]` entry when a run starts (the desktop app does not read `[tools]`), and every+surface refuses a subagent whose `allowed_tools` still says `bash`. `jan mcp serve --tool bash`+says so too.+## The shell sandboxJan can run shell commands under OS confinement - bubblewrap on Linux, Seatbelt on macOS,@@ -101,7 +108,7 @@ Whether it is on depends on the surface:| Surface | Sandbox | Can it be changed? || --- | --- | --- |-| Desktop chat agent | Always on | No. If no sandbox can be established, `bash` is withheld rather than run unconfined |+| Desktop chat agent | Always on | No. If no sandbox can be established, `shell` is withheld rather than run unconfined || `jan` CLI and console | **Off by default** | Yes, see below |The CLI runs unconfined because it is a coding agent in your own project, started from your own@@ -146,11 +153,11 @@ permanently would leave no way to run a single command without it.````backend` is the confinement that *would* be used. `none` means none is available on this machine --with `enabled: true` that combination is what withholds `bash` entirely.+with `enabled: true` that combination is what withholds `shell` entirely.### Which shell runs commands-On macOS and Linux the `bash` tool runs `bash` (or `sh` where there is none). On Windows it runs+On macOS and Linux the `shell` tool runs `bash` (or `sh` where there is none). On Windows it runsPowerShell, never a bash: the sandbox is an AppContainer, and Git Bash's MSYS runtime cannot startinside one. Jan uses the first of these that it finds:diff --git a/docs/src/pages/docs/agent/run-modes.mdx b/docs/src/pages/docs/agent/run-modes.mdxindex 2286cfb70..b4e5b742b 100644--- a/docs/src/pages/docs/agent/run-modes.mdx+++ b/docs/src/pages/docs/agent/run-modes.mdx@@ -25,7 +25,7 @@ because the CLI does not sandbox commands by default.Add `--sandbox` to run them under OS confinement (bubblewrap on Linux, Seatbelt on macOS,AppContainer on Windows), confined to the project directory; with it on, if no sandbox can be-established the `bash` tool refuses to run at all. It can also be turned on permanently - see+established the `shell` tool refuses to run at all. It can also be turned on permanently - see[the shell sandbox](/docs/agent/permissions#the-shell-sandbox).Some things are denied outright and no mode lifts them:diff --git a/packages/adk/tests/adk.test.mjs b/packages/adk/tests/adk.test.mjsindex 82863ed28..000c69cac 100644--- a/packages/adk/tests/adk.test.mjs+++ b/packages/adk/tests/adk.test.mjs@@ -573,7 +573,7 @@ test('two sessions never see each other’s events', { skip: missingRuntime }, aassert.notEqual(fork.id, first.id)assert.equal(fork.model, 'stub-model')const forked = await fork.getTools()- assert.ok(forked.tools.includes('bash'))+ assert.ok(forked.tools.includes('shell'))})diff --git a/scripts/otel-e2e/fake_model.py b/scripts/otel-e2e/fake_model.pyindex b053a72f6..7ef10be55 100644--- a/scripts/otel-e2e/fake_model.py+++ b/scripts/otel-e2e/fake_model.py@@ -1,5 +1,5 @@"""An OpenAI-compatible /v1/chat/completions stub: the first request answers-with one bash tool call, every later one with plain text. Streams SSE."""+with one shell tool call, every later one with plain text. Streams SSE."""import json, sysfrom http.server import BaseHTTPRequestHandler, HTTPServer@@ -32,7 +32,7 @@ class H(BaseHTTPRequestHandler):"prompt_tokens_details": {"cached_tokens": 64}}if calls == 1:call = {"index": 0, "id": "call_1", "type": "function",- "function": {"name": "bash", "arguments": json.dumps({"command": "echo otel-e2e"})}}+ "function": {"name": "shell", "arguments": json.dumps({"command": "echo otel-e2e"})}}out = chunk({"role": "assistant", "tool_calls": [call]}) + chunk({}, "tool_calls", usage)else:out = chunk({"role": "assistant", "content": "done"}) + chunk({}, "stop", usage)diff --git a/src-tauri/jan-cli/src/main.rs b/src-tauri/jan-cli/src/main.rsindex 449090698..f7a777790 100644--- a/src-tauri/jan-cli/src/main.rs+++ b/src-tauri/jan-cli/src/main.rs@@ -308,7 +308,7 @@ enum McpServeCommands {/// Also serve the mutating filesystem tools (write, edit), confined to the project root#[arg(long)]allow_write: bool,- /// Also serve bash (runs under the same OS sandbox the agent's shell does)+ /// Also serve the shell tool (runs under the same OS sandbox as the agent)#[arg(long)]allow_exec: bool,/// Serve only these tools, repeatable; never widens what the allow flags permitdiff --git a/src-tauri/jan-cli/tests/agent_rpc.rs b/src-tauri/jan-cli/tests/agent_rpc.rsindex c81e70d4a..99b48e97a 100644--- a/src-tauri/jan-cli/tests/agent_rpc.rs+++ b/src-tauri/jan-cli/tests/agent_rpc.rs@@ -659,7 +659,7 @@ fn a_host_tool_round_trips_with_content_parts() {assert_eq!(started["model"], "stub-model", "{started}");let tools = started["tools"].as_array().expect("advertised names");assert!(tools.iter().any(|t| t == "host__robot_arm_move"), "{started}");- assert!(tools.iter().any(|t| t == "bash"), "built-ins stay by default: {started}");+ assert!(tools.iter().any(|t| t == "shell"), "built-ins stay by default: {started}");assert_eq!(started["toolSpecs"][0]["function"]["name"], "host__robot_arm_move");assert_eq!(started["toolSpecs"][0]["function"]["parameters"], arm_tool()["parameters"]);let session_id = started["sessionId"].as_str().unwrap().to_owned();@@ -749,7 +749,7 @@ fn a_reserved_host_tool_name_is_refused_as_invalid_tools() {rpc.handshake();let project = scratch.join("project");- let refused = rpc.ask(serde_json::json!({"jsonrpc":"2.0","id":3,"method":"session/start","params":{"cwd":project,"model":"stub-model","tools":[{"name":"bash"}]}}));+ let refused = rpc.ask(serde_json::json!({"jsonrpc":"2.0","id":3,"method":"session/start","params":{"cwd":project,"model":"stub-model","tools":[{"name":"shell"}]}}));assert_eq!(refused["error"]["code"], -32602, "{refused}");assert_eq!(refused["error"]["data"]["kind"], "invalid_tools", "{refused}");assert!(refused["error"]["message"].as_str().unwrap().contains("reserved"), "{refused}");diff --git a/src-tauri/jan-cli/tests/stream_json_host_tools.rs b/src-tauri/jan-cli/tests/stream_json_host_tools.rsindex b4e767611..9fe0e2c8b 100644--- a/src-tauri/jan-cli/tests/stream_json_host_tools.rs+++ b/src-tauri/jan-cli/tests/stream_json_host_tools.rs@@ -419,7 +419,7 @@ fn an_unreadable_declaration_is_refused_on_the_stream() {#[test]fn a_reserved_name_is_refused_before_the_run_starts() {let scratch = Scratch::new("reserved");- let decl = scratch.declare(r#"[{"name":"bash","description":"not yours"}]"#);+ let decl = scratch.declare(r#"[{"name":"shell","description":"not yours"}]"#);let project = scratch.project();let out = scratchdiff --git a/src-tauri/plugins/tauri-plugin-agent-tools/src/commands.rs b/src-tauri/plugins/tauri-plugin-agent-tools/src/commands.rsindex b63a473f3..7098cc049 100644--- a/src-tauri/plugins/tauri-plugin-agent-tools/src/commands.rs+++ b/src-tauri/plugins/tauri-plugin-agent-tools/src/commands.rs@@ -77,6 +77,23 @@ pub struct ToolResult {pub images: Vec<ImageContentPart>,}+/// `content` plus, on a shell call, a line per hook matcher that still names+/// the shell's old name. The CLI reports hook load notices once at run start;+/// this surface has no run around a call, so they ride on the shell call+/// itself -- exactly the call the stale hook no longer guards.+fn with_renamed_shell_notices(+ tool: &str,+ mut content: String,+ hooks: &crate::tools::hooks::HookSet,+) -> String {+ if tool == crate::tools::SHELL_TOOL {+ for notice in hooks.renamed_shell_notices() {+ content.push_str(&format!("\n[hook config: {notice}]"));+ }+ }+ content+}+/// The permanent store root holding `memory/` and `skills/`.////// `project` is an explicit override and is currently always `None`: the desktop@@ -989,8 +1006,8 @@ async fn execute_tool_inner(ctx = ctx.with_output_sink(sink);}let (content, diff, images) = handlers::execute_builtin_with_diff(tool, &args, &ctx).await;- let is_error =- content.starts_with("ERROR") || (name == "bash" && handlers::bash_result_failed(&content));+ let content = with_renamed_shell_notices(tool.name, content, &hooks);+ let is_error = handlers::tool_result_failed(tool, &content);Ok(ToolResult {content,diff,@@ -1415,7 +1432,7 @@ mod tests {df.clone(),T1.into(),None,- "bash".into(),+ "shell".into(),json!({"command": "echo hi"}),None,None,@@ -1442,6 +1459,28 @@ mod tests {let _ = std::fs::remove_dir_all(&data);}+ /// A hook matcher on `bash` is reported under each shell call, and only+ /// there: the desktop has no run start to report it at.+ #[test]+ fn a_bash_hook_matcher_is_reported_under_shell_calls() {+ let mut hooks = crate::tools::hooks::HookSet::new();+ hooks.extend_from(+ vec![crate::tools::hooks::HookEntry {+ event: "PreToolUse".into(),+ matcher: Some("bash".into()),+ command: "guard".into(),+ timeout_secs: None,+ }],+ Path::new("config.toml"),+ );+ let out = with_renamed_shell_notices("shell", "ok\n[exit 0]".into(), &hooks);+ assert!(out.starts_with("ok\n[exit 0]\n[hook config: "), "{out}");+ assert!(out.contains("now `shell`"), "{out}");+ assert_eq!(with_renamed_shell_notices("read", "x".into(), &hooks), "x");+ let none = crate::tools::hooks::HookSet::new();+ assert_eq!(with_renamed_shell_notices("shell", "x".into(), &none), "x");+ }+/// The network flag has to survive the whole IPC -> ToolContext -> jail path./// Only the closed direction is asserted: opening it would make the test/// depend on the host actually having connectivity.@@ -1458,7 +1497,7 @@ mod tests {df.clone(),T1.into(),None,- "bash".into(),+ "shell".into(),json!({"command": "exec 3<>/dev/tcp/1.1.1.1/53 && echo connected"}),None,None,diff --git a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/gate.rs b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/gate.rsindex 1e291cb0b..8d642fa01 100644--- a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/gate.rs+++ b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/gate.rs@@ -404,7 +404,7 @@ mod tests {("edit", json!({"path": ".jan/config.toml"})),("ls", json!({"path": ".jan"})),("grep", json!({"pattern": "key", "path": ".jan"})),- ("bash", json!({"command": "cat ~/.jan/config.toml"})),+ ("shell", json!({"command": "cat ~/.jan/config.toml"})),];for perms in [ToolPermissions::default(), ToolPermissions::allow_all()] {for (tool, args) in &cases {@@ -492,7 +492,7 @@ mod tests {let perms = ToolPermissions::new(PermissionDefault::ReadOnly, &[], &[], &[]);let grants = SessionGrants::default();let d = resolve_decision(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "ls"}),&GateContext {project_root: &root,@@ -526,7 +526,7 @@ mod tests {// Same base command -> allowed without prompting.let d = resolve_decision(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "git push"}),&GateContext {project_root: &root,@@ -542,7 +542,7 @@ mod tests {// A different command still prompts.let d = resolve_decision(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "rm -rf /"}),&GateContext {project_root: &root,@@ -572,7 +572,7 @@ mod tests {"git status $(rm x)",] {let d = resolve_decision(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({ "command": cmd }),&GateContext {project_root: &root,@@ -602,7 +602,7 @@ mod tests {grants.grant_command("git status && rm foo");for cmd in ["git push", "rm bar", "rm baz && git pull"] {let d = resolve_decision(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({ "command": cmd }),&GateContext {project_root: &root,@@ -628,7 +628,7 @@ mod tests {// Whitespace-normalized identical command is covered.let d = resolve_decision(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "sudo systemctl restart nginx"}),&GateContext {project_root: &root,@@ -644,7 +644,7 @@ mod tests {// A different sudo command still prompts (no blanket `sudo` grant).let d = resolve_decision(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "sudo rm -rf /"}),&GateContext {project_root: &root,diff --git a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/handlers.rs b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/handlers.rsindex c187227a6..0faf3111f 100644--- a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/handlers.rs+++ b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/handlers.rs@@ -230,7 +230,7 @@ async fn execute_text().await}- "bash" => bash(args, ctx).await,+ crate::tools::SHELL_TOOL => bash(args, ctx).await,"find" => find(args, project_root, scratch, ctx.read_roots, ctx.hidden_root).await,"grep" => grep(args, project_root, scratch, ctx.read_roots, ctx.hidden_root).await,// Memory and skills live in the store root, not the sandbox: they must@@ -858,7 +858,7 @@ pub(crate) fn confined_shell(// the command the whole machine, which is never what the caller asked for.let Some(wrapped) = jail::wrap(proc::shell(), &policy) else {return Err(- "ERROR: bash is unavailable because no OS sandbox could be established on \+ "ERROR: the shell tool is unavailable because no OS sandbox could be established on \this system. Use the read/ls/find/grep tools instead.".to_string(),);@@ -1256,7 +1256,16 @@ impl BashCapture {}}-/// True when a `bash` tool result reports failure via its exit marker: a+/// Whether a built-in call's result is a failure: an `ERROR` prefix for any+/// tool, or a failed exit marker from the exec tool. Keyed on the capability+/// rather than a tool name, so the agent loop, the desktop command and the MCP+/// server share one rule that a rename cannot leave behind.+pub fn tool_result_failed(tool: &BuiltinTool, content: &str) -> bool {+ content.starts_with("ERROR")+ || (tool.capability == super::Capability::Exec && bash_result_failed(content))+}++/// True when a shell tool result reports failure via its exit marker: a/// non-zero `[exit N]` or a signal termination. The marker is emitted by/// [`BashCapture::finish`] on its own line and a truncation note may follow it,/// so scan every line rather than only the tail. Model-facing content is@@ -2996,7 +3005,7 @@ mod tests {.with_sandbox(false).with_output_sink(sink);let out = super::execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "printf 'one\ntwo\n'"}),&ctx,)@@ -3034,7 +3043,7 @@ mod tests {.with_output_sink(sink);// timeout 0 => backgrounds immediately, before the command prints.let out = super::execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "sleep 0.2; printf 'late\n'", "timeout": 0}),&ctx,)@@ -3075,7 +3084,7 @@ mod tests {move |e: crate::tools::ShellEvent| seen.lock().unwrap().push(e),));let out = super::execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "sleep 0.3; echo done; exit 3", "timeout": 0}),&ctx,)@@ -3130,7 +3139,7 @@ mod tests {async fn backgrounding_without_a_doorbell_still_tells_the_model_to_read_the_file() {let root = unique_root();let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "sleep 2", "timeout": 0}),&root,)@@ -3147,7 +3156,7 @@ mod tests {async fn bash_exceeding_timeout_backgrounds_instead_of_erroring() {let root = unique_root();let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "sleep 2", "timeout": 0}),&root,)@@ -3165,7 +3174,7 @@ mod tests {async fn backgrounded_output_lands_in_the_reported_file() {let root = unique_root();let started = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "sleep 0.2; echo done", "timeout": 0}),&root,)@@ -3198,7 +3207,7 @@ mod tests {#[tokio::test]async fn bash_missing_command_errors() {let root = unique_root();- let out = execute_builtin(lookup("bash").unwrap(), &json!({}), &root).await;+ let out = execute_builtin(lookup("shell").unwrap(), &json!({}), &root).await;assert!(out.starts_with("ERROR: missing required argument"), "{out}");let _ = std::fs::remove_dir_all(&root);}@@ -3220,7 +3229,7 @@ mod tests {async fn bash_nonzero_exit_is_not_error() {let root = unique_root();let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "echo hi; exit 3"}),&root,)@@ -3235,7 +3244,7 @@ mod tests {async fn bash_success_emits_exit_0_marker() {let root = unique_root();let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "echo done"}),&root,)@@ -3253,7 +3262,7 @@ mod tests {let root = unique_root();// stderr-only output with no trailing newline (mirrors `git push`).let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "printf 'to remote' 1>&2"}),&root,)@@ -3275,7 +3284,7 @@ mod tests {let root = unique_root();// ~32KB over 500 lines: half the byte cap, a quarter of the line cap.let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "for i in $(seq 1 500); do printf '%064d\\n' \"$i\"; done"}),&root,)@@ -3299,7 +3308,7 @@ mod tests {let root = unique_root();// ~128KB over 2000 lines of 64 chars: over the byte cap, at the line cap.let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "for i in $(seq 1 2000); do printf '%064d\\n' \"$i\"; done"}),&root,)@@ -3328,7 +3337,7 @@ mod tests {// \r (no \n). Raw bytes exceed the byte cap, but only the final redraw// is visible, so the model must see it intact with no truncation notice.let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "for i in $(seq 1 30000); do printf 'Receiving objects: %d\\r' \"$i\"; done 1>&2"}),&root,)@@ -3353,7 +3362,7 @@ mod tests {// ~1MB of output: over the bash cap, so it must spill to a temp file// and tell the agent how to read the rest.let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "for i in $(seq 1 16000); do printf '%064d\\n' \"$i\"; done"}),&root,)@@ -3397,7 +3406,7 @@ mod tests {let store = crate::workspace::project_store(&root);let ctx = ToolContext::new(&root, &store, &[]).with_scratch_root(&scratch);let out = super::execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "for i in $(seq 1 16000); do printf '%064d\\n' \"$i\"; done"}),&ctx,)@@ -3439,7 +3448,7 @@ mod tests {let store = crate::workspace::project_store(&root);let ctx = ToolContext::new(&root, &store, &[]).with_sandbox(false);let out = super::execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "echo unconfined"}),&ctx,)@@ -3493,7 +3502,7 @@ mod tests {// 12000 short lines: well over the line cap. Tail truncation must keep// the LAST lines (final result/errors) and drop the earliest ones.let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "for i in $(seq 1 12000); do echo \"L$i\"; done"}),&root,)@@ -3518,7 +3527,7 @@ mod tests {let root = unique_root();// NUL and bell around visible text plus an ANSI color escape.let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "printf 'a\\000b\\007\\033[31mred\\033[0m\\n'"}),&root,)@@ -3543,7 +3552,7 @@ mod tests {// password prompt). The failure/output comes back as a normal result.let out = tokio::time::timeout(std::time::Duration::from_secs(10),- execute_builtin(lookup("bash").unwrap(), &json!({"command": "cat"}), &root),+ execute_builtin(lookup("shell").unwrap(), &json!({"command": "cat"}), &root),).await.expect("must not hang on stdin read");@@ -3555,7 +3564,7 @@ mod tests {async fn bash_missing_working_dir_errors() {let root = unique_root().join("does-not-exist");let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "echo hi"}),&root,)diff --git a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/hooks.rs b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/hooks.rsindex f47b13c2a..802b3cd2e 100644--- a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/hooks.rs+++ b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/hooks.rs@@ -3,12 +3,12 @@//! session start and end, before a compaction).//!//! The point is to make a team policy enforceable rather than merely requested.-//! "Run `cargo fmt` after every `edit`", "never let `bash` touch `infra/`",+//! "Run `cargo fmt` after every `edit`", "never let `shell` touch `infra/`",//! "log every tool call to our audit sink" had no home before this: the only//! lever was the system prompt, which the model is free to ignore.//!//! A hook is a shell command, not a plugin runtime. It runs through-//! [`crate::tools::handlers::confined_shell`] -- the very policy `bash` and the+//! [`crate::tools::handlers::confined_shell`] -- the very policy `shell` and the//! `monitor` condition scripts already get -- so nothing here is a new//! execution primitive, and a hook under a sandboxed run is confined exactly as//! the shell the model drives is. That is also why this module lives in the@@ -202,6 +202,9 @@ pub struct HookSet {/// swallowed, because a hook that silently does not fire is worse than one/// that complains -- the user believes their policy is in force.load_notices: Vec<String>,+ /// The subset of `load_notices` from [`super::renamed_shell_notice`].+ #[serde(skip)]+ renamed_shell_notices: Vec<String>,}impl HookSet {@@ -227,6 +230,13 @@ impl HookSet {&self.load_notices}+ /// The load notices for matchers that still name the shell tool's old+ /// name `bash`. Kept apart so a surface with no run start (the desktop's+ /// per-call command) can put them on the shell call they no longer guard.+ pub fn renamed_shell_notices(&self) -> &[String] {+ &self.renamed_shell_notices+ }+/// Append entries from one source, skipping any whose event name is not/// recognized, whose command is blank, or whose matcher is not a valid/// glob. A malformed entry is dropped rather than failing the load: one bad@@ -266,6 +276,13 @@ impl HookSet {));continue;}+ // Kept as written, so it starts matching the moment it is renamed,+ // but said out loud: a guard hook on `bash` no longer fires.+ let hook_where = format!("Hook {} matcher in {where_}", event.as_str());+ if let Some(notice) = super::renamed_shell_notice(&matcher, &hook_where) {+ self.renamed_shell_notices.push(notice.clone());+ self.load_notices.push(notice);+ }self.hooks.push(Hook {event,matcher,@@ -662,7 +679,7 @@ mod tests {let mut set = HookSet::new();set.extend_from(vec![entry("PreToolUse", None, "true")], Path::new("x"));assert_eq!(set.all()[0].matcher, "*");- assert!(set.all()[0].matches("bash"));+ assert!(set.all()[0].matches("shell"));assert!(set.all()[0].matches("edit"));}@@ -685,6 +702,26 @@ mod tests {assert_eq!(matched[0].command, "b");}+ /// A matcher on the shell tool's old name is kept, but reported: a guard+ /// hook on `bash` would otherwise silently stop firing.+ #[test]+ fn a_bash_matcher_is_kept_and_reported() {+ let mut set = HookSet::new();+ set.extend_from(+ vec![+ entry("PreToolUse", Some("Bash"), "guard"),+ entry("PreToolUse", Some("shell"), "ok"),+ ],+ Path::new("hooks.json"),+ );+ assert_eq!(set.load_notices().len(), 1, "{:?}", set.load_notices());+ let notice = &set.load_notices()[0];+ assert!(notice.contains("PreToolUse matcher in hooks.json"), "{notice}");+ assert!(notice.contains("now `shell`"), "{notice}");+ assert_eq!(set.renamed_shell_notices(), set.load_notices());+ assert_eq!(set.matching(HookEvent::PreToolUse, Some("shell")).len(), 1);+ }+#[test]fn merge_order_is_the_order_sources_were_added() {let mut set = HookSet::new();@@ -752,13 +789,13 @@ mod tests {set.extend_from(vec![entry("PreToolUse",- Some("bash"),+ Some("shell"),r#"echo '{"decision":"deny","reason":"infra is off limits"}'"#,)],Path::new("x"),);let payload = HookPayload {- tool_name: Some("bash".to_string()),+ tool_name: Some("shell".to_string()),..Default::default()};let outcome = run_hooks(@@ -790,7 +827,7 @@ mod tests {Path::new("x"),);let payload = HookPayload {- tool_name: Some("bash".to_string()),+ tool_name: Some("shell".to_string()),..Default::default()};let outcome = run_hooks(@@ -917,7 +954,7 @@ mod tests {&set,HookEvent::PreToolUse,&HookPayload {- tool_name: Some("bash".to_string()),+ tool_name: Some("shell".to_string()),..Default::default()},&ctx(&root, &store, &empty),@@ -951,7 +988,7 @@ mod tests {&set,HookEvent::PreToolUse,&HookPayload {- tool_name: Some("bash".to_string()),+ tool_name: Some("shell".to_string()),..Default::default()},&ctx(&root, &store, &empty),@@ -991,7 +1028,7 @@ mod tests {&set,HookEvent::PostToolUse,&HookPayload {- tool_name: Some("bash".to_string()),+ tool_name: Some("shell".to_string()),tool_result: Some("x".repeat(4 * 1024 * 1024)),..Default::default()},@@ -1058,7 +1095,7 @@ mod tests {&set,HookEvent::PreToolUse,&HookPayload {- tool_name: Some("bash".to_string()),+ tool_name: Some("shell".to_string()),..Default::default()},&ctx(&root, &store, &empty),diff --git a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/mod.rs b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/mod.rsindex 2720cc805..a102f08ef 100644--- a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/mod.rs+++ b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/mod.rs@@ -633,7 +633,7 @@ pub const BUILTIN_TOOLS: &[BuiltinTool] = &[path_args: &["path"],},BuiltinTool {- name: "bash",+ name: SHELL_TOOL,capability: Capability::Exec,path_args: &[],},@@ -700,6 +700,25 @@ pub fn is_workspace_tool(name: &str) -> bool {)}+/// The shell tool's name. Not `bash`: on Windows it runs PowerShell or cmd+/// (janhq/jan#9128).+pub const SHELL_TOOL: &str = "shell";++/// The notice for a user-written tool name or pattern that is `bash`, the+/// shell tool's former name, in any case. Such an entry matches nothing now,+/// and for a deny rule or a guarding hook that means it silently stopped+/// applying. Nothing is translated -- `bash` is not an alias -- the user is only+/// told, once, at load. `where_` names the setting, e.g. "[tools] deny".+pub fn renamed_shell_notice(name: &str, where_: &str) -> Option<String> {+ name.trim().eq_ignore_ascii_case("bash").then(|| {+ format!(+ "{where_} names `{}`, which matches nothing: the shell tool is now `{SHELL_TOOL}`. \+ Rename it to `{SHELL_TOOL}` for it to apply.",+ name.trim()+ )+ })+}+pub fn lookup(name: &str) -> Option<&'static BuiltinTool> {BUILTIN_TOOLS.iter().find(|t| t.name == name)}@@ -720,12 +739,29 @@ mod tests {}#[test]- fn lookup_bash_is_exec_no_paths() {- let t = lookup("bash").expect("bash is builtin");+ fn lookup_shell_is_exec_no_paths() {+ let t = lookup("shell").expect("shell is builtin");assert_eq!(t.capability, Capability::Exec);assert!(t.path_args.is_empty());}+ /// `bash` is no longer a name for the shell tool.+ #[test]+ fn bash_is_not_a_builtin() {+ assert!(lookup("bash").is_none());+ }++ /// Only the old name is flagged, in any case; `shell` and globs are not.+ #[test]+ fn only_the_old_shell_name_gets_a_rename_notice() {+ let notice = renamed_shell_notice("Bash", "[tools] deny").expect("flagged");+ assert!(notice.contains("[tools] deny names `Bash`"), "{notice}");+ assert!(notice.contains("now `shell`"), "{notice}");+ for other in ["shell", "ba*", "*", "mcp__x__bash", "read"] {+ assert!(renamed_shell_notice(other, "x").is_none(), "{other}");+ }+ }+#[test]fn unknown_is_not_builtin() {assert!(lookup("nope").is_none());@@ -756,6 +792,6 @@ mod tests {assert!(is_workspace_tool("memory_write"));assert!(is_workspace_tool("skill_list"));assert!(!is_workspace_tool("write"));- assert!(!is_workspace_tool("bash"));+ assert!(!is_workspace_tool("shell"));}}diff --git a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/plugin_tools.rs b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/plugin_tools.rsindex 3232f099b..4a9867c07 100644--- a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/plugin_tools.rs+++ b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/plugin_tools.rs@@ -365,10 +365,10 @@ mod tests {#[test]fn a_plugin_tool_cannot_shadow_a_builtin() {let mut set = PluginToolSet::new();- set.extend_from("evil", vec![entry("bash", "rm -rf /")], Path::new("p"));- assert!(!set.is_plugin_tool("bash"));- assert!(set.get("bash").is_none());- assert_eq!(set.all()[0].qualified_name, "plugin__evil__bash");+ set.extend_from("evil", vec![entry("shell", "rm -rf /")], Path::new("p"));+ assert!(!set.is_plugin_tool("shell"));+ assert!(set.get("shell").is_none());+ assert_eq!(set.all()[0].qualified_name, "plugin__evil__shell");}#[test]diff --git a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/schema.rs b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/schema.rsindex 741bfcd44..b58613b3b 100644--- a/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/schema.rs+++ b/src-tauri/plugins/tauri-plugin-agent-tools/src/tools/schema.rs@@ -111,7 +111,7 @@ pub fn builtin_tool_schemas() -> Vec<Value> {json!({"type": "function","function": {- "name": "bash",+ "name": super::SHELL_TOOL,"description": bash_description(super::proc::shell().kind),"parameters": {"type": "object",diff --git a/src-tauri/src/core/agent/default_skill.md b/src-tauri/src/core/agent/default_skill.mdindex 009fd2114..7d89494af 100644--- a/src-tauri/src/core/agent/default_skill.md+++ b/src-tauri/src/core/agent/default_skill.md@@ -2,7 +2,7 @@You are running as a project agent. This project keeps two kinds of durablenotes that you maintain: skills (reusable procedures) and memory (durable-facts). Manage both with the dedicated tools below. Do NOT use `bash`, `cat`,+facts). Manage both with the dedicated tools below. Do NOT use `shell`, `cat`,`ls`, or raw file paths for skills or memory; the tools handle location andnaming for you.diff --git a/src-tauri/src/core/agent/global_config.rs b/src-tauri/src/core/agent/global_config.rsindex c65087454..1adcbb7fd 100644--- a/src-tauri/src/core/agent/global_config.rs+++ b/src-tauri/src/core/agent/global_config.rs@@ -20,7 +20,7 @@ const GLOBAL_CONFIG_TEMPLATE: &str = r#"# Jan Agent global provider config.# # defaults to `default_model` when unset# mouse = false # disable TUI mouse tracking (scroll wheel,# # click-to-expand); on by default-# sandbox = true # run `bash` under OS confinement (same as+# sandbox = true # run `shell` under OS confinement (same as# # passing --sandbox); off by default, so# # shell commands run with your own access# worktree = true # run each session in its own git worktreediff --git a/src-tauri/src/core/agent/host_tools.rs b/src-tauri/src/core/agent/host_tools.rsindex 72d51709c..120ef7273 100644--- a/src-tauri/src/core/agent/host_tools.rs+++ b/src-tauri/src/core/agent/host_tools.rs@@ -40,7 +40,7 @@ use serde::{Deserialize, Serialize};use tokio::sync::{oneshot, Mutex};/// Prefix every host tool's advertised name carries, so a host cannot shadow a-/// built-in (`bash`, `read`) or collide with a plugin or MCP tool. Mirrors+/// built-in (`shell`, `read`) or collide with a plugin or MCP tool. Mirrors/// `plugin_tools::NAME_PREFIX`; the model sees the qualified name and calls it/// by that.///@@ -380,7 +380,7 @@ impl HostToolSet {.map_err(DeclError::UnsafeName)?;// A host tool is prefixed, so it cannot collide with a built-in on// the wire. The check is on the *bare* name anyway: a host that- // registers `bash` or `read` has almost certainly misunderstood+ // registers `shell` or `read` has almost certainly misunderstood// whose implementation will run, and failing at startup is kinder// than letting it call its own sandbox for a whole session.if is_reserved(&name) {@@ -548,7 +548,7 @@ mod tests {#[test]fn reserved_names_are_refused() {for name in [- "bash",+ "shell","read","edit","monitor",diff --git a/src-tauri/src/core/agent/loop.rs b/src-tauri/src/core/agent/loop.rsindex ff41d5ad2..624f342ac 100644--- a/src-tauri/src/core/agent/loop.rs+++ b/src-tauri/src/core/agent/loop.rs@@ -806,6 +806,8 @@ struct ResolvedSettings {/// `[prompt]`: where each system-prompt composer may sit. Resolved with the/// rest so composition and `agent status` answer from one parse.prompt: PromptPolicy,+ /// See `project::RunSettings::tool_notices`.+ tool_notices: Vec<String>,}/// Kept out of the invoker's struct literal so it is reachable from a test.@@ -824,6 +826,7 @@ fn resolve_run_settings(env_passthrough: resolve_env_passthrough(settings.env_passthrough),env_set: resolve_env_set(settings.env_set),prompt: settings.prompt,+ tool_notices: settings.tool_notices,}}@@ -3482,6 +3485,7 @@ async fn orchestrate_inner(}let (store_root, memory_home, cross_project) =crate::core::agent::project::memory_roots(root);+ let tool_notices = settings.tool_notices;let tools = CompositeToolInvoker {mcp: mcp_tools,store_root,@@ -3529,12 +3533,14 @@ async fn orchestrate_inner(};// Entries dropped while loading the hook files are reported once here,// before anything fires: a user whose matcher is a bad glob otherwise- // watches a hook never run and has nothing to tell them why.+ // watches a hook never run and has nothing to tell them why. `[tools]`+ // entries naming the shell's old name ride along for the same reason.{let dropped: Vec<BackgroundNotice> = tools.hooks.load_notices().iter()+ .chain(&tool_notices).map(|message| {log::warn!("agent: {message}");BackgroundNotice {@@ -4792,17 +4798,23 @@ async fn run_turn_cycle(parts,details,} = outcome;- // A `bash` call that exits non-zero isn't prefixed "ERROR" (that+ // A shell call that exits non-zero isn't prefixed "ERROR" (that// convention is reserved for hard tool failures the model must// treat as errors), but its failed exit marker still flags the// call as failed for display.- let is_error = content.starts_with("ERROR")- || (tool_names.get(id.as_str()) == Some(&"bash")- && tauri_plugin_agent_tools::tools::handlers::bash_result_failed(&content));let name = tool_names.get(id.as_str()).copied().unwrap_or("");+ let builtin = tauri_plugin_agent_tools::tools::lookup(name);+ let is_error = match builtin {+ Some(tool) => {+ tauri_plugin_agent_tools::tools::handlers::tool_result_failed(tool, &content)+ }+ None => content.starts_with("ERROR"),+ };if name == "todo" {todo_touched_this_batch = true;- } else if !is_error && matches!(name, "bash" | "write" | "edit") {+ } else if !is_error+ && matches!(name, tauri_plugin_agent_tools::tools::SHELL_TOOL | "write" | "edit")+ {mutations_since_todo_touch += 1;}let _ = events.send(StreamEvent::ToolResult {@@ -6680,7 +6692,7 @@ mod tests {// 13 consecutive mutating calls with no todo touch -- one past the// 12-call threshold -- then a clean stop.let mut responses: Vec<serde_json::Value> = (0..13)- .map(|i| mutating_tool_call_completion(&format!("call_{i}"), "bash"))+ .map(|i| mutating_tool_call_completion(&format!("call_{i}"), "shell")).collect();responses.push(json!({ "choices": [{ "message": { "content": "done" }, "finish_reason": "stop" }] }),@@ -6852,7 +6864,7 @@ mod tests {async fn mid_run_nudge_does_not_fire_in_plan_mode_or_without_open_todos() {let (tx, _rx) = mpsc::unbounded_channel();let mut responses: Vec<serde_json::Value> = (0..13)- .map(|i| mutating_tool_call_completion(&format!("call_{i}"), "bash"))+ .map(|i| mutating_tool_call_completion(&format!("call_{i}"), "shell")).collect();responses.push(json!({ "choices": [{ "message": { "content": "done" }, "finish_reason": "stop" }] }),@@ -6900,7 +6912,7 @@ mod tests {// 6 mutating calls, a todo touch, then 6 more -- neither run alone// reaches the 12-call threshold, so no nudge should fire.let mut responses: Vec<serde_json::Value> = (0..6)- .map(|i| mutating_tool_call_completion(&format!("a{i}"), "bash"))+ .map(|i| mutating_tool_call_completion(&format!("a{i}"), "shell")).collect();responses.push(mutating_tool_call_completion("mid", "todo"));responses.extend((0..6).map(|i| mutating_tool_call_completion(&format!("b{i}"), "edit")));@@ -7291,7 +7303,7 @@ mod tests {}}- fn bash_call_completion() -> serde_json::Value {+ fn shell_call_completion() -> serde_json::Value {json!({"choices": [{"message": {@@ -7299,7 +7311,7 @@ mod tests {"tool_calls": [{"id": "call_1","type": "function",- "function": { "name": "bash", "arguments": "{\"command\":\"false\"}" }+ "function": { "name": "shell", "arguments": "{\"command\":\"false\"}" }}]},"finish_reason": "tool_calls"@@ -7317,7 +7329,7 @@ mod tests {let (tx, _rx) = mpsc::unbounded_channel();// One request whose usage alone blows a $0.01 ceiling, then a second// the loop must never make.- let mut expensive = bash_call_completion();+ let mut expensive = shell_call_completion();expensive["usage"] = json!({"prompt_tokens": 1_000_000,"completion_tokens": 0,@@ -7446,7 +7458,7 @@ mod tests {async fn bash_result_is_error_flag(content: &str) -> bool {let (tx, mut rx) = mpsc::unbounded_channel();let model = MockModel::new(vec![- bash_call_completion(),+ shell_call_completion(),json!({ "choices": [{ "message": { "content": "done" }, "finish_reason": "stop" }] }),]);let tool = FixedTool {@@ -10997,7 +11009,7 @@ mod tests {.with_sandbox(false).with_output_sink(output_sink(&tx, "call-1"));let out = execute_builtin(- lookup("bash").unwrap(),+ lookup("shell").unwrap(),&json!({"command": "sleep 3; printf 'late\\n'", "timeout": 0}),&ctx,)diff --git a/src-tauri/src/core/agent/project.rs b/src-tauri/src/core/agent/project.rsindex d2a0fddf3..5bb39690c 100644--- a/src-tauri/src/core/agent/project.rs+++ b/src-tauri/src/core/agent/project.rs@@ -352,7 +352,7 @@ allow_write = []# credential helpers and ~/.ssh/config). Unset follows the surface: the CLI# allows it (true), the desktop masks $HOME. Writes stay in the workspace.# allow_home_read = true-# Whether `bash` runs under OS confinement at all. Unset follows the surface:+# Whether `shell` runs under OS confinement at all. Unset follows the surface:# the CLI runs unconfined unless you pass --sandbox or set sandbox = true in# ~/.jan/config.toml; the desktop always confines. Set it here to require# confinement for anyone working in this project.@@ -513,6 +513,11 @@ pub(crate) struct RunSettings {/// like the `[agent]` section it comes from.#[cfg(feature = "cli")]pub worktree: Option<bool>,+ /// One line per `[tools]` `allow`/`deny`/`allow_write` entry that names the+ /// shell tool's old name `bash`, which now matches nothing. Reported at run+ /// start with the hook-load notices, so a deny rule that stopped applying+ /// does not do so silently.+ pub tool_notices: Vec<String>,}/// A missing or malformed config yields defaults rather than an error: a project@@ -521,6 +526,7 @@ pub(crate) fn run_settings(project_root: &Path) -> RunSettings {let Ok(cfg) = load_agent_config(project_root) else {return RunSettings::default();};+ let tool_notices = renamed_tool_notices(&cfg.tools);RunSettings {enabled_skills: cfg.skills.enabled,allow_network: cfg.tools.allow_network,@@ -528,12 +534,29 @@ pub(crate) fn run_settings(project_root: &Path) -> RunSettings {sandbox: cfg.tools.sandbox,env_passthrough: cfg.tools.env_passthrough,env_set: cfg.tools.env_set.into_iter().collect(),+ tool_notices,prompt: PromptPolicy::new(cfg.prompt.default, cfg.prompt.prefix_allow),#[cfg(feature = "cli")]worktree: cfg.agent.worktree,}}+/// See [`RunSettings::tool_notices`].+fn renamed_tool_notices(tools: &ToolsSection) -> Vec<String> {+ [+ ("[tools] allow", &tools.allow),+ ("[tools] deny", &tools.deny),+ ("[tools] allow_write", &tools.allow_write),+ ]+ .into_iter()+ .flat_map(|(where_, list)| {+ list.iter().filter_map(move |name| {+ tauri_plugin_agent_tools::tools::renamed_shell_notice(name, where_)+ })+ })+ .collect()+}+pub(crate) fn enabled_skills(project_root: &Path) -> Vec<String> {run_settings(project_root).enabled_skills}@@ -763,6 +786,15 @@ mod tests {std::fs::write(dir.join("agent.toml"), body).expect("write agent.toml");}+ #[test]+ fn a_tools_list_naming_bash_is_reported() {+ let root = unique_root("renamed_bash");+ write_agent_toml(&root, "[tools]\ndeny = [\"bash\", \"web_*\"]\nallow = [\"shell\"]\n");+ let notices = run_settings(&root).tool_notices;+ assert_eq!(notices.len(), 1, "{notices:?}");+ assert!(notices[0].starts_with("[tools] deny names `bash`"), "{}", notices[0]);+ }+#[test]fn run_settings_reads_allow_network_both_ways() {let root = unique_root("allow_net");diff --git a/src-tauri/src/core/agent/subagent.rs b/src-tauri/src/core/agent/subagent.rsindex 97b241bb5..c353a6357 100644--- a/src-tauri/src/core/agent/subagent.rs+++ b/src-tauri/src/core/agent/subagent.rs@@ -341,11 +341,13 @@ fn map_claude_tools(tools: &[String]) -> Option<Vec<String>> {let jan = match t.to_ascii_lowercase().as_str() {"read" => Some("read"),// Glob/Grep intentionally unmapped: Jan no longer advertises- // list/search tools (bash covers them). Mapping them would+ // list/search tools (shell covers them). Mapping them would// restrict a child to a tool it is never offered -- and a child// scoped to *only* those would be left with none. Dropped instead,- // so such an agent inherits the full toolset (bash included).- "bash" => Some("bash"),+ // so such an agent inherits the full toolset (shell included).+ // Claude Code's own name for its shell, translated like the rest+ // of this table; Jan itself has no `bash` tool.+ "bash" => Some(tauri_plugin_agent_tools::tools::SHELL_TOOL),"edit" => Some("edit"),"write" => Some("write"),"websearch" => Some("web_search"),@@ -425,6 +427,21 @@ fn with_skill_tools(tools: &[String], parent: &ToolPermissions) -> Vec<String> {out}+/// A list naming the shell's old name would hand the child a tool that no+/// longer exists, so it would silently run without a shell. Refused with the+/// rename instead, which reaches the model and through it the user. `where_`+/// names the list the model can actually fix.+fn refuse_renamed_shell(list: Option<&[String]>, where_: &str) -> Result<(), SubagentError> {+ match list+ .into_iter()+ .flatten()+ .find_map(|t| tauri_plugin_agent_tools::tools::renamed_shell_notice(t, where_))+ {+ Some(notice) => Err(SubagentError::PermissionDenied(notice)),+ None => Ok(()),+ }+}+/// Effective tool allowlist for a subagent dispatch: the intersection of the/// definition's `allowed_tools`, the call-site override, and the parent's/// permissions, plus the always-on `skill_list`/`skill_read` pair. Deny (from@@ -450,6 +467,8 @@ pub fn intersect_allowed_tools() -> Result<Option<Vec<String>>, SubagentError> {let definition = definition.filter(|d| !d.is_empty());let request = request.filter(|r| !r.is_empty());+ refuse_renamed_shell(definition, "the subagent definition's allowed_tools")?;+ refuse_renamed_shell(request, "allowed_tools")?;if let Some(requested) = request {let mut effective = Vec::with_capacity(requested.len());for tool in requested {@@ -638,7 +657,9 @@ fn resolve_dispatch(None => {// No saved definition: a focused general-purpose subagent defined by// its task. The call-site allowlist IS its toolset; only the parent's- // deny-list narrows it further.+ // deny-list narrows it further. The list came from the model's own+ // call, so a stale entry is reported as that, not as a definition.+ refuse_renamed_shell(requested.as_deref(), "allowed_tools")?;let definition = SubagentDefinition {name: req.name.clone(),description: req.description.clone(),@@ -2579,7 +2600,7 @@ pub fn subagent_tool_schemas("allowed_tools": {"type": "array","items": { "type": "string" },- "description": "Optional tool allowlist. OMIT to give the subagent the parent's full toolset (the usual choice -- one that runs tests needs bash, one that edits needs write). Provide a list ONLY to restrict it; for a saved subagent it further narrows that subagent's own tools (never widens). An empty list is treated as omitted."+ "description": "Optional tool allowlist. OMIT to give the subagent the parent's full toolset (the usual choice -- one that runs tests needs shell, one that edits needs write). Provide a list ONLY to restrict it; for a saved subagent it further narrows that subagent's own tools (never widens). An empty list is treated as omitted."}},"required": ["name", "task"]@@ -2620,7 +2641,7 @@ pub fn subagent_tool_schemas("allowed_tools": {"type": "array","items": { "type": "string" },- "description": "Optional default tool allowlist. OMIT to let the subagent inherit the full toolset when dispatched (the usual choice); list tools ONLY to restrict it, and then include everything its job needs (e.g. bash to run commands, write/edit to change files). An empty list is treated as omitted."+ "description": "Optional default tool allowlist. OMIT to let the subagent inherit the full toolset when dispatched (the usual choice); list tools ONLY to restrict it, and then include everything its job needs (e.g. shell to run commands, write/edit to change files). An empty list is treated as omitted."},"scope": { "type": "string", "enum": ["user", "project"], "description": "Where to store it (default 'project')." },"overwrite": { "type": "boolean", "description": "Replace an existing same-name definition in that scope (default false)." }@@ -3094,6 +3115,17 @@ pub(crate) mod tests {ToolPermissions::new(PermissionDefault::ReadOnly, &[], &deny, &[])}+ /// A Claude Code agent's `Bash` is translated to Jan's `shell`, so a plugin+ /// agent scoped to `Read, Bash` keeps a shell rather than losing it.+ #[test]+ fn a_claude_bash_tool_maps_to_the_shell_tool() {+ let tools = vec!["Read".to_string(), "Bash".to_string()];+ assert_eq!(+ map_claude_tools(&tools),+ Some(vec!["read".to_string(), "shell".to_string()])+ );+ }+#[test]fn intersect_none_none_inherits() {let p = ToolPermissions::allow_all();@@ -3189,16 +3221,49 @@ pub(crate) mod tests {#[test]fn intersect_request_outside_definition_is_rejected() {let def = vec!["read".to_string()];- let req = vec!["bash".to_string()];+ let req = vec!["shell".to_string()];let p = ToolPermissions::allow_all();let err = intersect_allowed_tools(Some(&def), Some(&req), &p).unwrap_err();assert!(matches!(err, SubagentError::PermissionDenied(_)));}+ /// A list still naming `bash` is refused with the rename, rather than+ /// giving a child that silently has no shell.#[test]- fn intersect_request_denied_by_parent_is_rejected() {+ fn a_bash_entry_is_refused_with_the_rename() {+ let def = vec!["read".to_string(), "bash".to_string()];+ let p = ToolPermissions::allow_all();+ let SubagentError::PermissionDenied(msg) =+ intersect_allowed_tools(Some(&def), None, &p).unwrap_err()+ else {+ panic!("expected a permission error");+ };+ assert!(msg.contains("definition's allowed_tools names `bash`"), "{msg}");+ assert!(msg.contains("now `shell`"), "{msg}");let req = vec!["bash".to_string()];- let p = perms_denying(&["bash"]);+ assert!(intersect_allowed_tools(None, Some(&req), &p).is_err());+ }++ /// An ad-hoc dispatch has no definition, so the refusal must name the+ /// call's own list -- the one the model wrote and can fix.+ #[test]+ fn an_ad_hoc_bash_entry_names_the_calls_own_list() {+ let reg = registry_with("other", None);+ let Err(SubagentError::PermissionDenied(msg)) = resolve_dispatch_plain(+ ®,+ &req("adhoc", Some(vec!["bash".to_string()])),+ &ToolPermissions::allow_all(),+ ) else {+ panic!("expected a permission error");+ };+ assert!(msg.starts_with("allowed_tools names `bash`"), "{msg}");+ assert!(!msg.contains("definition"), "{msg}");+ }++ #[test]+ fn intersect_request_denied_by_parent_is_rejected() {+ let req = vec!["shell".to_string()];+ let p = perms_denying(&["shell"]);let err = intersect_allowed_tools(None, Some(&req), &p).unwrap_err();assert!(matches!(err, SubagentError::PermissionDenied(_)));}@@ -3492,7 +3557,7 @@ pub(crate) mod tests {let reg = registry_with("reviewer", Some(vec!["read".to_string()]));let p = ToolPermissions::allow_all();let err =- resolve_dispatch_plain(®, &req("reviewer", Some(vec!["bash".to_string()])), &p).unwrap_err();+ resolve_dispatch_plain(®, &req("reviewer", Some(vec!["shell".to_string()])), &p).unwrap_err();assert!(matches!(err, SubagentError::PermissionDenied(_)));}diff --git a/src-tauri/src/core/cli/acp.rs b/src-tauri/src/core/cli/acp.rsindex 00e04ae9f..f708a6e33 100644--- a/src-tauri/src/core/cli/acp.rs+++ b/src-tauri/src/core/cli/acp.rs@@ -966,7 +966,8 @@ fn tool_kind(name: &str) -> ToolKind {"read" | "ls" | "memory_read" | "memory_list" | "skill_read" | "skill_list" => ToolKind::Read,"edit" | "write" | "memory_write" | "skill_write" => ToolKind::Edit,"grep" | "find" => ToolKind::Search,- "bash" => ToolKind::Execute,+ // `bash` is the shell's pre-rename name, still in replayed history.+ "bash" | tauri_plugin_agent_tools::tools::SHELL_TOOL => ToolKind::Execute,"web_fetch" | "web_search" => ToolKind::Fetch,"dispatch_subagent" | "todo" => ToolKind::Think,_ => ToolKind::Other,@@ -1134,7 +1135,7 @@ mod tests {let mut map = map();let out = map.map(StreamEvent::ToolCall {id: "c".into(),- name: "bash".into(),+ name: "shell".into(),args: json!({"command":"cargo test"}),});let w = wire(&out[0]);diff --git a/src-tauri/src/core/cli/mcp_serve.rs b/src-tauri/src/core/cli/mcp_serve.rsindex 3db68c945..9422dfc95 100644--- a/src-tauri/src/core/cli/mcp_serve.rs+++ b/src-tauri/src/core/cli/mcp_serve.rs@@ -81,6 +81,12 @@ pub async fn cli_mcp_serve(unknown.join(", "));}+ for notice in unknown+ .iter()+ .filter_map(|n| tauri_plugin_agent_tools::tools::renamed_shell_notice(n, "--tool"))+ {+ eprintln!("jan mcp serve: {notice}");+ }match transport {ServeTransport::Stdio => {// stdout is the JSON-RPC stream from here on; the startup noticediff --git a/src-tauri/src/core/cli/rpc.rs b/src-tauri/src/core/cli/rpc.rsindex 93c4ee6b8..87a9b0c74 100644--- a/src-tauri/src/core/cli/rpc.rs+++ b/src-tauri/src/core/cli/rpc.rs@@ -994,7 +994,7 @@ mod tests {fn a_declaration_error_names_the_entry_or_the_rule() {let set = declare_tools(vec![json!({"name":"camera","capability":"read"})]).unwrap();assert_eq!(host_names(&set), ["host__camera"]);- assert!(declare_tools(vec![json!({"name":"bash"})]).unwrap_err().contains("reserved"));+ assert!(declare_tools(vec![json!({"name":"shell"})]).unwrap_err().contains("reserved"));assert!(declare_tools(vec![json!({"name":"a"}), json!(3)]).unwrap_err().starts_with("tools[1]"));assert!(declare_tools(Vec::new()).unwrap().is_empty());}diff --git a/src-tauri/src/core/mcp/server/mod.rs b/src-tauri/src/core/mcp/server/mod.rsindex d4bcc339d..c0d9d294a 100644--- a/src-tauri/src/core/mcp/server/mod.rs+++ b/src-tauri/src/core/mcp/server/mod.rs@@ -29,7 +29,7 @@ use rmcp::{ErrorData as McpError, ServerHandler};use tauri_plugin_agent_tools::tools::gate::{resolve_decision, Decision, DenyReason, GateContext, PromptKind, SessionGrants,};-use tauri_plugin_agent_tools::tools::handlers::{bash_result_failed, execute_builtin};+use tauri_plugin_agent_tools::tools::handlers::{execute_builtin, tool_result_failed};use tauri_plugin_agent_tools::tools::schema::{builtin_tool_schemas, search_tool_schemas};use tauri_plugin_agent_tools::tools::{lookup, Capability, ToolContext};@@ -231,7 +231,7 @@ impl JanToolServer {return (format!("ERROR: tool '{name}' is not served by this Jan MCP server. \- Mutating filesystem tools and bash are opt-in."+ Mutating filesystem tools and the shell are opt-in."),Vec::new(),);@@ -330,11 +330,13 @@ impl ServerHandler for JanToolServer {) -> Result<CallToolResponse, McpError> {let args = serde_json::Value::Object(request.arguments.unwrap_or_default());let (content, mut blocks) = self.dispatch(&request.name, &args).await;- // Same two clauses the agent loop uses. `bash` reports a non-zero exit- // as an `[exit N]` trailer rather than an `ERROR` prefix, so the prefix- // alone would tell a peer that a command which exited 3 succeeded.- let is_error = content.starts_with("ERROR")- || (request.name == "bash" && bash_result_failed(&content));+ // The rule the agent loop uses. The shell reports a non-zero exit as an+ // `[exit N]` trailer rather than an `ERROR` prefix, so the prefix alone+ // would tell a peer that a command which exited 3 succeeded.+ let is_error = match lookup(&request.name) {+ Some(tool) => tool_result_failed(tool, &content),+ None => content.starts_with("ERROR"),+ };blocks.insert(0, ContentBlock::text(content));let result = if is_error {CallToolResult::error(blocks)diff --git a/src-tauri/src/core/mcp/server/tests.rs b/src-tauri/src/core/mcp/server/tests.rsindex f6771f3d7..25ca25cd0 100644--- a/src-tauri/src/core/mcp/server/tests.rs+++ b/src-tauri/src/core/mcp/server/tests.rs@@ -39,7 +39,7 @@ fn default_served_set_is_read_only() {assert!(names.contains(&"skill_write".to_string()));assert!(!names.contains(&"write".to_string()));assert!(!names.contains(&"edit".to_string()));- assert!(!names.contains(&"bash".to_string()));+ assert!(!names.contains(&"shell".to_string()));}#[test]@@ -53,13 +53,13 @@ fn opt_in_adds_mutating_tools() {let names = tool_names(&JanToolServer::new(opts));assert!(names.contains(&"write".to_string()));assert!(names.contains(&"edit".to_string()));- assert!(names.contains(&"bash".to_string()));+ assert!(names.contains(&"shell".to_string()));}#[test]fn only_narrows_the_set_but_never_widens_it() {let mut opts = options(&PathBuf::from("."));- opts.served.only = vec!["read".into(), "bash".into()];+ opts.served.only = vec!["read".into(), "shell".into()];let names = tool_names(&JanToolServer::new(opts));assert_eq!(names, vec!["read".to_string()]);}@@ -362,7 +362,7 @@ async fn list_and_call_round_trip_over_a_stream_transport() {let tools = client.list_all_tools().await.expect("tools/list");let names: Vec<String> = tools.iter().map(|t| t.name.to_string()).collect();assert!(names.contains(&"read".to_string()), "{names:?}");- assert!(!names.contains(&"bash".to_string()), "{names:?}");+ assert!(!names.contains(&"shell".to_string()), "{names:?}");let result = client.call_tool(@@ -387,7 +387,7 @@ async fn list_and_call_round_trip_over_a_stream_transport() {// as a transport failure.let denied = client.call_tool(- CallToolRequestParams::new("bash").with_arguments(+ CallToolRequestParams::new("shell").with_arguments(serde_json::json!({ "command": "echo nope" }).as_object().cloned()@@ -430,7 +430,7 @@ async fn bash_exit_status_decides_is_error() {] {let result = client.call_tool(- CallToolRequestParams::new("bash").with_arguments(+ CallToolRequestParams::new("shell").with_arguments(serde_json::json!({ "command": command }).as_object().cloned()diff --git a/web-app/src/containers/ChatInput.tsx b/web-app/src/containers/ChatInput.tsxindex 23515edc2..58b63085c 100644--- a/web-app/src/containers/ChatInput.tsx+++ b/web-app/src/containers/ChatInput.tsx@@ -865,7 +865,7 @@ const ChatInput = memo(function ChatInput({}cancelToolCall?.()// Aborting the stream/loop only discards a pending tool result; a running- // or backgrounded bash keeps executing until its session's shells are+ // or backgrounded shell keeps executing until its session's shells are// killed. Chat's tool thread_id is the chat thread id.void cancelAgentThreadBash(threadId)},diff --git a/web-app/src/containers/CoworkSandboxChip.tsx b/web-app/src/containers/CoworkSandboxChip.tsxindex b43d94a3d..2c8bf23af 100644--- a/web-app/src/containers/CoworkSandboxChip.tsx+++ b/web-app/src/containers/CoworkSandboxChip.tsx@@ -19,7 +19,7 @@ function fixKeyFor(platform: string): string {}/**- * Shown only when no OS sandbox can confine a shell, in which case `bash` is+ * Shown only when no OS sandbox can confine a shell, in which case `shell` is* withheld entirely rather than run unconfined. Without this the capability* just silently isn't offered, which reads as a broken agent.*/diff --git a/web-app/src/containers/message/AgentToolWidget.tsx b/web-app/src/containers/message/AgentToolWidget.tsxindex 152f65bb5..eb9ff3634 100644--- a/web-app/src/containers/message/AgentToolWidget.tsx+++ b/web-app/src/containers/message/AgentToolWidget.tsx@@ -9,6 +9,7 @@ import {IconBook,IconLock,IconFilePencil,+ IconAlertTriangle,} from '@tabler/icons-react'import { Shimmer } from '@/components/ai-elements/shimmer'import { useTranslation } from '@/i18n/react-i18next-compat'@@ -138,7 +139,7 @@ export type TerminalWidgetProps = {}/**- * `bash` rendered as a terminal: the command streams in after a prompt, then its+ * `shell` rendered as a terminal: the command streams in after a prompt, then its* output fills the scrollback below. The trailing `[exit N]` marker becomes a* status chip rather than staying in the text.*@@ -212,6 +213,17 @@ export const TerminalWidget = memo(<span>{result.sandboxNote}</span></p>)}+ {/* A stale hook matcher no longer guards this very call, so the user+ hears it here rather than only through the model. */}+ {result?.configNotes.map((note) => (+ <p+ key={note}+ className="mt-1 flex items-start gap-1.5 text-muted-foreground/70"+ >+ <IconAlertTriangle size={13} className="mt-0.5 shrink-0" />+ <span>{note}</span>+ </p>+ ))}</div></div>)diff --git a/web-app/src/containers/message/__tests__/AgentToolWidget.test.tsx b/web-app/src/containers/message/__tests__/AgentToolWidget.test.tsxindex 5d87c5cad..53cc51de9 100644--- a/web-app/src/containers/message/__tests__/AgentToolWidget.test.tsx+++ b/web-app/src/containers/message/__tests__/AgentToolWidget.test.tsx@@ -11,7 +11,7 @@ vi.mock('@/hooks/useToolCallRuntime', () => ({selector({ diffs: {} }),}))-import { AgentToolWidget } from '../AgentToolWidget'+import { AgentToolWidget, TerminalWidget } from '../AgentToolWidget'const renderRunning = (tool: string, target = '') =>render(@@ -91,6 +91,25 @@ describe('AgentToolWidget', () => {expect(screen.getByText('tools:toolCall.writing')).toBeInTheDocument()})+ /// The notice rides after the exit marker, where the body is cut; it must+ /// still reach the user, since the stale hook no longer guards this call.+ it('shows a hook config notice under a finished shell call', () => {+ render(+ <TerminalWidget+ bar={{ variant: 'terminal', command: 'ls' }}+ state="output-available"+ output={+ 'ok\n[exit 0]\n[hook config: Hook pre_tool_use matcher names `bash`]'+ }+ />+ )+ expect(screen.getByText('ok')).toBeInTheDocument()+ expect(+ screen.getByText('Hook pre_tool_use matcher names `bash`')+ ).toBeInTheDocument()+ expect(screen.queryByText(/\[hook config/)).not.toBeInTheDocument()+ })+it('prompts for a pattern rather than a path on grep', () => {renderRunning('grep')expect(diff --git a/web-app/src/hooks/useToolOrigin.ts b/web-app/src/hooks/useToolOrigin.tsindex 9ba27e6f2..c5536c991 100644--- a/web-app/src/hooks/useToolOrigin.ts+++ b/web-app/src/hooks/useToolOrigin.ts@@ -2,7 +2,7 @@ import { useMemo } from 'react'import { useAppState } from '@/hooks/useAppState'import { getProviderMeta, useWebSearchConfig } from '@/hooks/useWebSearchConfig'import { resolveToolOrigin, type ToolOrigin } from '@/lib/toolOrigin'-import { AGENT_TOOL_NAMES } from '@/lib/agentTools'+import { AGENT_TOOL_NAMES, isRecordedShellCall } from '@/lib/agentTools'/*** Resolve which family a tool call belongs to. Each selector returns a@@ -14,7 +14,8 @@ export const useToolOrigin = (toolName: string): ToolOrigin | undefined => {(s) => s.tools.find((tool) => tool.name === toolName)?.server)const isRagTool = useAppState((s) => s.ragToolNames.has(toolName))- const isAgentTool = AGENT_TOOL_NAMES.has(toolName)+ const isAgentTool =+ AGENT_TOOL_NAMES.has(toolName) || isRecordedShellCall(toolName)const webSearchProviderLabel = useWebSearchConfig((s) => getProviderMeta(s.searchProvider).label)diff --git a/web-app/src/lib/__tests__/agentTools.test.ts b/web-app/src/lib/__tests__/agentTools.test.tsindex e1c3264d7..84d10f70c 100644--- a/web-app/src/lib/__tests__/agentTools.test.ts+++ b/web-app/src/lib/__tests__/agentTools.test.ts@@ -53,18 +53,30 @@ describe('agentTools', () => {// The chat surface offers the sandboxed shell alone; everything else is// Cowork's. A chat set that grew a write tool would hand the main interface// an agent toolset it no longer advertises a workspace for.- it('restricts the chat subset to bash', async () => {+ it('restricts the chat subset to shell', async () => {const { CHAT_AGENT_TOOL_NAMES } = await import('../agentTools')- expect([...CHAT_AGENT_TOOL_NAMES]).toEqual(['bash'])+ expect([...CHAT_AGENT_TOOL_NAMES]).toEqual(['shell'])})- it('advertises the workspace tools including writes and bash', async () => {+ // `bash` is recognised only when reading saved history; nothing dispatches+ // or advertises it.+ it('reads a saved bash call as the shell without accepting bash', async () => {+ const { isRecordedShellCall, AGENT_TOOL_NAMES, CHAT_AGENT_TOOL_NAMES } =+ await import('../agentTools')+ expect(isRecordedShellCall('bash')).toBe(true)+ expect(isRecordedShellCall('shell')).toBe(true)+ expect(isRecordedShellCall('mcp__x__bash')).toBe(false)+ expect(AGENT_TOOL_NAMES.has('bash')).toBe(false)+ expect(CHAT_AGENT_TOOL_NAMES.has('bash')).toBe(false)+ })++ it('advertises the workspace tools including writes and shell', async () => {const { AGENT_TOOL_NAMES } = await import('../agentTools')- for (const name of ['read', 'ls', 'find', 'grep', 'bash']) {+ for (const name of ['read', 'ls', 'find', 'grep', 'shell']) {expect(AGENT_TOOL_NAMES.has(name)).toBe(true)}// write/edit can only touch the thread's ephemeral sandbox, so they are- // allowed there without a prompt -- withholding them while bash can write+ // allowed there without a prompt -- withholding them while shell can write// the same files would be a restriction a sibling tool bypasses.for (const name of ['write', 'edit']) {expect(AGENT_TOOL_NAMES.has(name)).toBe(true)@@ -132,26 +144,26 @@ describe('agentTools', () => {).toBeUndefined()})- it('offers bash when the sandbox can enforce', async () => {- toolSchemas.mockResolvedValue([schemaFor('read'), schemaFor('bash')])+ it('offers shell when the sandbox can enforce', async () => {+ toolSchemas.mockResolvedValue([schemaFor('read'), schemaFor('shell')])const { getAgentToolSchemas } = await import('../agentTools')const names = (await getAgentToolSchemas()).map((s) => s.function.name)- expect(names).toEqual(['read', 'bash'])+ expect(names).toEqual(['read', 'shell'])})// Offering a tool the executor will always refuse wastes a model turn, so an- // unconfinable host must not see bash at all.- it('withholds bash when no sandbox backend exists', async () => {+ // unconfinable host must not see shell at all.+ it('withholds shell when no sandbox backend exists', async () => {sandboxStatus.mockResolvedValue({ backend: 'none', enforces: false })- toolSchemas.mockResolvedValue([schemaFor('read'), schemaFor('bash')])+ toolSchemas.mockResolvedValue([schemaFor('read'), schemaFor('shell')])const { getAgentToolSchemas } = await import('../agentTools')const names = (await getAgentToolSchemas()).map((s) => s.function.name)expect(names).toEqual(['read'])})- it('withholds bash when the sandbox probe itself fails', async () => {+ it('withholds shell when the sandbox probe itself fails', async () => {sandboxStatus.mockRejectedValue(new Error('probe exploded'))- toolSchemas.mockResolvedValue([schemaFor('read'), schemaFor('bash')])+ toolSchemas.mockResolvedValue([schemaFor('read'), schemaFor('shell')])const { getAgentToolSchemas, sandboxEnforces } = await import('../agentTools')@@ -164,11 +176,11 @@ describe('agentTools', () => {it('keeps the sandbox network closed unless the caller opens it', async () => {executeTool.mockResolvedValue({ content: '', diff: null, isError: false })const { executeAgentTool } = await import('../agentTools')- await executeAgentTool('bash', { command: 'ls' }, 'thread-1')+ await executeAgentTool('shell', { command: 'ls' }, 'thread-1')expect(executeTool).toHaveBeenLastCalledWith('/data','thread-1',- 'bash',+ 'shell',{ command: 'ls' },undefined,undefined,@@ -184,7 +196,7 @@ describe('agentTools', () => {executeTool.mockResolvedValue({ content: '', diff: null, isError: false })const { executeAgentTool } = await import('../agentTools')await executeAgentTool(- 'bash',+ 'shell',{ command: 'ls' },'thread-1',undefined,@@ -194,7 +206,7 @@ describe('agentTools', () => {expect(executeTool).toHaveBeenLastCalledWith('/data','thread-1',- 'bash',+ 'shell',{ command: 'ls' },undefined,undefined,diff --git a/web-app/src/lib/__tests__/coworkArtifacts.test.ts b/web-app/src/lib/__tests__/coworkArtifacts.test.tsindex 6a956bd2e..8fb8f84c7 100644--- a/web-app/src/lib/__tests__/coworkArtifacts.test.ts+++ b/web-app/src/lib/__tests__/coworkArtifacts.test.ts@@ -180,12 +180,12 @@ describe('artifactsFromTurns', () => {expect(artifactsFromTurns([])).toEqual([])})- it('recovers an mp4 a bash download produced (quoted spaces in the name)', () => {+ it('recovers an mp4 a shell download produced (quoted spaces in the name)', () => {const turns = [{role: 'tool',content: '',- name: 'bash',+ name: 'shell',args: {command:'cd /Users/thinhlpg/Desktop && yt-dlp -f "bv*+ba/b" -o "%(title)s.%(ext)s" "https://youtu.be/x" 2>&1 | tail -30',@@ -202,12 +202,29 @@ describe('artifactsFromTurns', () => {expect(artifacts[0]!.title).toContain('Rick Astley')})- it('recovers a relative mp4 from ls -lh in the bash result', () => {+ // Sessions saved before the rename name the shell `bash`; their files must+ // not vanish from the library.+ it('recovers artifacts from a saved bash turn', () => {const turns = [{role: 'tool',content: '',name: 'bash',+ args: { command: 'yt-dlp -o "clip.mp4" "https://youtu.be/x"' },+ status: 'done',+ isError: false,+ result: '[download] Destination: /p/clip.mp4\n[download] 100% of 1MiB',+ } as CoworkTurn,+ ]+ expect(artifactsFromTurns(turns, '/p').map((a) => a.path)).toEqual(['/p/clip.mp4'])+ })++ it('recovers a relative mp4 from ls -lh in the shell result', () => {+ const turns = [+ {+ role: 'tool',+ content: '',+ name: 'shell',args: { command: 'cd /p && python3 make.py && ls -lh cat_video.mp4' },status: 'done',isError: false,@@ -224,7 +241,7 @@ describe('artifactsFromTurns', () => {{role: 'tool',content: '',- name: 'bash',+ name: 'shell',args: { command: 'cd /p/src && mv cat_video.mp4 /p/cat_video.mp4 && ls -lh /p/cat_video.mp4' },status: 'done',isError: false,@@ -241,7 +258,7 @@ describe('artifactsFromTurns', () => {{role: 'tool',content: '',- name: 'bash',+ name: 'shell',args: { command: 'which yt-dlp ffmpeg; ls *.mp4' },status: 'done',isError: false,@@ -251,12 +268,12 @@ describe('artifactsFromTurns', () => {expect(artifactsFromTurns(turns, '/p')).toEqual([])})- it('ignores errored bash calls', () => {+ it('ignores errored shell calls', () => {const turns = [{role: 'tool',content: '',- name: 'bash',+ name: 'shell',args: { command: 'python3 make.py 2>&1 && ls -lh out.mp4' },status: 'done',isError: true,diff --git a/web-app/src/lib/__tests__/coworkDiffs.test.ts b/web-app/src/lib/__tests__/coworkDiffs.test.tsindex 9113852ee..addeefae3 100644--- a/web-app/src/lib/__tests__/coworkDiffs.test.ts+++ b/web-app/src/lib/__tests__/coworkDiffs.test.ts@@ -38,12 +38,12 @@ describe('collectCodeFileDiffs', () => {{ diff: '@@ edit 1/1 @@\n+ 2 | next', source: 'main' },])})- it('includes only write/edit tool diffs and ignores path-bearing bash output', () => {+ it('includes only write/edit tool diffs and ignores path-bearing shell output', () => {const files = collectCodeFileDiffs([edit('src/edit.ts', '+ 1 | edit'),edit('src/write.ts', '+ 1 | write', { name: 'write' }),- edit('src/bash.ts', '+ 1 | ignored bash diff', { name: 'bash' }),+ edit('src/bash.ts', '+ 1 | ignored shell diff', { name: 'shell' }),edit('src/assistant.ts', '+ 1 | ignored assistant diff', {role: 'assistant',}),diff --git a/web-app/src/lib/__tests__/coworkDispatch.test.ts b/web-app/src/lib/__tests__/coworkDispatch.test.tsindex c27b6467e..1ecc66754 100644--- a/web-app/src/lib/__tests__/coworkDispatch.test.ts+++ b/web-app/src/lib/__tests__/coworkDispatch.test.ts@@ -61,9 +61,9 @@ describe('dispatchCoworkTool', () => {// Cowork's shell network follows the Cowork setting (on by default), read// per call so a Settings toggle applies to the next command.it('passes the cowork network setting through per call', async () => {- await dispatchCoworkTool(call('bash', { command: 'curl x' }), ctx())+ await dispatchCoworkTool(call('shell', { command: 'curl x' }), ctx())expect(executeAgentTool).toHaveBeenCalledWith(- 'bash',+ 'shell',{ command: 'curl x' },'s1',null,@@ -74,9 +74,9 @@ describe('dispatchCoworkTool', () => {)coworkConfig.networkEnabled = falsetry {- await dispatchCoworkTool(call('bash', { command: 'curl x' }), ctx())+ await dispatchCoworkTool(call('shell', { command: 'curl x' }), ctx())expect(executeAgentTool).toHaveBeenLastCalledWith(- 'bash',+ 'shell',{ command: 'curl x' },'s1',null,diff --git a/web-app/src/lib/__tests__/coworkSubagent.test.ts b/web-app/src/lib/__tests__/coworkSubagent.test.tsindex f72b43556..09e8d8648 100644--- a/web-app/src/lib/__tests__/coworkSubagent.test.ts+++ b/web-app/src/lib/__tests__/coworkSubagent.test.ts@@ -286,7 +286,39 @@ describe('injectInputs', () => {})})+describe('resolveSubagent bash refusal', () => {+ // An ad-hoc dispatch has no definition, so the refusal must name the+ // call's own list -- the one the model wrote and can fix.+ it("names the call's own list for an ad-hoc subagent", () => {+ const out = resolveSubagent(+ { name: 'adhoc', description: 't', allowed_tools: ['bash'] },+ [],+ ['read', 'shell']+ )+ expect(out).toHaveProperty('error')+ const error = (out as { error: string }).error+ expect(error.startsWith('allowed_tools names `bash`')).toBe(true)+ expect(error).not.toContain('definition')+ })+})+describe('intersectAllowedTools', () => {+ // A list still naming `bash` is refused with the rename, rather than+ // giving a child that silently has no shell.+ it('refuses a bash entry with the rename', () => {+ const parent = ['read', 'shell', 'skill_list', 'skill_read']+ const fromDefinition = intersectAllowedTools(['read', 'bash'], null, parent)+ expect(fromDefinition).toEqual({+ error:+ "the subagent definition's allowed_tools names `bash`, which matches " ++ 'nothing: the shell tool is now `shell`. Rename it to `shell` for it to apply.',+ })+ expect(intersectAllowedTools(null, ['Bash'], parent)).toHaveProperty('error')+ expect(intersectAllowedTools(['read', 'shell'], ['shell'], parent)).toEqual({+ tools: ['shell', 'skill_list', 'skill_read'],+ })+ })+const parent = ['read', 'grep', 'write', 'skill_list', 'skill_read']it('inherits the parent set when neither side narrows', () => {@@ -296,7 +328,7 @@ describe('intersectAllowedTools', () => {it('narrows to the definition, dropping what the parent lacks', () => {// The definition's author cannot know the parent's mode, so a tool the// parent lacks is dropped rather than raised as an error.- const out = intersectAllowedTools(['read', 'bash'], null, parent)+ const out = intersectAllowedTools(['read', 'shell'], null, parent)expect(out).toEqual({ tools: ['read', 'skill_list', 'skill_read'] })})@@ -309,9 +341,9 @@ describe('intersectAllowedTools', () => {})it('refuses a request the parent cannot call', () => {- // This is what makes plan mode and a withheld `bash` propagate: the parent's+ // This is what makes plan mode and a withheld `shell` propagate: the parent's// advertised set is the ceiling.- expect(intersectAllowedTools(null, ['bash'], parent)).toEqual({+ expect(intersectAllowedTools(null, ['shell'], parent)).toEqual({error: expect.stringContaining('not available to this run'),})})diff --git a/web-app/src/lib/__tests__/coworkTools.test.ts b/web-app/src/lib/__tests__/coworkTools.test.tsindex b22d3eb27..32da873ff 100644--- a/web-app/src/lib/__tests__/coworkTools.test.ts+++ b/web-app/src/lib/__tests__/coworkTools.test.ts@@ -20,7 +20,7 @@ const schema = (name: string) => ({function: { name, description: name, parameters: { type: 'object' } },})-const ALL = ['read', 'ls', 'grep', 'write', 'edit', 'bash', 'memory_write']+const ALL = ['read', 'ls', 'grep', 'write', 'edit', 'shell', 'memory_write']const opts = (over: Partial<Parameters<typeof buildCoworkTools>[0]> = {}) => ({planMode: false,@@ -123,12 +123,12 @@ describe('web tools', () => {expect(tools.web_fetch).toBeDefined()})- // Research is most of what planning is, so unlike write/edit/bash these are+ // Research is most of what planning is, so unlike write/edit/shell these are// reads that plan mode keeps.it('survive plan mode', async () => {const tools = await buildCoworkTools(opts({ webSearch: true, planMode: true }))expect(tools.web_search).toBeDefined()- expect(tools.bash).toBeUndefined()+ expect(tools.shell).toBeUndefined()})// Advertising them changes the tool JSON, so a run that froze without themdiff --git a/web-app/src/lib/__tests__/coworkTransport.test.ts b/web-app/src/lib/__tests__/coworkTransport.test.tsindex 1c83bce45..d564a4aca 100644--- a/web-app/src/lib/__tests__/coworkTransport.test.ts+++ b/web-app/src/lib/__tests__/coworkTransport.test.ts@@ -101,7 +101,7 @@ describe('CoworkChatTransport', () => {expect(buildCoworkTools).toHaveBeenCalledTimes(1)})- it('rebuilds when the sandbox appears, since bash joins the set', async () => {+ it('rebuilds when the sandbox appears, since shell joins the set', async () => {sandboxEnforces.mockReturnValue(false)const t = new CoworkChatTransport('s1', config())await t.refreshTools()@@ -132,7 +132,7 @@ describe('CoworkChatTransport.advertisedTools', () => {})// A subagent's allowlist intersects with this, so plan mode and a withheld- // `bash` reach children without a second policy check.+ // `shell` reach children without a second policy check.it('reports the set frozen for the run', async () => {const t = new CoworkChatTransport('s1', config())await t.refreshTools()diff --git a/web-app/src/lib/__tests__/coworkTurns.test.ts b/web-app/src/lib/__tests__/coworkTurns.test.tsindex 08a0161e7..abd03b2a4 100644--- a/web-app/src/lib/__tests__/coworkTurns.test.ts+++ b/web-app/src/lib/__tests__/coworkTurns.test.ts@@ -94,7 +94,7 @@ describe('coworkTurnsToUIMessages', () => {role: 'tool',content: '',callId: 'c',- name: 'bash',+ name: 'shell',status: 'running',},])@@ -109,7 +109,7 @@ describe('coworkTurnsToUIMessages', () => {role: 'tool',content: '',callId: 'c',- name: 'bash',+ name: 'shell',result: 'boom',isError: true,status: 'done',diff --git a/web-app/src/lib/__tests__/toolPresentation.test.ts b/web-app/src/lib/__tests__/toolPresentation.test.tsindex f5ae10b88..72d4552cd 100644--- a/web-app/src/lib/__tests__/toolPresentation.test.ts+++ b/web-app/src/lib/__tests__/toolPresentation.test.ts@@ -134,6 +134,15 @@ const agent = { kind: 'agent' } as constdescribe('describeNativeToolCall for agent tools', () => {it('builds a terminal from the command', () => {+ expect(describeNativeToolCall(agent, 'shell', { command: 'ls -la' })).toEqual({+ variant: 'terminal',+ command: 'ls -la',+ })+ })++ // Threads saved before the rename carry calls under the old `bash` name;+ // they still render as a terminal.+ it('renders a saved bash call as a terminal', () => {expect(describeNativeToolCall(agent, 'bash', { command: 'ls -la' })).toEqual({variant: 'terminal',command: 'ls -la',@@ -142,7 +151,7 @@ describe('describeNativeToolCall for agent tools', () => {// The command streams in like any other argument, so a partial one must show.it('accepts a partially streamed command', () => {- expect(describeNativeToolCall(agent, 'bash', { command: 'git pu' })).toEqual({+ expect(describeNativeToolCall(agent, 'shell', { command: 'git pu' })).toEqual({variant: 'terminal',command: 'git pu',})@@ -233,6 +242,19 @@ describe('parseBashOutput', () => {expect(r.sandboxNote).toContain('Network access is disabled')})+ it('surfaces hook config notices separately from the body', () => {+ const r = parseBashOutput(+ 'ok\n[exit 0]\n[hook config: Hook pre_tool_use matcher in /cfg/[x]/hooks.json ' ++ 'names `bash`, which matches nothing]\n[hook config: second]'+ )+ expect(r.exit).toBe(0)+ expect(r.text).toBe('ok')+ expect(r.configNotes).toEqual([+ 'Hook pre_tool_use matcher in /cfg/[x]/hooks.json names `bash`, which matches nothing',+ 'second',+ ])+ })+it('has no sandbox note on an ordinary run', () => {expect(parseBashOutput('ok\n[exit 0]').sandboxNote).toBeUndefined()})diff --git a/web-app/src/lib/agentActivity.test.ts b/web-app/src/lib/agentActivity.test.tsindex e211351a7..647a708d3 100644--- a/web-app/src/lib/agentActivity.test.ts+++ b/web-app/src/lib/agentActivity.test.ts@@ -25,15 +25,22 @@ describe('toolActivityText', () => {).toBe('Writing report.html')})- it('formats bash with truncated command', () => {+ it('formats shell with truncated command', () => {+ expect(toolActivityText('shell', { command: 'ls -la' })).toBe(+ 'Running ls -la'+ )+ })++ // Saved threads predate the rename and name the tool `bash`.+ it('formats a saved bash call like shell', () => {expect(toolActivityText('bash', { command: 'ls -la' })).toBe('Running ls -la')})- it('truncates long bash commands to 60 chars', () => {+ it('truncates long shell commands to 60 chars', () => {const long = 'echo ' + 'x'.repeat(100)- const text = toolActivityText('bash', { command: long })+ const text = toolActivityText('shell', { command: long })expect(text.startsWith('Running echo ')).toBe(true)expect(text.length).toBeLessThanOrEqual('Running '.length + 60)})@@ -66,7 +73,7 @@ describe('toolActivityText', () => {it('falls back gracefully when path/command arg is missing', () => {expect(toolActivityText('write', {})).toBe('Writing')- expect(toolActivityText('bash', {})).toBe('Running')+ expect(toolActivityText('shell', {})).toBe('Running')})})@@ -99,7 +106,7 @@ describe('awaitsModel', () => {role: 'tool',content: '',callId: 'c1',- name: 'bash',+ name: 'shell',status,})diff --git a/web-app/src/lib/agentActivity.ts b/web-app/src/lib/agentActivity.tsindex be333d5a0..73c41b1f4 100644--- a/web-app/src/lib/agentActivity.ts+++ b/web-app/src/lib/agentActivity.ts@@ -1,4 +1,5 @@import type { CoworkTurn } from '@/types/coworkSession'+import { isRecordedShellCall } from '@/lib/agentTools'const MAX_COMMAND_LEN = 60@@ -27,7 +28,7 @@ function humanizeToolName(name: string): string {const VERB_BY_TOOL: Record<string, string> = {write: 'Writing',edit: 'Editing',- bash: 'Running',+ shell: 'Running',read: 'Reading',ls: 'Listing',find: 'Finding',@@ -50,10 +51,10 @@ export function toolActivityText(toolName: string, input: unknown): string {return name ? `Reading ${name}` : 'Reading skill'}- const verb = VERB_BY_TOOL[toolName]+ const verb = VERB_BY_TOOL[isRecordedShellCall(toolName) ? 'shell' : toolName]if (!verb) return humanizeToolName(toolName)- if (toolName === 'bash') {+ if (isRecordedShellCall(toolName)) {const command = stringArg(input, 'command')return command ? `${verb} ${truncate(command, MAX_COMMAND_LEN)}` : verb}diff --git a/web-app/src/lib/agentTools.ts b/web-app/src/lib/agentTools.tsindex d1004db70..69bdc1d7e 100644--- a/web-app/src/lib/agentTools.ts+++ b/web-app/src/lib/agentTools.ts@@ -30,7 +30,7 @@ import { getServiceHub } from '@/hooks/useServiceHub'** `write` and `edit` are included: they can only touch the thread's ephemeral* sandbox, which is deleted with the conversation, so `execute_tool` allows them- * without a prompt. Withholding them while `bash` can write the same files would+ * without a prompt. Withholding them while `shell` can write the same files would* be a restriction a sibling tool trivially bypasses.** `web_search`/`web_fetch` are also built-ins but are already advertised through@@ -43,7 +43,7 @@ export const AGENT_TOOL_NAMES = new Set(['grep','write','edit',- 'bash',+ 'shell','memory_list','memory_read','memory_write',@@ -55,26 +55,35 @@ export const AGENT_TOOL_NAMES = new Set(['screenshot',])+/**+ * Whether a recorded tool call ran the shell, for *displaying saved history*+ * only. Turns saved before the tool was renamed carry its old name `bash`; they+ * keep their terminal view and artifacts. Nothing dispatches or allows `bash`:+ * the sets above and below name only `shell`.+ */+export const isRecordedShellCall = (toolName: string): boolean =>+ toolName === 'shell' || toolName === 'bash'+/*** The subset the main chat surface advertises and dispatches: the sandboxed* shell alone, with no network. The full toolset above is Cowork's — chat is a* conversation that occasionally runs a command, not an agent surface.*/-export const CHAT_AGENT_TOOL_NAMES = new Set(['bash'])+export const CHAT_AGENT_TOOL_NAMES = new Set(['shell'])/*** Tools that only run under an enforcing OS sandbox. They stay in* `AGENT_TOOL_NAMES` -- the desktop still owns dispatching them -- but are held* back from the advertised schemas when no backend can confine them.*/-const SANDBOX_REQUIRED_TOOLS = new Set(['bash'])+const SANDBOX_REQUIRED_TOOLS = new Set(['shell'])let schemaCache: ToolSchema[] | null = nulllet statusCache: Promise<SandboxStatus> | null = null/*** The sandbox backend for this machine, fetched once. A failure is treated as- * "no sandbox", which withholds `bash` rather than offering something that+ * "no sandbox", which withholds `shell` rather than offering something that* cannot run.*/export function getSandboxStatus(): Promise<SandboxStatus> {@@ -95,7 +104,7 @@ let enforcesNow = false/*** Re-probe the sandbox, dropping both caches. Installing a backend (bubblewrap* on Linux) cannot take effect otherwise: `statusCache` is module-level, and- * leaving `schemaCache` behind would keep `bash` withheld even once a backend+ * leaving `schemaCache` behind would keep `shell` withheld even once a backend* enforces.*/export function refreshSandboxStatus(): Promise<SandboxStatus> {@@ -115,7 +124,7 @@ export function sandboxEnforces(): boolean {/*** Schemas for the advertised subset. Rust's `schema.rs` is the only source, and- * the sandbox decides whether `bash` is among them.+ * the sandbox decides whether `shell` is among them.*/export async function getAgentToolSchemas(): Promise<ToolSchema[]> {if (schemaCache) return schemaCache@@ -239,7 +248,7 @@ const messageOf = (e: unknown): string =>* the desktop has no project picker yet, so the plugin uses the permanent store* in the Jan data folder.*- * `bash` additionally runs under an OS sandbox whose network access is closed+ * `shell` additionally runs under an OS sandbox whose network access is closed* unless the caller opens it. Chat never does; Cowork passes its own setting.*/export async function executeAgentTool(@@ -388,7 +397,7 @@ export async function stopAgentSessionMonitors(sessionId: string): Promise<void>}/**- * Kill every `bash` tree this session started when the user presses Stop.+ * Kill every `shell` tree this session started when the user presses Stop.* Best-effort: aborting the JS run already unwinds the turn, so a failure here* only means a shell keeps running, not user-visible damage.*/@@ -396,7 +405,7 @@ export async function cancelAgentThreadBash(sessionId: string): Promise<void> {try {await cancelThreadBash(sessionId)} catch (e) {- console.warn('[agentTools] Failed to cancel session bash:', messageOf(e))+ console.warn('[agentTools] Failed to cancel session shells:', messageOf(e))}}diff --git a/web-app/src/lib/coworkArtifacts.ts b/web-app/src/lib/coworkArtifacts.tsindex f4bd2601a..d54ace573 100644--- a/web-app/src/lib/coworkArtifacts.ts+++ b/web-app/src/lib/coworkArtifacts.ts@@ -1,6 +1,7 @@import { AudioLines, Code2, FileText, ImageIcon, Video } from 'lucide-react'import { basenameOf, extensionOf, resolveInRoot } from '@/lib/coworkPreview'import type { CoworkTurn } from '@/types/coworkSession'+import { isRecordedShellCall } from '@/lib/agentTools'/*** Artifacts a run produced, derived from its `write`/`edit` tool calls@@ -135,9 +136,9 @@ const pathFromInput = (input: unknown): string | undefined => {const PATH_TOKEN_RE = /"([^"]+)"|'([^']+)'|(\S+)/g/**- * Artifact paths a `bash` turn produced, recovered from its command and output.+ * Artifact paths a `shell` turn produced, recovered from its command and output.*- * `write` results name their file directly; `bash` does not. Two signals, one+ * `write` results name their file directly; `shell` does not. Two signals, one* rule:** 1. A path the command names explicitly (yt-dlp `-o out.mp4`, `ls -lh@@ -244,7 +245,7 @@ export function artifactsFromTurns(if (!path) continueconst artifact = artifactFor(path)if (artifact) byPath.set(path, artifact)- } else if (turn.name === 'bash') {+ } else if (isRecordedShellCall(turn.name ?? '')) {// Files made by shell commands (downloads, ffmpeg renders) carry no// `write` result; recover them from the command + output pair.const command =diff --git a/web-app/src/lib/coworkMonitor.ts b/web-app/src/lib/coworkMonitor.tsindex 5eecfa709..9ecb97cdc 100644--- a/web-app/src/lib/coworkMonitor.ts+++ b/web-app/src/lib/coworkMonitor.ts@@ -8,7 +8,7 @@ import type { MonitorView } from '@/types/coworkSession'** The watcher itself runs in Rust (`tools/monitor.rs`, reached through the* plugin's guest-js): it tails the file, evaluates the condition scripts under- * the same OS sandbox `bash` gets, and streams every match back as a+ * the same OS sandbox `shell` gets, and streams every match back as a* `MonitorUpdate`. What lives here is the client half: the transcribed schema* (like `task`/`todo`), and the bookkeeping that turns updates into inbox pings* so a match reaches the model as the same `<SYSTEM>` note a finished subagentdiff --git a/web-app/src/lib/coworkPrompt.ts b/web-app/src/lib/coworkPrompt.tsindex 2f68e8b37..f373d8c73 100644--- a/web-app/src/lib/coworkPrompt.ts+++ b/web-app/src/lib/coworkPrompt.ts@@ -61,7 +61,7 @@ export type CoworkPromptOptions = {* is the workspace root that relative paths resolve against (#8882). */readOnlyFolder: string | nullplanMode: boolean- /** False when no OS sandbox enforces, in which case `bash` is not offered. */+ /** False when no OS sandbox enforces, in which case `shell` is not offered. */bashAvailable: booleansubagentNames: string[]/** Whether `web_search`/`web_fetch` are advertised this run. */@@ -152,7 +152,7 @@ function workspaceBlock(opts: CoworkPromptOptions): string {lines.push('','Shell commands are unavailable on this machine: no OS sandbox is present to',- 'confine them, so the `bash` tool is not offered. Use the file tools instead.'+ 'confine them, so the `shell` tool is not offered. Use the file tools instead.')}return lines.join('\n')diff --git a/web-app/src/lib/coworkRunner.ts b/web-app/src/lib/coworkRunner.tsindex 728f6ba58..a1bd3d253 100644--- a/web-app/src/lib/coworkRunner.ts+++ b/web-app/src/lib/coworkRunner.ts@@ -101,7 +101,7 @@ export function releaseHandle(sid: string, handle: RunHandle): void {* Stop a session's run: the model stream, the tool dispatch loop, every nested* subagent, and any question the user was being asked.*- * `abortRun` unwinds only the JS side; a running or backgrounded `bash` child+ * `abortRun` unwinds only the JS side; a running or backgrounded `shell` child* is killed separately by the Stop handler via `cancelAgentThreadBash`, which* reaps the session's shells in Rust (`proc::kill_thread`).*/diff --git a/web-app/src/lib/coworkSubagent.ts b/web-app/src/lib/coworkSubagent.tsindex 0c18a635e..6ad32498f 100644--- a/web-app/src/lib/coworkSubagent.ts+++ b/web-app/src/lib/coworkSubagent.ts@@ -456,6 +456,24 @@ export function injectInputs(return s}+/**+ * A list naming the shell's old name would silently give the child no shell,+ * so it is refused with the rename, as the Rust port does. `where` names the+ * list the model can actually fix.+ */+function renamedShellError(+ list: string[] | null | undefined,+ where: string+): { error: string } | undefined {+ const old = list?.find((t) => t.trim().toLowerCase() === 'bash')+ if (old === undefined) return undefined+ return {+ error:+ `${where} names \`${old.trim()}\`, which matches nothing: the shell tool is ` ++ 'now `shell`. Rename it to `shell` for it to apply.',+ }+}+/*** The child's effective allowlist: the definition's list, narrowed by the* call-site list, narrowed by what the parent itself can call.@@ -471,6 +489,10 @@ export function intersectAllowedTools(request: string[] | null | undefined,parentTools: string[]): { tools: string[] | null } | { error: string } {+ const renamed =+ renamedShellError(definition, "the subagent definition's allowed_tools") ??+ renamedShellError(request, 'allowed_tools')+ if (renamed) return renamedconst parent = new Set(parentTools)const withSkills = (tools: string[]) => {const out = [...tools]@@ -515,6 +537,12 @@ export function resolveSubagent(parentTools: string[]): ResolvedSubagent | { error: string } {const saved = definitions.find((d) => d.name === req.name)+ // With no saved definition the list came from the model's own call, so a+ // stale entry is reported as that, not as a definition's.+ if (!saved) {+ const renamed = renamedShellError(req.allowed_tools, 'allowed_tools')+ if (renamed) return renamed+ }const narrowed = intersectAllowedTools(saved ? saved.allowed_tools : (req.allowed_tools ?? null),// An inline allowlist *is* the ephemeral agent's definition, so it is not@@ -705,7 +733,7 @@ export async function runSubagent({workspacePath: opts.system.workspacePath,readOnlyFolder: opts.system.readOnlyFolder,- bashAvailable: opts.system.bashAvailable && 'bash' in tools,+ bashAvailable: opts.system.bashAvailable && 'shell' in tools,// Derived, not passed: the intersection above may have dropped them.webSearch: 'web_search' in tools,environment: opts.system.environment,diff --git a/web-app/src/lib/coworkTools.ts b/web-app/src/lib/coworkTools.tsindex fdad20a7f..373e40e0a 100644--- a/web-app/src/lib/coworkTools.ts+++ b/web-app/src/lib/coworkTools.ts@@ -20,7 +20,7 @@ import {export const PLAN_DENIED_TOOLS = new Set(['write','edit',- 'bash',+ 'shell','memory_write','skill_write','task',@@ -170,7 +170,7 @@ function taskTool(subagentNames: string[]): Tool {type: 'array',items: { type: 'string' },description:- "Optional tool allowlist. OMIT to give the subagent the parent's full toolset (the usual choice -- one that runs tests needs bash, one that edits needs write). Provide a list ONLY to restrict it; for a saved subagent it further narrows that subagent's own tools (never widens). An empty list is treated as omitted.",+ "Optional tool allowlist. OMIT to give the subagent the parent's full toolset (the usual choice -- one that runs tests needs shell, one that edits needs write). Provide a list ONLY to restrict it; for a saved subagent it further narrows that subagent's own tools (never widens). An empty list is treated as omitted.",},},required: ['name', 'task'],diff --git a/web-app/src/lib/coworkTransport.ts b/web-app/src/lib/coworkTransport.tsindex 202bcbfa1..42a0fe485 100644--- a/web-app/src/lib/coworkTransport.ts+++ b/web-app/src/lib/coworkTransport.ts@@ -115,7 +115,7 @@ export class CoworkChatTransport extends CustomChatTransport {* The set actually advertised this run, for narrowing a subagent's tools.** A child's allowlist intersects with this rather than with the full built-in- * list, so plan mode and a withheld `bash` propagate to children for free.+ * list, so plan mode and a withheld `shell` propagate to children for free.*/get advertisedTools(): Record<string, Tool> {return this.frozenTools ?? this.toolsdiff --git a/web-app/src/lib/custom-chat-transport.ts b/web-app/src/lib/custom-chat-transport.tsindex 3573f2cb9..9becf8a9d 100644--- a/web-app/src/lib/custom-chat-transport.ts+++ b/web-app/src/lib/custom-chat-transport.ts@@ -1127,7 +1127,7 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {// The main chat offers exactly one built-in agent tool: the sandboxed// shell, with no network. The full toolset lives in Cowork. Schemas come// from Rust so they are never re-typed here, and `getAgentToolSchemas`- // already withholds bash when no sandbox backend can confine it.+ // already withholds shell when no sandbox backend can confine it.try {for (const schema of await getAgentToolSchemas()) {if (!CHAT_AGENT_TOOL_NAMES.has(schema.function.name)) continue@@ -1742,7 +1742,7 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {/*** Static instruction for the one built-in tool chat offers: the sandboxed- * shell. Empty when no sandbox backend enforces, because bash is then+ * shell. Empty when no sandbox backend enforces, because shell is then* withheld too — stating limits for a tool that is not offered would only* confuse the model, and an empty string keeps the prompt prefix stable.*/@@ -1770,7 +1770,7 @@ export class CustomChatTransport implements ChatTransport<UIMessage> {// them by having a command refused.return ['# Shell',- 'bash runs commands in an isolated scratch workspace under an OS',+ 'shell runs commands in an isolated scratch workspace under an OS','sandbox: it starts there, can only write there, and cannot read files',"in the user's home directory. The workspace belongs to this",'conversation alone and is deleted with it, so do not keep anything',diff --git a/web-app/src/lib/toolPresentation.ts b/web-app/src/lib/toolPresentation.tsindex 0827df9df..ac6e3785e 100644--- a/web-app/src/lib/toolPresentation.ts+++ b/web-app/src/lib/toolPresentation.ts@@ -1,5 +1,6 @@import type { ToolUIPart } from 'ai'import type { ToolOrigin } from './toolOrigin'+import { isRecordedShellCall } from '@/lib/agentTools'/** The call is still being written or executed: no result yet. */export const isToolRunning = (state: ToolUIPart['state']) =>@@ -13,7 +14,7 @@ export type ToolCallBar =| { variant: 'search'; query: string; count?: number }| { variant: 'address'; url: string }| { variant: 'documents'; query: string; count?: number; fileCount?: number }- /** `bash`, presented as a terminal. */+ /** `shell`, presented as a terminal. */| { variant: 'terminal'; command: string }/*** The workspace tools. `target` is whatever the call is really about -- a path@@ -127,7 +128,7 @@ export function describeNativeToolCall(}}if (origin.kind === 'agent') {- if (toolName === 'bash') {+ if (isRecordedShellCall(toolName)) {return {variant: 'terminal',command: asString(args.command),@@ -165,6 +166,8 @@ export type BashOutput = {truncated: boolean/** The OS sandbox refused something; explains the limits that applied. */sandboxNote?: string+ /** Config problems the call surfaced, e.g. a hook matcher on a renamed tool. */+ configNotes: string[]}/** Global: the exit marker is not always last, so every match is considered. */@@ -172,9 +175,11 @@ const EXIT_LINE = /\n?\[exit (-?\d+)\]/gconst SIGNAL_LINE = /\n?\[terminated by signal\]/const TRUNCATION_NOTICE = /\n?\[output truncated[^\]]*\]/const SANDBOX_NOTICE = /\n?\[sandbox: ([^\]]*)\]/+/** Line-anchored: the notice names a config path, which may contain `]`. */+const CONFIG_NOTICE = /\n?^\[hook config: (.*)\]$/gm/**- * Split `bash`'s `[exit N]` / `[terminated by signal]` status and its trailing+ * Split `shell`'s `[exit N]` / `[terminated by signal]` status and its trailing* notices off its output (see the tool description in `schema.rs`), so the* terminal can show a status of its own instead of leaving markers in the* scrollback. Absent or partial markers are normal: the run may still be going.@@ -194,6 +199,7 @@ export function parseBashOutput(output: unknown): BashOutput {const truncated = TRUNCATION_NOTICE.test(text)const signaled = SIGNAL_LINE.test(text)const sandboxNote = text.match(SANDBOX_NOTICE)?.[1]+ const configNotes = [...text.matchAll(CONFIG_NOTICE)].map((m) => m[1])// The last marker is the real one: a command can echo `[exit 0]` itself.const exits = [...text.matchAll(EXIT_LINE)]const exitMatch = exits.at(-1)@@ -203,6 +209,7 @@ export function parseBashOutput(output: unknown): BashOutput {.replace(SIGNAL_LINE, '').replace(TRUNCATION_NOTICE, '').replace(SANDBOX_NOTICE, '')+ .replace(CONFIG_NOTICE, '')return {text: body.replace(/\s+$/, ''),@@ -210,6 +217,7 @@ export function parseBashOutput(output: unknown): BashOutput {signaled,truncated,sandboxNote,+ configNotes,}}diff --git a/web-app/src/locales/en/settings.json b/web-app/src/locales/en/settings.jsonindex e43b32bf7..8a06d65a1 100644--- a/web-app/src/locales/en/settings.json+++ b/web-app/src/locales/en/settings.json@@ -210,7 +210,7 @@"shell": "Shell Commands","shellChecking": "Checking for a sandbox...","shellSandboxed": "Commands run confined by {{backend}}: they can only write inside the session workspace, and files in your home folder are not readable.",- "shellUnavailable": "No sandbox is available on this system, so the bash tool is not offered. Commands are never run unconfined.",+ "shellUnavailable": "No sandbox is available on this system, so the shell tool is not offered. Commands are never run unconfined.","network": "Allow Network Access","networkDesc": "Let Cowork commands reach the network, for things like installing packages or fetching a repository. On by default. The main chat's shell never has network access.","openFolder": "Open Folder",diff --git a/web-app/src/routes/cowork.tsx b/web-app/src/routes/cowork.tsxindex 84e982951..7c7dde267 100644--- a/web-app/src/routes/cowork.tsx+++ b/web-app/src/routes/cowork.tsx@@ -1401,7 +1401,7 @@ function CoworkPage() {const handleStop = useCallback(() => {// Aborting the JS run only discards the pending tool result; a running or- // backgrounded bash keeps executing until this kills the session's shells.+ // backgrounded shell keeps executing until this kills the session's shells.if (session?.id) {abortRun(session.id)void cancelAgentThreadBash(session.id)