User Shell Plugin
This plugin contributes the shell command: a user types !npm test (or
!git status, !ls build/) in the composer and the command runs directly
in the conversation's workspace. There is no model call and no approval
prompt. Design: doc/core-dev/design/user-shell-commands.md.
It is a builtin, not a config-listed plugin. Do not add it to
plugins:. Operators switch the feature withtools.user_shell.
What a run is
- It runs under the same execution strategy the agent's
shelltool uses in this conversation: the same isolated workspace or light sandbox, the same mounts and network policy. With direct execution it runs on the host, as the agent's commands do. - It runs as a foreground background process (
origin: "user",provisional: true): the transcript gets the usualplugin.background.process_started/process_finishedcard events at once, and the conversation is busy until the run ends. While it runs, a second!and a new message are refused (the turn route answers 409). - Stop is
POST /ui/background-processes/{id}/kill. Move to background isPOST /ui/background-processes/{id}/background: the run keeps going, the conversation is free, and the agent can wait for it withbg_waitand read its log withtail/rg. - After
tools.shell_timeoutseconds in the foreground, the run is moved to the background whenbackground_processes.auto_background_on_timeoutis on, and killed otherwise. - Every run starts in the directory the conversation's previous
!run ended in (the workspace root for the first; POSIX shells only, seeplugins/user_shell/cwd.py; theuser_shell_runs.cwdcolumn holds each run's start directory and the invoke result'sdata.cwddescribes it), with stdin closed and no TTY, and withPAGER=cat,GIT_PAGER=cat,GIT_TERMINAL_PROMPT=0,TERM=dumbandCODUMENTOR_USER_SHELL=1in its environment. - A program that needs a terminal is refused before it starts (
rejected, reasoninvalid_arguments, with a hint):vim/vi/nvim/nano/emacs,htop,watch, a pager anywhere in the command (less,more,most—git log | lessis told to drop the| less),man,topwithout-b, and a bare REPL as the first word (python/python3,node,psql,mysql,sqlite3,irbwith no script or query;ssh hostwith no remote command). A REPL fed by a pipe or redirect is left alone. UX, not security: anything that slips past reads EOF. - Run facts. The card events (
process_started,process_finished) and the REST summaries (/kill,/background, the list) carryrun_facts, the facts an approval dialog shows, computed from the strategy the run spawned under (shell_sandbox_request.shell_run_facts):{strategy, sandbox: none|light|isolated, sandboxed, network, sandbox_unavailable, network_rerun}. Agent processes carry none. - Why it ended.
process_finishedand the summary carryend_reason:exited(any exit code),stopped(Stop,bg_kill),timeout(the foreground limit ormax_runtime_seconds),output_limitorinterrupted(shutdown, deleted conversation, lost process). For every background process, not only!runs. - Rerun with network.
arguments: {command, allow_network: true}runs the command with the per-run network escape the agent'snetwork: truegets — only whererun_facts.network_rerunis true (the light sandbox, offline run); elsewhere it isrejected/unavailable. The operator rules decide it as they decide the agent's networked call: a[network]-qualified deny rule (Shell(curl:) [network]) refuses it (forbidden), the user typing it is the approval.allow_networkis structured-only*: typed/shell …never sets it. - Download cards. When the process ends (exited, stopped or timed out), the files it wrote are found the way the shell tool finds its own (
tools/shell_file_effects.shell_file_effects: the session's overlay layer under isolation, the paths the command names otherwise) and reported on theonFileEffectshook;workspace_filesemits the usualplugin.file_links.file_writtencard (tool: "user_shell", plus the run'sprocess_id), turn-free. - Every run is bracketed by the
onUserShellRunStart/onUserShellRunEndhooks (codumentor.agent.user_shell_hooks), file effects or not;scm_pushannounces a commit the run made (plugin.scm_push.committed) and pins the workspace.
What the agent sees
- By default the agent sees each run on its next turn: one user-role message is stored in the conversation history right before the turn's own message, with a
[User ran a shell command]block per run — the command, its exit code, duration and output (truncated like the agent's own shell output; the full log behind aread_contenthint). A run moved to the background is listed with its process id;bg_waitreports it with its log path. Nothing is sent to the model on its own: a!run never starts a turn. - The card's Agent sees this toggle is
POST /ui/plugins/user_shell/runs/{process_id}/sharewith{"shared": false}(ortrue), until the next turn starts. After that the answer is final and the route returns 409. Every change, and the lock at the turn start, is aplugin.user_shell.share_changedevent (shared,share_locked) merged into the run's card, so a reload shows the same state. A new run starts with the share state the conversation's previous run had (first run: shared), and when that remembered state is off the plugin emits oneshare_changed(shared: false) at spawn, since the spawn/finished events carry nosharedfield and an absent value reads "on". - The history message is tagged
synthetic_note: readers of "the user's last message" (memory recall, the memory curator, note placement) skip it.
Who may run it
Exactly the users who could have the agent run the same command:
- the access profile must allow the
shelltool (required_permissions); - reviewer-mediated conversations cannot;
- an operator
Shell(...)deny rule refuses the command and names the rule. Any other answer of the permission gate counts as approved — typing the command is the approval.
Configuration
tools:
user_shell: auto # auto | on | off
| Parameter | Type | Default | Description |
|---|---|---|---|
tools.user_shell | auto \ | on \ | off |
The builtin's own section takes only enabled:
user_shell:
enabled: true
Notes
- The command catalog (
GET /ui/commands?conversation_id=…) says whether!is available in that conversation, and why not, in theuser_shell.shellentry'savailability:capability_denied(profile without shell, mediated conversation) orunavailable(tools.user_shell: off, background processes disabled). Invoking it is refused with the same answer. - On a conversation that never ran a turn, under workspace isolation, the first
!builds the workspace the first turn would have built (and waits for it). - Clients invoke the stable id
user_shell.shellwitharguments: {command: "…"}(plusallow_network: truefor a network rerun); typed/shell <command>also works. Thecompletedresult carriesdata.process_id, the card's process id. !on a brand-new conversation:POST /ui/conversations, then the invoke with the new id; the run builds the workspace if needed.- Without workspace isolation a
!runs on the host like the agent's shell; the admin Server panel's posture notice names it ("the agent and users can run commands on this host"). Settools.user_shell: offto keep every command behind the agent's approval record. - Retrying the same
invocation_idnever runs the command twice. - It is
idle_only: refused while a turn is running or awaiting an approval.