pub struct TerminalAgentBuilder<LLM, P, E, H = ()>{ /* private fields */ }Expand description
Builder for creating terminal-first agents.
All registered tools become IPC commands accessible via terminal.
The LLM only sees the terminal tool.
Implementations§
Source§impl<LLM, P, E> TerminalAgentBuilder<LLM, P, E, ()>
impl<LLM, P, E> TerminalAgentBuilder<LLM, P, E, ()>
Sourcepub fn new(llm: LLM, terminal_tool: TerminalTool<P, E, Unconfigured>) -> Self
pub fn new(llm: LLM, terminal_tool: TerminalTool<P, E, Unconfigured>) -> Self
Creates a new terminal-first agent builder.
Creates the agent with native tools (terminal_kill, terminal_input,
terminal_read, terminal) and IPC commands accessible through
terminal (registered via .tool()).
Source§impl<LLM, P, E, H> TerminalAgentBuilder<LLM, P, E, H>where
LLM: LanguageModel + Clone,
P: PermissionHandler + 'static,
E: Executor + Clone + 'static,
H: Hook,
impl<LLM, P, E, H> TerminalAgentBuilder<LLM, P, E, H>where
LLM: LanguageModel + Clone,
P: PermissionHandler + 'static,
E: Executor + Clone + 'static,
H: Hook,
Sourcepub fn shell_runtime_availability(
self,
availability: ShellRuntimeAvailability,
) -> Self
pub fn shell_runtime_availability( self, availability: ShellRuntimeAvailability, ) -> Self
Sets runtime shell backend availability for terminal.
Sourcepub fn ssh_servers(self, servers: Vec<SshServer>) -> Self
pub fn ssh_servers(self, servers: Vec<SshServer>) -> Self
Sets preconfigured SSH targets that can be used by terminal with ssh mode.
§Panics
Panics when the SSH server configuration is invalid.
Sets the SSH session authorizer for interactive connect/install consent prompts.
Sourcepub fn container_runtime(self, runtime: ContainerShellRuntime) -> Self
pub fn container_runtime(self, runtime: ContainerShellRuntime) -> Self
Sets the container runtime for container-backed shell sessions.
Sourcepub fn tool<T>(self, tool: T) -> Selfwhere
T: Tool + Send + Sync + 'static,
T::Arguments: DeserializeOwned + JsonSchema + Send + 'static,
pub fn tool<T>(self, tool: T) -> Selfwhere
T: Tool + Send + Sync + 'static,
T::Arguments: DeserializeOwned + JsonSchema + Send + 'static,
Sourcepub fn definition_handler<F>(
self,
definition: &ToolDefinition,
handler: F,
) -> Self
pub fn definition_handler<F>( self, definition: &ToolDefinition, handler: F, ) -> Self
Registers a schema-defined command on the terminal IPC bridge.
This is the dynamic counterpart to Self::tool. The command wrapper
is still derived entirely from the tool definition schema, so --help,
positional arguments, and validation all stay automatic.
Sourcepub fn tool_with_desc<T>(self, tool: T, description: impl Into<String>) -> Selfwhere
T: Tool + Send + Sync + 'static,
T::Arguments: DeserializeOwned + JsonSchema + Send + 'static,
pub fn tool_with_desc<T>(self, tool: T, description: impl Into<String>) -> Selfwhere
T: Tool + Send + Sync + 'static,
T::Arguments: DeserializeOwned + JsonSchema + Send + 'static,
Registers a tool with a custom description.
Sourcepub fn tool_description(
self,
name: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn tool_description( self, name: impl Into<String>, description: impl Into<String>, ) -> Self
Adds a pre-configured tool description (for tools registered elsewhere).
Use this when the tool was already registered on the registry builder.
Sourcepub fn system_prompt_raw(self, prompt: impl Into<String>) -> Self
pub fn system_prompt_raw(self, prompt: impl Into<String>) -> Self
Sets a custom system prompt (raw string, no template processing).
Sourcepub fn persona_prompt(self, prompt: impl Into<String>) -> Self
pub fn persona_prompt(self, prompt: impl Into<String>) -> Self
Sets an optional persona overlay prompt.
Sourcepub fn agent_kind(self, kind: AgentKind) -> Self
pub fn agent_kind(self, kind: AgentKind) -> Self
Sets agent kind (coding/chatbot).
Sourcepub fn transcript_path(self, path: impl Into<String>) -> Self
pub fn transcript_path(self, path: impl Into<String>) -> Self
Sets transcript path for long-memory recovery guidance.
Sourcepub fn transcript(self, path: impl Into<PathBuf>) -> Self
pub fn transcript(self, path: impl Into<PathBuf>) -> Self
Enables writing readable transcript entries to the given file path.
Sourcepub fn system<T: Serialize>(self, value: T) -> Self
pub fn system<T: Serialize>(self, value: T) -> Self
Inserts or replaces a typed persistent system block.
Sourcepub fn system_named(
self,
tag: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn system_named( self, tag: impl Into<String>, content: impl Into<String>, ) -> Self
Inserts or replaces a persistent system block with an explicit tag.
Sourcepub fn system_text(
self,
tag: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn system_text( self, tag: impl Into<String>, content: impl Into<String>, ) -> Self
Inserts or replaces a persistent system block with raw text.
Unlike system and system_named,
the content is stored verbatim without any XML wrapping. This is the
preferred entry point for prose system blocks (workspace descriptions,
runtime metadata, environment hints) where XML structure adds tokens
without providing semantic value.
Sourcepub fn with_default_prompt(self) -> Self
pub fn with_default_prompt(self) -> Self
Generates and sets the default system prompt using the built-in template.
This should be called after all tools are registered.
§Panics
Panics when no shell backend is available.
Sourcepub fn hook<NH: Hook>(
self,
hook: NH,
) -> TerminalAgentBuilder<LLM, P, E, HCons<NH, H>>
pub fn hook<NH: Hook>( self, hook: NH, ) -> TerminalAgentBuilder<LLM, P, E, HCons<NH, H>>
Adds a hook to intercept agent operations.
Sourcepub fn skill(
self,
name: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn skill( self, name: impl Into<String>, description: impl Into<String>, ) -> Self
Adds a skill manually without loading from filesystem.
Sourcepub async fn with_subagents(
self,
path: impl AsRef<Path>,
) -> Result<Self, AgentError>
pub async fn with_subagents( self, path: impl AsRef<Path>, ) -> Result<Self, AgentError>
Loads subagents and exposes the subagent directory inside the sandbox.
§Errors
Returns an error when loading subagents or creating the sandbox symlink fails.
Sourcepub async fn with_subagents_readable_only(
self,
path: impl AsRef<Path>,
) -> Result<Self, AgentError>
pub async fn with_subagents_readable_only( self, path: impl AsRef<Path>, ) -> Result<Self, AgentError>
Loads subagent metadata and grants read-only access to the source
directory without creating a subagents symlink in the sandbox.
Use this when the runtime already mounts subagents inside the sandbox.
§Errors
Returns an error when loading subagents or registering the readable directory fails.
Sourcepub fn max_iterations(self, limit: usize) -> Self
pub fn max_iterations(self, limit: usize) -> Self
Sets the maximum number of iterations.
Sourcepub fn tool_descriptions(&self) -> &[(String, String)]
pub fn tool_descriptions(&self) -> &[(String, String)]
Returns the list of registered tool descriptions.
Useful for dynamically building system prompts.
Sourcepub fn terminal_tool_factory(&self) -> TerminalToolFactory
pub fn terminal_tool_factory(&self) -> TerminalToolFactory
Returns a factory for spawning child terminal tools (for subagents).
Sourcepub const fn tool_registry_mut(&mut self) -> &mut ToolRegistryBuilder
pub const fn tool_registry_mut(&mut self) -> &mut ToolRegistryBuilder
Returns a mutable reference to the tool registry builder.
Sourcepub fn sandbox_dir(&self) -> Cow<'_, str>
pub fn sandbox_dir(&self) -> Cow<'_, str>
Returns the sandbox working directory path.
Trait Implementations§
Source§impl<LLM, P, E, H> Debug for TerminalAgentBuilder<LLM, P, E, H>
impl<LLM, P, E, H> Debug for TerminalAgentBuilder<LLM, P, E, H>
Auto Trait Implementations§
impl<LLM, P, E, H = ()> !RefUnwindSafe for TerminalAgentBuilder<LLM, P, E, H>
impl<LLM, P, E, H = ()> !Unpin for TerminalAgentBuilder<LLM, P, E, H>
impl<LLM, P, E, H = ()> !UnsafeUnpin for TerminalAgentBuilder<LLM, P, E, H>
impl<LLM, P, E, H = ()> !UnwindSafe for TerminalAgentBuilder<LLM, P, E, H>
impl<LLM, P, E, H> Freeze for TerminalAgentBuilder<LLM, P, E, H>
impl<LLM, P, E, H> Send for TerminalAgentBuilder<LLM, P, E, H>
impl<LLM, P, E, H> Sync for TerminalAgentBuilder<LLM, P, E, H>
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