Skip to main content

RuntimeBuilder

Struct RuntimeBuilder 

Source
pub struct RuntimeBuilder { /* private fields */ }
Expand description

Builder for an embeddable Talos runtime.

The safe default is conservative: registered tools are wrapped in a permission-aware adapter, and unresolved Ask decisions are denied instead of being executed.

Implementations§

Source§

impl RuntimeBuilder

Source

pub fn new() -> Self

Creates a builder with no provider and the current directory as the workspace root.

Source

pub fn provider(self, provider: Arc<dyn LanguageModel>) -> Self

Sets the language model provider used by the runtime.

Source

pub fn workspace_root(self, root: impl Into<PathBuf>) -> Self

Sets the workspace root used for path-sensitive runtime behavior.

Source

pub fn tool(self, tool: Arc<dyn AgentTool>) -> Self

Registers a tool with runtime-level permission gating.

Source

pub fn permission_rule(self, rule: PermissionRule) -> Self

Adds an extra permission rule to the runtime permission engine.

Runtime rules are evaluated before the engine’s default fallback, so embedders can add narrow allow-list or deny-list rules without changing the safe default for unmatched write, execute, and network tools. Richer policy import remains a later RUNTIME-001 follow-up.

Source

pub fn sandbox(self, sandbox: Box<dyn SandboxProvider>) -> Self

Sets an optional sandbox provider for sandbox-capable tools.

Source

pub fn sandbox_fallback_policy(self, policy: SandboxFallbackPolicy) -> Self

Sets the sandbox fallback policy. The default is Deny.

Source

pub fn sandbox_fallback(self, policy: SandboxFallbackPolicy) -> Self

Sets the sandbox fallback policy using the SDK contract name.

Source

pub fn preset(self, preset: RuntimePreset) -> Self

Selects an explicit runtime capability preset.

Source

pub fn coding_preset(self) -> Self

Selects the shared coding capability composition.

Source

pub fn initial_history(self, history: Vec<Message>) -> Self

Seeds the runtime with existing conversation history.

Source

pub fn model_context_limit(self, limit: u32) -> Self

Sets the model context limit used by the session compactor.

Source

pub fn approval_handler(self, handler: Arc<dyn ApprovalHandler>) -> Self

Sets the approval handler for tools whose permission policy returns Ask.

Without a handler, Ask decisions are denied. AlwaysApprove choices install first-class in-memory Session grants for this runtime build only; they are not persisted to user configuration or durable sessions.

Source

pub fn custom_prompt(self, prompt: impl Into<String>) -> Self

Replaces the default Talos identity/system prompt.

This is intended for embedders that reuse the runtime in a product with its own identity. Use RuntimeBuilder::append_prompt when the default identity should remain and only extra instructions are needed.

Source

pub fn append_prompt(self, prompt: impl Into<String>) -> Self

Appends extra instructions to the system prompt.

Source

pub fn durable_session(self, session: DurableSession) -> Self

Binds this runtime to a host-selected durable Talos session.

The session’s model history is restored during Self::build. Every successful turn is atomically persisted by Talos before its success completion event is emitted; failed, cancelled, and denied turns are not persisted. Calling this is optional and does not alter the existing in-memory runtime behavior when omitted.

Source

pub fn durable_session_with_policy( self, session: DurableSession, policy: PersistencePolicy, ) -> Self

Sets the filtering policy for a durable session binding.

Source

pub fn hook_registry(self, registry: Arc<HookRegistry>) -> Self

Injects a pre-populated HookRegistry into the runtime.

This allows embedders to register reviewed hooks (e.g., from a curated hook catalog) before the runtime starts, following the same builder pattern as RuntimeBuilder::approval_handler.

If not called, the runtime uses an empty HookRegistry.

Source

pub fn skill_index(self, skills: Vec<SkillIndex>) -> Self

Sets the skill index for the runtime’s system prompt.

Embedders that discover skills via talos_skill::SkillLoader (e.g., from a local or remote skill store) can inject the Level 0 index here, following the same pattern as the CLI’s skill_runtime.rs.

If not called, the runtime has no skills in its system prompt.

Source

pub fn build(self) -> RuntimeResult<RuntimeHandle>

Builds and starts the runtime actor.

The returned primary handle owns submission and event access. Dropping it initiates the non-blocking default shutdown plan; use RuntimeHandle::shutdown or RuntimeHandle::shutdown_with when the host must observe terminal cleanup.

Trait Implementations§

Source§

impl Default for RuntimeBuilder

Source§

fn default() -> Self

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

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

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