Skip to main content

Agent

Struct Agent 

Source
pub struct Agent {
    pub spec: AgentSpec,
    /* private fields */
}

Fields§

§spec: AgentSpec

Implementations§

Source§

impl Agent

Source

pub fn new(spec: AgentSpec) -> Self

Source

pub fn name(&self) -> &str

Source

pub fn fallback(&self) -> Option<&Agent>

The stand in, if one is configured.

Source

pub fn program(&self) -> &str

The program the template names, before any resolution. What somebody has to install when spar reports it missing.

Source

pub fn env_key(&self) -> String

The environment variable that points this agent’s binary somewhere else.

Source

pub fn resolve_bin(&self) -> Result<&Path>

SPAR_<NAME>_BIN first, then the template’s own program name on PATH or as an absolute path, then the preset’s search paths. Never guess silently: a miss reports every location tried, because a tool that quietly runs the wrong binary is worse than one that fails.

Source

pub fn render(&self, values: &Placeholders) -> Result<Vec<String>>

Substitute placeholders. A group whose placeholder is unset is dropped whole, so omitting model drops --model with it rather than passing an empty string that the CLI would reject or, worse, accept.

Source

pub fn supports_schema(&self) -> bool

True when the template has somewhere to put a schema, meaning the CLI can do structured output natively rather than being asked in the prompt.

Either form counts: a path for a CLI that reads the schema from disk, or the schema itself for one that takes it as an argument.

Source

pub fn extract(&self, stdout: &str) -> Result<String>

Source

pub fn ask( &self, prompt: &str, cwd: &Path, effort: Option<&str>, ) -> Result<String>

Source

pub fn ask_json<T: DeserializeOwned>( &self, prompt: &str, schema: &Value, cwd: &Path, effort: Option<&str>, ) -> Result<T>

Structured output through the CLI’s own mechanism when the template exposes one, otherwise by asking for JSON in the prompt and parsing it back out.

Source

pub fn review<T: DeserializeOwned>( &self, base: &str, prompt: &str, schema: &Value, cwd: &Path, effort: Option<&str>, ) -> Result<T>

Review the branch against base.

Deliberately generic. codex exec review was tried and rejected: it refuses a custom prompt alongside --base and returns prose regardless of --output-schema, so it cannot yield a machine checkable verdict. Running inside the worktree is what makes an agent repo aware, not a subcommand.

Trait Implementations§

Source§

impl Debug for Agent

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Agent

§

impl RefUnwindSafe for Agent

§

impl Send for Agent

§

impl Sync for Agent

§

impl Unpin for Agent

§

impl UnsafeUnpin for Agent

§

impl UnwindSafe for Agent

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