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
impl HarnessWorkspace
Sourcepub fn for_attempt(&self, input: &Payload) -> Result<PathBuf, HarnessError>
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.
Sourcepub fn fixed(&self) -> Option<&Path>
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.
Sourcepub fn per_run(&self) -> Option<&str>
pub fn per_run(&self) -> Option<&str>
The parameter name, when the directory arrives with each job.
Sourcepub fn prompt_for_attempt(
&self,
input: &Payload,
reserved: &[&str],
) -> Result<String, HarnessError>
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 (
Payloadis 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
reservedparameter 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
impl Clone for HarnessWorkspace
Source§fn clone(&self) -> HarnessWorkspace
fn clone(&self) -> HarnessWorkspace
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more