execute
Run privileged commands or pipelines locally or on remote hosts after terminal approval; the call blocks until a human responds and returns per-stage output and exit codes.
Instructions
Execute a command (or multi-stage pipeline) on a sudo-proxy host after a human approves it at that host's terminal. Provide argv for a single command or pipeline for piped stages (e.g. [["ls", "/tmp"], ["wc", "-l"]]); host targets a remote daemon started via start_server (omit for localhost). Unprivileged commands on the local machine are refused — use your Bash tool, which applies the same controls. timeout is in milliseconds (max 600000); it defaults to 120000 for privileged commands but is opt-in for unprivileged ones (omitted = wait as long as the daemon needs, so an approved-but-slow command is not falsely timed out). Invisible/format characters (e.g. emoji variation selectors, zero-width or bidi controls) are removed from description before it is shown to the approver. Blocks until the human answers, then returns the final stage's stdout plus per-stage stderr and exit codes. Errors: 'Request denied by user.' if the human declines, a timeout error if unanswered within 60s, and 'sudo-proxy is not running' if the daemon is down — call start_server first.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "execute"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| env | No | Environment variables | |
| argv | No | Command as argument array | |
| host | No | Target host (omit for localhost) | |
| plan | No | Structured execution plan (advanced; mutually exclusive with `argv`/`pipeline`). A JSON object the daemon executes *directly* — no shell on the privileged path — and renders stage by stage at the approval prompt, so every real binary and per-stage privilege is visible. Prefer this over wrapping commands in `bash -lc`. Nodes are `op`-tagged, e.g. {"op":"exec","argv":["sysctl","-w","vm.mmap_rnd_bits=28"]} (one command); {"op":"pipe","stages":[{"op":"exec",...},{"op":"exec",...}]} (= `|`); {"op":"run","steps":[...]} (≈ `&&`: run in order, stop on first failure); {"op":"seq","steps":[...]} (≈ `;`: run every step regardless of exit); {"op":"alt","steps":[...]} (≈ `||`: run until one succeeds); {"op":"run-as","as":"root","do":{...}} or {"op":"run-as","as":"user","name":"alice","do":{...}}; {"op":"redirect","stream":"stdout","target":{"to":"file","path":"/tmp/o","mode":"truncate"},"do":{...}}; {"op":"setenv","key":"LANG","value":"C","do":{...}}; {"op":"chdir","dir":"/srv","do":{...}}; {"op":"shell","shell":"bash","script":"..."} (explicit opaque escape hatch; an exec whose program is a shell, e.g. ["sh","-c",...], also behind a wrapper such as ["env","sh","-c",...], or an inline-code interpreter such as ["python3","-c",...], is flagged opaque the same way, and a daemon in no_shell mode rejects them all — prefer run/seq/alt/pipe/redirect over a shell). Rules: paths in chdir / redirect / with-stdin-from must be absolute; a stream may be redirected at most once along any path; with-stdin-from is allowed only on the first stage of a pipe; env keys must be shell variable names; run-as names a user, never a `#uid`. Unknown keys are rejected at any depth (`unknown field …`), never silently ignored. Semantics to plan around: a `run` (`&&`) runs its steps in order and STOPS at the first failing step — the earlier steps have already run and their effects are committed, so make early steps idempotent (or put the riskiest / privileged step first) and do not blindly resubmit a failed plan; the response's per-stage exit codes show which steps ran (a skipped step reports exit -1) so you can resume from the failure instead. A `seq` (`;`) instead runs every step regardless of exit (a timeout / spawn failure still aborts). An `alt` (`||`) runs its steps until the first SUCCESS, continuing past failures — use it for `probe || fallback`. A privileged stage placed INSIDE a `pipe` cannot prompt for a sudo password; if it may need one, make it a standalone `run-as` stage rather than a pipe stage (or ensure passwordless sudo on the host). | |
| timeout | No | Timeout in milliseconds, max 600000. For privileged commands the default is 120000. For unprivileged commands the timeout is opt-in: if omitted, the call waits as long as the daemon needs (the 60s approval prompt and the executor's own bound still apply), so an approved-but-slow command is not falsely reported as timed out. Set it explicitly to bound either. | |
| pipeline | No | Pipeline of commands, each as an argument array. Use this for piped commands like [["ls", "/tmp"], ["wc", "-l"]]. | |
| requester | No | Optional self-identification of the AI requester (e.g. your model name), shown to the human approver. It is always shown as `ai:<value>`, so a request through this server is always disclosed as AI-originated. | |
| privileged | No | Privilege escalation (default: true) | |
| description | No | What this command does (shown in TUI prompt) | |
| forward_agent | No | Forward the local SSH agent to the command (unprivileged only). Requires the proxy session to have been started with `forward_agent: true`. Useful for `git clone` of private repos via SSH on a remote host. |