Skip to main content

AppBuilder

Struct AppBuilder 

Source
pub struct AppBuilder { /* private fields */ }

Implementations§

Source§

impl AppBuilder

Source

pub fn new() -> Self

Source

pub fn with_config(self, cfg: Config) -> Self

Source

pub fn with_cwd(self, cwd: impl Into<PathBuf>) -> Self

Source

pub fn with_permission_gate(self, gate: Arc<dyn PermissionGate>) -> Self

Source

pub fn with_builtin_tools(self) -> Self

Install Capo’s builtin tools (read, bash).

This is mutually exclusive with with_custom_tools_factory / build_with_custom_tools; build() returns a configuration error if both are set.

Source

pub fn with_max_iterations(self, n: usize) -> Self

Source

pub fn with_llm(self, llm: Arc<dyn LlmClient>) -> Self

Source

pub fn with_permissions_config(self, path: PathBuf) -> Self

Source

pub fn with_ui_channel(self, tx: Sender<UiEvent>) -> Self

Source

pub fn with_headless_permissions(self) -> Self

Register PermissionExtension in headless-deny mode — permissions.toml and read-only auto-allow still apply, but a tool call that would otherwise prompt is denied (there is no UI to ask). Used by --json. Ignored if with_ui_channel is also set (an interactive channel wins).

Source

pub fn with_settings(self, settings: Settings) -> Self

M3: install user Settings. Replaces with_config for new code.

Source

pub fn with_auth(self, auth: Auth) -> Self

M3: install Auth (credentials for LLM providers).

Source

pub fn disable_context_discovery(self) -> Self

M3: disable AGENTS.md / CLAUDE.md discovery for this App. Opt-out — discovery is on by default in build().

Source

pub fn with_session_store(self, store: Arc<dyn SessionStore>) -> Self

M3 Phase A: install a SessionStore (e.g. motosan_agent_loop::FileSessionStore) for persistence. When omitted, sessions are ephemeral (no jsonl on disk).

Source

pub fn with_autocompact(self) -> Self

M3 Phase A: enable autocompact at the Settings::session.compact_at_context_pct threshold. Requires with_settings to have been called; otherwise uses Settings::default(). Settings provide max_context_tokens and keep_turns. No-op when settings.session.compact_at_context_pct == 0.0.

Source

pub fn with_skills(self, skills: Vec<Skill>) -> Self

M4 Phase A: register skills. Pass an empty Vec (or omit the call, or call without_skills()) to disable skill injection. Skills are rendered into the system prompt’s <available_skills> block when the read tool is available, and matched against /skill:<name> expansion before user messages reach the LLM.

Source

pub fn without_skills(self) -> Self

Source

pub fn with_extra_tools(self, tools: Vec<Arc<dyn Tool>>) -> Self

M4 Phase B: register additional tools (typically MCP). Unlike with_custom_tools_factory, this APPENDS to the builtin tools and does NOT replace them.

Source

pub fn with_extension_registry(self, registry: Arc<ExtensionRegistry>) -> Self

Source

pub fn with_extension_diagnostics( self, diagnostics: Arc<Vec<ExtensionDiagnostic>>, ) -> Self

Source

pub fn with_mcp_servers( self, servers: Vec<(String, Arc<dyn McpServer>)>, ) -> Self

M4 Phase B: register MCP server handles so App::disconnect_mcp can iterate them on shutdown. Storage only — does not connect.

Source

pub fn with_custom_tools_factory( self, factory: impl FnOnce(ToolCtx) -> Vec<Arc<dyn Tool>> + 'static, ) -> Self

Install a custom tool set for this app.

This is mutually exclusive with with_builtin_tools; build() returns a configuration error if both are set.

Source

pub async fn build_with_custom_tools( self, factory: impl FnOnce(ToolCtx) -> Vec<Arc<dyn Tool>> + 'static, ) -> Result<App>

Convenience wrapper for with_custom_tools_factory(...).build().

This is mutually exclusive with with_builtin_tools.

Source

pub async fn build_with_session(self, resume: Option<SessionId>) -> Result<App>

M3 Phase A: build the App with an optional resume session id.

  • Some(id) + session_store: Some(_)AgentSession::resume(id, store, engine, llm), then replay history into ToolCtx.read_files.
  • Some(id) + session_store: None → error (resume requires a store).
  • None + session_store: Some(_)AgentSession::new_with_store(fresh_id, store, engine, llm).
  • None + session_store: NoneAgentSession::new(engine, llm) (ephemeral).
Source

pub async fn build(self) -> Result<App>

Legacy entry point; equivalent to build_with_session(None).

Trait Implementations§

Source§

impl Default for AppBuilder

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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: 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: 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, 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