pub struct Host { /* private fields */ }Implementations§
Source§impl Host
impl Host
Sourcepub fn sandboxed(
self,
settings: &Value,
home: &Path,
tmp: Option<&Path>,
) -> Self
pub fn sandboxed( self, settings: &Value, home: &Path, tmp: Option<&Path>, ) -> Self
Run this host’s shell commands isolated and contain its writes by settings (sandbox.*). home is the
user’s home, tmp the session temp dir seen as /tmp inside (None: a private /tmp per command).
Sourcepub fn sandboxed_with_mechanism(
self,
settings: &Value,
home: &Path,
tmp: Option<&Path>,
mechanism: Option<Mechanism>,
) -> Self
pub fn sandboxed_with_mechanism( self, settings: &Value, home: &Path, tmp: Option<&Path>, mechanism: Option<Mechanism>, ) -> Self
Host::sandboxed under mechanism instead of the strongest one that works here (tests run every backend
this way; None runs unisolated, as auto does when nothing works).
Source§impl Host
impl Host
Sourcepub fn guard_stats(&self) -> Vec<Value>
pub fn guard_stats(&self) -> Vec<Value>
Each file-hook guard’s statistics (fileHooks.stats()).
Sourcepub fn begin_turn(&self)
pub fn begin_turn(&self)
A new root turn began: per-turn guard times start from zero (fileHooks.beginTurn()).
Sourcepub fn cell_started(&self, lane: &str)
pub fn cell_started(&self, lane: &str)
A cell on lane is starting: the after-cell file hooks take their baseline picture if they have none.
Sourcepub fn recording_cell_writes(self, on: bool) -> Self
pub fn recording_cell_writes(self, on: bool) -> Self
Record what each cell writes through checked writes, for Host::take_cell_writes (off by default).
Sourcepub fn take_cell_writes(&self, lane: &str) -> Vec<CellWrite>
pub fn take_cell_writes(&self, lane: &str) -> Vec<CellWrite>
The files lane’s cell wrote through checked writes, with their texts (and forget them).
Sourcepub fn cell_ended(&self, lane: &str)
pub fn cell_ended(&self, lane: &str)
A cell on lane ended: the after-cell file hooks check what it changed, in the background.
Sourcepub fn take_pending(&self, lane: &str) -> Option<String>
pub fn take_pending(&self, lane: &str) -> Option<String>
Findings of after-cell checks not yet shown to lane (and forget them), for its next cell result.
Sourcepub fn new(
cwd: impl Into<PathBuf>,
jobs_dir: impl Into<PathBuf>,
spill_dir: impl Into<PathBuf>,
guard: Box<dyn Guard>,
) -> Self
pub fn new( cwd: impl Into<PathBuf>, jobs_dir: impl Into<PathBuf>, spill_dir: impl Into<PathBuf>, guard: Box<dyn Guard>, ) -> Self
cwd is where commands run; job spill files go to jobs_dir/<id>.log, blocking-bash spill files to
spill_dir/pi-bash-<hex>.log (TS: the OS temp dir).
Sourcepub fn with_base_env(self, env: Vec<(String, String)>) -> Self
pub fn with_base_env(self, env: Vec<(String, String)>) -> Self
Every command (blocking bash, shell jobs, the sandbox’s allowlisted variables) starts from env instead of
this process’s environment, and the shell and the sandbox launcher are found on its PATH: a session’s
commands see the session’s environment, never the server’s. Call before Host::sandboxed.
Sourcepub fn with_env(self, env: Vec<(String, String)>) -> Self
pub fn with_env(self, env: Vec<(String, String)>) -> Self
Every command (blocking bash and shell jobs) runs with env over the inherited environment, as
withShellEnv(operations, laneWorkspace(lane).env) runs a worktree subagent’s.
Sourcepub fn sharing_jobs(self, session: &Host) -> Self
pub fn sharing_jobs(self, session: &Host) -> Self
This host’s shell jobs join session’s one table (TypeScript’s single ShellJobs for every lane): the root
lane lists them, the root turn’s abort cancels them, their ends are announced and journaled by the session’s
hooks. The jobs keep running after this host is dropped (they are the session’s).
Sourcepub fn with_shell_path(self, shell_path: Option<String>) -> Self
pub fn with_shell_path(self, shell_path: Option<String>) -> Self
Commands run under shell_path (the shellPath setting), resolved for each command as TypeScript’s
createLocalBashOperations({ shellPath }) does: a path that does not exist fails the command.
Sourcepub fn with_journal(
self,
journal: Arc<dyn DocumentStore>,
) -> Result<Host, String>
pub fn with_journal( self, journal: Arc<dyn DocumentStore>, ) -> Result<Host, String>
Makes shell jobs durable: restores the jobs journal from journal and journals every start and end from now
on. A job the journal lists as running is settled from its process: followed again while its keeper runs,
completed with the exit status the keeper wrote, or lost when the process ended without one. Records
without a process (TypeScript journals) read as interrupted, as there. Call once, before the first request.
Sourcepub fn release_jobs(&self)
pub fn release_jobs(&self)
Hands the running jobs to the next owner of the journal: this host stops following and journaling them, and dropping it no longer stops them (a worker handing over to its successor). Without a journal it changes nothing but the drop.
A stop already asked for is carried out first, so the successor does not keep following a job the person cancelled. The release is decided under the jobs lock, as each job’s end and each stop request are: a job either ends here (and the journal says so) or is the successor’s, and a later stop here returns at once.
Sourcepub fn stop_jobs(&self)
pub fn stop_jobs(&self)
Stops every running job and waits until each has ended (worker shutdown). Dropping the host does the same
unless Host::release_jobs was called. Nothing is reported of them.
Sourcepub fn on_job_end(&self, ends: JobEnds)
pub fn on_job_end(&self, ends: JobEnds)
Who hears of every job’s end (onEnd): the completion events of jobs nobody waited on.
Sourcepub fn set_roots(&self, roots: RootOf)
pub fn set_roots(&self, roots: RootOf)
Where a new job’s usage root comes from (host.rootOf(caller)).
Sourcepub fn cancel_root(&self, root: &str)
pub fn cancel_root(&self, root: &str)
cancelRoot: Esc aborted a root turn: stop every job started under it (their ends are not announced).
Sourcepub fn job_waiters(&self, id: &str) -> usize
pub fn job_waiters(&self, id: &str) -> usize
How many callers are waiting on job id now (a waiter that sees the job end gets its result inline, so
the end is not announced).
Sourcepub fn job_records(&self, lane: &str) -> Vec<JobRecord>
pub fn job_records(&self, lane: &str) -> Vec<JobRecord>
Every job’s record, newest first (ShellJobs.list()), as lane may see them: the root lane every job, another
lane its own.
pub fn running_jobs(&self) -> usize
Sourcepub fn running(
&self,
lane: &str,
excluded: &dyn Fn(Option<&str>) -> bool,
) -> usize
pub fn running( &self, lane: &str, excluded: &dyn Fn(Option<&str>) -> bool, ) -> usize
Running jobs of lane whose root excluded does not exclude (running).
Sourcepub fn handle_lane(
&self,
lane: &str,
kind: &str,
payload: Map<String, Value>,
signal: &Signal,
) -> Result<Value, String>
pub fn handle_lane( &self, lane: &str, kind: &str, payload: Map<String, Value>, signal: &Signal, ) -> Result<Value, String>
A request of lane’s kernel: its jobs belong to it (and to its root turn), and a lane other than the root’s
sees only its own.
Sourcepub fn user_bash(
&self,
command: &str,
signal: &Signal,
on_chunk: &mut dyn FnMut(&str),
) -> Result<Value, String>
pub fn user_bash( &self, command: &str, signal: &Signal, on_chunk: &mut dyn FnMut(&str), ) -> Result<Value, String>
A user’s own command (RPC bash, the TUI’s !; AgentSession executeBash): the shell guard, then the
blocking bash, each cleaned output chunk passed to on_chunk as it arrives (bash-executor.ts onChunk, which
AgentSession streams as bash_execution_update).