Skip to main content

AgentDefinition

Struct AgentDefinition 

Source
pub struct AgentDefinition {
    pub kind: String,
    pub name: String,
    pub title: Option<String>,
    pub hide_title: bool,
    pub description: Option<String>,
    pub category: Option<String>,
    pub inputs: Option<Vec<String>>,
    pub outputs: Option<Vec<String>>,
    pub configs: Option<AgentConfigSpecs>,
    pub global_configs: Option<FnvIndexMap<String, AgentConfigSpec>>,
    pub native_thread: bool,
    pub new_boxed: Option<fn(ma: ModularAgent, id: String, spec: AgentSpec) -> Result<Box<dyn Agent>, AgentError>>,
}
Expand description

The definition (blueprint) of an agent type.

An agent definition describes the metadata and capabilities of an agent type, including its ports, configuration options, and factory function. Multiple agent instances can be created from a single definition.

Fields§

§kind: String

The kind/category identifier for this agent type (e.g., “Agent”, “Board”).

§name: String

Unique name of this agent definition.

§title: Option<String>

Human-readable title for display in UI.

§hide_title: bool

Whether to hide the title in UI.

§description: Option<String>

Description of what this agent does.

§category: Option<String>

Category path for organizing agents (e.g., “Flow/Control”).

§inputs: Option<Vec<String>>

Default input port names.

§outputs: Option<Vec<String>>

Default output port names.

§configs: Option<AgentConfigSpecs>

Configuration specifications for this agent type.

§global_configs: Option<FnvIndexMap<String, AgentConfigSpec>>

Global configuration specifications (shared across instances).

§native_thread: bool

Whether to run this agent on a native OS thread instead of the async runtime.

§new_boxed: Option<fn(ma: ModularAgent, id: String, spec: AgentSpec) -> Result<Box<dyn Agent>, AgentError>>

Factory function to create new agent instances.

Implementations§

Source§

impl AgentDefinition

Source

pub fn new( kind: impl Into<String>, name: impl Into<String>, new_boxed: Option<fn(ma: ModularAgent, id: String, spec: AgentSpec) -> Result<Box<dyn Agent>, AgentError>>, ) -> Self

Creates a new agent definition.

§Arguments
  • kind - The kind/category identifier (e.g., “std”, “llm”)
  • name - Unique name for this agent definition
  • new_boxed - Optional factory function to create agent instances
Source

pub fn title(self, title: &str) -> Self

Sets the display title. Returns self for method chaining.

Source

pub fn hide_title(self) -> Self

Hides the title in UI. Returns self for method chaining.

Source

pub fn description(self, description: &str) -> Self

Sets the description. Returns self for method chaining.

Source

pub fn category(self, category: &str) -> Self

Sets the category path. Returns self for method chaining.

Source

pub fn inputs(self, inputs: Vec<&str>) -> Self

Sets the input port names. Returns self for method chaining.

Source

pub fn outputs(self, outputs: Vec<&str>) -> Self

Sets the output port names. Returns self for method chaining.

Source

pub fn configs(self, configs: Vec<(&str, AgentConfigSpec)>) -> Self

Sets all configuration specifications at once.

Source

pub fn unit_config(self, key: &str) -> Self

Adds a unit (trigger/signal) configuration.

Source

pub fn unit_config_with<F>(self, key: &str, f: F) -> Self

Adds a unit configuration with customization callback.

Source

pub fn boolean_config(self, key: &str, default: bool) -> Self

Adds a boolean configuration with a default value.

Source

pub fn boolean_config_with<F>(self, key: &str, default: bool, f: F) -> Self

Adds a boolean configuration with customization callback.

Source

pub fn boolean_config_default(self, key: &str) -> Self

Adds a boolean configuration with default value false.

Source

pub fn integer_config(self, key: &str, default: i64) -> Self

Adds an integer configuration with a default value.

Source

pub fn integer_config_with<F>(self, key: &str, default: i64, f: F) -> Self

Adds an integer configuration with customization callback.

Source

pub fn integer_config_default(self, key: &str) -> Self

Adds an integer configuration with default value 0.

Source

pub fn number_config(self, key: &str, default: f64) -> Self

Adds a number (f64) configuration with a default value.

Source

pub fn number_config_with<F>(self, key: &str, default: f64, f: F) -> Self

Adds a number configuration with customization callback.

Source

pub fn number_config_default(self, key: &str) -> Self

Adds a number configuration with default value 0.0.

Source

pub fn string_config(self, key: &str, default: impl Into<String>) -> Self

Adds a string configuration with a default value.

Source

pub fn string_config_with<F>( self, key: &str, default: impl Into<String>, f: F, ) -> Self

Adds a string configuration with customization callback.

Source

pub fn string_config_default(self, key: &str) -> Self

Adds a string configuration with empty default value.

Source

pub fn text_config(self, key: &str, default: impl Into<String>) -> Self

Adds a multiline text configuration with a default value.

Source

pub fn text_config_with<F>( self, key: &str, default: impl Into<String>, f: F, ) -> Self

Adds a text configuration with customization callback.

Source

pub fn text_config_default(self, key: &str) -> Self

Adds a text configuration with empty default value.

Source

pub fn array_config(self, key: &str, default: impl Into<AgentValue>) -> Self

