ide
(alias: shell)v0.13.11Unix shell + filesystem worker — exec with denylist/timeout/output caps and background jobs; fs::ls|stat|mkdir|rm|chmod|mv|grep|sed|read|write with host jail, denylist, size caps, and sandbox-target forwarding
Install
iii call compose::add worker=ide@0.13.11Run in your project with the iii engine running. Exact versions are immutable and digest-pinned.
skill doc
shell
The shell worker is the single door every agent uses to touch the OS: run a
build, call a CLI, read a file, list a directory. Routing it all through
shell::* and shell::fs::* keeps a denylist, timeouts, output
caps, and an optional host-root jail (unjailed by default — see Boundaries)
in one enforceable place. Both surfaces take an
optional target field that forwards the call into a live iii-sandbox
microVM, so the same denylist gates host and sandbox execution alike.
Host-targeted shell::exec is not an isolation boundary. The denylist is a
regex tripwire on argv.join(" "), and any interpreter (sh,
node, python3) can construct any forbidden token at runtime to bypass it.
Run untrusted input with target: { kind: "sandbox", sandbox_id }. Prefer the
shell::fs::* backends over exec-ing ls/stat/grep/rg: they stay
in-process, honor fs.host_roots when it's configured, and return
structured results.
Sandbox forwarding (and shell::fs::* into a VM) requires the iii-sandbox
worker; iii call compose::add worker=ide does not pull it in. To surface shell::* to LLM
agents, pair with the skills worker.
When to Use
- Run a one-shot command and block for its full output:
git status,wc,head, a quick compile probe (shell::exec). - Kick off long work (build, watcher, wide grep) without blocking the turn,
observe its completion, then read its output (
shell::exec_bg+shell::on-job-finished+shell::status). - Survey or terminate in-flight background jobs (
shell::list,shell::kill). - List, stat, or read files with structured output instead of shelling out to
ls/stat/cat(shell::fs::ls,shell::fs::stat,shell::fs::read). - Search or rewrite across a tree without spawning
rg/sed(shell::fs::grep,shell::fs::sed). - Create, move, remove, or re-permission paths (jailed only if
fs.host_rootsis set) (shell::fs::mkdir,shell::fs::mv,shell::fs::rm,shell::fs::chmod). - Persist a generated artefact, or bootstrap files into a sandbox, by streaming
bytes to a path (
shell::fs::writewith atarget).
Boundaries
- Host
shell::execis not a security sandbox: the denylist is bypassable by any interpreter. Run untrusted commands withtarget: sandbox(needsiii-sandbox). shell::fs::*honorsfs.host_rootsas a jail WHEN it's set — empty (the shipped default) means unjailed, confined only byfs.denylist_paths— and always refuses denylisted paths regardless; paths must be absolute (unless jailed, where a relative path resolves against the primary root) and symlinks are never followed.- In a harness session every call carries a trusted
fs_scope.root. Under theworkspaceboundary (harnessfilesystem_boundary),coder::*,shell::fs::*and an execcwdrefuse paths outside that root and the session's grants (C220/S220,C215/S215); underconfigured_rootsthe root is only the default directory for relative paths. - A host
shell::execrunninggit worktree addthat creates a worktree and names its directory on the command line moves the session there, for the rest of the turn and later turns. Run it as the only call of its step; use relative paths in the new worktree only after the session-context note confirms the move (calls already written in the same step are re-anchored). Underworkspacethe old checkout leaves scope and the new worktree needs no grant; underlandlockit must be where the exec can write (root, grants,fs.exec_writable).git worktree removeof the worktree you are rooted in returns the session to the main checkout, andgit worktree moveof it takes you along. Underlandlockthat way back needs the worktree's parent and the main checkout writable for the exec; otherwise git empties the worktree, unregisters it and fails, and you stay in the empty directory. For a worktree meant for a child or a side look, passfollow_worktree: falseon the call: a worktree it adds does not move you (removing or moving the one you are rooted in still takes you back or along).worktree::createdoes not move you either. - With
fs.exec_confinement: landlock, a session's hostshell::exec/exec_bgcan write only under its root, its grants, the repository's git dir andfs.exec_writable(/tmp,/dev, caches, toolchains); reads stay open. Without Landlock such a call fails closed withS222. - Sandbox-backed background jobs cannot be hard-killed:
shell::killflips the record but the in-VM process runs until itstimeout_ms(orsandbox::stop). - Not for inlining file bytes into an LLM tool result:
shell::fs::read/writemove bytes over channels; use theharnessworker'sharness::fs::read_inlinewrapper for inline reads on the web surface. - No batch or glob form for single-path ops (
mv,rm,stat, …); loop in the caller. - Not a package manager, editor, or migration tool; for SQL use the
databaseworker.
Functions
shell::exec: run a command in the foreground and return its stdout, stderr, exit code, and timing; blocks until exit or timeout. Sandbox execution is fully valid (target: { kind: "sandbox", sandbox_id }); only the host-only override fields —stdin(string piped to the program's stdin, then EOF), pluscwd/env— are rejected withS210when supplied on a sandbox target, because the sandbox exec protocol does not forward them.shell::exec_bg: spawn a command as a background job and return ajob_idimmediately. Host-targeted jobs run until they exit,shell::killterminates them, orharness::stopstops the session that started them — unbounded by default, capped only when the operator sets a positivemax_bg_timeout_ms(default0= unbounded), after which a runaway job is killed and its status becomeskilled. Sandbox jobs honortimeout_ms. Same optional host-onlystdinasshell::exec. Host commands run without a terminal: one that needs it (a password or host-key prompt) fails, and a job that stays stopped for 30 seconds is killed with the reason in its stderr.shell::status: fetch one job's full record: state, exit code, and captured stdout/stderr. A running host job shows the last 8 KiB of each stream, flagged truncated when there is more, and the kept output once it ends. A missing id (never existed or aged out) returns anS211("no such job") error.shell::list: enumerate current jobs as lightweight summaries (no argv, stdout, or stderr).shell::kill: terminate a running background job byjob_id.shell::config-status(operator/automation only — not agent-callable): report the last hot-reload outcome —last_outcome(applied/rejected),last_error, andrejected_reloads(count since boot). A rejected outcome or non-zero count means a stored config was refused and shell is enforcing an older policy than the central store. Takes no arguments.shell::fs::ls: list a directory's entries with structured metadata.shell::fs::stat: read one path's metadata (size, mode, symlink flag).shell::fs::mkdir: create a directory, optionally with missing parents. Returns{ created: bool, path: string, already_existed: bool }.shell::fs::rm: remove a file or directory, optionally recursive. Returns{ removed: bool, path: string, was_present: bool }.shell::fs::chmod: change a path's mode, and optionally its uid/gid. Returns{ entries_changed: u64, path: string, recursive: bool }. Note: the field was renamed fromupdatedtoentries_changed— callers relying onupdatedmust migrate.shell::fs::mv: rename or move one path within the jail. Returns{ moved: bool, src: string, dst: string, overwrote: bool }.shell::fs::grep: recursive regex search across a tree, returning structured matches.shell::fs::sed: regex find-and-replace across one file or many.shell::fs::write: write a file. Simplest form is inline stringcontent(host target only):{ path, content: "file text" }, withmode(octal, default"0644") andparents: true. AContentRefobject incontentinstead streams large/staged payloads via a channel (temp file + atomic rename) and is required for sandbox targets. Batch form: passfiles: [{ path, content, mode?, parents? }, ...]to write several files in one host call; the response then carries per-filefiles: [{ path, bytes_written }](a single-file write leavesfilesempty).shell::fs::read: stream a file's bytes out through a channel.
Every shell::fs::* call accepts the same optional target as exec, so host
and sandbox share one wire shape; reads and writes move bytes over SDK channels
rather than inlining them.
Observable functions
The worker hosts four private event functions: observe them, never call
them. An agent observes through harness::observe
({ function_id, args?, filters?, once? }); a worker uses iii.observe.
shell::on-job-finished, args{ job_id? }: called once when a background job finishes, is killed, or fails, with{ job_id, argv, status, exit_code, started_at_ms, finished_at_ms, duration_ms }. Pass your ownjob_idtoshell::exec_bgand observe it before starting the job, or observe the returned one: an observer added after its job finished receives the event while the job is retained. Read the output withshell::status.shell::on-changed, args{ path, include_ignored? }: a system-level directory watch. Every change underpathreaches the observer, whoever made it:coder::*calls,shell::execside effects, or an editor outside the engine. Event:{ path, kind, root, dir, ignored }withkind∈created | modified | deleted,pathrelative toroot,dirtrue for directories (skip those when opening files). Events coalesce per path in a short window (create + write =created; deletion supersedes),.gitinternals are filtered, and delivery is fire-and-forget. Ignored paths (git-ignored, ordata/,config/,.iii/,node_modules/outside a repository) are not delivered unless the observer setsinclude_ignored: true: a wake on a project root would otherwise fire on the engine's own data writes. Read content on demand viacoder::read-file; the event carries none.shell::on-git-changed, args{ path }: one call per ~200 ms batch when the repositorypathsits in changes state, with{ path, worktree?, git_dir?, common_dir?, changes }(head,index,refs,worktrees,repository).shell::turns::on-changed, no args (filter oninput.session_id):{ session_id }when a session's change history (shell::turns::list) changes.
Code files (coder::*)
The shell worker also serves the coder::* code-file surface (formerly a
standalone worker) over the same jail (fs.host_roots): coder::info
(discover roots/caps first), coder::read-file (windowed + batch reads),
coder::search (add respect_gitignore: true to skip ignored files,
fuzzy_paths: true to rank path matches like an editor's quick open),
coder::list-folder, coder::tree, and the batched
coder::create-file / coder::update-file / coder::delete-file /
coder::move. Prefer these structured ops over editing files through
shell::exec. They return C2xx error codes (distinct from shell::*'s
S2xx); protected paths are the shared code.non_accessible_globs.
coder::list-templates lists the worker templates (code.templates: a local
dir, or a cached git clone) with their language and the compose containers
they need.
coder::scaffold-worker { template, name, directory?, operation_id?, start_after? }
writes one into a missing or empty folder whose last segment is name
(default workers/<name>), all or nothing, then adds it to the stack in the
same call (compose::add with the worker, its start_after and the
requires the stack lacks): a name the stack already has fails C235
before any write, and the result carries operation_id and started, or
start_error with the files kept. start: false writes the files only and
returns compose_add, the compose::add payload to send whole, adding
start_after to its entry and missing requires as more entries (never the
bare worker string form, which drops the scripts). It adds to the stack
the ide runs in, so a harness session without compose::add, or whose
compose::add the approval gate would not allow outright, gets the files
only, with a note (an explicit start: true is refused there); its own
compose::add then goes through approval as usual.