Skip to main content

RuntimeBuilder

Struct RuntimeBuilder 

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

Builder for constructing a Runtime with the desired configuration.

Implementations§

Source§

impl RuntimeBuilder

Source

pub fn new() -> Self

Create a new builder with default settings.

Source

pub fn from_file(path: &str) -> Result<Self, KernexError>

Create a new builder pre-populated from a declarative agent definition file.

The file format is detected by extension: .yaml / .yml use YAML (requires the yaml feature on kernex-core); all other extensions use TOML. Missing files silently fall back to defaults.

Maps [runtime] fields (data_dir, system_prompt, channel, project) and [memory]db_path into the builder. Provider selection is left to the caller.

§Example (agent.toml)
[runtime]
name       = "my-agent"
data_dir   = "~/.my-agent"
channel    = "api"
project    = "acme"
system_prompt = "You are a helpful coding assistant."

[memory]
db_path = "~/.my-agent/memory.db"
Source

pub fn from_config(config: &KernexConfig) -> Self

Populate a builder from a pre-parsed KernexConfig.

Maps runtime.{data_dir, system_prompt, channel, project} and memory.db_path into builder fields. Provider selection is left to the caller.

Source

pub fn from_env() -> Self

Create a new builder configured from environment variables.

Recognizes:

  • KERNEX_DATA_DIR
  • KERNEX_DB_PATH (when sqlite-store feature is enabled)
  • KERNEX_SYSTEM_PROMPT
  • KERNEX_CHANNEL
  • KERNEX_PROJECT
Source

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

Set the data directory (default: ~/.kernex).

Source

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

Set a custom database path (default: {data_dir}/memory.db).

Source

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

Set the base system prompt.

Source

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

Set the channel identifier (default: "cli").

Source

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

Set the active project for scoping memory.

Source

pub fn hook_runner(self, runner: Arc<dyn HookRunner>) -> Self

Set a hook runner for tool lifecycle events.

Source

pub fn permission_rules(self, rules: PermissionRules) -> Self

Set declarative allow/deny permission rules for tool calls.

Source

pub fn guardrail_runner(self, runner: Arc<dyn GuardrailRunner>) -> Self

Set a guardrail runner that intercepts and filters input/output text.

Source

pub fn auto_compact(self, enable: bool) -> Self

Enable automatic context compaction on long conversations.

When enabled, every call into the runtime that builds context (e.g. Runtime::complete, Runtime::complete_stream, Runtime::run) will, on overflow past max_context_messages, summarize the dropped rows via the active provider and prepend the summary to the system prompt under [Earlier conversation summary]. The summarization adds one extra provider round-trip per overflow event (not per turn), uses a fixed instruction prompt that never reveals the agent’s own system prompt, and falls back to the default Drop behavior if the provider call fails.

Default is off to preserve v0.4.0 behavior. Recommended for any long-running interactive session; the default exists only so existing callers do not silently change billing characteristics.

Source

pub async fn build(self) -> Result<Runtime, KernexError>

Build and initialize the runtime.

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