Skip to main content

HarnessWorkspace

Enum HarnessWorkspace 

Source
pub enum HarnessWorkspace {
    Fixed(PathBuf),
    PerRun(String),
}
Expand description

Where each attempt’s working directory comes from.

Variants§

§

Fixed(PathBuf)

Every attempt stands in this one directory, resolved and absolute. The form for a worker that serves exactly one tree.

§

PerRun(String)

Each attempt’s directory arrives in that attempt’s input, under this parameter name. The form for a worker whose jobs each name their own tree.

Implementations§

Source§

impl HarnessWorkspace

Source

pub fn for_attempt(&self, input: &Payload) -> Result<PathBuf, HarnessError>

This attempt’s working directory.

The fixed form ignores the input entirely. The per-run form reads the named parameter out of it and refuses — TERMINALLY, never falling back — when the input is not a JSON object, when the parameter is absent, when it is not a string, or when it is blank. Every one of those is a job that did not say where to work, and an agent that guesses stands in the launching process’s directory: invisible in the document, in the argv and in the log, which is the whole hazard the setting exists to close.

The path is returned as WRITTEN. Whether it is absolute, exists, and is a directory is the launching adapter’s check, kept there so one adapter’s refusal wording and one adapter’s spawn stay in the same place.

§Errors

Returns HarnessError::Configuration for every case above. That variant is the right one for the same reason it is right for a malformed env_pass: nothing was spawned, no frame was exchanged, and what is wrong is a value somebody WROTE — here in the workflow that dispatched the job rather than in the worker document. The next attempt reads the same input and meets the same wall, so the worker’s mapping of this variant to a TERMINAL failure is exactly what should happen.

Source

pub fn fixed(&self) -> Option<&Path>

The fixed directory, when this workspace is the fixed form.

For the callers that report a launch before any attempt exists — a worker’s startup narration has no input to resolve against, and saying “the directory this worker uses” of a per-run workspace would be stating a fact that does not exist.

Source

pub fn per_run(&self) -> Option<&str>

The parameter name, when the directory arrives with each job.

Source

pub fn prompt_for_attempt( &self, input: &Payload, reserved: &[&str], ) -> Result<String, HarnessError>

The prompt text this attempt’s input carries.

The activity input is a serialized Payload, not raw prompt text, so the decoding is deliberate:

  • Bytes that are not valid JSON → the raw UTF-8 text, unchanged (Payload is a dumb carrier that does not validate on construction).
  • JSON string → the inner string, so the agent receives the exact text a caller passed and a multi-line prompt survives verbatim.
  • JSON object → the ONE field that is not this workspace’s directory parameter and not one of the caller’s reserved parameter names, read by name. This is the shape an authored action produces: its input is an object keyed by parameter name even when it declares a single parameter, so an adapter that passed the object through handed the agent {"prompt":"…"} as its literal instructions.
  • Any other JSON value (array, number, boolean, null) → the raw JSON text: there is no field to read by, and inventing a projection would lose information.

reserved names every further input parameter the caller’s adapter reads for itself — a session parameter, say — so the prompt stays defined by SUBTRACTION: the prompt is whatever remains once every parameter the adapter already knows by name is removed. An adapter with no such parameters passes &[] and the rule is unchanged.

The object arm is read by NAME rather than by position because position is not carried on the wire — a JSON object has no order that survives serialization — and because the subtracted fields are exactly the fields whose names the adapter already knows. Subtracting them leaves exactly one field for every shape the checker admits, which is what makes this a total function rather than a guess.

§Errors

HarnessError::Protocol when the bytes are not UTF-8 at all. Otherwise HarnessError::Configuration — terminal, never retried — when an object carries no prompt field, carries more than one, or carries one that is not a string. Each is a call that did not state what to ask the agent, and an adapter that guessed would send an agent instructions nobody wrote.

Trait Implementations§

Source§

impl Clone for HarnessWorkspace

Source§

fn clone(&self) -> HarnessWorkspace

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HarnessWorkspace

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for HarnessWorkspace

Source§

impl PartialEq for HarnessWorkspace

Source§

fn eq(&self, other: &HarnessWorkspace) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for HarnessWorkspace

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, <T as TryFrom<U>>::Error>

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.