Skip to main content

BlockConfig

Struct BlockConfig 

Source
pub struct BlockConfig {
    pub script_path: PathBuf,
    pub project_root: PathBuf,
    pub relay_url: Option<String>,
    pub secret_key: Option<String>,
    pub mcp_rpc_timeout: Duration,
    pub prompt: Option<String>,
    pub context: Option<String>,
    pub host_handlers: HashMap<String, Arc<dyn Handler>>,
    pub auto_serve_bus: bool,
}

Fields§

§script_path: PathBuf§project_root: PathBuf§relay_url: Option<String>§secret_key: Option<String>

Ed25519 secret key (64 hex chars). If None, a random keypair is generated. Required to talk to registry/ACL-gated hosted meshes.

§mcp_rpc_timeout: Duration

Per-RPC timeout for every MCP round-trip (connect / list / call). Defaults to agent_block_mcp::DEFAULT_RPC_TIMEOUT.

§prompt: Option<String>

Prompt string injected as _PROMPT Lua global. None = global not set.

§context: Option<String>

Context string injected as _CONTEXT Lua global. None = global not set.

§host_handlers: HashMap<String, Arc<dyn Handler>>

Host-side Rust handlers pre-installed on the EventBus before the user script starts. Each entry registers handler against kind via EventBus::on, so a script-side bus.emit(kind, payload) is captured by the Rust handler rather than dispatched to a Lua function.

Intended for SDK consumers that embed agent-block-core and need to receive script output programmatically (e.g. a Spawner adapter that turns LLM script output into a typed WorkerResult). Lua-side bus.on(kind, fn) registrations layered on top of the handler Isle are still possible, but the EventBus dispatches a single handler per kind (last-write-wins), so host-side and Lua-side registrations on the same kind collide; choose one side per routing key.

Defaults to an empty map (no host handlers).

§auto_serve_bus: bool

When true, the EventBus dispatcher loop is driven in the background for the duration of the script and shut down gracefully after the script completes. Required for SDK-embed callers that supply Self::host_handlers and need bus.emit(kind, payload) events emitted from the script to actually reach those handlers without requiring the script to call bus.serve() (which blocks on SIGTERM / Ctrl+C and never returns under programmatic embedding).

After the script finishes, the dispatcher is given a grace window (AGENT_BLOCK_TASK_GRACE_MS, default 1000ms) to drain queued events and finish any in-flight handler, then is cancelled.

Mutually exclusive with Lua-side bus.serve(): enabling this flag takes ownership of the EventBus before the script runs, so a script that calls bus.on(...) followed by bus.serve() will error (“bus.serve() has already taken ownership”). Use this flag when the script’s sole purpose is to push events to host handlers.

Defaults to false (legacy behavior: dispatcher only runs when the script calls bus.serve()).

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = 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<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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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