pub struct IrisAgentService { /* private fields */ }Expand description
High-level service for executing agent tasks with structured context.
This is the primary interface for all agent-based operations in git-iris. It handles:
- Configuration management
- Agent lifecycle
- Task context validation and formatting
- Environment validation
§Example
let service = IrisAgentService::from_common_params(¶ms, None)?;
let context = TaskContext::for_gen();
let result = service.execute_task("commit", context).await?;Implementations§
Source§impl IrisAgentService
impl IrisAgentService
Sourcepub fn new(
config: Config,
provider: String,
model: String,
fast_model: String,
) -> Self
pub fn new( config: Config, provider: String, model: String, fast_model: String, ) -> Self
Create a new service with explicit provider configuration
Sourcepub fn from_common_params(
common_params: &CommonParams,
repository_url: Option<String>,
) -> Result<Self>
pub fn from_common_params( common_params: &CommonParams, repository_url: Option<String>, ) -> Result<Self>
Create service from common CLI parameters
This is the primary constructor for CLI usage. It:
- Loads and applies configuration
- Sets up the git repository (local or remote)
- Validates the environment
§Errors
Returns an error when config loading, agent backend resolution, or repository setup fails.
Sourcepub fn check_environment(&self) -> Result<()>
pub fn check_environment(&self) -> Result<()>
Check that the environment is properly configured
§Errors
Returns an error when the active provider configuration is incomplete.
Sourcepub async fn execute_task(
&self,
capability: &str,
context: TaskContext,
) -> Result<StructuredResponse>
pub async fn execute_task( &self, capability: &str, context: TaskContext, ) -> Result<StructuredResponse>
Execute an agent task with structured context
§Arguments
capability- The capability to invoke (e.g., “commit”, “review”, “pr”)context- Structured context describing what to analyze
§Returns
The structured response from the agent
§Errors
Returns an error when agent construction or task execution fails.
Sourcepub async fn execute_task_with_prompt(
&self,
capability: &str,
task_prompt: &str,
) -> Result<StructuredResponse>
pub async fn execute_task_with_prompt( &self, capability: &str, task_prompt: &str, ) -> Result<StructuredResponse>
Execute a task with a custom prompt (for backwards compatibility)
§Errors
Returns an error when agent construction or task execution fails.
Sourcepub async fn execute_task_with_style(
&self,
capability: &str,
context: TaskContext,
preset: Option<&str>,
use_gitmoji: Option<bool>,
instructions: Option<&str>,
) -> Result<StructuredResponse>
pub async fn execute_task_with_style( &self, capability: &str, context: TaskContext, preset: Option<&str>, use_gitmoji: Option<bool>, instructions: Option<&str>, ) -> Result<StructuredResponse>
Execute an agent task with style overrides
Allows runtime override of preset and gitmoji settings without modifying the underlying config. Useful for UI flows where the user can change settings per-invocation.
§Arguments
capability- The capability to invokecontext- Structured context describing what to analyzepreset- Optional preset name override (e.g., “conventional”, “cosmic”)use_gitmoji- Optional gitmoji setting overrideinstructions- Optional custom instructions from the user
§Errors
Returns an error when agent construction or task execution fails.
Sourcepub async fn execute_chat_with_updates(
&self,
task_prompt: &str,
content_update_sender: ContentUpdateSender,
) -> Result<StructuredResponse>
pub async fn execute_chat_with_updates( &self, task_prompt: &str, content_update_sender: ContentUpdateSender, ) -> Result<StructuredResponse>
Execute a chat task with content update capabilities
This is used by Studio to enable Iris to update content via tool calls.
§Errors
Returns an error when agent construction or chat execution fails.
Sourcepub async fn execute_chat_streaming<F>(
&self,
task_prompt: &str,
content_update_sender: ContentUpdateSender,
on_chunk: F,
) -> Result<StructuredResponse>
pub async fn execute_chat_streaming<F>( &self, task_prompt: &str, content_update_sender: ContentUpdateSender, on_chunk: F, ) -> Result<StructuredResponse>
Execute a chat task with streaming and content update capabilities
Combines streaming output with tool-based content updates for the TUI chat.
§Errors
Returns an error when agent construction or chat streaming fails.
Sourcepub async fn execute_task_streaming<F>(
&self,
capability: &str,
context: TaskContext,
on_chunk: F,
) -> Result<StructuredResponse>
pub async fn execute_task_streaming<F>( &self, capability: &str, context: TaskContext, on_chunk: F, ) -> Result<StructuredResponse>
Execute an agent task with streaming
This method streams LLM output in real-time, calling the callback with each text chunk as it arrives. Ideal for TUI display of generation progress.
§Arguments
capability- The capability to invoke (e.g., “review”, “pr”, “changelog”)context- Structured context describing what to analyzeon_chunk- Callback receiving(chunk, aggregated_text)for each delta
§Returns
The final structured response after streaming completes
§Errors
Returns an error when agent construction or streaming execution fails.
Sourcepub fn config_mut(&mut self) -> &mut Config
pub fn config_mut(&mut self) -> &mut Config
Get a mutable reference to the configuration
Sourcepub fn set_git_repo(&mut self, repo: GitRepo)
pub fn set_git_repo(&mut self, repo: GitRepo)
Attach a git repository to this service
Sourcepub fn fast_model(&self) -> &str
pub fn fast_model(&self) -> &str
Get the fast model name (for subagents and simple tasks)
Auto Trait Implementations§
impl Freeze for IrisAgentService
impl RefUnwindSafe for IrisAgentService
impl Send for IrisAgentService
impl Sync for IrisAgentService
impl Unpin for IrisAgentService
impl UnsafeUnpin for IrisAgentService
impl UnwindSafe for IrisAgentService
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
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> 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