pub struct LuaInProcessSpawnerFactory { /* private fields */ }Expand description
Factory for AgentKind::Lua. At build time it looks the fn_id
up in its internal registry and returns an InProcSpawner with the
Lua-eval WorkerFn registered under agent_name — one InProcSpawner
instance per agent.
Naming convention: <WorkerIMPL><AdapterType>SpawnerFactory (Lua
worker on InProcess adapter). One half of the old
InProcSpawnerFactory, split into Lua and RustFn variants.
Spec shape:
{ "fn_id": "patch-spawner" } // Lua source id pre-registered with the factoryImplementations§
Source§impl LuaInProcessSpawnerFactory
impl LuaInProcessSpawnerFactory
Sourcepub fn with_bridge(self, name: impl Into<String>, bridge: HostBridge) -> Self
pub fn with_bridge(self, name: impl Into<String>, bridge: HostBridge) -> Self
Register a host bridge. Subsequent register_lua calls snapshot
the current bridge set.
Ordering rule: register bridges first, then call register_lua;
bridges added after register_lua will not be visible to that
script.
Sourcepub fn register_lua(
self,
fn_id: impl Into<String>,
source: LuaScriptSource,
) -> Self
pub fn register_lua( self, fn_id: impl Into<String>, source: LuaScriptSource, ) -> Self
Register a Lua-eval Worker under fn_id.
Each dispatch spins up a fresh mlua::Lua VM, injects globals
(_PROMPT / _AGENT / _TASK_ID / _ATTEMPT / _CTX — the last
is _PROMPT parsed as JSON, or nil if that fails), evaluates
the script, and marshals the returned table into a WorkerResult.
Marshalling rules for the return value:
{ value = ..., ok = bool }→WorkerResult.value/WorkerResult.okverbatim.- Anything else →
value = <returned value>,ok = true.
Execution runs on tokio::task::spawn_blocking because mlua::Lua
is !Send and needs to stay away from the tokio async context.
Host bridges (the Lua-to-Rust callback path) previously registered
with Self::with_bridge are snapshotted at call time and
injected into every dispatch inside run_lua_worker.
Trait Implementations§
Source§impl Default for LuaInProcessSpawnerFactory
impl Default for LuaInProcessSpawnerFactory
Source§impl SpawnerFactory for LuaInProcessSpawnerFactory
impl SpawnerFactory for LuaInProcessSpawnerFactory
Source§fn build(
&self,
agent_def: &AgentDef,
_hint: Option<&Value>,
) -> Result<Arc<dyn SpawnerAdapter>, CompileError>
fn build( &self, agent_def: &AgentDef, _hint: Option<&Value>, ) -> Result<Arc<dyn SpawnerAdapter>, CompileError>
SpawnerAdapter for one AgentDef. hint is
the matching entry (if any) from Blueprint.hints.per_agent.Source§impl SpawnerFactoryKind for LuaInProcessSpawnerFactory
impl SpawnerFactoryKind for LuaInProcessSpawnerFactory
Source§const KIND: AgentKind = AgentKind::Lua
const KIND: AgentKind = AgentKind::Lua
AgentKind this factory handles — used as the HashMap key
by SpawnerRegistry::register.Source§type Worker = LuaWorker
type Worker = LuaWorker
AgentKind — this
binds the type chain all the way from AgentKind down to Worker.
Every factory declares it so the AgentKind → Worker mapping is
explicit across all four layers. It is the source of truth for
preserving the concrete type right up until SpawnerAdapter::spawn
erases it into Box<dyn Worker>.Auto Trait Implementations§
impl !RefUnwindSafe for LuaInProcessSpawnerFactory
impl !UnwindSafe for LuaInProcessSpawnerFactory
impl Freeze for LuaInProcessSpawnerFactory
impl Send for LuaInProcessSpawnerFactory
impl Sync for LuaInProcessSpawnerFactory
impl Unpin for LuaInProcessSpawnerFactory
impl UnsafeUnpin for LuaInProcessSpawnerFactory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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