Adds an array configuration with a default value.

Source

pub fn array_config_with<V: Into<AgentValue>, F>( self, key: &str, default: V, f: F, ) -> Self

Adds an array configuration with customization callback.

Source

pub fn array_config_default(self, key: &str) -> Self

Adds an array configuration with empty default value.

Source

pub fn object_config<V: Into<AgentValue>>(self, key: &str, default: V) -> Self

Adds an object configuration with a default value.

Source

pub fn object_config_with<V: Into<AgentValue>, F>( self, key: &str, default: V, f: F, ) -> Self

Adds an object configuration with customization callback.

Source

pub fn object_config_default(self, key: &str) -> Self

Adds an object configuration with empty default value.

Source

pub fn custom_config_with<V: Into<AgentValue>, F>( self, key: &str, default: V, type_: &str, f: F, ) -> Self

Adds a custom-typed configuration with customization callback.

Source

pub fn global_configs(self, configs: Vec<(&str, AgentConfigSpec)>) -> Self

Sets all global configuration specifications at once.

Source

pub fn boolean_global_config(self, key: &str, default: bool) -> Self

Adds a boolean global configuration.

Source

pub fn boolean_global_config_with<F>( self, key: &str, default: bool, f: F, ) -> Self

Adds a boolean global configuration with customization callback.

Source

pub fn integer_global_config(self, key: &str, default: i64) -> Self

Adds an integer global configuration.

Source

pub fn integer_global_config_with<F>( self, key: &str, default: i64, f: F, ) -> Self

Adds an integer global configuration with customization callback.

Source

pub fn number_global_config(self, key: &str, default: f64) -> Self

Adds a number (f64) global configuration.

Source

pub fn number_global_config_with<F>(self, key: &str, default: f64, f: F) -> Self

Adds a number global configuration with customization callback.

Source

pub fn string_global_config(self, key: &str, default: impl Into<String>) -> Self

Adds a string global configuration.

Source

pub fn string_global_config_with<F>( self, key: &str, default: impl Into<String>, f: F, ) -> Self

Adds a string global configuration with customization callback.

Source

pub fn text_global_config(self, key: &str, default: impl Into<String>) -> Self

Adds a multiline text global configuration.

Source

pub fn text_global_config_with<F>( self, key: &str, default: impl Into<String>, f: F, ) -> Self

Adds a text global configuration with customization callback.

Source

pub fn array_global_config( self, key: &str, default: impl Into<AgentValue>, ) -> Self

Adds an array global configuration.

Source

pub fn array_global_config_with<V: Into<AgentValue>, F>( self, key: &str, default: V, f: F, ) -> Self

Adds an array global configuration with customization callback.

Source

pub fn array_global_config_default(self, key: &str) -> Self

Adds an array global configuration with empty default value.

Source

pub fn object_global_config<V: Into<AgentValue>>( self, key: &str, default: V, ) -> Self

Adds an object global configuration.

Source

pub fn object_global_config_with<V: Into<AgentValue>, F>( self, key: &str, default: V, f: F, ) -> Self

Adds an object global configuration with customization callback.

Source

pub fn custom_global_config_with<V: Into<AgentValue>, F>( self, key: &str, default: V, type_: &str, f: F, ) -> Self

Adds a custom-typed global configuration with customization callback.

Source

pub fn use_native_thread(self) -> Self

Configures this agent to run on a native OS thread.

Use this for agents that perform blocking I/O or CPU-intensive operations that would block the async runtime.

Source

pub fn to_spec(&self) -> AgentSpec

Creates a new agent specification from this definition.

Generates a unique ID and copies the definition’s ports and configs to create a new instance specification.

Source

pub fn reconcile_spec(&self, spec: &mut AgentSpec)

Reconciles an existing AgentSpec with this definition for backward compatibility.

When loading old JSON presets, the spec may not match the current definition. This method:

  • Fills missing config keys with definition defaults
  • Renames stale keys (not in definition) with _ prefix for lazy migration
  • Overwrites config_specs with current definition metadata
  • Overwrites ports with current definition ports

Keys already starting with _ are skipped during rename (idempotency). _-prefixed keys are cleaned up by AgentData::new().

Config names must not start with _ (reserved for stale key migration).

Trait Implementations§

Source§

impl Clone for AgentDefinition

Source§

fn clone(&self) -> AgentDefinition

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentDefinition

Source§

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

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

impl Default for AgentDefinition

Source§

fn default() -> AgentDefinition

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for AgentDefinition

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AgentDefinition

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: FloatComponent, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
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<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>

Convert the given value into an approximately equivalent representation.
Source§

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

Source§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
Source§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
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, Dst> ConvAsUtil<Dst> for T

Source§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
Source§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
Source§

impl<T> ConvUtil for T

Source§

fn approx_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject to a given type with the default scheme.
Source§

fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject to a given type with a specific scheme.
Source§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
Source§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
Source§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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<Src> TryFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
Source§

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

Source§

type Error = Infallible

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<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

Source§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
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, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<Src> ValueFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>

Convert the given value into an exactly equivalent representation.
Source§

impl<Src, Dst> ValueInto<Dst> for Src
where Dst: ValueFrom<Src>,

Source§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.
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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,