pub struct JsExtensionRuntimeHandle { /* private fields */ }Expand description
Handle to the JS extension runtime thread.
Cloning shares the same underlying runtime. Call shutdown
to request a graceful exit; the runtime thread will finish the current
command, break out of the event loop, and signal completion via
exit_signal.
Implementations§
Source§impl JsExtensionRuntimeHandle
impl JsExtensionRuntimeHandle
pub async fn start( config: PiJsRuntimeConfig, tools: Arc<ToolRegistry>, manager: ExtensionManager, ) -> Result<Self>
Sourcepub async fn start_with_policy(
config: PiJsRuntimeConfig,
tools: Arc<ToolRegistry>,
manager: ExtensionManager,
policy: ExtensionPolicy,
) -> Result<Self>
pub async fn start_with_policy( config: PiJsRuntimeConfig, tools: Arc<ToolRegistry>, manager: ExtensionManager, policy: ExtensionPolicy, ) -> Result<Self>
Like start but uses a specific ExtensionPolicy.
Sourcepub async fn start_with_interceptor(
config: PiJsRuntimeConfig,
tools: Arc<ToolRegistry>,
manager: ExtensionManager,
interceptor: Arc<dyn HostcallInterceptor>,
) -> Result<Self>
pub async fn start_with_interceptor( config: PiJsRuntimeConfig, tools: Arc<ToolRegistry>, manager: ExtensionManager, interceptor: Arc<dyn HostcallInterceptor>, ) -> Result<Self>
Like start but installs a HostcallInterceptor that
can short-circuit hostcalls before they reach real dispatch handlers.
Used by conformance tests to provide deterministic exec/http/ui stubs.
Sourcepub async fn start_with_interceptor_and_policy(
config: PiJsRuntimeConfig,
tools: Arc<ToolRegistry>,
manager: ExtensionManager,
interceptor: Arc<dyn HostcallInterceptor>,
policy: ExtensionPolicy,
) -> Result<Self>
pub async fn start_with_interceptor_and_policy( config: PiJsRuntimeConfig, tools: Arc<ToolRegistry>, manager: ExtensionManager, interceptor: Arc<dyn HostcallInterceptor>, policy: ExtensionPolicy, ) -> Result<Self>
Like start_with_interceptor but with
an explicit ExtensionPolicy.
Sourcepub async fn shutdown(&self, budget: Duration) -> bool
pub async fn shutdown(&self, budget: Duration) -> bool
Request the JS runtime thread to shut down gracefully.
Sends a Shutdown command and waits up to budget for the thread
to exit its event loop. Returns true if the runtime exited
within the budget.
pub async fn get_registered_tools(&self) -> Result<Vec<ExtensionToolDef>>
pub async fn pump_once(&self) -> Result<bool>
pub async fn dispatch_event( &self, event_name: String, event_payload: Value, ctx_payload: Arc<Value>, timeout_ms: u64, ) -> Result<Value>
Sourcepub async fn dispatch_event_batch(
&self,
events: Vec<(String, Value)>,
ctx_payload: Arc<Value>,
timeout_ms: u64,
) -> Result<Vec<Result<Value>>>
pub async fn dispatch_event_batch( &self, events: Vec<(String, Value)>, ctx_payload: Arc<Value>, timeout_ms: u64, ) -> Result<Vec<Result<Value>>>
Dispatch multiple events in a single JS bridge call with shared context.
pub async fn execute_tool( &self, tool_name: String, tool_call_id: String, input: Value, ctx_payload: Arc<Value>, timeout_ms: u64, ) -> Result<Value>
pub async fn execute_command( &self, command_name: String, args: String, ctx_payload: Arc<Value>, timeout_ms: u64, ) -> Result<Value>
pub async fn execute_shortcut( &self, key_id: String, ctx_payload: Arc<Value>, timeout_ms: u64, ) -> Result<Value>
pub async fn set_flag_value( &self, extension_id: String, flag_name: String, value: Value, ) -> Result<()>
Sourcepub async fn drain_repair_events(&self) -> Vec<ExtensionRepairEvent>
pub async fn drain_repair_events(&self) -> Vec<ExtensionRepairEvent>
Drain all accumulated auto-repair events from the JS runtime.
Sourcepub async fn reset_transient_state(&self) -> Result<()>
pub async fn reset_transient_state(&self) -> Result<()>
Reset transient runtime state for warm isolate reuse.
Clears extension roots, dynamic virtual modules, and repair events while preserving the transpiled source cache (memory + disk). This enables a runtime to be returned to a warm pool and reloaded with a fresh set of extensions without paying the full cold-start cost.
pub async fn provider_stream_simple_start( &self, provider_id: String, model: Value, context: Value, options: Value, timeout_ms: u64, ) -> Result<String>
pub async fn provider_stream_simple_next( &self, stream_id: String, timeout_ms: u64, ) -> Result<Option<Value>>
pub async fn provider_stream_simple_cancel( &self, stream_id: String, timeout_ms: u64, ) -> Result<()>
pub fn provider_stream_simple_cancel_best_effort(&self, stream_id: String)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JsExtensionRuntimeHandle
impl !RefUnwindSafe for JsExtensionRuntimeHandle
impl Send for JsExtensionRuntimeHandle
impl Sync for JsExtensionRuntimeHandle
impl Unpin for JsExtensionRuntimeHandle
impl UnsafeUnpin for JsExtensionRuntimeHandle
impl !UnwindSafe for JsExtensionRuntimeHandle
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
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