Skip to main content

Host

Struct Host 

Source
pub struct Host { /* private fields */ }

Implementations§

Source§

impl Host

Source

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).

Source

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

pub fn launcher(&self) -> Option<&Arc<Launcher>>

The launcher of a sandboxed host (for doctor and status lines).

Source§

impl Host

Source

pub fn guard_stats(&self) -> Vec<Value>

Each file-hook guard’s statistics (fileHooks.stats()).

Source

pub fn begin_turn(&self)

A new root turn began: per-turn guard times start from zero (fileHooks.beginTurn()).

Source

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.

Source

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).

Source

pub fn cwd(&self) -> &Path

Where commands run and relative paths resolve.

Source

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).

Source

pub fn cell_ended(&self, lane: &str)

A cell on lane ended: the after-cell file hooks check what it changed, in the background.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn on_job_end(&self, ends: JobEnds)

Who hears of every job’s end (onEnd): the completion events of jobs nobody waited on.

Source

pub fn set_roots(&self, roots: RootOf)

Where a new job’s usage root comes from (host.rootOf(caller)).

Source

pub fn cancel_root(&self, root: &str)

cancelRoot: Esc aborted a root turn: stop every job started under it (their ends are not announced).

Source

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).

Source

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.

Source

pub fn running_jobs(&self) -> usize

Source

pub fn running( &self, lane: &str, excluded: &dyn Fn(Option<&str>) -> bool, ) -> usize

Running jobs of lane whose root excluded does not exclude (running).

Source

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.

Source

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).

Trait Implementations§

Source§

impl Drop for Host

Source§

fn drop(&mut self)

Worker shutdown: stop every running job, unless they were released to the next owner.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl HostHandler for Host

Source§

fn handle( &self, kind: &str, payload: Map<String, Value>, signal: &Signal, ) -> Result<Value, String>

Auto Trait Implementations§

§

impl !RefUnwindSafe for Host

§

impl !UnwindSafe for Host

§

impl Forget for Host

§

impl Freeze for Host

§

impl Move for Host

§

impl Send for Host

§

impl Sync for Host

§

impl Unpin for Host

§

impl UnsafeUnpin for Host

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more