Skip to main content

Crate host

Crate host 

Source
Expand description

Host operations the Python kernel API calls (RLM-first core), served as a kernel::HostHandler.

Ported from the TypeScript session worker’s host handler (experimental/session-worker.ts), its blocking bash (ultron/rlm/host-bash.ts over core/bash-executor.ts) and host-owned shell jobs (ultron/rlm/shell-jobs.ts). read, write and edit run inside runtime.py; the host only answers their files.before_write check. Requests that need a model, subagents or durable stores are refused with not_available.

Shell jobs are durable (Host::with_journal): each runs under a small keeper shell in its own process group that writes the raw output to <id>.out and the exit status to <id>.exit, so the job does not depend on the worker that started it. The host follows those files into the cleaned, bounded spill file <id>.log and journals every start and end. A reopened worker settles each job the journal lists as running from what really happened: still running (the keeper is alive: it is followed again), completed with the status the keeper wrote, or lost (the process ended without one); never silently gone.

Modules§

bash_notes
Result conventions of the model’s bash (wave 38, from Mirror’s tools/bash_tool.rs):
cell
One cell’s tool result text: UltronRlmKernel.executeCell (experimental/session-worker.ts) over truncateToolOutput (ultron/rlm/output-truncation.ts) and maskCellOutputCounted (ultron/rlm/output-secrets.ts).
cell_writes
The files a cell wrote through the checked write()/edit() (files.before_write), with their text before and after, so the cell’s result can carry a diff of what it changed (the interactive mode’s expanded rlm cell). The text before is read when the write is proposed, while the file still holds it; at the cell’s end a write counts only when the file holds what was proposed. Files changed by other means (bash) are not seen here.
file_hooks
Generic file-write hooks for the RLM REPL (ultron/file-hooks.ts):
journal
The shell job journal (session value ultron.module/jobs) and job-done events, ported from ultron/rlm/shell-jobs.ts (#load, #persist, jobSummary, #fileTail) and experimental/session-worker.ts jobEvent.
loki_guard
Ultron’s built-in Loki guardrails (ultron/loki.ts LokiGuard), running the Rust Loki engine in-process instead of python loki.py:
sandboxed
Isolation for the host’s operations, from the sandbox crate.
secrets
Secret masking of cell output, ported from ultron/secrets.ts (SecretDetector over rlm/secret-patterns.json), ultron/rlm/output-secrets.ts (known secret values, ULTRON_MASK_SECRETS) and ultron/sensitive.ts.
shell
The shell commands run under (utils/shell.ts getShellConfig on Unix): the shellPath setting when it names an existing file (else the command fails with “Custom shell path not found: ”), else /bin/bash, else bash found on PATH, else sh. Every shell runs the command as <shell> -c <command>.
text
Output text handling shared by the blocking bash and shell jobs, ported from utils/ansi.ts (stripAnsi), utils/shell.ts (sanitizeBinaryOutput), core/tools/truncate.ts (truncateTail) and the streaming TextDecoder.
view_image
rlm.view_image host side, ported from ultron/rlm/view-image.ts over utils/image-process.ts, utils/image-resize-core.ts and utils/mime.ts: content-sniffed type, conversion of BMP to PNG, auto-resize to the model’s limits (Lanczos3, then the smaller of PNG and JPEG under the byte budget, then 3/4 steps), and the kernel’s short description. Photon (WASM) is replaced by the image crate, so resized or converted bytes differ from TypeScript’s; dimensions, type choice and limits do not.

Structs§

AllowAll
Host
JobEnd
A job that ended, as ShellJobs onEnd reports it: its record, whether a caller was waiting on it (the result came inline, so nothing is announced) and whether its root turn’s abort stopped it.

Constants§

JOB_MAX_ACTIVE
JOB_MAX_RETAINED
JOB_RETAINED_BYTES
JOB_TEXT_BYTES
PARENT_TOKEN_ENV
The verdict token of an ultron mcp --child server (ULTRON_PARENT_TOKEN), removed from every command’s environment.

Traits§

Guard
The before-write and before-shell guards (Loki). The default allows everything.

Functions§

not_available
sandboxed_argv
argv as it runs inside a sandbox: every sandbox clears the environment to its allowlist (bwrap --clearenv, env -i under unshare and in a Docker container), so the command’s own variables (a worktree subagent’s ULTRON_WORKTREE, ULTRON_PARENT_REPO, ULTRON_WORKTREE_BRANCH, PWD) are set inside, by env.

Type Aliases§

JobEnds
Sees every job end (not those stopped by the host’s shutdown).
RootOf
The usage root a job started by lane belongs to (host.rootOf(caller)): the root turn running on the root lane, or the root of the task that owns another lane.